boot0.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2017 Theobroma Systems Design und Consulting GmbH
  4. */
  5. /*
  6. * Execution starts on the instruction following this 4-byte header
  7. * (containing the magic 'RK30', 'RK31', 'RK32' or 'RK33'). This
  8. * magic constant will be written into the final image by the rkimage
  9. * tool, but we need to reserve space for it here.
  10. *
  11. * To make life easier for everyone, we build the SPL binary with
  12. * space for this 4-byte header already included in the binary.
  13. */
  14. #ifdef CONFIG_SPL_BUILD
  15. /*
  16. * We need to add 4 bytes of space for the 'RK33' at the
  17. * beginning of the executable. However, as we want to keep
  18. * this generic and make it applicable to builds that are like
  19. * the RK3368 (TPL needs this, SPL doesn't) or the RK3399 (no
  20. * TPL, but extra space needed in the SPL), we simply insert
  21. * a branch-to-next-instruction-word with the expectation that
  22. * the first one may be overwritten, if this is the first stage
  23. * contained in the final image created with mkimage)...
  24. */
  25. b 1f /* if overwritten, entry-address is at the next word */
  26. 1:
  27. #endif
  28. #if CONFIG_IS_ENABLED(ROCKCHIP_EARLYRETURN_TO_BROM)
  29. adr r3, entry_counter
  30. ldr r0, [r3]
  31. cmp r0, #1 /* check if entry_counter == 1 */
  32. beq reset /* regular bootup */
  33. add r0, #1
  34. str r0, [r3] /* increment the entry_counter in memory */
  35. mov r0, #0 /* return 0 to the BROM to signal 'OK' */
  36. bx lr /* return control to the BROM */
  37. entry_counter:
  38. .word 0
  39. #endif
  40. #if (defined(CONFIG_SPL_BUILD) || defined(CONFIG_ARM64))
  41. /* U-Boot proper of armv7 do not need this */
  42. b reset
  43. #endif
  44. #if !defined(CONFIG_ARM64)
  45. /*
  46. * For armv7, the addr '_start' will used as vector start address
  47. * and write to VBAR register, which needs to aligned to 0x20.
  48. */
  49. .align(5), 0x0
  50. _start:
  51. ARM_VECTORS
  52. #endif
  53. #if defined(CONFIG_SPL_BUILD) && (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0)
  54. .space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for the ATF data */
  55. #endif