Initial efforts to transform utcb handling.

This commit is contained in:
Bahadir Balban
2008-03-18 21:50:47 +00:00
parent 26e6366014
commit ac3935a5d9
4 changed files with 61 additions and 24 deletions

View File

@@ -5,8 +5,11 @@
*/
#include <l4lib/kip.h>
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/utcb.h>
#include <l4lib/ipcdefs.h>
#include <l4/macros.h>
#include INC_GLUE(memlayout.h)
#include <stdio.h>
__l4_ipc_t __l4_ipc = 0;
__l4_map_t __l4_map = 0;
@@ -23,9 +26,47 @@ __l4_kmem_reclaim_t __l4_kmem_reclaim = 0;
struct kip *kip;
/* UTCB address of this task. */
struct utcb *utcb;
#include <stdio.h>
/*
* Private UTCB of this task. Used only for pushing/reading ipc
* 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)
{
@@ -47,10 +88,9 @@ void __l4_init(void)
/* Initialise utcb only if we're not the pager */
if (self_tid() != PAGER_TID) {
/* FIXME: C library should give the environ pointer for this */
utcb = *(struct utcb **)(USER_AREA_END - PAGE_SIZE);
printf("UTCB Read from userspace as: 0x%x\n",
(unsigned long)utcb);
utcb_page = l4_utcb_page();
printf("UTCB Read from mm0 as: 0x%x\n",
(unsigned long)utcb_page);
}
}