Compare commits
No commits in common. "d97ec36f8c86036b0378e9e900a2c93286b08cd5" and "745cf9045cc15f70dd246856ee5fd95fe167f1a5" have entirely different histories.
d97ec36f8c
...
745cf9045c
7 changed files with 6 additions and 81 deletions
|
|
@ -1,50 +0,0 @@
|
||||||
/* kdtables.h
|
|
||||||
* Kernel Discriptor Tables
|
|
||||||
*
|
|
||||||
* Contains GDT, IDT, and any relevant functions and structs pertaining to them
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,8 +1,3 @@
|
||||||
/* 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,8 +1,6 @@
|
||||||
#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;
|
||||||
|
|
@ -11,13 +9,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;
|
||||||
} mb_info_t;
|
} multiboot_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)) mb_mmap_entry_t;
|
} __attribute__((packed));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ ENTRY(start)
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
/*start me at 1Mb because below that is x86 essential stuff, which we dont want to be written on top of.*/
|
/*start me at 1Mb because below that is x86 essential stuff, which we dont want to be written on top of.*/
|
||||||
. = 1M;
|
. = 2M;
|
||||||
|
|
||||||
/* we're going to maintain 4K alignment - apparently useful for paging, and i'm not complaining about the lost space anyway. */
|
/* we're going to maintain 4K alignment - apparently useful for paging, and i'm not complaining about the lost space anyway. */
|
||||||
|
|
||||||
|
|
@ -20,7 +20,6 @@ SECTIONS
|
||||||
.rodata BLOCK(4K) : ALIGN(4K)
|
.rodata BLOCK(4K) : ALIGN(4K)
|
||||||
{
|
{
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
*(.gdt_sect)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*initialized rw data. */
|
/*initialized rw data. */
|
||||||
|
|
@ -34,6 +33,5 @@ SECTIONS
|
||||||
{
|
{
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
*(.bss)
|
*(.bss)
|
||||||
*(.tss_sect)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
/* kdtables.c
|
|
||||||
* Kernel Descriptor Tables
|
|
||||||
*
|
|
||||||
* Contains GDT, LDT, and any relevant functions and structs pertaining to them
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -10,6 +10,7 @@ void kern_main(uint32_t multiboot_magic, multiboot_info_t* multiboot_info)
|
||||||
{
|
{
|
||||||
//wipe the screen
|
//wipe the screen
|
||||||
vga_clear();
|
vga_clear();
|
||||||
|
|
||||||
//We're going to use this buffer as our 8char hex representation for reading mem
|
//We're going to use this buffer as our 8char hex representation for reading mem
|
||||||
|
|
||||||
vga_printf("Entry eax:%X\n", multiboot_magic);
|
vga_printf("Entry eax:%X\n", multiboot_magic);
|
||||||
|
|
@ -23,5 +24,6 @@ void kern_main(uint32_t multiboot_magic, multiboot_info_t* multiboot_info)
|
||||||
|
|
||||||
vga_printf("MEM_LOWER:%X\n", multiboot_info->mem_lower);
|
vga_printf("MEM_LOWER:%X\n", multiboot_info->mem_lower);
|
||||||
vga_printf("MEM_UPPER:%X\n", multiboot_info->mem_upper);
|
vga_printf("MEM_UPPER:%X\n", multiboot_info->mem_upper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
src/start.s
13
src/start.s
|
|
@ -1,6 +1,7 @@
|
||||||
//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
|
||||||
|
|
||||||
|
|
@ -27,19 +28,7 @@
|
||||||
//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