| 1 | #ifndef SYS__GDT_H__ |
| 2 | #define SYS__GDT_H__ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | struct gdtr { |
| 7 | uint16_t limit; |
| 8 | #if defined (__x86_64__) |
| 9 | uint64_t ptr; |
| 10 | #elif defined (__i386__) |
| 11 | uint32_t ptr; |
| 12 | uint32_t ptr_hi; |
| 13 | #endif |
| 14 | } __attribute__((packed)); |
| 15 | |
| 16 | struct gdt_desc { |
| 17 | uint16_t limit; |
| 18 | uint16_t base_low; |
| 19 | uint8_t base_mid; |
| 20 | uint8_t access; |
| 21 | uint8_t granularity; |
| 22 | uint8_t base_hi; |
| 23 | } __attribute__((packed)); |
| 24 | |
| 25 | extern struct gdtr gdt; |
| 26 | |
| 27 | void init_gdt(void); |
| 28 | |
| 29 | #endif |
