mirror of
https://github.com/drasko/codezero.git
synced 2026-01-17 13:23:16 +01:00
Various minor fixes.
Removed some commented out code. Removed excessive printfs. Fixed spid not initialising for mm0 Fixed some faults with fs0. TODO: - Need to store vfs files in a separate list. - Need to define vnum as a vfs-file-specific data, i.e. in priv_data field of vm_file. - Need to then fix vfs_receive_sys_open.
This commit is contained in:
@@ -65,8 +65,10 @@ void handle_fs_requests(void)
|
||||
|
||||
/* Read mrs not used by syslib */
|
||||
for (int i = 0; i < MR_UNUSED_TOTAL; i++)
|
||||
mr[i] = read_mr(i);
|
||||
mr[i] = read_mr(MR_UNUSED_START + i);
|
||||
|
||||
/* FIXME: Fix all these syscalls to read any buffer data from the caller task's utcb.
|
||||
* Make sure to return -EINVAL if data is not valid. */
|
||||
switch(tag) {
|
||||
case L4_IPC_TAG_WAIT:
|
||||
printf("%s: Synced with waiting thread.\n", __TASKNAME__);
|
||||
|
||||
@@ -91,7 +91,7 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode)
|
||||
|
||||
/* Get the vnode */
|
||||
if (IS_ERR(v = vfs_lookup_bypath(task, pathbuf))) {
|
||||
if (!flags & O_CREAT) {
|
||||
if (!(flags & O_CREAT)) {
|
||||
return (int)v;
|
||||
} else {
|
||||
if ((err = vfs_create(task, pathname, mode)) < 0)
|
||||
@@ -100,7 +100,7 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode)
|
||||
}
|
||||
|
||||
/* Get a new fd */
|
||||
BUG_ON(!(fd = id_new(task->fdpool)));
|
||||
BUG_ON((fd = id_new(task->fdpool)) < 0);
|
||||
|
||||
/* Assign the new fd with the vnode's number */
|
||||
task->fd[fd] = v->vnum;
|
||||
|
||||
@@ -115,6 +115,7 @@ struct tcb *create_tcb(void)
|
||||
if (!(t = kmalloc(sizeof(*t))))
|
||||
return PTR_ERR(-ENOMEM);
|
||||
|
||||
t->fdpool = id_pool_new_init(TASK_OFILES_MAX);
|
||||
INIT_LIST_HEAD(&t->list);
|
||||
list_add_tail(&t->list, &tcb_head.list);
|
||||
tcb_head.total++;
|
||||
|
||||
@@ -90,8 +90,8 @@ int utcb_init(void)
|
||||
|
||||
/* Obtain our utcb page address */
|
||||
utcb_page = l4_utcb_page();
|
||||
printf("%s: UTCB Read from mm0 as: 0x%x\n", __FUNCTION__,
|
||||
(unsigned long)utcb_page);
|
||||
//printf("%s: UTCB Read from mm0 as: 0x%x\n", __FUNCTION__,
|
||||
// (unsigned long)utcb_page);
|
||||
|
||||
/* Use it as a key to create a shared memory region */
|
||||
BUG_ON((shmid = shmget((key_t)utcb_page,
|
||||
|
||||
@@ -35,6 +35,7 @@ static inline int l4_open(const char *pathname, int flags, mode_t mode)
|
||||
|
||||
// write_mr(L4SYS_ARG0, (unsigned long)pathname);
|
||||
copy_to_utcb((void *)pathname, strlen(pathname));
|
||||
write_mr(L4SYS_ARG0, (unsigned long)utcb_page);
|
||||
write_mr(L4SYS_ARG1, flags);
|
||||
write_mr(L4SYS_ARG2, (u32)mode);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <arch/mm.h>
|
||||
#include <lib/spinlock.h>
|
||||
|
||||
#define DEBUG_FAULT_HANDLING
|
||||
// #define DEBUG_FAULT_HANDLING
|
||||
#ifdef DEBUG_FAULT_HANDLING
|
||||
#define dprintf(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
|
||||
@@ -22,32 +22,32 @@ void init_mm(struct initdata *initdata)
|
||||
{
|
||||
/* Initialise the page and bank descriptors */
|
||||
init_physmem(initdata, membank);
|
||||
printf("%s: Initialised physmem.\n", __TASKNAME__);
|
||||
// printf("%s: Initialised physmem.\n", __TASKNAME__);
|
||||
|
||||
/* Initialise the page allocator on first bank. */
|
||||
init_page_allocator(membank[0].free, membank[0].end);
|
||||
printf("%s: Initialised page allocator.\n", __TASKNAME__);
|
||||
// printf("%s: Initialised page allocator.\n", __TASKNAME__);
|
||||
|
||||
/* Initialise the pager's memory allocator */
|
||||
kmalloc_init();
|
||||
printf("%s: Initialised kmalloc.\n", __TASKNAME__);
|
||||
// printf("%s: Initialised kmalloc.\n", __TASKNAME__);
|
||||
|
||||
/* Initialise the zero page */
|
||||
init_devzero();
|
||||
printf("%s: Initialised devzero.\n", __TASKNAME__);
|
||||
// printf("%s: Initialised devzero.\n", __TASKNAME__);
|
||||
|
||||
/* Initialise in-memory boot files */
|
||||
init_boot_files(initdata);
|
||||
printf("%s: Initialised in-memory boot files.\n", __TASKNAME__);
|
||||
// printf("%s: Initialised in-memory boot files.\n", __TASKNAME__);
|
||||
|
||||
shm_init();
|
||||
printf("%s: Initialised shm structures.\n", __TASKNAME__);
|
||||
// printf("%s: Initialised shm structures.\n", __TASKNAME__);
|
||||
|
||||
if (utcb_pool_init() < 0) {
|
||||
printf("UTCB initialisation failed.\n");
|
||||
BUG();
|
||||
}
|
||||
printf("%s: Initialised utcb address pool.\n", __TASKNAME__);
|
||||
// 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));
|
||||
|
||||
@@ -564,8 +564,8 @@ int do_mmap(struct vm_file *mapfile, unsigned long file_offset,
|
||||
}
|
||||
|
||||
/* Finished initialising the vma, add it to task */
|
||||
printf("%s: Mapping 0x%x - 0x%x\n", __FUNCTION__,
|
||||
map_address, map_address + npages * PAGE_SIZE);
|
||||
dprintf("%s: Mapping 0x%x - 0x%x\n", __FUNCTION__,
|
||||
map_address, map_address + npages * PAGE_SIZE);
|
||||
list_add(&new->list, &task->vm_area_list);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -34,6 +34,15 @@ struct tcb_head {
|
||||
int total; /* Total threads */
|
||||
} tcb_head;
|
||||
|
||||
void print_tasks(void)
|
||||
{
|
||||
struct tcb *task;
|
||||
printf("Tasks:\n========\n");
|
||||
list_for_each_entry(task, &tcb_head.list, list) {
|
||||
printf("Task tid: %d, spid: %d\n", task->tid, task->spid);
|
||||
}
|
||||
}
|
||||
|
||||
struct tcb *find_task(int tid)
|
||||
{
|
||||
struct tcb *t;
|
||||
@@ -73,14 +82,12 @@ struct tcb *task_create(struct task_ids *ids)
|
||||
int err;
|
||||
|
||||
/* Create the thread structures and address space */
|
||||
printf("Creating new thread with ids: %d, %d.\n", ids->tid, ids->spid);
|
||||
if ((err = l4_thread_control(THREAD_CREATE, ids)) < 0) {
|
||||
printf("l4_thread_control failed with %d.\n", err);
|
||||
return PTR_ERR(err);
|
||||
}
|
||||
|
||||
/* Create a task and use given space and thread ids. */
|
||||
printf("New task with id: %d, space id: %d\n", ids->tid, ids->spid);
|
||||
if (IS_ERR(task = tcb_alloc_init()))
|
||||
return PTR_ERR(task);
|
||||
|
||||
@@ -195,7 +202,7 @@ int task_start(struct tcb *task, struct task_ids *ids)
|
||||
int err;
|
||||
|
||||
/* Start the thread */
|
||||
printf("Starting task with id %d\n", task->tid);
|
||||
printf("Starting task with id %d, spid: %d\n", task->tid, task->spid);
|
||||
if ((err = l4_thread_control(THREAD_RUN, ids)) < 0) {
|
||||
printf("l4_thread_control failed with %d\n", err);
|
||||
return err;
|
||||
@@ -409,7 +416,7 @@ struct vm_file *initdata_next_bootfile(struct initdata *initdata)
|
||||
*/
|
||||
int start_boot_tasks(struct initdata *initdata)
|
||||
{
|
||||
struct vm_file *file, *fs0, *mm0, *n;
|
||||
struct vm_file *file = 0, *fs0 = 0, *mm0 = 0, *n;
|
||||
struct svc_image *img;
|
||||
struct task_ids ids;
|
||||
struct list_head files;
|
||||
@@ -438,7 +445,7 @@ int start_boot_tasks(struct initdata *initdata)
|
||||
/* MM0 needs partial initialisation, since its already running. */
|
||||
printf("%s: Initialising mm0 tcb.\n", __TASKNAME__);
|
||||
ids.tid = PAGER_TID;
|
||||
ids.tid = PAGER_TID;
|
||||
ids.spid = PAGER_TID;
|
||||
if (mm0_task_init(mm0, INITTASK_AREA_START, INITTASK_AREA_END, &ids) < 0)
|
||||
BUG();
|
||||
total++;
|
||||
@@ -460,14 +467,6 @@ int start_boot_tasks(struct initdata *initdata)
|
||||
BUG();
|
||||
total++;
|
||||
}
|
||||
{
|
||||
struct tcb *t;
|
||||
printf("Tasks:\n========\n");
|
||||
list_for_each_entry(t, &tcb_head.list, list) {
|
||||
printf("Task tid: %d, spid: %d\n", t->tid, t->spid);
|
||||
BUG_ON(t->tid != t->spid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!total) {
|
||||
printf("%s: Could not start any tasks.\n", __TASKNAME__);
|
||||
|
||||
Reference in New Issue
Block a user