From 5b7bb880086de55070cb6d57246d5a262121eaa9 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Thu, 28 Feb 2008 00:40:43 +0000 Subject: [PATCH] Wrote the bits that would fill in arg/env info to first page of task stack. --- tasks/mm0/include/task.h | 2 +- tasks/mm0/src/fault.c | 17 ++++++++++++++++- tasks/mm0/src/task.c | 6 +++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tasks/mm0/include/task.h b/tasks/mm0/include/task.h index 04cd7f6..87de34a 100644 --- a/tasks/mm0/include/task.h +++ b/tasks/mm0/include/task.h @@ -60,7 +60,7 @@ struct tcb { unsigned long args_end; /* UTCB address */ - unsigned long utcb_addr; + unsigned long utcb_address; /* Virtual memory areas */ struct list_head vm_area_list; diff --git a/tasks/mm0/src/fault.c b/tasks/mm0/src/fault.c index d0c038b..122551a 100644 --- a/tasks/mm0/src/fault.c +++ b/tasks/mm0/src/fault.c @@ -258,6 +258,20 @@ int is_env_arg_page(struct fault_data *fault) return fault->address >= page_align(fault->task->stack_end); } +int fill_env_arg_info(struct fault_data *fault, void *vaddr) +{ + /* Get the env start offset in the page */ + unsigned long env_offset = fault->task->env_start & PAGE_MASK; + + /* Write the environment information */ + *(unsigned long *)(vaddr + env_offset) = fault->task->utcb_address; + printf("%s: Written env value 0x%x, to task address 0x%x\n", + __TASKNAME__, fault->task->utcb_address, + page_align(fault->address) + env_offset); + + return 0; +} + /* * Handles any page allocation or file ownership change for anonymous pages. * For read accesses initialises a wired-in zero page and for write accesses @@ -319,8 +333,9 @@ int do_anon_page(struct fault_data *fault) /* Clear the page */ memset((void *)vaddr, 0, PAGE_SIZE); + /* If its the env/arg page on stack, fill that information */ if (is_env_arg_page(fault)) - /* TODO: Fill in environment information here. */ + fill_env_arg_info(fault, vaddr); /* Remove temporary mapping */ l4_unmap((void *)vaddr, 1, self_tid()); diff --git a/tasks/mm0/src/task.c b/tasks/mm0/src/task.c index ea57b94..8256f04 100644 --- a/tasks/mm0/src/task.c +++ b/tasks/mm0/src/task.c @@ -72,7 +72,7 @@ struct tcb *create_init_tcb(struct tcb_head *tcbs) tcbs->total++; /* Allocate a utcb virtual address */ - task->utcb_addr = (unsigned long)utcb_vaddr_new(); + task->utcb_address = (unsigned long)utcb_vaddr_new(); return task; } @@ -158,8 +158,8 @@ int start_boot_tasks(struct initdata *initdata, struct tcb_head *tcbs) /* mmap each task's utcb as single page anonymous memory. */ printf("%s: Mapping utcb for new task at: 0x%x\n", __TASKNAME__, - task->utcb_addr); - if ((err = do_mmap(0, 0, task, task->utcb_addr, + task->utcb_address); + if ((err = do_mmap(0, 0, task, task->utcb_address, VM_READ | VM_WRITE | VMA_ANON, 1) < 0)) { printf("do_mmap: Mapping utcb failed with %d.\n", err); goto error;