swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "kint.h" |
| 4 | |
| 5 | struct gdt_entry |
| 6 | { |
| 7 | ushort limit_low; |
| 8 | ushort base_low; |
| 9 | uchar base_middle; |
| 10 | |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 11 | union { |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 12 | struct |
| 13 | { |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 14 | uint a_p : 1; |
| 15 | uint a_dpl : 2; |
| 16 | uint a_dt : 1; |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 17 | uint a_type : 4; |
swissChili | 0b35bf2 | 2021-02-18 12:49:40 -0800 | [diff] [blame] | 18 | } __attribute__((packed)); |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 19 | |
| 20 | uchar access; |
| 21 | }; |
| 22 | |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 23 | union { |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 24 | struct |
| 25 | { |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 26 | uint g_g : 1; |
| 27 | uint g_d : 1; |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 28 | uint g_zero : 2; /* includes A */ |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 29 | uint g_len : 4; |
swissChili | 0b35bf2 | 2021-02-18 12:49:40 -0800 | [diff] [blame] | 30 | } __attribute__((packed)); |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 31 | |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 32 | uchar granularity; |
| 33 | }; |
| 34 | |
| 35 | uchar base_high; |
| 36 | } __attribute__((packed)); |
| 37 | |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 38 | struct gdt_pointer |
| 39 | { |
| 40 | /* Upper 16 bits of selector limits */ |
| 41 | ushort limit; |
| 42 | /* first struct gdt_entry */ |
| 43 | uint base; |
| 44 | } __attribute__((packed)); |
| 45 | |
| 46 | struct idt_entry |
| 47 | { |
| 48 | ushort base_low; |
| 49 | ushort selector; |
| 50 | uchar zero; |
| 51 | |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 52 | union { |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 53 | struct |
| 54 | { |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 55 | uchar f_p : 1; |
| 56 | uchar f_dpl : 2; |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 57 | uchar f_const : 5; |
swissChili | 0b35bf2 | 2021-02-18 12:49:40 -0800 | [diff] [blame] | 58 | } __attribute__((packed)); |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 59 | |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 60 | uchar flags; |
| 61 | }; |
swissChili | 825d46b | 2021-02-21 10:14:16 -0800 | [diff] [blame] | 62 | |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 63 | ushort base_high; |
| 64 | } __attribute__((packed)); |
| 65 | |
| 66 | #define IDT_F_CONST 0b00110 |
| 67 | |
| 68 | struct idt_pointer |
| 69 | { |
| 70 | ushort limit; |
| 71 | uint base; |
| 72 | } __attribute__((packed)); |
| 73 | |
| 74 | extern void isr0(); |
| 75 | extern void isr1(); |
| 76 | extern void isr2(); |
| 77 | extern void isr3(); |
| 78 | extern void isr4(); |
| 79 | extern void isr5(); |
| 80 | extern void isr6(); |
| 81 | extern void isr7(); |
| 82 | extern void isr8(); |
| 83 | extern void isr9(); |
| 84 | extern void isr10(); |
| 85 | extern void isr11(); |
| 86 | extern void isr12(); |
| 87 | extern void isr13(); |
| 88 | extern void isr14(); |
| 89 | extern void isr15(); |
| 90 | extern void isr16(); |
| 91 | extern void isr17(); |
| 92 | extern void isr18(); |
| 93 | extern void isr19(); |
| 94 | extern void isr20(); |
| 95 | extern void isr21(); |
| 96 | extern void isr22(); |
| 97 | extern void isr23(); |
| 98 | extern void isr24(); |
| 99 | extern void isr25(); |
| 100 | extern void isr26(); |
| 101 | extern void isr27(); |
| 102 | extern void isr28(); |
| 103 | extern void isr29(); |
| 104 | extern void isr30(); |
| 105 | extern void isr31(); |
| 106 | |
swissChili | ee6d10d | 2021-05-29 18:05:16 -0700 | [diff] [blame] | 107 | // Syscall |
| 108 | extern void isr128(); |
| 109 | // Tasking setup |
| 110 | extern void isr129(); |
| 111 | |
swissChili | 9b3584b | 2021-02-18 13:57:27 -0800 | [diff] [blame] | 112 | extern void irq0(); |
| 113 | extern void irq1(); |
| 114 | extern void irq2(); |
| 115 | extern void irq3(); |
| 116 | extern void irq4(); |
| 117 | extern void irq5(); |
| 118 | extern void irq6(); |
| 119 | extern void irq7(); |
| 120 | extern void irq8(); |
| 121 | extern void irq9(); |
| 122 | extern void irq10(); |
| 123 | extern void irq11(); |
| 124 | extern void irq12(); |
| 125 | extern void irq13(); |
| 126 | extern void irq14(); |
| 127 | extern void irq15(); |
| 128 | |
swissChili | d813792 | 2021-02-17 15:34:07 -0800 | [diff] [blame] | 129 | void init_descriptor_tables(); |
| 130 | void init_idt(); |
| 131 | void init_gdt(); |