*-nemu,cte: support _kcontext() with arg
This commit is contained in:
parent
4bd8eea09d
commit
fccdf292df
|
@ -61,6 +61,7 @@ int _cte_init(_Context*(*handler)(_Event, _Context*)) {
|
|||
_Context *_kcontext(_Area kstack, void (*entry)(void *), void *arg) {
|
||||
_Context *c = (_Context*)kstack.end - 1;
|
||||
c->epc = (uintptr_t)entry;
|
||||
c->GPR2 = (uintptr_t)arg; // a0
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ _Context *_kcontext(_Area kstack, void (*entry)(void *), void *arg) {
|
|||
_Context *c = (_Context*)kstack.end - 1;
|
||||
|
||||
c->epc = (uintptr_t)entry;
|
||||
c->GPR2 = (uintptr_t)arg;
|
||||
c->status = 0x000c0100;
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -63,11 +63,15 @@ int _cte_init(_Context*(*handler)(_Event, _Context*)) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void __am_kcontext_start();
|
||||
|
||||
_Context* _kcontext(_Area kstack, void (*entry)(void *), void *arg) {
|
||||
_Context *c = (_Context *)kstack.end - 1;
|
||||
c->cs = 0x8;
|
||||
c->eip = (uintptr_t)entry;
|
||||
c->eip = (uintptr_t)__am_kcontext_start;
|
||||
c->eflags = 0x2 | FL_IF;
|
||||
c->GPR1 = (uintptr_t)arg;
|
||||
c->GPR2 = (uintptr_t)entry;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
.globl __am_irq0; __am_irq0: pushl $0; pushl $32; jmp __am_asm_trap
|
||||
.globl __am_vecnull; __am_vecnull: pushl $0; pushl $-1; jmp __am_asm_trap
|
||||
|
||||
.globl __am_kcontext_start
|
||||
__am_kcontext_start:
|
||||
pushl %eax
|
||||
call *%ebx
|
||||
|
||||
__am_asm_trap:
|
||||
pushal
|
||||
|
||||
|
|
Loading…
Reference in New Issue