AsmMacroIoLib.inc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ;%HEADER%
  2. ;/** @file
  3. ; Macros to work around lack of Apple support for LDR register, =expr
  4. ;
  5. ; Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
  6. ; Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
  7. ;
  8. ; This program and the accompanying materials
  9. ; are licensed and made available under the terms and conditions of the BSD License
  10. ; which accompanies this distribution. The full text of the license may be found at
  11. ; http://opensource.org/licenses/bsd-license.php
  12. ;
  13. ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  14. ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  15. ;
  16. ;**/
  17. MACRO
  18. MmioWrite32Macro $Address, $Data
  19. ldr r1, = ($Address)
  20. ldr r0, = ($Data)
  21. str r0, [r1]
  22. MEND
  23. MACRO
  24. MmioOr32Macro $Address, $OrData
  25. ldr r1, =($Address)
  26. ldr r2, =($OrData)
  27. ldr r0, [r1]
  28. orr r0, r0, r2
  29. str r0, [r1]
  30. MEND
  31. MACRO
  32. MmioAnd32Macro $Address, $AndData
  33. ldr r1, =($Address)
  34. ldr r2, =($AndData)
  35. ldr r0, [r1]
  36. and r0, r0, r2
  37. str r0, [r1]
  38. MEND
  39. MACRO
  40. MmioAndThenOr32Macro $Address, $AndData, $OrData
  41. ldr r1, =($Address)
  42. ldr r0, [r1]
  43. ldr r2, =($AndData)
  44. and r0, r0, r2
  45. ldr r2, =($OrData)
  46. orr r0, r0, r2
  47. str r0, [r1]
  48. MEND
  49. MACRO
  50. MmioWriteFromReg32Macro $Address, $Reg
  51. ldr r1, =($Address)
  52. str $Reg, [r1]
  53. MEND
  54. MACRO
  55. MmioRead32Macro $Address
  56. ldr r1, =($Address)
  57. ldr r0, [r1]
  58. MEND
  59. MACRO
  60. MmioReadToReg32Macro $Address, $Reg
  61. ldr r1, =($Address)
  62. ldr $Reg, [r1]
  63. MEND
  64. MACRO
  65. LoadConstantMacro $Data
  66. ldr r0, =($Data)
  67. MEND
  68. MACRO
  69. LoadConstantToRegMacro $Data, $Reg
  70. ldr $Reg, =($Data)
  71. MEND
  72. ; The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack
  73. ; Note: Global Size will be modified
  74. MACRO
  75. SetPrimaryStack $StackTop, $GlobalSize, $Tmp
  76. and $Tmp, $GlobalSize, #7
  77. rsbne $Tmp, $Tmp, #8
  78. add $GlobalSize, $GlobalSize, $Tmp
  79. sub sp, $StackTop, $GlobalSize
  80. ; Set all the global variables to 0
  81. mov $Tmp, sp
  82. mov $GlobalSize, #0x0
  83. _SetPrimaryStackInitGlobals
  84. cmp $Tmp, $StackTop
  85. beq _SetPrimaryStackEnd
  86. str $GlobalSize, [$Tmp], #4
  87. b _SetPrimaryStackInitGlobals
  88. _SetPrimaryStackEnd
  89. MEND
  90. MACRO
  91. InitializePrimaryStack $GlobalSize, $Tmp1
  92. and $Tmp1, $GlobalSize, #7
  93. rsbne $Tmp1, $Tmp1, #8
  94. add $GlobalSize, $GlobalSize, $Tmp1
  95. mov $Tmp1, sp
  96. sub sp, $GlobalSize
  97. ; Set all the global variables to 0
  98. mov $GlobalSize, #0x0
  99. _InitializePrimaryStackLoop
  100. cmp $Tmp1, sp
  101. bls _InitializePrimaryStackEnd
  102. str $GlobalSize, [$Tmp1], #-4
  103. b _InitializePrimaryStackLoop
  104. _InitializePrimaryStackEnd
  105. MEND
  106. END