Compare commits

..

1 commit

Author SHA1 Message Date
3e27882a75
nemu: support yield()
Some checks failed
Build abstract machine with nix / build-abstract-machine (push) Failing after 2m0s
Run CTests within npc / npc-test (push) Failing after 48s
2024-07-25 16:48:57 +08:00
3 changed files with 3 additions and 9 deletions

View file

@ -2,7 +2,6 @@
#include <am.h>
#include <klib.h>
#include <riscv/riscv.h>
#include <stdint.h>
static Context *(*user_handler)(Event, Context *) = NULL;
@ -38,10 +37,7 @@ bool cte_init(Context *(*handler)(Event, Context *)) {
}
Context *kcontext(Area kstack, void (*entry)(void *), void *arg) {
Context *c = kstack.end - sizeof(Context);
c->mepc = (uintptr_t)entry;
c->gpr[10] = (uintptr_t)arg;
return c;
return NULL;
}
void yield() {

View file

@ -60,8 +60,6 @@ __am_asm_trap:
mv a0, sp
jal __am_irq_handle
mv sp, a0
LOAD t1, OFFSET_STATUS(sp)
LOAD t2, OFFSET_EPC(sp)
csrw mstatus, t1

View file

@ -158,6 +158,8 @@ breakpoint_t *cpu_exec_with_bp(uint64_t n, breakpoint_t *bp, size_t len) {
static Decode s;
nemu_state.state = NEMU_RUNNING;
do {
exec_once(&s, cpu.pc);
g_nr_guest_inst++;
for (int i = 0; i < len; i++) {
size_t addr = bp[i].addr;
bp_type_t bptype = bp[i].type;
@ -174,8 +176,6 @@ breakpoint_t *cpu_exec_with_bp(uint64_t n, breakpoint_t *bp, size_t len) {
return bp + i;
}
}
exec_once(&s, cpu.pc);
g_nr_guest_inst++;
if (nemu_state.state != NEMU_RUNNING)
return NULL;
} while (--n);