diff --git a/src/api/ipc.c b/src/api/ipc.c index b09cb12..0ab9338 100644 --- a/src/api/ipc.c +++ b/src/api/ipc.c @@ -85,8 +85,8 @@ int ipc_send(l4id_t recv_tid) /* Do the work */ ipc_msg_copy(sleeper, current); - //printk("(%d) Waking up (%d)\n", current->tid, - // sleeper->tid); + printk("%s: (%d) Waking up (%d)\n", __FUNCTION__, + current->tid, sleeper->tid); /* Wake it up, we can yield here. */ sched_resume_task(sleeper); @@ -100,7 +100,7 @@ int ipc_send(l4id_t recv_tid) list_add_tail(&wq.task_list, &wqhs->task_list); sched_notify_sleep(current); need_resched = 1; - //printk("(%d) waiting for (%d)\n", current->tid, recv_tid); + printk("%s: (%d) waiting for (%d)\n", __FUNCTION__, current->tid, recv_tid); spin_unlock(&wqhr->slock); spin_unlock(&wqhs->slock); return 0; @@ -133,8 +133,8 @@ int ipc_recv(l4id_t senderid) /* Do the work */ ipc_msg_copy(current, sleeper); - //printk("(%d) Waking up (%d)\n", current->tid, - // sleeper->tid); + printk("%s: (%d) Waking up (%d)\n", __FUNCTION__, + current->tid, sleeper->tid); /* Wake it up */ sched_resume_task(sleeper); @@ -149,7 +149,7 @@ int ipc_recv(l4id_t senderid) list_add_tail(&wq.task_list, &wqhr->task_list); sched_notify_sleep(current); need_resched = 1; -// printk("(%d) waiting for (%d) \n", current->tid, current->senderid); + printk("%s: (%d) waiting for (%d) \n", __FUNCTION__, current->tid, current->senderid); spin_unlock(&wqhr->slock); spin_unlock(&wqhs->slock); return 0; diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index aae0ca4..3867f3d 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -30,6 +30,8 @@ int pager_sys_open(l4id_t sender, int fd, unsigned long vnum, unsigned long size { int err; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + l4_save_ipcregs(); write_mr(L4SYS_ARG0, sender); @@ -104,6 +106,8 @@ int pager_sys_close(l4id_t sender, l4id_t closer, int fd) struct tcb *task; int err; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + BUG_ON(!(task = find_task(closer))); printf("Deleting fd: %d\n", fd); @@ -132,6 +136,7 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode) int fd; int retval, err; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); /* Get the task */ BUG_ON(!(task = find_task(sender))); @@ -337,6 +342,7 @@ int pager_sys_read(l4id_t sender, unsigned long vnum, unsigned long f_offset, struct vnode *v; int err, retval = 0; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); if (sender != PAGER_TID) { retval = -EINVAL; goto out; @@ -370,6 +376,7 @@ int pager_update_stats(l4id_t sender, unsigned long vnum, struct vnode *v; int retval = 0; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); if (sender != PAGER_TID) { retval = -EINVAL; goto out; @@ -402,6 +409,7 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset, struct vnode *v; int err, retval = 0; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); if (sender != PAGER_TID) { retval = -EINVAL; goto out; @@ -419,6 +427,9 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset, goto out; } + printf("%s/%s: Writing to vnode %lu, at pgoff 0x%x, %d pages, buf at 0x%x\n", + __TASKNAME__, __FUNCTION__, vnum, f_offset, npages, pagebuf); + /* * If the file is extended, write silently extends it. * But we expect an explicit pager_update_stats from the @@ -430,7 +441,9 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset, } out: + printf("%s/%s: Returning ipc result.\n", __TASKNAME__, __FUNCTION__); l4_ipc_return(retval); + printf("%s/%s: Done.\n", __TASKNAME__, __FUNCTION__); return 0; } @@ -482,6 +495,7 @@ int sys_readdir(l4id_t sender, int fd, void *buf, int count) struct dentry *d; struct tcb *t; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); /* Get the task */ BUG_ON(!(t = find_task(sender))); diff --git a/tasks/mm0/src/file.c b/tasks/mm0/src/file.c index df2d42e..e15d493 100644 --- a/tasks/mm0/src/file.c +++ b/tasks/mm0/src/file.c @@ -55,6 +55,8 @@ int vfs_read(unsigned long vnum, unsigned long file_offset, { int err; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + l4_save_ipcregs(); write_mr(L4SYS_ARG0, vnum); @@ -90,6 +92,8 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd, struct vm_file *vmfile; struct tcb *t; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + /* Check argument validity */ if (sender != VFS_TID) { l4_ipc_return(-EPERM); @@ -214,6 +218,7 @@ int vfs_write(unsigned long vnum, unsigned long file_offset, { int err; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); l4_save_ipcregs(); write_mr(L4SYS_ARG0, vnum); @@ -241,6 +246,7 @@ int vfs_close(l4id_t sender, int fd) { int err; + printf("%s/%s Sending to %d\n", __TASKNAME__, __FUNCTION__, VFS_TID); l4_save_ipcregs(); write_mr(L4SYS_ARG0, sender); @@ -250,6 +256,7 @@ int vfs_close(l4id_t sender, int fd) printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); return err; } + printf("%s/%s Received from %d\n", __TASKNAME__, __FUNCTION__, VFS_TID); /* Check if syscall was successful */ if ((err = l4_get_retval()) < 0) { @@ -267,6 +274,7 @@ int vfs_update_file_stats(struct vm_file *f) { int err; + printf("%s/%s\n", __TASKNAME__, __FUNCTION__); l4_save_ipcregs(); write_mr(L4SYS_ARG0, vm_file_to_vnum(f)); @@ -373,7 +381,7 @@ int sys_close(l4id_t sender, int fd) l4_ipc_return(retval); return 0; } - + /* Close the file descriptor. */ retval = fd_close(sender, fd); printf("%s: Closed fd %d. Returning %d\n", @@ -454,6 +462,7 @@ copy: copy_offset = (unsigned long)buf; page_copy(head, task_virt_to_page(task, copy_offset), cursor_offset, copy_offset & PAGE_MASK, copysize); + head->flags |= VM_DIRTY; left -= copysize; last_pgoff = head->offset; @@ -473,6 +482,7 @@ copy: page_copy(this, task_virt_to_page(task, copy_offset), 0, 0, copysize); + this->flags |= VM_DIRTY; left -= copysize; last_pgoff = this->offset; } diff --git a/tasks/mm0/src/pagers.c b/tasks/mm0/src/pagers.c index b68e853..4a7e609 100644 --- a/tasks/mm0/src/pagers.c +++ b/tasks/mm0/src/pagers.c @@ -84,9 +84,15 @@ int file_page_out(struct vm_object *vm_obj, unsigned long page_offset) if (!(page->flags & VM_DIRTY)) return 0; + paddr = (void *)page_to_phys(page); + vaddr = phys_to_virt(paddr); + /* Map the page to vfs task */ l4_map(paddr, vaddr, 1, MAP_USR_RW_FLAGS, VFS_TID); + printf("%s/%s: Writing to vnode %d, at pgoff 0x%x, %d pages, buf at 0x%x\n", + __TASKNAME__, __FUNCTION__, vm_file_to_vnum(f), page_offset, 1, vaddr); + /* Syscall to vfs to write page back to file. */ if ((err = vfs_write(vm_file_to_vnum(f), page_offset, 1, vaddr)) < 0) goto out_err; diff --git a/tasks/test0/src/fileio.c b/tasks/test0/src/fileio.c index 212d6df..8f74af1 100644 --- a/tasks/test0/src/fileio.c +++ b/tasks/test0/src/fileio.c @@ -21,7 +21,7 @@ int fileio2(void) perror("OPEN"); return -1; } - printf("Created newfile.txt\n"); + printf("Created newfile2.txt\n"); printf("%s: write.\n", __TASKNAME__); if ((int)(cnt = write(fd, str, strlen(str))) < 0) { diff --git a/tools/l4-qemunew b/tools/l4-qemunew index c202ffc..d3ca3fe 100755 --- a/tools/l4-qemunew +++ b/tools/l4-qemunew @@ -1,6 +1,6 @@ cd build #arm-none-eabi-insight & -/opt/bin/qemu-system-arm -s -kernel final.axf -nographic -m 128 -M versatilepb & +/opt/qemu/bin/qemu-system-arm -s -kernel final.axf -nographic -m 128 -M versatilepb & arm-none-linux-gnueabi-insight ; pkill qemu-system-arm #arm-none-eabi-gdb ; pkill qemu-system-arm cd ..