mirror of
https://github.com/drasko/codezero.git
synced 2026-01-13 19:33:15 +01:00
Previously a so-called utcb shared page was used for transfering data between posix services. This was a special shmat/get/dt case allocating from its own virtual pool. Now the term utcb is renamed as a shared page and integrated with the shm* handling routines. Generic l4 threads will use long-ipc and not this method. Posix services will continue to communicate on a shared page for now. modified: tasks/libl4/include/l4lib/ipcdefs.h modified: tasks/libl4/src/init.c new file: tasks/libposix/init.c modified: tasks/mm0/include/shm.h modified: tasks/mm0/include/task.h deleted: tasks/mm0/include/utcb.h modified: tasks/mm0/main.c modified: tasks/mm0/src/boot.c modified: tasks/mm0/src/clone.c modified: tasks/mm0/src/execve.c modified: tasks/mm0/src/exit.c modified: tasks/mm0/src/init.c modified: tasks/mm0/src/shm.c modified: tasks/mm0/src/task.c deleted: tasks/mm0/src/utcb.c deleted: tools/l4-qemu
80 lines
2.0 KiB
C
80 lines
2.0 KiB
C
/*
|
|
* Shared page initialisation of posix-like tasks.
|
|
*
|
|
* POSIX tasks currently use a default shared page for communciation.
|
|
* This could have been also done by long ipc calls.
|
|
*/
|
|
|
|
/*
|
|
* Shared 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 *shared_page;
|
|
|
|
/*
|
|
* Obtains a unique address for the task's shared page. Note this
|
|
* just returns the address. This address is used as an shm key
|
|
* to map it via shmget()/shmat() later on.
|
|
*/
|
|
static void *shared_page_address(void)
|
|
{
|
|
void *addr;
|
|
int err;
|
|
|
|
/* We're asking it for ourself. */
|
|
write_mr(L4SYS_ARG0, self_tid());
|
|
|
|
/* Call pager with utcb address request. Check ipc error. */
|
|
if ((err = l4_sendrecv(PAGER_TID, PAGER_TID,
|
|
L4_IPC_TAG_DEFAULT_SHPAGE)) < 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;
|
|
}
|
|
|
|
/*
|
|
* Initialises a non-pager task's default shared memory page
|
|
* using posix semantics. Used during task initialisation
|
|
* and by child tasks after a fork.
|
|
*/
|
|
int shared_page_init(void)
|
|
{
|
|
int shmid;
|
|
void *shmaddr;
|
|
|
|
/*
|
|
* Initialise shared page only if we're not the pager.
|
|
* The pager does it differently for itself.
|
|
*/
|
|
BUG_ON(self_tid() == PAGER_TID);
|
|
|
|
/* Obtain our utcb page address */
|
|
utcb_page = l4_utcb_page();
|
|
//printf("%s: UTCB Read from mm0 as: 0x%x\n", __FUNCTION__,
|
|
// (unsigned long)utcb_page);
|
|
|
|
/* Use it as a key to create a shared memory region */
|
|
BUG_ON((shmid = shmget((key_t)utcb_page,
|
|
PAGE_SIZE, IPC_CREAT)) < 0);
|
|
|
|
/* Attach to the region */
|
|
BUG_ON((shmaddr = shmat(shmid, utcb_page, 0)) < 0);
|
|
BUG_ON(shmaddr != utcb_page);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|