nuclear@11: #ifndef INTR_H_ nuclear@11: #define INTR_H_ nuclear@11: nuclear@11: #include nuclear@25: #include "asmops.h" nuclear@11: nuclear@35: /* offset used to remap IRQ numbers (+32) */ nuclear@35: #define IRQ_OFFSET 32 nuclear@35: /* conversion macros between IRQ and interrupt numbers */ nuclear@35: #define IRQ_TO_INTR(x) ((x) + IRQ_OFFSET) nuclear@35: #define INTR_TO_IRQ(x) ((x) - IRQ_OFFSET) nuclear@35: /* checks whether a particular interrupt is an remapped IRQ */ nuclear@35: #define IS_IRQ(n) ((n) >= IRQ_OFFSET && (n) < IRQ_OFFSET + 16) nuclear@35: nuclear@47: /* structure used to pass the interrupt stack frame from the nuclear@47: * entry points to the C dispatch function. nuclear@47: */ nuclear@47: struct intr_frame { nuclear@47: /* registers pushed by pusha in intr_entry_* */ nuclear@47: struct registers regs; nuclear@54: /* data segment selectors */ nuclear@54: uint32_t ds, es, fs, gs; nuclear@47: /* interrupt number and error code pushed in intr_entry_* */ nuclear@47: uint32_t inum, err; nuclear@47: /* pushed by CPU during interrupt entry */ nuclear@47: uint32_t eip, cs, eflags; nuclear@47: /* pushed by CPU during interrupt entry from user space */ nuclear@47: uint32_t esp, ss; nuclear@49: } __attribute__ ((packed)); nuclear@47: nuclear@47: nuclear@35: nuclear@52: typedef void (*intr_func_t)(int); nuclear@11: nuclear@11: nuclear@11: void init_intr(void); nuclear@11: nuclear@52: struct intr_frame *get_intr_frame(void); nuclear@52: nuclear@11: void interrupt(int intr_num, intr_func_t func); nuclear@11: nuclear@25: /* defined in intr-asm.S */ nuclear@25: int get_intr_state(void); nuclear@25: void set_intr_state(int s); nuclear@25: nuclear@47: void intr_ret(struct intr_frame ifrm); nuclear@47: nuclear@51: void end_of_irq(int irq); nuclear@51: nuclear@11: #endif /* INTR_H_ */