zboot_macros.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef __ZBOOT_MACRO_H
  2. #define __ZBOOT_MACRO_H
  3. /* The LIST command is used to include comments in the script */
  4. .macro LIST comment
  5. .endm
  6. /* The ED command is used to write a 32-bit word */
  7. .macro ED, addr, data
  8. LDR r0, 1f
  9. LDR r1, 2f
  10. STR r1, [r0]
  11. B 3f
  12. 1 : .long \addr
  13. 2 : .long \data
  14. 3 :
  15. .endm
  16. /* The EW command is used to write a 16-bit word */
  17. .macro EW, addr, data
  18. LDR r0, 1f
  19. LDR r1, 2f
  20. STRH r1, [r0]
  21. B 3f
  22. 1 : .long \addr
  23. 2 : .long \data
  24. 3 :
  25. .endm
  26. /* The EB command is used to write an 8-bit word */
  27. .macro EB, addr, data
  28. LDR r0, 1f
  29. LDR r1, 2f
  30. STRB r1, [r0]
  31. B 3f
  32. 1 : .long \addr
  33. 2 : .long \data
  34. 3 :
  35. .endm
  36. /* The WAIT command is used to delay the execution */
  37. .macro WAIT, time, reg
  38. LDR r1, 1f
  39. LDR r0, 2f
  40. STR r0, [r1]
  41. 10 :
  42. LDR r0, [r1]
  43. CMP r0, #0x00000000
  44. BNE 10b
  45. NOP
  46. B 3f
  47. 1 : .long \reg
  48. 2 : .long \time * 100
  49. 3 :
  50. .endm
  51. /* The DD command is used to read a 32-bit word */
  52. .macro DD, start, end
  53. LDR r1, 1f
  54. B 2f
  55. 1 : .long \start
  56. 2 :
  57. .endm
  58. /* loop until a given value has been read (with mask) */
  59. .macro WAIT_MASK, addr, data, cmp
  60. LDR r0, 2f
  61. LDR r1, 3f
  62. LDR r2, 4f
  63. 1:
  64. LDR r3, [r0, #0]
  65. AND r3, r1, r3
  66. CMP r2, r3
  67. BNE 1b
  68. B 5f
  69. 2: .long \addr
  70. 3: .long \data
  71. 4: .long \cmp
  72. 5:
  73. .endm
  74. /* read 32-bit value from addr, "or" an immediate and write back */
  75. .macro ED_OR, addr, data
  76. LDR r4, 1f
  77. LDR r5, 2f
  78. LDR r6, [r4]
  79. ORR r5, r6, r5
  80. STR r5, [r4]
  81. B 3f
  82. 1: .long \addr
  83. 2: .long \data
  84. 3:
  85. .endm
  86. /* read 32-bit value from addr, "and" an immediate and write back */
  87. .macro ED_AND, addr, data
  88. LDR r4, 1f
  89. LDR r5, 2f
  90. LDR r6, [r4]
  91. AND r5, r6, r5
  92. STR r5, [r4]
  93. B 3f
  94. 1: .long \addr
  95. 2: .long \data
  96. 3:
  97. .endm
  98. #endif /* __ZBOOT_MACRO_H */