From 57420942bad85dcf836bbbc642d8cf9ad139efee Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 9 Feb 2008 15:48:10 +0000 Subject: [PATCH] Removed unnecessary printks, fixed few minor issues. --- src/api/ipc.c | 11 +++++++++-- src/api/thread.c | 18 ++++-------------- src/arch/arm/exception.c | 10 +++++----- src/generic/space.c | 1 + tasks/fs0/include/task.h | 5 +++-- tasks/fs0/main.c | 2 +- tasks/fs0/src/syscalls.c | 8 ++++---- tasks/fs0/src/task.c | 11 ++++++++--- tasks/mm0/src/arch-arm/mm.c | 2 ++ tasks/mm0/src/fault.c | 4 ++-- tasks/mm0/src/init.c | 2 +- tasks/mm0/src/task.c | 4 ++-- 12 files changed, 42 insertions(+), 36 deletions(-) diff --git a/src/api/ipc.c b/src/api/ipc.c index 81a9ffd..2fec995 100644 --- a/src/api/ipc.c +++ b/src/api/ipc.c @@ -46,8 +46,15 @@ int sys_ipc_control(struct syscall_args *regs) int ipc_send(l4id_t recv_tid) { struct ktcb *receiver = find_task(recv_tid); - struct waitqueue_head *wqhs = &receiver->wqh_send; - struct waitqueue_head *wqhr = &receiver->wqh_recv; + struct waitqueue_head *wqhs, *wqhr; + + if (!receiver) { + printk("%s: tid: %d, no such task.\n", __FUNCTION__, + recv_tid); + return -EINVAL; + } + wqhs = &receiver->wqh_send; + wqhr = &receiver->wqh_recv; spin_lock(&wqhs->slock); spin_lock(&wqhr->slock); diff --git a/src/api/thread.c b/src/api/thread.c index 28102f6..80bc054 100644 --- a/src/api/thread.c +++ b/src/api/thread.c @@ -83,29 +83,19 @@ int thread_create(struct task_ids *ids) copy_pgd_kern_all(new->pgd); /* Get new space id */ - if (ids->spid == TASK_ID_INVALID) { + if (ids->spid == TASK_ID_INVALID) ids->spid = id_new(space_id_pool); - printk("Got new space id: %d\n", ids->spid); - } else { - printk("Try new space id: %d\n", ids->spid); + else if ((ids->spid = id_get(space_id_pool, ids->spid)) < 0) ids->spid = id_new(space_id_pool); - else - printk("Success.\n"); - } spc_found: /* Get a new thread id */ - if (ids->tid == TASK_ID_INVALID) { + if (ids->tid == TASK_ID_INVALID) ids->tid = id_new(thread_id_pool); - printk("Got new thread id: %d\n", ids->tid); - } else { - printk("Try new thread id: %d\n", ids->tid); + else if ((ids->tid = id_get(thread_id_pool, ids->tid)) < 0) ids->tid = id_new(thread_id_pool); - else - printk("Success.\n"); - } /* Set all ids */ set_task_ids(new, ids); diff --git a/src/arch/arm/exception.c b/src/arch/arm/exception.c index 9bd4f73..31322db 100644 --- a/src/arch/arm/exception.c +++ b/src/arch/arm/exception.c @@ -91,22 +91,22 @@ int check_aborts(u32 faulted_pc, u32 fsr, u32 far) int ret = 0; if (is_prefetch_abort(fsr)) { - dprintk("Prefetch abort @ ", faulted_pc); + // dprintk("Prefetch abort @ ", faulted_pc); return 0; } switch (fsr & ARM_FSR_MASK) { /* Aborts that are expected on page faults: */ case DABT_PERM_PAGE: - dprintk("Page permission fault @ ", far); +// dprintk("Page permission fault @ ", far); ret = 0; break; case DABT_XLATE_PAGE: - dprintk("Page translation fault @ ", far); +// dprintk("Page translation fault @ ", far); ret = 0; break; case DABT_XLATE_SECT: - dprintk("Section translation fault @ ", far); +// dprintk("Section translation fault @ ", far); ret = 0; break; @@ -175,7 +175,7 @@ int check_aborts(u32 faulted_pc, u32 fsr, u32 far) void data_abort_handler(u32 faulted_pc, u32 fsr, u32 far) { set_abort_type(fsr, ARM_DABT); - dprintk("Data abort @ PC: ", faulted_pc); + // dprintk("Data abort @ PC: ", faulted_pc); if (check_aborts(faulted_pc, fsr, far) < 0) { printascii("This abort can't be handled by any pager.\n"); goto error; diff --git a/src/generic/space.c b/src/generic/space.c index 2732722..a976f3c 100644 --- a/src/generic/space.c +++ b/src/generic/space.c @@ -25,6 +25,7 @@ int check_access(unsigned long vaddr, unsigned long size, unsigned int flags) /* Do not allow ridiculously big sizes */ if (size >= USER_AREA_SIZE) return -EINVAL; + /* Check if in user range, but this is more up to the pager to decide */ if (current->tid == PAGER_TID) { if (!(vaddr >= INITTASK_AREA_START && vaddr < INITTASK_AREA_END)) diff --git a/tasks/fs0/include/task.h b/tasks/fs0/include/task.h index f4185ae..b0aefb7 100644 --- a/tasks/fs0/include/task.h +++ b/tasks/fs0/include/task.h @@ -6,8 +6,9 @@ #include #include +#include -#define __TASKNAME__ "FS0" +#define __TASKNAME__ __VFSNAME__ #define TASK_OFILES_MAX 32 @@ -20,6 +21,6 @@ struct tcb { }; struct tcb *find_task(int tid); -void init_task_data(void); +int init_task_data(void); #endif /* __FS0_TASK_H__ */ diff --git a/tasks/fs0/main.c b/tasks/fs0/main.c index b3d0987..2855c79 100644 --- a/tasks/fs0/main.c +++ b/tasks/fs0/main.c @@ -71,7 +71,7 @@ void handle_fs_requests(void) void main(void) { - printf("\n\n%s: Started with tid: %d\n", __TASKNAME__, self_tid()); + printf("\n%s: Started with tid: %d\n", __TASKNAME__, self_tid()); initialise(); diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index 3b3ff19..5037f92 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -8,11 +8,11 @@ #include #include #include -#include #include #include #include #include +#include /* * This notifies mm0 that this is the fd that refers to this vnode number @@ -26,9 +26,9 @@ int send_pager_opendata(l4id_t sender, int fd, unsigned long vnum) { int err; - write_mr(L4SYS_ARG0, sender); - write_mr(L4SYS_ARG1, fd); - write_mr(L4SYS_ARG2, vnum); + write_mr(sender, L4SYS_ARG0); + write_mr(fd, L4SYS_ARG1); + write_mr(vnum, L4SYS_ARG2); if ((err = l4_send(PAGER_TID, L4_IPC_TAG_OPENDATA)) < 0) { printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); diff --git a/tasks/fs0/src/task.c b/tasks/fs0/src/task.c index 0479a18..2e7cde1 100644 --- a/tasks/fs0/src/task.c +++ b/tasks/fs0/src/task.c @@ -56,10 +56,13 @@ int receive_pager_taskdata(l4id_t *tdata) __FUNCTION__); BUG(); } + // printf("%s: %d Total tasks.\n", __FUNCTION__, tdata[0]); /* Now read task ids. */ - for (int i = 0; i < (int)tdata[0]; i++) + for (int i = 0; i < (int)tdata[0]; i++) { tdata[1 + i] = (l4id_t)read_mr(L4SYS_ARG1 + i); + // printf("%s: Task id: %d\n", __FUNCTION__, tdata[1 + i]); + } return 0; } @@ -92,7 +95,7 @@ int init_task_structs(l4id_t *tdata) return 0; } -void init_task_data(void) +int init_task_data(void) { l4id_t tdata[MR_UNUSED_TOTAL]; @@ -102,6 +105,8 @@ void init_task_data(void) BUG_ON(receive_pager_taskdata(tdata) < 0); /* Initialise local task structs using this info */ - init_task_structs(tdata); + BUG_ON(init_task_structs(tdata) < 0); + + return 0; } diff --git a/tasks/mm0/src/arch-arm/mm.c b/tasks/mm0/src/arch-arm/mm.c index 1e7efcb..444bb22 100644 --- a/tasks/mm0/src/arch-arm/mm.c +++ b/tasks/mm0/src/arch-arm/mm.c @@ -51,9 +51,11 @@ void set_generic_fault_params(struct fault_data *fault) else BUG(); } + /* printf("%s: Handling %s fault (%s abort) from %d. fault @ 0x%x\n", __TASKNAME__, (fault->reason & VM_READ) ? "read" : "write", is_prefetch_abort(fault->kdata->fsr) ? "prefetch" : "data", fault->task->tid, fault->address); + */ } diff --git a/tasks/mm0/src/fault.c b/tasks/mm0/src/fault.c index bab8e64..b8e2ad1 100644 --- a/tasks/mm0/src/fault.c +++ b/tasks/mm0/src/fault.c @@ -118,8 +118,8 @@ int do_file_page(struct fault_data *fault) BUG_ON(!list_empty(&page->list)); list_add(&page->list, &page->owner->page_cache_list); spin_unlock(&page->lock); - printf("%s: Mapped new page @ 0x%x to task: %d\n", __TASKNAME__, - fault->address, fault->task->tid); + //printf("%s: Mapped new page @ 0x%x to task: %d\n", __TASKNAME__, + // fault->address, fault->task->tid); /* Upgrade RO page to non-cow write */ } else if ((reason & VM_WRITE) && (pte_flags & VM_READ) && !(vma_flags & VMA_COW)) { diff --git a/tasks/mm0/src/init.c b/tasks/mm0/src/init.c index 3f64246..3656b52 100644 --- a/tasks/mm0/src/init.c +++ b/tasks/mm0/src/init.c @@ -34,7 +34,7 @@ void init_mm(struct initdata *initdata) /* Initialise the zero page */ init_devzero(); - printf("%s: Initialised zero page.\n", __TASKNAME__); + printf("%s: Initialised devzero.\n", __TASKNAME__); init_utcb(); printf("%s: Initialised own utcb.\n", __TASKNAME__); diff --git a/tasks/mm0/src/task.c b/tasks/mm0/src/task.c index 356f7ed..d8b42d2 100644 --- a/tasks/mm0/src/task.c +++ b/tasks/mm0/src/task.c @@ -207,13 +207,13 @@ void send_task_data(l4id_t requester) } /* First word is total number of tcbs */ - write_mr(L4SYS_ARG0, tcb_head.total); + write_mr(tcb_head.total, L4SYS_ARG0); /* Write each tcb's tid */ li = 0; list_for_each_entry(t, &tcb_head.list, list) { BUG_ON(li >= MR_USABLE_TOTAL); - write_mr(L4SYS_ARG1 + li, t->tid); + write_mr(t->tid, L4SYS_ARG1 + li); li++; }