From 36bbfd9184426576d38841bcabfa5ba2b59f726c Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 14 Sep 2019 17:05:06 +0200 Subject: Added very basic kernel and vga driver --- src/boot.s | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/boot.s (limited to 'src/boot.s') diff --git a/src/boot.s b/src/boot.s new file mode 100644 index 0000000..6cb2f7c --- /dev/null +++ b/src/boot.s @@ -0,0 +1,41 @@ +// Constants for the multiboot header +.set ALIGN, 1<<0 +.set MEMINFO, 1<<1 +.set FLAGS, ALIGN | MEMINFO +.set MAGIC, 0x1BADB002 +.set CHECKSUM, -(MAGIC + FLAGS) + +// Header marking the program as kernel +.section .multiboot +.align 4 +.long MAGIC +.long FLAGS +.long CHECKSUM + +// Initialize a small stack +.section .bss +.align 16 +stack_bottom: +.skip 16384 // 16 KiB +stack_top: + +// Use _start from linker as starting point +.section .text +.global _start +.type _start, @function +_start: + // Set up stack by setting esp to top of stack + mov $stack_top, %esp + + // TODO: Initialize processor, load GDT, enable paging + + // Call the kernel + call kernel_main + + // Put the system in an infinite loop + cli +1: hlt + jmp 1b + +// Set the size of the _start symbol to the current location '.' minus its start +.size _start, . - _start -- cgit v1.2.3