diff options
Diffstat (limited to 'kernel/entry.S')
-rw-r--r-- | kernel/entry.S | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/entry.S b/kernel/entry.S new file mode 100644 index 0000000..5b16b30 --- /dev/null +++ b/kernel/entry.S @@ -0,0 +1,42 @@ +# declare some constants +.set ALIGN, 1<<0 # align loaded modules on page boundaries +.set MEMINFO, 1<<1 # provide memory map +.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field +.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header +.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot + +# the bootloader will search for this magic sequence +# and recognize us as a multiboot kernel +.section .multiboot +.align 4 +.long MAGIC +.long FLAGS +.long CHECKSUM + +# allocatable, writable, contains no data +.section .bootstrap_stack, "aw", @nobits +stack_bottom: +.skip 16384 # 16 KiB +stack_top: + +# the linker script specifies _start as the entry point to the kernel and the +# bootloader will jump to this position once the kernel has been loaded +.section .text +.global _start +.type _start, @function +_start: + movl $stack_top, %esp + push %eax + push %ebx + + call kernel_main + + cli + +hang: + hlt + jmp hang + +# Set the size of the _start symbol to the current location '.' minus its start. +# This is useful when debugging or when you implement call tracing. +.size _start, . - _start |