summaryrefslogtreecommitdiff
path: root/Kernel/Prekernel
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-09-30 09:36:43 -0400
committerLinus Groh <mail@linusgroh.de>2021-09-30 15:38:43 +0100
commitd0c1db5efc88a75a9060208b3196b089afec8baf (patch)
treead40f5b15874821b2da29810cde645792b9261ab /Kernel/Prekernel
parent715f9666f2255146e0e50c55324a48528762c135 (diff)
downloadserenity-d0c1db5efc88a75a9060208b3196b089afec8baf.zip
Kernel: Zero out .bss contents on aarch64
After building and running objcopy -O binary Build/aarch64/Kernel/Prekernel/Prekernel \ /media/sdcard/kernel8.img things start booting on an actual RPi4 :^) (Assuming the sdcard contains RPi firmware, an empty config.txt, and no other kernel*.img files).
Diffstat (limited to 'Kernel/Prekernel')
-rw-r--r--Kernel/Prekernel/Arch/aarch64/boot.S8
-rw-r--r--Kernel/Prekernel/Arch/aarch64/linker.ld4
2 files changed, 12 insertions, 0 deletions
diff --git a/Kernel/Prekernel/Arch/aarch64/boot.S b/Kernel/Prekernel/Arch/aarch64/boot.S
index c5eee1a801..7eaa7fa557 100644
--- a/Kernel/Prekernel/Arch/aarch64/boot.S
+++ b/Kernel/Prekernel/Arch/aarch64/boot.S
@@ -21,6 +21,14 @@ start:
ldr x14, =start
mov sp, x14
+ // Clear BSS.
+ ldr x14, =start_of_bss
+ ldr x15, =size_of_bss_divided_by_8
+Lbss_clear_loop:
+ str xzr, [x14], #8
+ subs x15, x15, #1
+ bne Lbss_clear_loop
+
b init
.globl wait_cycles
diff --git a/Kernel/Prekernel/Arch/aarch64/linker.ld b/Kernel/Prekernel/Arch/aarch64/linker.ld
index 9a89f1d4d9..6b093cbd89 100644
--- a/Kernel/Prekernel/Arch/aarch64/linker.ld
+++ b/Kernel/Prekernel/Arch/aarch64/linker.ld
@@ -29,6 +29,10 @@ SECTIONS
.bss ALIGN(4K) (NOLOAD) : AT (ADDR(.bss))
{
+ start_of_bss = .;
*(.bss)
+ end_of_bss = .;
} :bss
}
+
+size_of_bss_divided_by_8 = (end_of_bss - start_of_bss) / 8;