Skip to content

Commit 3d78371

Browse files
committed
Rewrite so that kernel is mapped into same address space as bootloader
1 parent 91bff4f commit 3d78371

File tree

8 files changed

+418
-220
lines changed

8 files changed

+418
-220
lines changed

Cargo.lock

Lines changed: 119 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ panic = "abort"
1919

2020
[profile.release]
2121
panic = "abort"
22-
lto = true
22+
lto = false
23+
debug = true

linker.ld

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ SECTIONS {
77
. += 512;
88
/* page tables */
99
. = ALIGN(0x1000);
10+
__page_table_start = .;
1011
_p4 = .;
1112
. += 0x1000;
1213
_p3 = .;
1314
. += 0x1000;
1415
_p2 = .;
1516
. += 0x1000;
17+
_p1 = .;
18+
. += 0x1000;
19+
__page_table_end = .;
20+
__bootloader_start = .;
1621
_memory_map = .;
1722
. += 0x1000;
1823

19-
/* bootloader */
24+
_stack_start = .;
2025
. = 0x7c00;
26+
_stack_end = .;
27+
2128
.bootloader :
2229
{
2330
/* first stage */
@@ -39,5 +46,6 @@ SECTIONS {
3946
. += 512; /* kernel info block */
4047
_kernel_info_block_end = .;
4148

49+
__bootloader_end = .;
4250
_kernel_start_addr = .;
4351
}

src/context_switch.s

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
.code64
33

44
# Expected arguments:
5-
# - p4 address in `rdi`
5+
# - boot info ptr in `rdi`
66
# - entry point address in `rsi`
77
# - stack pointer in `rdx`
8-
# - boot info ptr in `rcx`
98
context_switch:
10-
# load new P4 table
11-
mov cr3, rdi
129

1310
# load stack pointer
1411
mov rsp, rdx
1512

16-
mov rdi, rcx
17-
1813
# jump to entry point
1914
jmp rsi
2015
context_switch_spin:

0 commit comments

Comments
 (0)