diff --git a/am/include/x86.h b/am/include/x86.h index 5341c841..bc78fa0e 100644 --- a/am/include/x86.h +++ b/am/include/x86.h @@ -47,6 +47,7 @@ #define EX_PF 14 #define EX_MF 15 #define EX_SYSCALL 0x80 +#define EX_YIELD 0x81 // List of interrupts and exceptions (#irq, DPL, hardware errorcode) #define IRQS(_) \ @@ -85,7 +86,8 @@ _( 45, KERN, NOERR) \ _( 46, KERN, NOERR) \ _( 47, KERN, NOERR) \ - _(128, USER, NOERR) + _(128, USER, NOERR) \ + _(129, USER, NOERR) // AM-specific configurations #define MAX_CPU 8 @@ -330,8 +332,8 @@ static inline uint64_t rdtsc() { return ((uint64_t)hi << 32) | lo; } -#define interrupt(id, ax) \ - asm volatile ("int $" #id : : "a"(ax)); +#define interrupt(id) \ + asm volatile ("int $" #id); static inline void stack_switch_call(void *sp, void *entry, uintptr_t arg) { asm volatile ( diff --git a/am/src/x86/qemu/cte.c b/am/src/x86/qemu/cte.c index 880b4660..ca92fce7 100644 --- a/am/src/x86/qemu/cte.c +++ b/am/src/x86/qemu/cte.c @@ -57,13 +57,10 @@ static void __am_irq_handle_internal(struct trap_frame *tf) { ev.event = _EVENT_IRQ_TIMER; break; case IRQ 1: MSG("I/O device IRQ1 (keyboard)") ev.event = _EVENT_IRQ_IODEV; break; - case EX_SYSCALL: MSG("int $0x80 trap: _yield() or system call") - if ((int32_t)saved_ctx.GPRx == -1) { - ev.event = _EVENT_YIELD; - } else { - ev.event = _EVENT_SYSCALL; - } - break; + case EX_SYSCALL: MSG("int $0x80 system call") + ev.event = _EVENT_SYSCALL; break; + case EX_YIELD: MSG("int $0x81 yield") + ev.event = _EVENT_YIELD; break; case EX_DE: MSG("DE #0 divide by zero") ev.event = _EVENT_ERROR; break; case EX_UD: MSG("UD #6 invalid opcode") @@ -129,7 +126,7 @@ int _cte_init(_Context *(*handler)(_Event, _Context *)) { } void _yield() { - interrupt(0x80, -1); + interrupt(0x81); } int _intr_read() {