mirror of
https://github.com/drasko/codezero.git
synced 2026-04-18 09:49:05 +02:00
Initial efforts to transform utcb handling.
This commit is contained in:
@@ -15,23 +15,20 @@
|
|||||||
* needed for all ipcs. Those mrs are defined the kernel message.h
|
* needed for all ipcs. Those mrs are defined the kernel message.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Compact utcb for now! :-) */
|
/*
|
||||||
|
* This is a per-task private structure where message registers are
|
||||||
|
* pushed for ipc. Its *not* TLS, but can be part of TLS when it is
|
||||||
|
* supported.
|
||||||
|
*/
|
||||||
struct utcb {
|
struct utcb {
|
||||||
u32 mr[MR_TOTAL];
|
u32 mr[MR_TOTAL];
|
||||||
u32 tid; /* Thread id */
|
u32 tid; /* Thread id */
|
||||||
|
}; __attribute__((__packed__));
|
||||||
/*
|
extern struct utcb utcb;
|
||||||
* For passing ipc data larger than mrs,
|
|
||||||
* that is, if the callee is allowed to map it
|
|
||||||
*/
|
|
||||||
char buf[];
|
|
||||||
};
|
|
||||||
extern struct utcb *utcb;
|
|
||||||
|
|
||||||
static inline struct utcb *l4_get_utcb()
|
static inline struct utcb *l4_get_utcb()
|
||||||
{
|
{
|
||||||
return utcb;
|
return &utcb;
|
||||||
// (struct utcb **)USER_UTCB_REF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Functions to read/write utcb registers */
|
/* Functions to read/write utcb registers */
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
/* For ping ponging */
|
/* For ping ponging */
|
||||||
#define L4_IPC_TAG_WAIT 3
|
#define L4_IPC_TAG_WAIT 3
|
||||||
|
|
||||||
/* To negotiate a shared memory mapping */
|
/* To obtain utcb address */
|
||||||
#define L4_IPC_TAG_SHM 4
|
#define L4_IPC_TAG_UTCB 4
|
||||||
|
|
||||||
/* To negotiate a grant mapping */
|
/* XXX: unused */
|
||||||
#define L4_IPC_TAG_GRANT 5
|
#define L4_IPC_TAG_GRANT 5
|
||||||
|
|
||||||
/* Posix system call tags */
|
/* Posix system call tags */
|
||||||
|
|||||||
@@ -5,8 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
#include <l4lib/kip.h>
|
#include <l4lib/kip.h>
|
||||||
#include <l4lib/arch/syslib.h>
|
#include <l4lib/arch/syslib.h>
|
||||||
|
#include <l4lib/arch/utcb.h>
|
||||||
|
#include <l4lib/ipcdefs.h>
|
||||||
#include <l4/macros.h>
|
#include <l4/macros.h>
|
||||||
#include INC_GLUE(memlayout.h)
|
#include INC_GLUE(memlayout.h)
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
__l4_ipc_t __l4_ipc = 0;
|
__l4_ipc_t __l4_ipc = 0;
|
||||||
__l4_map_t __l4_map = 0;
|
__l4_map_t __l4_map = 0;
|
||||||
@@ -23,9 +26,47 @@ __l4_kmem_reclaim_t __l4_kmem_reclaim = 0;
|
|||||||
|
|
||||||
struct kip *kip;
|
struct kip *kip;
|
||||||
|
|
||||||
/* UTCB address of this task. */
|
/*
|
||||||
struct utcb *utcb;
|
* Private UTCB of this task. Used only for pushing/reading ipc
|
||||||
#include <stdio.h>
|
* message registers.
|
||||||
|
*/
|
||||||
|
struct utcb utcb;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shared utcb page for this task. Used for passing data among ipc
|
||||||
|
* parties when message registers are not big enough. Every thread
|
||||||
|
* has right to own one, and it has an address unique to every
|
||||||
|
* thread. It must be explicitly mapped by both parties of the ipc
|
||||||
|
* in order to be useful.
|
||||||
|
*/
|
||||||
|
void *utcb_page;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Obtains a unique address for the task's shared utcb page. Note this
|
||||||
|
* does *not* map the utcb, just returns the address. This address
|
||||||
|
* is used as an shm key to map it via shmget()/shmat() later on.
|
||||||
|
*/
|
||||||
|
static void *l4_utcb_page(void)
|
||||||
|
{
|
||||||
|
void *addr;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* Call pager with utcb address request. Check ipc error. */
|
||||||
|
if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_UTCB)) < 0) {
|
||||||
|
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
|
||||||
|
return PTR_ERR(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if syscall itself was successful */
|
||||||
|
if (IS_ERR(addr = (void *)l4_get_retval())) {
|
||||||
|
printf("%s: Request UTCB Address Error: %d.\n",
|
||||||
|
__FUNCTION__, (int)addr);
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
void __l4_init(void)
|
void __l4_init(void)
|
||||||
{
|
{
|
||||||
@@ -47,10 +88,9 @@ void __l4_init(void)
|
|||||||
|
|
||||||
/* Initialise utcb only if we're not the pager */
|
/* Initialise utcb only if we're not the pager */
|
||||||
if (self_tid() != PAGER_TID) {
|
if (self_tid() != PAGER_TID) {
|
||||||
/* FIXME: C library should give the environ pointer for this */
|
utcb_page = l4_utcb_page();
|
||||||
utcb = *(struct utcb **)(USER_AREA_END - PAGE_SIZE);
|
printf("UTCB Read from mm0 as: 0x%x\n",
|
||||||
printf("UTCB Read from userspace as: 0x%x\n",
|
(unsigned long)utcb_page);
|
||||||
(unsigned long)utcb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ static inline int l4_readdir(int fd, void *buf, size_t count)
|
|||||||
write_mr(L4SYS_ARG1, (unsigned long)buf);
|
write_mr(L4SYS_ARG1, (unsigned long)buf);
|
||||||
write_mr(L4SYS_ARG2, count);
|
write_mr(L4SYS_ARG2, count);
|
||||||
|
|
||||||
/* Call pager with shmget() request. Check ipc error. */
|
/* Call pager with readdir() request. Check ipc error. */
|
||||||
if ((cnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_READDIR)) < 0) {
|
if ((cnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_READDIR)) < 0) {
|
||||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, cnt);
|
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, cnt);
|
||||||
return cnt;
|
return cnt;
|
||||||
@@ -42,8 +42,8 @@ static inline int l4_read(int fd, void *buf, size_t count)
|
|||||||
write_mr(L4SYS_ARG1, (unsigned long)buf);
|
write_mr(L4SYS_ARG1, (unsigned long)buf);
|
||||||
write_mr(L4SYS_ARG2, count);
|
write_mr(L4SYS_ARG2, count);
|
||||||
|
|
||||||
/* Call pager with shmget() request. Check ipc error. */
|
/* Call pager with read() request. Check ipc error. */
|
||||||
if ((cnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_READ)) < 0) {
|
if ((cnt = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_READ)) < 0) {
|
||||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, cnt);
|
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, cnt);
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user