From 1d7843c2b6d746376f87c2634c92cd93d8cdb728 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Thu, 18 Dec 2014 18:32:33 -0500 Subject: add boot stub --- boot.S | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 boot.S diff --git a/boot.S b/boot.S new file mode 100644 index 0000000..90cf9d1 --- /dev/null +++ b/boot.S @@ -0,0 +1,31 @@ + .set ALIGN, 1<<0 + .set MEMINFO, 1<<1 + .set FLAGS, ALIGN | MEMINFO + .set MAGIC, 0x1BADB002 # "1 Bad Boot" + .set CHECKSUM, -(MAGIC + FLAGS) + +.section .multiboot + .align 4 +multiboot_header: + .long MAGIC + .long FLAGS + .long CHECKSUM + +.section .stack +stack_bottom: # Stack grows up in addresses, so bottom is + # lower than the top + .skip 32768 # 32KB stack +stack_top: + +.section .text + .global _start + .type _start, @function +_start: # This is where execution begins + movl $stack_bottom, %esp # Initialize the stack + push %ebp # Add register ebp to the arguments of kernel_main + call kernel_main # Start the kernel, shouldn't return + cli + hlt +.kernel_hang: # Idle + jmp .kernel_hang + .size _start, . - _start -- cgit v1.1