diff options
author | Wojtek Kosior <kwojtus@protonmail.com> | 2019-10-03 11:00:21 +0200 |
---|---|---|
committer | Wojtek Kosior <kwojtus@protonmail.com> | 2019-10-03 11:00:21 +0200 |
commit | 4e7666742e6089e7f0ff359c42f726acde7e2a0c (patch) | |
tree | 102d0dbf4983a81651d05f0c0ecaa86dc7c0a8e3 /boot.S | |
parent | 5f5df2cbe593b8d4365b5a20c2ec240746c9d914 (diff) | |
download | rpi-MMU-example-4e7666742e6089e7f0ff359c42f726acde7e2a0c.tar.gz rpi-MMU-example-4e7666742e6089e7f0ff359c42f726acde7e2a0c.zip |
copy-paste broken code from wiki.osdev; fix it; add Makefile
Diffstat (limited to 'boot.S')
-rw-r--r-- | boot.S | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -0,0 +1,52 @@ +// AArch32 mode + +// To keep this in the first portion of the binary. +.section ".text.boot" + +// Make _start global. +.globl _start + +.org 0x8000 +// Entry point for the kernel. +// r15 -> should begin execution at 0x8000. +// r0 -> 0x00000000 +// r1 -> 0x00000C42 +// r2 -> 0x00000100 - start of ATAGS +// preserve these registers as argument for kernel_main +_start: + // Shut off extra cores + mrc p15, 0, r5, c0, c0, 5 + and r5, r5, #3 + cmp r5, #0 + bne halt + + // Setup the stack. + ldr r5, =_start + mov sp, r5 + + // Clear out bss. + ldr r4, =__bss_start + ldr r9, =__bss_end + mov r5, #0 + mov r6, #0 + mov r7, #0 + mov r8, #0 + b 2f + +1: + // store multiple at r4. + stmia r4!, {r5-r8} + + // If we are still below bss_end, loop. +2: + cmp r4, r9 + blo 1b + + // Call kernel_main + ldr r3, =kernel_main + blx r3 + + // halt +halt: + wfe + b halt |