diff --git a/include/kdtables.h b/include/kdtables.h index fbb6be1..92edd20 100644 --- a/include/kdtables.h +++ b/include/kdtables.h @@ -1,5 +1,49 @@ +/* kdtables.h +* Kernel Discriptor Tables +* +* Contains GDT, IDT, and any relevant functions and structs pertaining to them +* +*/ #ifndef KDTABLES_H #define KDTABLES_H +#include + +// 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; + +void clear_tss(); + +// GDT + diff --git a/include/kio.h b/include/kio.h index ff1cc13..cf2286c 100644 --- a/include/kio.h +++ b/include/kio.h @@ -1,3 +1,8 @@ +/* kio.h + * Kernel I/O + * + * Handles any in/output + */ #ifndef KIO_H #define KIO_H #define VGA_GRID_COLS 80 diff --git a/include/kmultiboot.h b/include/kmultiboot.h index 9997d53..a8e6f91 100644 --- a/include/kmultiboot.h +++ b/include/kmultiboot.h @@ -1,6 +1,8 @@ #ifndef KMULTIBOOT_H #define KMULTIBOOT_H +#include + typedef struct { uint32_t flags; uint32_t mem_lower; @@ -9,13 +11,13 @@ typedef struct { uint32_t cmdline; uint32_t mods_count; uint32_t mods_addr; -} multiboot_info_t; +} mb_info_t; typedef struct multiboot_mmap_entry { uint32_t ssize; //size of the entry uint64_t addr; //physical location of memory uint64_t msize; uint32_t type; -} __attribute__((packed)); +} __attribute__((packed)) mb_mmap_entry_t; #endif diff --git a/linker.ld b/linker.ld index 78a5f6d..85dda0f 100644 --- a/linker.ld +++ b/linker.ld @@ -20,6 +20,7 @@ SECTIONS .rodata BLOCK(4K) : ALIGN(4K) { *(.rodata*) + *(.gdt_sect) } /*initialized rw data. */ @@ -33,5 +34,6 @@ SECTIONS { *(COMMON) *(.bss) + *(.tss_sect) } } diff --git a/src/kdtables.c b/src/kdtables.c index e69de29..046bcf2 100644 --- a/src/kdtables.c +++ b/src/kdtables.c @@ -0,0 +1,7 @@ +/* kdtables.c +* Kernel Descriptor Tables +* +* Contains GDT, LDT, and any relevant functions and structs pertaining to them +*/ + + diff --git a/src/start.s b/src/start.s index 5f2dbaa..14322da 100644 --- a/src/start.s +++ b/src/start.s @@ -1,7 +1,6 @@ //C main function for our kernel //See: kernel.c .extern kern_main - //This will be our entrypoint function name - gotta initialize it now as global so the linker knows later. .global start @@ -28,7 +27,19 @@ //Remember, stack grows DOWNWARD! So the last thing in the section -> the highest memory address -> the very first thing on the stack! //Therefore, we put a label here to represent the top of our stack for later. stack_top: + //Allocation of some space for our TSS. + + +.section .tss_sect: + .align 8 + tss: + .skip 104 +.section .gdt_sect: + .align 8 + gdt: + .skip 48 + //Actual code. Entry point goes here! .section .text