Half-baked commit, but i added a struct type for the tss and allocated
some memory for it in bss. Also put some space in for the gdt in rodata. Need to leave now, so this broken build goes to the repo!
This commit is contained in:
parent
295e622fe1
commit
d97ec36f8c
6 changed files with 74 additions and 3 deletions
|
|
@ -1,5 +1,49 @@
|
||||||
|
/* kdtables.h
|
||||||
|
* Kernel Discriptor Tables
|
||||||
|
*
|
||||||
|
* Contains GDT, IDT, and any relevant functions and structs pertaining to them
|
||||||
|
*
|
||||||
|
*/
|
||||||
#ifndef KDTABLES_H
|
#ifndef KDTABLES_H
|
||||||
#define KDTABLES_H
|
#define KDTABLES_H
|
||||||
|
#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;
|
||||||
|
|
||||||
|
void clear_tss();
|
||||||
|
|
||||||
|
// GDT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
/* kio.h
|
||||||
|
* Kernel I/O
|
||||||
|
*
|
||||||
|
* Handles any in/output
|
||||||
|
*/
|
||||||
#ifndef KIO_H
|
#ifndef KIO_H
|
||||||
#define KIO_H
|
#define KIO_H
|
||||||
#define VGA_GRID_COLS 80
|
#define VGA_GRID_COLS 80
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef KMULTIBOOT_H
|
#ifndef KMULTIBOOT_H
|
||||||
#define KMULTIBOOT_H
|
#define KMULTIBOOT_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t mem_lower;
|
uint32_t mem_lower;
|
||||||
|
|
@ -9,13 +11,13 @@ typedef struct {
|
||||||
uint32_t cmdline;
|
uint32_t cmdline;
|
||||||
uint32_t mods_count;
|
uint32_t mods_count;
|
||||||
uint32_t mods_addr;
|
uint32_t mods_addr;
|
||||||
} multiboot_info_t;
|
} mb_info_t;
|
||||||
|
|
||||||
typedef struct multiboot_mmap_entry {
|
typedef struct multiboot_mmap_entry {
|
||||||
uint32_t ssize; //size of the entry
|
uint32_t ssize; //size of the entry
|
||||||
uint64_t addr; //physical location of memory
|
uint64_t addr; //physical location of memory
|
||||||
uint64_t msize;
|
uint64_t msize;
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed)) mb_mmap_entry_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ SECTIONS
|
||||||
.rodata BLOCK(4K) : ALIGN(4K)
|
.rodata BLOCK(4K) : ALIGN(4K)
|
||||||
{
|
{
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
|
*(.gdt_sect)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*initialized rw data. */
|
/*initialized rw data. */
|
||||||
|
|
@ -33,5 +34,6 @@ SECTIONS
|
||||||
{
|
{
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
*(.bss)
|
*(.bss)
|
||||||
|
*(.tss_sect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
/* kdtables.c
|
||||||
|
* Kernel Descriptor Tables
|
||||||
|
*
|
||||||
|
* Contains GDT, LDT, and any relevant functions and structs pertaining to them
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
13
src/start.s
13
src/start.s
|
|
@ -1,7 +1,6 @@
|
||||||
//C main function for our kernel
|
//C main function for our kernel
|
||||||
//See: kernel.c
|
//See: kernel.c
|
||||||
.extern kern_main
|
.extern kern_main
|
||||||
|
|
||||||
//This will be our entrypoint function name - gotta initialize it now as global so the linker knows later.
|
//This will be our entrypoint function name - gotta initialize it now as global so the linker knows later.
|
||||||
.global start
|
.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!
|
//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.
|
//Therefore, we put a label here to represent the top of our stack for later.
|
||||||
stack_top:
|
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!
|
//Actual code. Entry point goes here!
|
||||||
.section .text
|
.section .text
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue