mirror of
https://github.com/drasko/codezero.git
synced 2026-04-02 01:59:05 +02:00
Removed unnecessary printks, fixed few minor issues.
This commit is contained in:
@@ -46,8 +46,15 @@ int sys_ipc_control(struct syscall_args *regs)
|
|||||||
int ipc_send(l4id_t recv_tid)
|
int ipc_send(l4id_t recv_tid)
|
||||||
{
|
{
|
||||||
struct ktcb *receiver = find_task(recv_tid);
|
struct ktcb *receiver = find_task(recv_tid);
|
||||||
struct waitqueue_head *wqhs = &receiver->wqh_send;
|
struct waitqueue_head *wqhs, *wqhr;
|
||||||
struct waitqueue_head *wqhr = &receiver->wqh_recv;
|
|
||||||
|
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(&wqhs->slock);
|
||||||
spin_lock(&wqhr->slock);
|
spin_lock(&wqhr->slock);
|
||||||
|
|||||||
@@ -83,29 +83,19 @@ int thread_create(struct task_ids *ids)
|
|||||||
copy_pgd_kern_all(new->pgd);
|
copy_pgd_kern_all(new->pgd);
|
||||||
|
|
||||||
/* Get new space id */
|
/* Get new space id */
|
||||||
if (ids->spid == TASK_ID_INVALID) {
|
if (ids->spid == TASK_ID_INVALID)
|
||||||
ids->spid = id_new(space_id_pool);
|
ids->spid = id_new(space_id_pool);
|
||||||
printk("Got new space id: %d\n", ids->spid);
|
else
|
||||||
} else {
|
|
||||||
printk("Try new space id: %d\n", ids->spid);
|
|
||||||
if ((ids->spid = id_get(space_id_pool, ids->spid)) < 0)
|
if ((ids->spid = id_get(space_id_pool, ids->spid)) < 0)
|
||||||
ids->spid = id_new(space_id_pool);
|
ids->spid = id_new(space_id_pool);
|
||||||
else
|
|
||||||
printk("Success.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
spc_found:
|
spc_found:
|
||||||
/* Get a new thread id */
|
/* Get a new thread id */
|
||||||
if (ids->tid == TASK_ID_INVALID) {
|
if (ids->tid == TASK_ID_INVALID)
|
||||||
ids->tid = id_new(thread_id_pool);
|
ids->tid = id_new(thread_id_pool);
|
||||||
printk("Got new thread id: %d\n", ids->tid);
|
else
|
||||||
} else {
|
|
||||||
printk("Try new thread id: %d\n", ids->tid);
|
|
||||||
if ((ids->tid = id_get(thread_id_pool, ids->tid)) < 0)
|
if ((ids->tid = id_get(thread_id_pool, ids->tid)) < 0)
|
||||||
ids->tid = id_new(thread_id_pool);
|
ids->tid = id_new(thread_id_pool);
|
||||||
else
|
|
||||||
printk("Success.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set all ids */
|
/* Set all ids */
|
||||||
set_task_ids(new, ids);
|
set_task_ids(new, ids);
|
||||||
|
|||||||
@@ -91,22 +91,22 @@ int check_aborts(u32 faulted_pc, u32 fsr, u32 far)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (is_prefetch_abort(fsr)) {
|
if (is_prefetch_abort(fsr)) {
|
||||||
dprintk("Prefetch abort @ ", faulted_pc);
|
// dprintk("Prefetch abort @ ", faulted_pc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fsr & ARM_FSR_MASK) {
|
switch (fsr & ARM_FSR_MASK) {
|
||||||
/* Aborts that are expected on page faults: */
|
/* Aborts that are expected on page faults: */
|
||||||
case DABT_PERM_PAGE:
|
case DABT_PERM_PAGE:
|
||||||
dprintk("Page permission fault @ ", far);
|
// dprintk("Page permission fault @ ", far);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case DABT_XLATE_PAGE:
|
case DABT_XLATE_PAGE:
|
||||||
dprintk("Page translation fault @ ", far);
|
// dprintk("Page translation fault @ ", far);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case DABT_XLATE_SECT:
|
case DABT_XLATE_SECT:
|
||||||
dprintk("Section translation fault @ ", far);
|
// dprintk("Section translation fault @ ", far);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
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)
|
void data_abort_handler(u32 faulted_pc, u32 fsr, u32 far)
|
||||||
{
|
{
|
||||||
set_abort_type(fsr, ARM_DABT);
|
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) {
|
if (check_aborts(faulted_pc, fsr, far) < 0) {
|
||||||
printascii("This abort can't be handled by any pager.\n");
|
printascii("This abort can't be handled by any pager.\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ int check_access(unsigned long vaddr, unsigned long size, unsigned int flags)
|
|||||||
/* Do not allow ridiculously big sizes */
|
/* Do not allow ridiculously big sizes */
|
||||||
if (size >= USER_AREA_SIZE)
|
if (size >= USER_AREA_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Check if in user range, but this is more up to the pager to decide */
|
/* Check if in user range, but this is more up to the pager to decide */
|
||||||
if (current->tid == PAGER_TID) {
|
if (current->tid == PAGER_TID) {
|
||||||
if (!(vaddr >= INITTASK_AREA_START && vaddr < INITTASK_AREA_END))
|
if (!(vaddr >= INITTASK_AREA_START && vaddr < INITTASK_AREA_END))
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
#include <lib/idpool.h>
|
#include <lib/idpool.h>
|
||||||
#include <l4/lib/list.h>
|
#include <l4/lib/list.h>
|
||||||
|
#include <l4/api/kip.h>
|
||||||
|
|
||||||
#define __TASKNAME__ "FS0"
|
#define __TASKNAME__ __VFSNAME__
|
||||||
|
|
||||||
#define TASK_OFILES_MAX 32
|
#define TASK_OFILES_MAX 32
|
||||||
|
|
||||||
@@ -20,6 +21,6 @@ struct tcb {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct tcb *find_task(int tid);
|
struct tcb *find_task(int tid);
|
||||||
void init_task_data(void);
|
int init_task_data(void);
|
||||||
|
|
||||||
#endif /* __FS0_TASK_H__ */
|
#endif /* __FS0_TASK_H__ */
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void handle_fs_requests(void)
|
|||||||
|
|
||||||
void main(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();
|
initialise();
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
#include <l4lib/ipcdefs.h>
|
#include <l4lib/ipcdefs.h>
|
||||||
#include <l4lib/arch/syscalls.h>
|
#include <l4lib/arch/syscalls.h>
|
||||||
#include <l4lib/arch/syslib.h>
|
#include <l4lib/arch/syslib.h>
|
||||||
#include <vfs.h>
|
|
||||||
#include <lib/malloc.h>
|
#include <lib/malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
|
#include <vfs.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This notifies mm0 that this is the fd that refers to this vnode number
|
* 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;
|
int err;
|
||||||
|
|
||||||
write_mr(L4SYS_ARG0, sender);
|
write_mr(sender, L4SYS_ARG0);
|
||||||
write_mr(L4SYS_ARG1, fd);
|
write_mr(fd, L4SYS_ARG1);
|
||||||
write_mr(L4SYS_ARG2, vnum);
|
write_mr(vnum, L4SYS_ARG2);
|
||||||
|
|
||||||
if ((err = l4_send(PAGER_TID, L4_IPC_TAG_OPENDATA)) < 0) {
|
if ((err = l4_send(PAGER_TID, L4_IPC_TAG_OPENDATA)) < 0) {
|
||||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
|
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
|
||||||
|
|||||||
@@ -56,10 +56,13 @@ int receive_pager_taskdata(l4id_t *tdata)
|
|||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
// printf("%s: %d Total tasks.\n", __FUNCTION__, tdata[0]);
|
||||||
|
|
||||||
/* Now read task ids. */
|
/* 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);
|
tdata[1 + i] = (l4id_t)read_mr(L4SYS_ARG1 + i);
|
||||||
|
// printf("%s: Task id: %d\n", __FUNCTION__, tdata[1 + i]);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -92,7 +95,7 @@ int init_task_structs(l4id_t *tdata)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_task_data(void)
|
int init_task_data(void)
|
||||||
{
|
{
|
||||||
l4id_t tdata[MR_UNUSED_TOTAL];
|
l4id_t tdata[MR_UNUSED_TOTAL];
|
||||||
|
|
||||||
@@ -102,6 +105,8 @@ void init_task_data(void)
|
|||||||
BUG_ON(receive_pager_taskdata(tdata) < 0);
|
BUG_ON(receive_pager_taskdata(tdata) < 0);
|
||||||
|
|
||||||
/* Initialise local task structs using this info */
|
/* Initialise local task structs using this info */
|
||||||
init_task_structs(tdata);
|
BUG_ON(init_task_structs(tdata) < 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ void set_generic_fault_params(struct fault_data *fault)
|
|||||||
else
|
else
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
printf("%s: Handling %s fault (%s abort) from %d. fault @ 0x%x\n",
|
printf("%s: Handling %s fault (%s abort) from %d. fault @ 0x%x\n",
|
||||||
__TASKNAME__, (fault->reason & VM_READ) ? "read" : "write",
|
__TASKNAME__, (fault->reason & VM_READ) ? "read" : "write",
|
||||||
is_prefetch_abort(fault->kdata->fsr) ? "prefetch" : "data",
|
is_prefetch_abort(fault->kdata->fsr) ? "prefetch" : "data",
|
||||||
fault->task->tid, fault->address);
|
fault->task->tid, fault->address);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ int do_file_page(struct fault_data *fault)
|
|||||||
BUG_ON(!list_empty(&page->list));
|
BUG_ON(!list_empty(&page->list));
|
||||||
list_add(&page->list, &page->owner->page_cache_list);
|
list_add(&page->list, &page->owner->page_cache_list);
|
||||||
spin_unlock(&page->lock);
|
spin_unlock(&page->lock);
|
||||||
printf("%s: Mapped new page @ 0x%x to task: %d\n", __TASKNAME__,
|
//printf("%s: Mapped new page @ 0x%x to task: %d\n", __TASKNAME__,
|
||||||
fault->address, fault->task->tid);
|
// fault->address, fault->task->tid);
|
||||||
/* Upgrade RO page to non-cow write */
|
/* Upgrade RO page to non-cow write */
|
||||||
} else if ((reason & VM_WRITE) && (pte_flags & VM_READ)
|
} else if ((reason & VM_WRITE) && (pte_flags & VM_READ)
|
||||||
&& !(vma_flags & VMA_COW)) {
|
&& !(vma_flags & VMA_COW)) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void init_mm(struct initdata *initdata)
|
|||||||
|
|
||||||
/* Initialise the zero page */
|
/* Initialise the zero page */
|
||||||
init_devzero();
|
init_devzero();
|
||||||
printf("%s: Initialised zero page.\n", __TASKNAME__);
|
printf("%s: Initialised devzero.\n", __TASKNAME__);
|
||||||
|
|
||||||
init_utcb();
|
init_utcb();
|
||||||
printf("%s: Initialised own utcb.\n", __TASKNAME__);
|
printf("%s: Initialised own utcb.\n", __TASKNAME__);
|
||||||
|
|||||||
@@ -207,13 +207,13 @@ void send_task_data(l4id_t requester)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* First word is total number of tcbs */
|
/* 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 */
|
/* Write each tcb's tid */
|
||||||
li = 0;
|
li = 0;
|
||||||
list_for_each_entry(t, &tcb_head.list, list) {
|
list_for_each_entry(t, &tcb_head.list, list) {
|
||||||
BUG_ON(li >= MR_USABLE_TOTAL);
|
BUG_ON(li >= MR_USABLE_TOTAL);
|
||||||
write_mr(L4SYS_ARG1 + li, t->tid);
|
write_mr(t->tid, L4SYS_ARG1 + li);
|
||||||
li++;
|
li++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user