diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-02 22:27:27 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-02 22:27:27 +0200 |
commit | 36e8ee0cdaa904ee00710b1d2df16691729cc93d (patch) | |
tree | 16e3836af7ef9efa6da1bbde4248ae5ad956bf58 /boot.asm | |
parent | libk: add its own makefile (diff) | |
download | kernel.cpp-36e8ee0cdaa904ee00710b1d2df16691729cc93d.tar.xz |
Print some multiboot2 information
Diffstat (limited to 'boot.asm')
-rw-r--r-- | boot.asm | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -1,9 +1,6 @@ ; Declare constants for the multiboot header. -MBALIGN equ 1 << 0 ; align loaded modules on page boundaries -MEMINFO equ 1 << 1 ; provide memory map -FLAGS equ MBALIGN | MEMINFO ; this is the Multiboot 'flag' field -MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header -CHECKSUM equ -(MAGIC + FLAGS) ; checksum of above, to prove we are multiboot +MAGIC equ 0xE85250D6 ; multiboot2 magic +ARCH equ 0 ; protected mode i386 ; Declare a multiboot header that marks the program as a kernel. These are magic ; values that are documented in the multiboot standard. The bootloader will @@ -11,10 +8,19 @@ CHECKSUM equ -(MAGIC + FLAGS) ; checksum of above, to prove we are multiboot ; 32-bit boundary. The signature is in its own section so the header can be ; forced to be within the first 8 KiB of the kernel file. section .multiboot -align 4 - dd MAGIC - dd FLAGS - dd CHECKSUM +header_start: + dd MAGIC + dd ARCH + dd header_end - header_start ; header length + dd 0x100000000 - (MAGIC + ARCH + (header_end - header_start)) + + ; optional multiboot tags here + + ; required end tag (u16, u16, u32) = (0, 0, 8) + dw 0 ; type + dw 0 ; flags + dd 8 ; size +header_end: ; The multiboot standard does not define the value of the stack pointer register ; (esp) and it is up to the kernel to provide a stack. This allocates room for a @@ -29,7 +35,7 @@ align 4 section .bss align 16 stack_bottom: -resb 16384 ; 16 KiB + resb 16384 ; 16 KiB stack_top: ; The linker script specifies _start as the entry point to the kernel and the @@ -54,6 +60,8 @@ _start: ; stack (as it grows downwards on x86 systems). This is necessarily done ; in assembly as languages such as C cannot function without a stack. mov esp, stack_top + push ebx + push eax ; This is a good place to initialize crucial processor state before the ; high-level kernel is entered. It's best to minimize the early |