From 1c3a453b3260ac7eb3b8065d0ee8a2ac08e8f34f Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 18 Jan 2018 19:43:07 +0100 Subject: [PATCH] Rename main entry point to kernel_main(), Fix descriptor tables not getting initialized, Disable stack protector (GCC) --- Makefile | 2 +- gdb.gdb | 2 +- src/gdt.asm | 4 +++- src/interrupt.asm | 4 +++- src/main.c | 5 ++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 425c76b..9a56455 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ BIN = bin SRC = src CC = gcc -CFLAGS = -Wall -ffreestanding -m32 -std=gnu99 -ggdb3 +CFLAGS = -Wall -ffreestanding -fno-stack-protector -m32 -std=gnu99 -ggdb3 LINK = ld LINKFLAGS = -melf_i386 -Tlink.ld CASM = nasm diff --git a/gdb.gdb b/gdb.gdb index ba89945..d9734eb 100644 --- a/gdb.gdb +++ b/gdb.gdb @@ -7,5 +7,5 @@ define hook-stop printf "\n" end -break main +break kernel_main continue diff --git a/src/gdt.asm b/src/gdt.asm index a72faa7..bd91f43 100644 --- a/src/gdt.asm +++ b/src/gdt.asm @@ -1,4 +1,6 @@ -; Sets up global descriptor table and interrupt descriptor table. +; Sets up global descriptor table and interrupt descriptor table + +[BITS 32] ; All instructions 32-bit [GLOBAL gdt_flush] ; Make 'gdt_flush' accessible from C diff --git a/src/interrupt.asm b/src/interrupt.asm index 6649720..58f6c5e 100644 --- a/src/interrupt.asm +++ b/src/interrupt.asm @@ -1,4 +1,6 @@ -; Contains interrupt service routine wrappers. +; Contains interrupt service routine wrappers + +[BITS 32] ; All instructions 32-bit ; Macro creating a stub for an ISR which does NOT pass it's own error code (adds a dummy errcode byte) %macro ISR_NOERRCODE 1 diff --git a/src/main.c b/src/main.c index 50d8f9d..7a61345 100644 --- a/src/main.c +++ b/src/main.c @@ -1,15 +1,18 @@ #include "monitor.h" +#include "descriptor_tables.h" struct multiboot; int kernel_main(struct multiboot *mboot_ptr) { + init_descriptor_tables(); + monitor_clear(); monitor_write("Welcome to Tyr ("); monitor_write_hex(0x547972); monitor_write("), the one-handed OS!\n"); asm volatile("int $0x3"); - //asm volatile("int $0x4"); + asm volatile("int $0x4"); return 0; }