Merge branch 'public'
This commit is contained in:
commit
fa8314c1c1
52
cpu/idt.c
52
cpu/idt.c
@ -85,7 +85,31 @@ void register_interrupt_handler(uint8_t i, isr_t handler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void trap(registers_t *r) {
|
void trap(registers_t *r) {
|
||||||
if (r->int_no == T_SYSCALL) {
|
// EOI
|
||||||
|
if (r->int_no >= 40) {
|
||||||
|
port_byte_out(0xA0, 0x20); /* follower */
|
||||||
|
}
|
||||||
|
if (r->int_no >= 32) {
|
||||||
|
port_byte_out(0x20, 0x20); /* leader */
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call registered handler
|
||||||
|
if (interrupt_handlers[r->int_no] != 0) {
|
||||||
|
isr_t handler = interrupt_handlers[r->int_no];
|
||||||
|
handler(r);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r->int_no < 32) {
|
||||||
|
const char* msg = "Reserved";
|
||||||
|
if (r->int_no < ARRLEN(exception_messages)) {
|
||||||
|
msg = exception_messages[r->int_no];
|
||||||
|
}
|
||||||
|
panic(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_syscall(registers_t* r) {
|
||||||
switch (r->eax) {
|
switch (r->eax) {
|
||||||
case SYS_exit:
|
case SYS_exit:
|
||||||
if (r->ebx == 0) {
|
if (r->ebx == 0) {
|
||||||
@ -102,30 +126,6 @@ void trap(registers_t *r) {
|
|||||||
printk("Unknown syscall\n");
|
printk("Unknown syscall\n");
|
||||||
r->eax = -1;
|
r->eax = -1;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r->int_no < 32) {
|
|
||||||
const char* msg = "Reserved";
|
|
||||||
if (r->int_no < ARRLEN(exception_messages)) {
|
|
||||||
msg = exception_messages[r->int_no];
|
|
||||||
}
|
|
||||||
panic(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Handle the interrupt in a more modular way */
|
|
||||||
if (interrupt_handlers[r->int_no] != 0) {
|
|
||||||
isr_t handler = interrupt_handlers[r->int_no];
|
|
||||||
handler(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOI
|
|
||||||
if (r->int_no >= 40) {
|
|
||||||
port_byte_out(0xA0, 0x20); /* follower */
|
|
||||||
}
|
|
||||||
if (r->int_no >= 32) {
|
|
||||||
port_byte_out(0x20, 0x20); /* leader */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_pic() {
|
static void init_pic() {
|
||||||
@ -165,6 +165,8 @@ void load_idt() {
|
|||||||
asm("lidt (%0)" : : "r"(&idt_reg));
|
asm("lidt (%0)" : : "r"(&idt_reg));
|
||||||
|
|
||||||
init_pic();
|
init_pic();
|
||||||
|
|
||||||
|
register_interrupt_handler(T_SYSCALL, handle_syscall);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cli() {
|
void cli() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user