From 959a93e653684b1ed8db4bd21eaca9831e372fb0 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Wed, 29 May 2024 01:18:02 +0200 Subject: 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 --- boot/startup-x86_64.s | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'boot') 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] -- cgit v1.2.3-70-g09d2