SayoriOS 0.3.3

isr.c
См. документацию.
1
10 #include "sys/isr.h"
11 #include "io/ports.h"
12 #include "sys/cpu_isr.h"
13
14 volatile isr_t interrupt_handlers[256];
15
16 void isr_handler(const registers_t regs){
17 if (interrupt_handlers[regs.int_num] != 0){
18 isr_t handler = interrupt_handlers[regs.int_num];
19 handler(regs);
20 }
21 }
22
23 void irq_handler(registers_t regs){
24 if (regs.int_num >= 40){
25 outb(0xA0, 0x20);
26 }
27
28 outb(0x20, 0x20);
29
30 if (interrupt_handlers[regs.int_num] != 0){
31 isr_t handler = interrupt_handlers[regs.int_num];
32 handler(regs);
33 }
34 }
35
36 /* @param n - Номер обработчика */
37 /* @param handler - Функция обработчик */
38 void register_interrupt_handler(uint8_t n, isr_t handler){
39 qemu_warn("Updated handler for IRQ%d", n);
40
41 interrupt_handlers[n] = handler;
42 }
43
44 /* Инициализация ISR */
45 void isr_init(){
46 register_interrupt_handler(INT_0, &division_by_zero);
47 register_interrupt_handler(INT_6, &fault_opcode);
48 register_interrupt_handler(INT_8, &double_error);
49 register_interrupt_handler(INT_10, &invalid_tss);
50 register_interrupt_handler(INT_11, &segment_is_not_available);
51 register_interrupt_handler(INT_12, &stack_error);
52 register_interrupt_handler(INT_13, &general_protection_error);
53 register_interrupt_handler(INT_14, &page_fault);
54 register_interrupt_handler(INT_16, &fpu_fault);
55 }
registers
Definition: common.h:59