*-nemu,cte: support _kcontext() with arg

This commit is contained in:
Zihao Yu 2020-02-10 15:10:44 +08:00
parent 4bd8eea09d
commit fccdf292df
4 changed files with 12 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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