Added exregs_set_mr() function

Moved all exregs-related calls to libl4 since these are part of the L4 api.
This commit is contained in:
Bahadir Balban
2008-09-15 17:57:09 +03:00
parent b7d1e46138
commit 9c2c9676e8
7 changed files with 73 additions and 46 deletions

View File

@@ -1,27 +0,0 @@
/*
* Generic to arch-specific interface for
* exchange_registers()
*
* Copyright (C) 2008 Bahadir Balban
*/
#include <exregs.h>
void exregs_set_pager(struct exregs_data *s, l4id_t pagerid)
{
s->pagerid = pagerid;
s->flags |= EXREGS_SET_PAGER;
}
void exregs_set_stack(struct exregs_data *s, unsigned long sp)
{
s->context.sp = sp;
s->valid_vect |= 1 << (offsetof(task_context_t, sp) >> 2);
}
void exregs_set_pc(struct exregs_data *s, unsigned long pc)
{
s->context.pc = pc;
s->valid_vect |= 1 << (offsetof(task_context_t, pc) >> 2);
}

View File

@@ -9,6 +9,7 @@
#include <mmap.h>
#include <l4lib/arch/syslib.h>
#include <l4lib/ipcdefs.h>
#include <l4lib/exregs.h>
#include <l4/api/thread.h>
#include <utcb.h>
#include <shm.h>
@@ -49,7 +50,9 @@ int vfs_notify_fork(struct tcb *child, struct tcb *parent)
int do_fork(struct tcb *parent)
{
int err;
struct tcb *child;
struct exregs_data exregs;
struct vm_file *utcb_shm;
struct task_ids ids = {
.tid = TASK_ID_INVALID,
@@ -70,6 +73,12 @@ int do_fork(struct tcb *parent)
return 0;
}
/* Set child's fork return value to 0 */
memset(&exregs, 0, sizeof(exregs));
exregs_set_mr(&exregs, MR_RETURN, 0);
if ((err = l4_exchange_registers(&exregs, child->tid)) < 0)
BUG();
/* Create new utcb for child since it can't use its parent's */
child->utcb = utcb_vaddr_new();

View File

@@ -15,6 +15,7 @@
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/utcb.h>
#include <l4lib/ipcdefs.h>
#include <l4lib/exregs.h>
#include <lib/addr.h>
#include <kmalloc/kmalloc.h>
#include <init.h>
@@ -26,7 +27,6 @@
#include <task.h>
#include <shm.h>
#include <mmap.h>
#include <exregs.h>
struct tcb_head {
struct list_head list;