Advertisement
Guest User

Untitled

a guest
Sep 4th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // FROM: https://wiki.osdev.org/Raspberry_Pi_Bare_Bones
  2.  
  3. // AArch64 mode
  4.  
  5. // To keep this in the first portion of the binary.
  6. .section ".text.boot"
  7.  
  8. // Make _start global.
  9. .globl _start
  10.  
  11. .org 0x80000
  12. // Entry point for the kernel. Registers:
  13. // x0 -> 32 bit pointer to DTB in memory (primary core only) / 0 (secondary cores)
  14. // x1 -> 0
  15. // x2 -> 0
  16. // x3 -> 0
  17. // x4 -> 32 bit kernel entry point, _start location
  18. _start:
  19. // set stack before our code
  20. ldr x5, =_start
  21. mov sp, x5
  22.  
  23. // clear bss
  24. ldr x5, =__bss_start
  25. ldr w6, =__bss_size
  26. 3: cbz w6, 4f
  27. str xzr, [x5], #8
  28. sub w6, w6, #1
  29. cbnz w6, 3b
  30.  
  31. // jump to C code, should not return
  32. 4: bl kernel_main
  33. // for failsafe, halt this core too
  34. hlt #0
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement