Few more fixes.

Boot files and tasks are now initialised together. Theads can ask for particular
space and thread ids, if they're unused. This enables us to get predefined ids for
known tasks such as the VFS task.

Fixes to README
Other minor fixes.
This commit is contained in:
Bahadir Balban
2008-02-09 14:24:49 +00:00
parent 4aa26af61d
commit ba0e3ada21
14 changed files with 134 additions and 64 deletions
+1
View File
@@ -71,6 +71,7 @@ static inline struct superblock *vfs_alloc_superblock(void)
{
struct superblock *sb = kmalloc(sizeof(struct superblock));
INIT_LIST_HEAD(&sb->list);
return sb;
}
+13 -2
View File
@@ -6,6 +6,8 @@
#include <init.h>
#include <fs.h>
#include <vfs.h>
#include <task.h>
#include <stdio.h>
#include <memfs/memfs.h>
#include <memfs/vnode.h>
#include <lib/idpool.h>
@@ -138,11 +140,16 @@ struct superblock *memfs_get_superblock(void *block)
struct memfs_superblock *sb = block;
struct superblock *vfs_sb;
printf("%s: %s: Reading superblock.\n", __TASKNAME__, __FUNCTION__);
/* We don't do sanity checks here, just confirm id. */
if (!strcmp(sb->name, "memfs"))
if (strcmp(sb->name, "memfs")) {
printf("%s: Name does not match: %s\n", __FUNCTION__, sb->name);
return 0;
if (sb->magic != MEMFS_MAGIC)
}
if (sb->magic != MEMFS_MAGIC) {
printf("%s: Magic number not match: %s\n", __FUNCTION__, sb->magic);
return 0;
}
/* Allocate a vfs superblock. */
vfs_sb = vfs_alloc_superblock();
@@ -154,6 +161,10 @@ struct superblock *memfs_get_superblock(void *block)
/* Registers sfs as an available filesystem type */
void memfs_register_fstype(struct list_head *fslist)
{
/* Initialise superblock list for this fstype */
INIT_LIST_HEAD(&memfs_fstype.sblist);
/* Add this fstype to list of available fstypes. */
list_add(&memfs_fstype.list, fslist);
}
-2
View File
@@ -16,8 +16,6 @@
#include INC_ARCH(bootdesc.h)
#include <vm_area.h>
#define BOOTDESC_IMAGE_START 1
struct initdata {
struct bootdesc *bootdesc;
struct list_head boot_file_list;
+2 -2
View File
@@ -34,7 +34,7 @@ void handle_requests(void)
u32 tag;
int err;
printf("%s: Initiating ipc.\n", __TASKNAME__);
// printf("%s: Initiating ipc.\n", __TASKNAME__);
if ((err = l4_receive(L4_ANYTHREAD)) < 0) {
printf("%s: %s: IPC Error: %d. Quitting...\n", __TASKNAME__,
__FUNCTION__, err);
@@ -55,7 +55,7 @@ void handle_requests(void)
* A thread that wants to sync with us would have
* started here.
*/
printf("%s: Synced with waiting thread.\n", __TASKNAME__);
// printf("%s: Synced with waiting thread.\n", __TASKNAME__);
break;
case L4_IPC_TAG_PFAULT:
+1 -32
View File
@@ -50,44 +50,13 @@ void init_mm(struct initdata *initdata)
l4_kmem_grant(__pfn(alloc_page(__pfn(SZ_1MB))), __pfn(SZ_1MB));
}
/* Create temporary run-time files in memory to test with mmap */
void init_boot_files(struct initdata *initdata)
{
struct vm_file *f;
struct svc_image *img;
struct bootdesc *bd = initdata->bootdesc;
INIT_LIST_HEAD(&initdata->boot_file_list);
for (int i = BOOTDESC_IMAGE_START; i < bd->total_images; i++) {
img = &bd->images[i];
if (!(!strcmp(img->name, "fs0") || !strcmp(img->name, "test0")))
continue; /* Img is not what we want */
f = kzalloc(sizeof(*f));
INIT_LIST_HEAD(&f->list);
INIT_LIST_HEAD(&f->page_cache_list);
list_add(&f->list, &initdata->boot_file_list);
/*
* For boot files, we use the physical address of the memory
* file as its inode.
*/
f->inode.i_addr = img->phys_start;
f->length = img->phys_end - img->phys_start;
f->pager = &default_file_pager;
}
}
void initialise(void)
{
request_initdata(&initdata);
init_mm(&initdata);
init_boot_files(&initdata);
// printf("INITTASK: Initialised mock-up bootfiles.\n");
init_pm(&initdata);
// printf("INITTASK: Initialised the memory/process manager.\n");
printf("%s: Initialised the memory/process manager.\n", __TASKNAME__);
}
+57 -9
View File
@@ -8,6 +8,7 @@
#include <l4/types.h>
#include <l4/lib/list.h>
#include <l4/api/thread.h>
#include <l4/api/kip.h>
#include INC_GLUE(memory.h)
#include <l4lib/arch/syscalls.h>
#include <l4lib/arch/syslib.h>
@@ -72,17 +73,62 @@ struct tcb *create_init_tcb(struct tcb_head *tcbs)
return task;
}
/* Create temporary run-time files in memory to test with mmap */
struct vm_file *create_init_vmfile(struct list_head *vmfile_head)
{
struct vm_file *file = kzalloc(sizeof(*file));
INIT_LIST_HEAD(&file->list);
INIT_LIST_HEAD(&file->page_cache_list);
list_add(&file->list, vmfile_head);
return file;
}
int start_boot_tasks(struct initdata *initdata, struct tcb_head *tcbs)
{
struct vm_file *file;
int err;
struct vm_file *file;
struct svc_image *img;
unsigned int sp, pc;
struct tcb *task;
struct task_ids ids;
struct bootdesc *bd = initdata->bootdesc;
INIT_LIST_HEAD(&tcb_head.list);
list_for_each_entry(file, &initdata->boot_file_list, list) {
struct tcb *task = create_init_tcb(tcbs);
unsigned int sp = align(USER_AREA_END - 1, 8);
unsigned int pc = USER_AREA_START;
struct task_ids ids = { .tid = task->tid, .spid = task->spid };
INIT_LIST_HEAD(&initdata->boot_file_list);
for (int i = 0; i < bd->total_images; i++) {
img = &bd->images[i];
/* Skip self */
if (!strcmp(img->name, __PAGERNAME__))
continue;
/* Set up task ids */
if (!strcmp(img->name, __VFSNAME__)) {
ids.tid = VFS_TID;
ids.spid = VFS_TID;
} else {
ids.tid = -1;
ids.spid = -1;
}
/* Set up task's registers */
sp = align(USER_AREA_END - 1, 8);
pc = USER_AREA_START;
/* Create vm file and tcb */
file = create_init_vmfile(&initdata->boot_file_list);
task = create_init_tcb(tcbs);
/*
* For boot files, we use the physical address of the memory
* file as its mock-up inode.
*/
file->inode.i_addr = img->phys_start;
file->length = img->phys_end - img->phys_start;
file->pager = &default_file_pager;
/* mmap each task's physical image to task's address space. */
if ((err = do_mmap(file, 0, task, USER_AREA_START,
@@ -102,7 +148,7 @@ int start_boot_tasks(struct initdata *initdata, struct tcb_head *tcbs)
/* mmap each task's utcb as single page anonymous memory. */
if ((err = do_mmap(0, 0, task, (unsigned long)__L4_ARM_Utcb(),
VM_READ | VM_WRITE | VMA_ANON, 1) < 0)) {
printf("do_mmap: Mapping stack failed with %d.\n", err);
printf("do_mmap: Mapping utcb failed with %d.\n", err);
goto error;
}
@@ -113,8 +159,8 @@ int start_boot_tasks(struct initdata *initdata, struct tcb_head *tcbs)
goto error;
}
printf("New task with id: %d, space id: %d\n", ids.tid, ids.spid);
/* Use returned space and thread ids. */
printf("New task with id: %d, space id: %d\n", ids.tid, ids.spid);
task->tid = ids.tid;
task->spid = ids.spid;
@@ -154,7 +200,9 @@ void send_task_data(l4id_t requester)
int li, err;
if (requester != VFS_TID) {
printf("Task data is not requested by FS0, ignoring.\n");
printf("%s: Task data requested by %d, which is not "
"FS0 id %d, ignoring.\n", __TASKNAME__, requester,
VFS_TID);
return;
}
+2 -2
View File
@@ -16,11 +16,11 @@
void wait_pager(l4id_t partner)
{
printf("%s: Syncing with pager.\n", __TASKNAME__);
// printf("%s: Syncing with pager.\n", __TASKNAME__);
for (int i = 0; i < 6; i++)
write_mr(i, i);
l4_send(partner, L4_IPC_TAG_WAIT);
printf("Pager synced with us.\n");
// printf("Pager synced with us.\n");
}
void main(void)