aboutsummaryrefslogtreecommitdiff
path: root/src/boot.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot.S')
-rw-r--r--src/boot.S48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/boot.S b/src/boot.S
index 0451066..3a07c19 100644
--- a/src/boot.S
+++ b/src/boot.S
@@ -1,35 +1,43 @@
-/*
- Declare a multiboot header that marks the program as a kernel.
- https://www.gnu.org/software/grub/manual/multiboot2/html_node/index.html
-
- The Multiboot2 header must be contained completely within the first
- 32kB of the OS image, and must be 64-bit (8 byte) aligned.
-*/
-.set MULTIBOOT_HEADER_MAGIC, 0xe85250d6 # multiboot2 magic number
-.set MULTIBOOT_ARCHITECTURE, 0 # protected mode i386
-.set MULTIBOOT_HEADER_TAG_END, 0
+/* Declare a multiboot header that marks the program as a kernel.
+ * https://www.gnu.org/software/grub/manual/multiboot2/html_node/index.html
+ * The Multiboot2 header must be contained completely within the first 32kB, and must be 8 byte aligned.
+ */
+#define ASM_FILE
+#include <multiboot2.h>
.section .multiboot.header, "a"
.align 8
header_start:
- .int MULTIBOOT_HEADER_MAGIC
- .int MULTIBOOT_ARCHITECTURE
+ .int MULTIBOOT2_HEADER_MAGIC
+ .int MULTIBOOT_ARCHITECTURE_I386
.int header_end - header_start
- .int -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE + (header_end - header_start))
+ .int -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (header_end - header_start))
- # TODO tags go here
+.align 8
+information_tag_start:
+ .short MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST
+ .short 0
+ .int information_tag_end - information_tag_start
+ .int MULTIBOOT_TAG_TYPE_MMAP
+information_tag_end:
+.align 8
+module_tag_start:
+ .short MULTIBOOT_HEADER_TAG_MODULE_ALIGN
+ .short 0
+ .int module_tag_end - module_tag_start
+module_tag_end:
+
+.align 8
.short MULTIBOOT_HEADER_TAG_END
.short 0
.int 8
header_end:
-/*
- The stack on x86 must be 16-byte aligned according to the System V ABI
- standard and de-facto extensions. The compiler will assume the stack is
- properly aligned and failure to align the stack will result in undefined
- behavior.
-*/
+/* The stack on x86 must be 16-byte aligned according to the System V ABI standard and de-facto extensions. The
+ * compiler will assume the stack is properly aligned and failure to align the stack will result in undefined
+ * behavior.
+ */
.section .stack, "aw", @nobits
.align 16
stack_bottom: