dat.h (1585B)
1 #ifndef dat_h 2 #define dat_h 3 4 #include <stdint.h> 5 #include <stddef.h> 6 7 /* vga */ 8 #define vga_width 80 9 #define vga_height 25 10 #define vga_start 0xb8000 11 #define vga_ctrl 0x3d4 12 #define vga_data 0x3d5 13 14 enum vga_color { 15 vga_color_black = 0, 16 vga_color_blue = 1, 17 vga_color_green = 2, 18 vga_color_cyan = 3, 19 vga_color_red = 4, 20 vga_color_magenta = 5, 21 vga_color_brown = 6, 22 vga_color_light_grey = 7, 23 vga_color_dark_grey = 8, 24 vga_color_light_blue = 9, 25 vga_color_light_green = 10, 26 vga_color_light_cyan = 11, 27 vga_color_light_red = 12, 28 vga_color_light_magenta = 13, 29 vga_color_light_brown = 14, 30 vga_color_white = 15, 31 }; 32 33 /* idt */ 34 typedef struct { 35 uint16_t isr_low; /* the lower 16 bits of the isr's address */ 36 uint16_t kernel_cs; /* the gdt segment selector that the cpu will load into cs before calling the isr */ 37 uint8_t reserved; /* set to zero */ 38 uint8_t attr; /* type and attributes; see the idt page */ 39 uint16_t isr_high; /* the higher 16 bits of the isr's address */ 40 } __attribute__((packed)) idt_entry_t; 41 42 typedef struct { 43 uint16_t limit; 44 uint32_t base; 45 } __attribute__((packed)) idtr_t; 46 47 typedef void (*int_handler)(); 48 49 #define icw_1 0x11 50 51 #define pic_1 0x20 52 #define pic_2 0xa0 53 #define pic_1_comm pic_1 54 #define pic_1_data (pic_1+1) 55 #define pic_2_comm pic_2 56 #define pic_2_data (pic_2+1) 57 58 #define irq_0 0x20 59 #define irq_8 0x28 60 61 /* vfs */ 62 #define stdin 0 63 #define stdout 1 64 #define EOF (-1) 65 66 /* syscalls */ 67 #define sys_read 0 68 #define sys_write 1 69 70 /* pit */ 71 #define pit_chan0 0x40 72 #define pit_comm 0x43 73 #define pit_base_freq 1193182 74 75 #endif /* dat_h */