Removed allocation of utcb shared pages by mm0 completely.

- Now libl4 has no references to utcb page or shmat etc.
- Pager does not deal with special case utcb page allocation.
  It instead allocates a shared page from shm memory pool.
- All tasks working to original standard.

Next:
- Add per-thread utcb allocation from the kernel
- Add larger register file for standard ipc
- Add long ipc (up to 1Kb)
This commit is contained in:
Bahadir Balban
2009-04-22 14:48:43 +03:00
parent 203f053878
commit 54a9b2901d
18 changed files with 207 additions and 124 deletions

View File

@@ -1,79 +1,30 @@
/*
* Shared page initialisation of posix-like tasks.
* Main entry point for posix services and applications.
*
* POSIX tasks currently use a default shared page for communciation.
* This could have been also done by long ipc calls.
* Copyright (C) 2007-2009 Bahadir Balban
*/
/*
* 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;
#include <shpage.h>
#include <posix_init.h>
/*
* 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 posix_init(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;
/* Non-pager tasks initialise their shared communication page */
if (self_tid() != PAGER_TID)
shared_page_init();
}
int main(void);
/*
* Initialises a non-pager task's default shared memory page
* using posix semantics. Used during task initialisation
* and by child tasks after a fork.
* Entry point for posix services container.
*
* This is executed by all posix system services and tasks
* that run in this container.
*/
int shared_page_init(void)
void __container_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;
posix_init();
main();
}