cte: use int $0x81 for _yield

This commit is contained in:
Yanyan Jiang 2020-02-03 05:59:51 +00:00
parent b495c6a9b3
commit ba82360c99
2 changed files with 10 additions and 11 deletions

View File

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

View File

@ -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() {