Skip to content

Commit 4ea0578

Browse files
committed
chore: cleanup startup code
1 parent 2335398 commit 4ea0578

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

boot/startup-x86_64.s

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; vi: ft=nasm
12
; Contains code from from the OSC lab project OOStuBS @ TU Dresden
23

34
; stack for the main function (renamed to _entry())
@@ -7,24 +8,31 @@ STACKSIZE: equ 65536
78
; DON'T MODIFY THIS UNLESS YOU UPDATE THE setup_paging accordingly
89
MAX_MEM: equ 512
910

11+
; be careful with the extern and exported symbols when mapping a higher-half
12+
; kernel: regardless where they are physically loaded
13+
; 1) extern symbols may have 64 bit virtual addresses or values. Do not use them
14+
; in the 32bit part of the startup code.
15+
; 2) if the exported (global) symbols are mapped to low (virtual) addresses,
16+
; they would be no longer accessable after the kernel switch to a higher half
17+
; mapping. This is especially true for the multiboot info data.
18+
19+
1020
; exported symbols
1121
[GLOBAL startup]
12-
[GLOBAL pml4]
13-
[GLOBAL pdp]
1422
[GLOBAL mb_magic]
1523
[GLOBAL mb_info_addr]
1624
; functions from other parts of rustubs
17-
[EXTERN vectors_start]
18-
[EXTERN idt]
19-
[EXTERN idt_descr]
2025
[EXTERN _entry]
21-
22-
; addresses provided by the linker
2326
[EXTERN ___BSS_START__]
2427
[EXTERN ___BSS_END__]
2528

2629
[SECTION .text]
2730

31+
; symbols used in 32bit mode:
32+
; mb_magic
33+
; mab_info_addr
34+
; gdt_80
35+
; init_stack
2836
[BITS 32]
2937
startup:
3038
cld

0 commit comments

Comments
 (0)