start32.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * raspi/start32.S
  3. * https://gitlab.com/bztsrc/imgrecv
  4. *
  5. * Copyright (C) 2020 bzt (bztsrc@github)
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation
  9. * files (the "Software"), to deal in the Software without
  10. * restriction, including without limitation the rights to use, copy,
  11. * modify, merge, publish, distribute, sublicense, and/or sell copies
  12. * of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be
  16. * included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. * DEALINGS IN THE SOFTWARE.
  26. *
  27. */
  28. .section ".text.boot"
  29. .global _start
  30. _start:
  31. // save arguments on stack (we will need them later for the new kernel)
  32. ldr sp, =_start
  33. push { r0, r1, r2, r3 }
  34. // relocate our code from load address to link address
  35. ldr r1, =LOAD_ADDR
  36. mov r0, r1
  37. ldr r2, =_start
  38. ldr r3, =__loader_size
  39. 1: ldr r4, [r1], #4
  40. str r4, [r2], #4
  41. subs r3, #1
  42. bne 1b
  43. // jump to relocated C code
  44. bl receiver-1024
  45. // restore registers and jump to new kernel's entry point
  46. mov lr, r0
  47. pop { r0, r1, r2, r3 }
  48. bx lr