Cleaned up all compile errors.

This commit is contained in:
Bahadir Balban
2008-08-25 16:59:00 +03:00
parent cdfaa4bbe9
commit 476bac5142
19 changed files with 99 additions and 80 deletions

View File

@@ -2,6 +2,9 @@
#define __MM0_IDPOOL_H__
#include <lib/bit.h>
#include <l4/macros.h>
#include INC_GLUE(memory.h)
#include <string.h>
struct id_pool {
int nwords;
@@ -9,7 +12,7 @@ struct id_pool {
};
/* Copy one id pool to another by calculating its size */
static inline void id_pool_copy(struct idpool *to, struct idpool *from, int totalbits)
static inline void id_pool_copy(struct id_pool *to, struct id_pool *from, int totalbits)
{
int nwords = BITWISE_GETWORD(totalbits);

View File

@@ -22,4 +22,8 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset,
int pager_sys_close(l4id_t sender, l4id_t closer, int fd);
int pager_update_stats(l4id_t sender, unsigned long vnum,
unsigned long newsize);
int pager_notify_fork(l4id_t sender, l4id_t parid,
l4id_t chid, unsigned long utcb_address);
#endif /* __FS0_SYSCALLS_H__ */

View File

@@ -10,12 +10,6 @@
#include INC_GLUE(memory.h)
#include <stdio.h>
static inline void id_pool_copy(struct idpool *to, struct idpool *from, int totalbits)
{
int nwords = BITWISE_GETWORD(totalbits);
memcpy(to, from, nwords * SZ_WORD + sizeof(struct id_pool));
}
struct id_pool *id_pool_new_init(int totalbits)
{
int nwords = BITWISE_GETWORD(totalbits);

View File

@@ -72,6 +72,22 @@ int receive_pager_taskdata_orig(l4id_t *tdata)
return 0;
}
/* Allocate a task struct and initialise it */
struct tcb *create_tcb(void)
{
struct tcb *t;
if (!(t = kmalloc(sizeof(*t))))
return PTR_ERR(-ENOMEM);
t->fdpool = id_pool_new_init(TASK_FILES_MAX);
INIT_LIST_HEAD(&t->list);
list_add_tail(&t->list, &tcb_head.list);
tcb_head.total++;
return t;
}
/*
* Receives ipc from pager about a new fork event and
* the information on the resulting child task.
@@ -80,7 +96,6 @@ int pager_notify_fork(l4id_t sender, l4id_t parid,
l4id_t chid, unsigned long utcb_address)
{
struct tcb *child, *parent;
int err;
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
BUG_ON(!(parent = find_task(parid)));
@@ -136,22 +151,6 @@ struct task_data_head *receive_pager_taskdata(void)
return (struct task_data_head *)utcb_page;
}
/* Allocate a task struct and initialise it */
struct tcb *create_tcb(void)
{
struct tcb *t;
if (!(t = kmalloc(sizeof(*t))))
return PTR_ERR(-ENOMEM);
t->fdpool = id_pool_new_init(TASK_FILES_MAX);
INIT_LIST_HEAD(&t->list);
list_add_tail(&t->list, &tcb_head.list);
tcb_head.total++;
return t;
}
/* Attaches to task's utcb. FIXME: Add SHM_RDONLY and test it. */
int task_utcb_attach(struct tcb *t)
{

View File

@@ -20,6 +20,9 @@
#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
struct vm_area *vma_new(unsigned long pfn_start, unsigned long npages,
unsigned int flags, unsigned long file_offset);
int do_munmap(void *vaddr, unsigned long size, struct tcb *task);
int do_mmap(struct vm_file *mapfile, unsigned long f_offset, struct tcb *t,

View File

@@ -10,6 +10,7 @@
#define __MM0_SYSARGS_H__
#include <sys/types.h>
#include <l4lib/types.h>
/* For reading argument data from a system call */
struct sys_mmap_args {
@@ -43,7 +44,7 @@ struct sys_shmget_args {
int sys_shmget(key_t key, int size, int shmflg);
int sys_fork(void);
int sys_fork(l4id_t parent);
#endif /* __MM0_SYSARGS_H__ */

View File

@@ -10,7 +10,7 @@
#include <l4/types.h>
#include INC_GLUE(memlayout.h)
#include <l4/lib/list.h>
#include <l4lib/types.h>
#include <l4lib/arch/types.h>
#include <l4lib/utcb.h>
#include <lib/addr.h>
#include <l4/api/kip.h>

View File

@@ -120,7 +120,7 @@ void handle_requests(void)
args->flags, args->fd, __pfn(args->offset));
break;
}
case L4_IPC_TAG_MMAP: {
case L4_IPC_TAG_FORK: {
sys_fork(sender);
break;
}

View File

@@ -6,7 +6,12 @@
#include <syscalls.h>
#include <vm_area.h>
#include <task.h>
#include <mmap.h>
#include <l4lib/arch/syslib.h>
#include <l4lib/ipcdefs.h>
#include <l4/api/thread.h>
#include <utcb.h>
#include <shm.h>
/*
* Copy all vmas from the given task and populate each with
@@ -16,10 +21,10 @@
*/
int copy_vmas(struct tcb *to, struct tcb *from)
{
struct vm_area *vma, new_vma;
struct vm_area *vma, *new_vma;
struct vm_obj_link *vmo_link, *new_link;
list_for_each_entry(vma, from->vm_area_list, list) {
list_for_each_entry(vma, &from->vm_area_list, list) {
/* Create a new vma */
new_vma = vma_new(vma->pfn_start, vma->pfn_end - vma->pfn_start,
@@ -44,7 +49,7 @@ int copy_vmas(struct tcb *to, struct tcb *from)
&vma->vm_obj_list)));
/* All link copying is finished, now add the new vma to task */
list_add_tail(&vma_new->list, &to->vm_area_list);
list_add_tail(&new_vma->list, &to->vm_area_list);
}
return 0;
@@ -78,16 +83,16 @@ int copy_tcb(struct tcb *to, struct tcb *from)
/* Copy all file descriptors */
memcpy(to->fd, from->fd,
TASK_FILES_MAX * sizeof(struct file_descriptor));
return 0;
}
/*
* Sends vfs task information about forked child, and its utcb
*/
void vfs_notify_fork(struct tcb *child, struct tcb *parent)
int vfs_notify_fork(struct tcb *child, struct tcb *parent)
{
int err;
struct task_data_head *tdata_head;
struct tcb *vfs;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
@@ -96,7 +101,7 @@ void vfs_notify_fork(struct tcb *child, struct tcb *parent)
/* Write parent and child information */
write_mr(L4SYS_ARG0, parent->tid);
write_mr(L4SYS_ARG1, child->tid);
write_mr(L4SYS_ARG2, child->utcb);
write_mr(L4SYS_ARG2, (unsigned int)child->utcb);
if ((err = l4_sendrecv(VFS_TID, VFS_TID,
L4_IPC_TAG_NOTIFY_FORK)) < 0) {
@@ -118,6 +123,7 @@ void vfs_notify_fork(struct tcb *child, struct tcb *parent)
int do_fork(struct tcb *parent)
{
struct tcb *child;
struct vm_file *utcb_shm;
struct task_ids ids = {
.tid = TASK_ID_INVALID,
.spid = parent->spid,
@@ -130,7 +136,7 @@ int do_fork(struct tcb *parent)
* Create a new L4 thread with parent's page tables
* kernel stack and kernel-side tcb copied
*/
child = task_create(&ids, THREAD_CREATE_COPYSPACE);
child = task_create(&ids, THREAD_CREATE_COPYSPC);
/* Copy parent tcb to child */
copy_tcb(child, parent);
@@ -142,9 +148,9 @@ int do_fork(struct tcb *parent)
* Create the utcb shared memory segment
* available for child to shmat()
*/
if (IS_ERR(shm = shm_new((key_t)child->utcb,
__pfn(DEFAULT_UTCB_SIZE)))) {
l4_ipc_return((int)shm);
if (IS_ERR(utcb_shm = shm_new((key_t)child->utcb,
__pfn(DEFAULT_UTCB_SIZE)))) {
l4_ipc_return((int)utcb_shm);
return 0;
}
/* FIXME: We should munmap() parent's utcb page from child */
@@ -153,7 +159,7 @@ int do_fork(struct tcb *parent)
vfs_notify_fork(child, parent);
/* Start forked child. */
l4_thread_control(THREAD_RUN, ids);
l4_thread_control(THREAD_RUN, &ids);
/* Return back to parent */
l4_ipc_return(child->tid);
@@ -161,3 +167,11 @@ int do_fork(struct tcb *parent)
return 0;
}
int sys_fork(l4id_t sender)
{
struct tcb *parent;
BUG_ON(!(parent = find_task(sender)));
return do_fork(parent);
}

View File

@@ -543,7 +543,7 @@ int vm_freeze_shadows(struct tcb *task)
/* Map the page as read-only */
l4_map((void *)page_to_phys(p),
(void *)virtual,
(void *)virtual, 1,
MAP_USR_RO_FLAGS, task->tid);
}
break;