mirror of
https://github.com/drasko/codezero.git
synced 2026-05-25 11:31:29 +02:00
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:
@@ -41,37 +41,37 @@ void do_exchange_registers(struct ktcb *task, struct exregs_data *exregs)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check register valid bit and copy registers */
|
/* Check register valid bit and copy registers */
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r0))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r0))
|
||||||
context->r0 = exregs->context.r0;
|
context->r0 = exregs->context.r0;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r1))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r1))
|
||||||
context->r1 = exregs->context.r1;
|
context->r1 = exregs->context.r1;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r2))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r2))
|
||||||
context->r2 = exregs->context.r2;
|
context->r2 = exregs->context.r2;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r3))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r3))
|
||||||
context->r3 = exregs->context.r3;
|
context->r3 = exregs->context.r3;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r4))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r4))
|
||||||
context->r4 = exregs->context.r4;
|
context->r4 = exregs->context.r4;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r5))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r5))
|
||||||
context->r5 = exregs->context.r5;
|
context->r5 = exregs->context.r5;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r6))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r6))
|
||||||
context->r6 = exregs->context.r6;
|
context->r6 = exregs->context.r6;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r7))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r7))
|
||||||
context->r7 = exregs->context.r7;
|
context->r7 = exregs->context.r7;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r8))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r8))
|
||||||
context->r8 = exregs->context.r8;
|
context->r8 = exregs->context.r8;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r9))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r9))
|
||||||
context->r9 = exregs->context.r9;
|
context->r9 = exregs->context.r9;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r10))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r10))
|
||||||
context->r10 = exregs->context.r10;
|
context->r10 = exregs->context.r10;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r11))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r11))
|
||||||
context->r11 = exregs->context.r11;
|
context->r11 = exregs->context.r11;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, r12))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, r12))
|
||||||
context->r12 = exregs->context.r12;
|
context->r12 = exregs->context.r12;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, sp))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, sp))
|
||||||
context->sp = exregs->context.sp;
|
context->sp = exregs->context.sp;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, lr))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, lr))
|
||||||
context->lr = exregs->context.lr;
|
context->lr = exregs->context.lr;
|
||||||
if (exregs->valid_vect & FIELD_TO_BIT(task_context_t, pc))
|
if (exregs->valid_vect & FIELD_TO_BIT(exregs_context_t, pc))
|
||||||
context->pc = exregs->context.pc;
|
context->pc = exregs->context.pc;
|
||||||
|
|
||||||
/* Set thread's pager if one is supplied */
|
/* Set thread's pager if one is supplied */
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <l4/api/exregs.h>
|
#include <l4/api/exregs.h>
|
||||||
|
|
||||||
void exregs_set_stack(struct exregs_data *s, unsigned long sp);
|
void exregs_set_stack(struct exregs_data *s, unsigned long sp);
|
||||||
void exregs_set_mr_return(struct exregs_data *s, unsigned long retreg);
|
void exregs_set_mr(struct exregs_data *s, int offset, unsigned long val);
|
||||||
void exregs_set_pc(struct exregs_data *s, unsigned long pc);
|
void exregs_set_pc(struct exregs_data *s, unsigned long pc);
|
||||||
void exregs_set_pager(struct exregs_data *s, l4id_t pagerid);
|
void exregs_set_pager(struct exregs_data *s, l4id_t pagerid);
|
||||||
|
|
||||||
45
tasks/libl4/src/arm/exregs.c
Normal file
45
tasks/libl4/src/arm/exregs.c
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Generic to arch-specific interface for
|
||||||
|
* exchange_registers()
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Bahadir Balban
|
||||||
|
*/
|
||||||
|
#include <l4/macros.h>
|
||||||
|
#include <l4lib/exregs.h>
|
||||||
|
#include INC_GLUE(message.h)
|
||||||
|
|
||||||
|
|
||||||
|
void exregs_set_mr(struct exregs_data *s, int offset, unsigned long val)
|
||||||
|
{
|
||||||
|
/* Get MR0 */
|
||||||
|
u32 *mr = &s->context.r3;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
BUG_ON(offset > MR_TOTAL || offset < 0);
|
||||||
|
|
||||||
|
/* Set MR */
|
||||||
|
mr[offset] = val;
|
||||||
|
|
||||||
|
/* Set valid bit for mr register */
|
||||||
|
s->valid_vect |= offsetof(exregs_context_t, r3) +
|
||||||
|
(offset * sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
|
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(exregs_context_t, sp) >> 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void exregs_set_pc(struct exregs_data *s, unsigned long pc)
|
||||||
|
{
|
||||||
|
s->context.pc = pc;
|
||||||
|
s->valid_vect |= 1 << (offsetof(exregs_context_t, pc) >> 2);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ BEGIN_PROC(arch_clone)
|
|||||||
*/
|
*/
|
||||||
cmp r0, #0 @ Check ipc success
|
cmp r0, #0 @ Check ipc success
|
||||||
blt ipc_failed
|
blt ipc_failed
|
||||||
cmp r2, #0 @ Check ipc return register MR_RETURN.
|
cmp r3, #0 @ Check ipc return register MR_RETURN.
|
||||||
blt clone_failed @ Ipc was ok but clone() failed.
|
blt clone_failed @ Ipc was ok but clone() failed.
|
||||||
bgt parent_return @ It has child pid, goto parent return.
|
bgt parent_return @ It has child pid, goto parent return.
|
||||||
child:
|
child:
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <mmap.h>
|
#include <mmap.h>
|
||||||
#include <l4lib/arch/syslib.h>
|
#include <l4lib/arch/syslib.h>
|
||||||
#include <l4lib/ipcdefs.h>
|
#include <l4lib/ipcdefs.h>
|
||||||
|
#include <l4lib/exregs.h>
|
||||||
#include <l4/api/thread.h>
|
#include <l4/api/thread.h>
|
||||||
#include <utcb.h>
|
#include <utcb.h>
|
||||||
#include <shm.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 do_fork(struct tcb *parent)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
struct tcb *child;
|
struct tcb *child;
|
||||||
|
struct exregs_data exregs;
|
||||||
struct vm_file *utcb_shm;
|
struct vm_file *utcb_shm;
|
||||||
struct task_ids ids = {
|
struct task_ids ids = {
|
||||||
.tid = TASK_ID_INVALID,
|
.tid = TASK_ID_INVALID,
|
||||||
@@ -70,6 +73,12 @@ int do_fork(struct tcb *parent)
|
|||||||
return 0;
|
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 */
|
/* Create new utcb for child since it can't use its parent's */
|
||||||
child->utcb = utcb_vaddr_new();
|
child->utcb = utcb_vaddr_new();
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <l4lib/arch/syslib.h>
|
#include <l4lib/arch/syslib.h>
|
||||||
#include <l4lib/arch/utcb.h>
|
#include <l4lib/arch/utcb.h>
|
||||||
#include <l4lib/ipcdefs.h>
|
#include <l4lib/ipcdefs.h>
|
||||||
|
#include <l4lib/exregs.h>
|
||||||
#include <lib/addr.h>
|
#include <lib/addr.h>
|
||||||
#include <kmalloc/kmalloc.h>
|
#include <kmalloc/kmalloc.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
@@ -26,7 +27,6 @@
|
|||||||
#include <task.h>
|
#include <task.h>
|
||||||
#include <shm.h>
|
#include <shm.h>
|
||||||
#include <mmap.h>
|
#include <mmap.h>
|
||||||
#include <exregs.h>
|
|
||||||
|
|
||||||
struct tcb_head {
|
struct tcb_head {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
|||||||
Reference in New Issue
Block a user