copy-kernel.S 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Arm assembly to copy the Gemini kernel on Storlink reference
  2. // designs and derived devices with the same flash layout and
  3. // boot loader.
  4. //
  5. // This will execute at 0x01600000
  6. //
  7. // Copies the kernel from two fragments (originally zImage
  8. // and initramdisk) to 0x00400000 making space for a kernel
  9. // image of up to 8 MB except for these 512 bytes used for
  10. // this bootstrap.
  11. //
  12. // 0x01600200 .. 0x017fffff -> 0x00400000 .. 0x005ffdff
  13. // 0x00800000 .. 0x00dfffff -> 0x005ffe00 .. 0x00bffdff
  14. // Memory used for this bootstrap
  15. .equ BOOT_HEADROOM, 0x200
  16. .global _start // Stand-alone assembly code
  17. _start:
  18. mov r1, #0x01600000
  19. mov r2, #0x00400000
  20. mov r3, #0x00200000
  21. add r1, r1, #BOOT_HEADROOM
  22. sub r3, r3, #BOOT_HEADROOM
  23. copyloop1:
  24. ldr r0, [r1]
  25. str r0, [r2]
  26. add r1, r1, #4
  27. add r2, r2, #4
  28. sub r3, r3, #4
  29. cmp r3, #0
  30. bne copyloop1
  31. mov r1, #0x00800000
  32. mov r3, #0x00600000
  33. copyloop2:
  34. ldr r0, [r1]
  35. str r0, [r2]
  36. add r1, r1, #4
  37. add r2, r2, #4
  38. sub r3, r3, #4
  39. cmp r3, #0
  40. bne copyloop2
  41. mov r0, #0x00400000
  42. // Let's go
  43. mov pc, r0