diff --git a/include/gdt.h b/include/gdt.h new file mode 100644 index 0000000..f66d62d --- /dev/null +++ b/include/gdt.h @@ -0,0 +1,23 @@ +#ifndef _GDT_H +#define _GDT_H + +#include + +struct gdt_entry { + uint16_t limit_low; /* Lower 16 bits of limit */ + uint16_t base_low; /* Lower 16 bits of base */ + uint8_t base_middle; /* Next 8 bits of base */ + uint8_t access; /* Access flags */ + uint8_t granularity; /* Granularity + high 4 bits of limit */ + uint8_t base_high; /* Last 8 bits of base */ +} __attribute__((packed)); + +struct gdt_ptr { + uint16_t limit; /* Size of GDT - 1 */ + uint32_t base; /* Base address of GDT */ +} __attribute__((packed)); + +void gdt_install(); +void gdt_set_entry(int num, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran); + +#endif diff --git a/include/idt.h b/include/idt.h new file mode 100644 index 0000000..364255f --- /dev/null +++ b/include/idt.h @@ -0,0 +1,24 @@ +#ifndef _IDT_H +#define _IDT_H + +#include + +struct idt_entry { + uint16_t base_low; + uint16_t sel; /* Kernel segment selector */ + uint8_t always0; /* Always 0 */ + uint8_t flags; /* Type and attributes */ + uint16_t base_high; +} __attribute__((packed)); + +struct idt_ptr { + uint16_t limit; + uint32_t base; +} __attribute__((packed)); + +void idt_install(void); +void idt_install_isrs(void); +void idt_install_syscall(void); +void idt_set_entry(int num, uint32_t base, uint16_t sel, uint8_t flags); + +#endif diff --git a/include/io.h b/include/io.h new file mode 100644 index 0000000..2cfa726 --- /dev/null +++ b/include/io.h @@ -0,0 +1,16 @@ +/* Defines a abstract base for I/O in the Espresso kernel. */ + +#ifndef ESPRESSO_IO_H +#define ESPRESSO_IO_H + +#include +#include + +void print(const char* str); + +char* input(uint8_t dev=0); + +void writefile(uint8_t mode, char* file, char* data); +char* readfile(char* file); + +#endif \ No newline at end of file diff --git a/include/isr.h b/include/isr.h new file mode 100644 index 0000000..bd4734c --- /dev/null +++ b/include/isr.h @@ -0,0 +1,15 @@ +#ifndef _ISR_H +#define _ISR_H + +#include + +typedef struct { + uint32_t ds, edi, esi, ebp, esp, ebx, edx, ecx, eax; + uint32_t int_no, err_code; + uint32_t eip, cs, eflags, useresp, ss; +} regs_t; + +void isr_handler(regs_t *r); +void syscall_handler(regs_t *r); + +#endif