idt.h (1676B)
1 #ifndef _IDT_H_ 2 #define _IDT_H_ 3 4 #include <u.h> 5 #include <regs.h> 6 7 #define INTVEC(name) CONCAT(intr_, name) 8 9 #define NINT 256 /* number of interrupts */ 10 11 /* gdt segments */ 12 #define NULLSEG 0 /* null segment */ 13 #define KCSEG 1 /* kernel code segment */ 14 #define KDSEG 2 /* kernel data segment */ 15 #define UCSEG 3 /* user code segment */ 16 #define UDSEG 4 /* kernel data segment */ 17 /* TODO: 9front mem.h */ 18 19 #define SELGDT (0 << 2) /* selector is in gdt */ 20 #define SELLDT (1 << 2) /* selector is in ldt */ 21 22 #define SEGIG (0x0e << 8) /* interrupt gate */ 23 #define SEGPL(x) ((x) << 13) /* priority level */ 24 #define SEGP (1 << 15) /* segment present */ 25 26 #define KPL 0 /* kernel priority level */ 27 #define DPL1 1 /* device driver priority level 1 */ 28 #define DPL2 2 /* device driver priority level 2 */ 29 #define UPL 3 /* user priority level */ 30 31 #define SELECTOR(i, t, p) (((i) << 3) | (t) | (p)) 32 33 /* selectors */ 34 #define NULLSEL SELECTOR(NULLSEG, SELGDT, KPL) 35 #define KDSEL SELECTOR(KDSEG, SELGDT, KPL) 36 #define KCSEL SELECTOR(KCSEG, SELGDT, KPL) 37 #define UCSEL SELECTOR(UCSEG, SELGDT, UPL) 38 #define UDSEL SELECTOR(UDSEG, SELGDT, UPL) 39 /* TODO: 9front mem.h */ 40 41 struct gate_desc { 42 u_int32_t gd_lo; 43 u_int32_t gd_hi; 44 } __packed; 45 46 struct region_desc { 47 u_int16_t rd_limit; 48 u_int32_t rd_base; 49 } __packed; 50 51 enum { 52 IRQ0 = 32, 53 IRQ1, 54 IRQ2, 55 IRQ3, 56 IRQ4, 57 IRQ5, 58 IRQ6, 59 IRQ7, 60 IRQ8, 61 IRQ9, 62 IRQ10, 63 IRQ11, 64 IRQ12, 65 IRQ13, 66 IRQ14, 67 IRQ15, 68 }; 69 70 typedef void (*intrhand_t)(struct regs *); 71 72 void idt_init(void); 73 void intr_handler(struct regs *); 74 void intr_register_handler(int, intrhand_t); 75 void dump_regs(struct regs *); /* FIXME: move elsewhere? */ 76 77 #endif /* _IDT_H_ */