2025-06-10 13:17:21 +00:00
|
|
|
/* kdtables.h
|
|
|
|
|
* Kernel Discriptor Tables
|
|
|
|
|
*
|
|
|
|
|
* Contains GDT, IDT, and any relevant functions and structs pertaining to them
|
|
|
|
|
*
|
|
|
|
|
*/
|
2025-06-09 22:27:55 +00:00
|
|
|
#ifndef KDTABLES_H
|
|
|
|
|
#define KDTABLES_H
|
2025-06-10 13:17:21 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
// TSS
|
|
|
|
|
typedef struct tss_s {
|
|
|
|
|
uint32_t LINK;
|
|
|
|
|
uint32_t ESP0;
|
|
|
|
|
uint32_t SS0;
|
|
|
|
|
uint32_t ESP1;
|
|
|
|
|
uint32_t SS1;
|
|
|
|
|
uint32_t ESP2;
|
|
|
|
|
uint32_t SS2;
|
|
|
|
|
uint32_t CR3;
|
|
|
|
|
uint32_t EIP;
|
|
|
|
|
uint32_t EFLAGS;
|
|
|
|
|
uint32_t EAX;
|
|
|
|
|
uint32_t ECX;
|
|
|
|
|
uint32_t EDX;
|
|
|
|
|
uint32_t EBX;
|
|
|
|
|
uint32_t ESP;
|
|
|
|
|
uint32_t ESI;
|
|
|
|
|
uint32_t EDI;
|
|
|
|
|
uint32_t ES;
|
|
|
|
|
uint32_t CS;
|
|
|
|
|
uint32_t SS;
|
|
|
|
|
uint32_t DS;
|
|
|
|
|
uint32_t FS;
|
|
|
|
|
uint32_t GS;
|
|
|
|
|
uint32_t LDTR;
|
|
|
|
|
uint32_t IOPB;
|
|
|
|
|
uint32_t SSP;
|
|
|
|
|
} __attribute__((packed)) tss_t;
|
|
|
|
|
|
|
|
|
|
extern tss_t tss;
|
|
|
|
|
|
2025-06-12 05:19:59 +00:00
|
|
|
//IDT
|
2025-06-10 13:17:21 +00:00
|
|
|
|
2025-06-12 05:19:59 +00:00
|
|
|
typedef struct InterruptDescriptor_s {
|
|
|
|
|
uint16_t offset_1;
|
|
|
|
|
uint16_t selector;
|
|
|
|
|
uint8_t reserved;
|
|
|
|
|
uint8_t attributes;
|
|
|
|
|
uint16_t offset_2;
|
|
|
|
|
} InterruptDescriptor_t;
|
2025-06-10 13:17:21 +00:00
|
|
|
|
2025-06-12 05:19:59 +00:00
|
|
|
typedef struct IDTR_s {
|
|
|
|
|
uint16_t size;
|
|
|
|
|
InterruptDescriptor_t* IDT;
|
|
|
|
|
} IDTR_t;
|
2025-06-09 22:27:55 +00:00
|
|
|
|
2025-06-12 05:19:59 +00:00
|
|
|
extern IDTR_t idtr;
|
2025-06-09 22:27:55 +00:00
|
|
|
|
2025-06-12 05:19:59 +00:00
|
|
|
void setup_idt();
|
|
|
|
|
void write_descriptors();
|
|
|
|
|
void load_idt();
|
2025-06-09 22:27:55 +00:00
|
|
|
|
|
|
|
|
#endif
|