From 13b9e5407abbbc28173c8a6a875dbdc708e12dc0 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Mon, 24 Mar 2008 00:46:31 +0000 Subject: [PATCH] Removed non-standard allocation of mm0 utcb. It is now allocated in a generic way using shm_new() which creates a posix shmat()/shmget()'able utcb. --- tasks/mm0/src/init.c | 29 ++++++----------------------- tasks/mm0/src/task.c | 17 ++++++++--------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/tasks/mm0/src/init.c b/tasks/mm0/src/init.c index f7853a0..32eeb01 100644 --- a/tasks/mm0/src/init.c +++ b/tasks/mm0/src/init.c @@ -1,7 +1,7 @@ /* * Initialise the system. * - * Copyright (C) 2007 Bahadir Balban + * Copyright (C) 2007, 2008 Bahadir Balban */ #include #include @@ -17,26 +17,6 @@ #include #include -/* - * Initialise the utcb virtual address pool and its own utcb. - * NOTE: This allocates memory so kmalloc must be initialised first. - * FIXME: Is this necessary anymore??? Who maps mm0's page to share? - */ -void init_utcb_page(void) -{ - void *utcb_virt, *utcb_phys; - - /* Allocate and map one for self */ - if (utcb_pool_init() < 0) - printf("UTCB initialisation failed.\n"); - utcb_virt = utcb_vaddr_new(); - printf("%s: Mapping 0x%x as utcb to self.\n", __TASKNAME__, utcb_virt); - utcb_phys = alloc_page(1); - l4_map(utcb_phys, utcb_virt, 1, MAP_USR_RW_FLAGS, self_tid()); - - /* Initialise the utcb page that is inside l4lib. */ - utcb_page = utcb_virt; -} void init_mm(struct initdata *initdata) { @@ -63,8 +43,11 @@ void init_mm(struct initdata *initdata) shm_init(); printf("%s: Initialised shm structures.\n", __TASKNAME__); - init_utcb_page(); - printf("%s: Initialised mm0 utcb page.\n", __TASKNAME__); + if (utcb_pool_init() < 0) { + printf("UTCB initialisation failed.\n"); + BUG(); + } + printf("%s: Initialised utcb address pool.\n", __TASKNAME__); /* Give the kernel some memory to use for its allocators */ l4_kmem_grant(__pfn(alloc_page(__pfn(SZ_1MB))), __pfn(SZ_1MB)); diff --git a/tasks/mm0/src/task.c b/tasks/mm0/src/task.c index 2aa08e0..2a02fc8 100644 --- a/tasks/mm0/src/task.c +++ b/tasks/mm0/src/task.c @@ -94,6 +94,7 @@ struct tcb *task_create(struct task_ids *ids) int task_mmap_regions(struct tcb *task, struct vm_file *file) { int err; + struct vm_file *shm; /* * mmap each task's physical image to task's address space. @@ -124,14 +125,19 @@ int task_mmap_regions(struct tcb *task, struct vm_file *file) return err; } + /* Task's utcb */ + task->utcb = utcb_vaddr_new(); + + /* Create a shared memory segment available for shmat() */ + if (IS_ERR(shm = shm_new((key_t)task->utcb, __pfn(DEFAULT_UTCB_SIZE)))) + return (int)shm; + return 0; } int task_setup_regions(struct vm_file *file, struct tcb *task, unsigned long task_start, unsigned long task_end) { - struct vm_file *shm; - /* * Set task's main address space boundaries. Not all tasks * run in the default user boundaries, e.g. mm0 pager. @@ -159,13 +165,6 @@ int task_setup_regions(struct vm_file *file, struct tcb *task, task->map_start = task->data_end; task->map_end = task->stack_start; - /* Task's utcb */ - task->utcb = utcb_vaddr_new(); - - /* Create a shared memory segment available for shmat() */ - if (IS_ERR(shm = shm_new((key_t)task->utcb, __pfn(DEFAULT_UTCB_SIZE)))) - return (int)shm; - return 0; }