Unify syscall/interrupt handling of rsp

This commit is contained in:
Justin C. Miller
2018-05-21 22:57:43 -07:00
parent 757bc21550
commit 1726d10554
2 changed files with 12 additions and 12 deletions

View File

@@ -11,8 +11,8 @@
extern "C" { extern "C" {
addr_t isr_handler(addr_t, cpu_state); addr_t isr_handler(addr_t, cpu_state);
void irq_handler(cpu_state); addr_t irq_handler(addr_t, cpu_state);
void syscall_handler(cpu_state); addr_t syscall_handler(addr_t, cpu_state);
#define ISR(i, name) extern void name (); #define ISR(i, name) extern void name ();
#define EISR(i, name) extern void name (); #define EISR(i, name) extern void name ();
@@ -138,11 +138,6 @@ isr_handler(addr_t return_rsp, cpu_state regs)
case isr::isrIgnore5: case isr::isrIgnore5:
case isr::isrIgnore6: case isr::isrIgnore6:
case isr::isrIgnore7: case isr::isrIgnore7:
/*
cons->printf("\nIGNORED PIC INTERRUPT %d\n",
(regs.interrupt % 0xff) - 0xf0);
*/
break; break;
case isr::isrGPFault: { case isr::isrGPFault: {
@@ -288,8 +283,8 @@ isr_handler(addr_t return_rsp, cpu_state regs)
return return_rsp; return return_rsp;
} }
void addr_t
irq_handler(cpu_state regs) irq_handler(addr_t return_rsp, cpu_state regs)
{ {
console *cons = console::get(); console *cons = console::get();
uint8_t irq = get_irq(regs.interrupt); uint8_t irq = get_irq(regs.interrupt);
@@ -318,10 +313,11 @@ irq_handler(cpu_state regs)
} }
*reinterpret_cast<uint32_t *>(0xffffff80fee000b0) = 0; *reinterpret_cast<uint32_t *>(0xffffff80fee000b0) = 0;
return return_rsp;
} }
void addr_t
syscall_handler(cpu_state regs) syscall_handler(addr_t return_rsp, cpu_state regs)
{ {
console *cons = console::get(); console *cons = console::get();
cons->printf("SYSCALL\n"); cons->printf("SYSCALL\n");
@@ -351,5 +347,5 @@ syscall_handler(cpu_state regs)
cons->puts("\n"); cons->puts("\n");
print_reg("rip", regs.rip); print_reg("rip", regs.rip);
return return_rsp;
} }

View File

@@ -100,7 +100,9 @@ global irq_handler_prelude
irq_handler_prelude: irq_handler_prelude:
push_all_and_segments push_all_and_segments
mov rdi, rsp
call irq_handler call irq_handler
mov rsp, rax
pop_all_and_segments pop_all_and_segments
@@ -152,7 +154,9 @@ syscall_handler_prelude:
push 0 ; bogus errorcode push 0 ; bogus errorcode
push_all_and_segments push_all_and_segments
mov rdi, rsp
call syscall_handler call syscall_handler
mov rsp, rax
pop_all_and_segments pop_all_and_segments
add rsp, 16 ; ignore bogus interrupt / error add rsp, 16 ; ignore bogus interrupt / error