A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/kernel/interupt.c

33 lines
672 B

3 years ago
#include "interupt.h"
3 years ago
typedef struct {
3 years ago
uint16 offset_1; // offset 0 to 15 bits
uint16 selector; // code segment sel
3 years ago
uint8 reserved; // should be zero
3 years ago
uint8 type_attr; // type & attr stuff
uint16 offset_2; // offset 16 to 31
3 years ago
} __attribute__((packed)) idt_entry;
typedef struct {
uint16 limit;
uint base;
} __attribute__((packed)) idtr;
3 years ago
void init_IDT(uint type_attr) {
3 years ago
__attribute__((aligned(4)))
static idt_entry IDT[256];
static idtr IDTR;
}
__attribute__((noreturn))
void exception_handler(void);
void exception_handler() {
__asm__ __volatile__("cli; hlt");
3 years ago
}
3 years ago
void interupt_handler() {
3 years ago
__asm__("pusha");
// handle stuff
__asm__("popa; leave; iret");
}