aboutsummaryrefslogtreecommitdiff
path: root/boot/startup-x86_64.s
diff options
context:
space:
mode:
authorTianhao Wang <shrik3@mailbox.org>2024-05-29 01:18:02 +0200
committerTianhao Wang <shrik3@mailbox.org>2024-06-11 15:17:10 +0200
commit959a93e653684b1ed8db4bd21eaca9831e372fb0 (patch)
tree152426d2f9eb39ff26941204aaa149840e59578a /boot/startup-x86_64.s
parent590d29c3e44fc06bc79c2624fc94273434505b9d (diff)
multiboot: basic support for multiboot info
well, it's not trivial to use bios function because thanks to grub + multiboot, we are already in protected mode when the startup code takes control. Also the MB info is easier to play with than BIOS (or ACPI) Signed-off-by: Tianhao Wang <shrik3@mailbox.org>
Diffstat (limited to 'boot/startup-x86_64.s')
-rw-r--r--boot/startup-x86_64.s14
1 files changed, 13 insertions, 1 deletions
diff --git a/boot/startup-x86_64.s b/boot/startup-x86_64.s
index 448576a..6392d0f 100644
--- a/boot/startup-x86_64.s
+++ b/boot/startup-x86_64.s
@@ -11,7 +11,8 @@ MAX_MEM: equ 512
[GLOBAL startup]
[GLOBAL pml4]
[GLOBAL pdp]
-
+[GLOBAL mb_magic]
+[GLOBAL mb_info_addr]
; functions from other parts of rustubs
[EXTERN vectors_start]
[EXTERN idt]
@@ -28,6 +29,12 @@ MAX_MEM: equ 512
startup:
cld
cli
+ ; with multiboot specs, grub initialzes the registers:
+ ; EAX: magic value 0x2BADB002
+ ; EBX: 32-bit physical address of the multiboot information struct
+ ; we store them in global variables for future uses in rust code.
+ mov dword [mb_magic], eax
+ mov dword [mb_info_addr], ebx
; setup GDT by loading GDT descriptor
; see docs/x86_gdt.txt
lgdt [gdt_80]
@@ -156,6 +163,11 @@ gdt_80:
dw 4*8 - 1 ; GDT limit=24, 4 GDT entries - 1
dq gdt ; GDT address
+; multiboot info
+mb_magic:
+ dd 0x00000000
+mb_info_addr:
+ dd 0x00000000
[SECTION .bss]