sysreg128.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (c) 2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <lib/extensions/sysreg128.h>
  9. .global read_par_el1
  10. .global write_par_el1
  11. .global read_ttbr0_el1
  12. .global write_ttbr0_el1
  13. .global read_ttbr1_el1
  14. .global write_ttbr1_el1
  15. .global read_ttbr0_el2
  16. .global write_ttbr0_el2
  17. .global read_ttbr1_el2
  18. .global write_ttbr1_el2
  19. .global read_vttbr_el2
  20. .global write_vttbr_el2
  21. .global read_rcwmask_el1
  22. .global write_rcwmask_el1
  23. .global read_rcwsmask_el1
  24. .global write_rcwsmask_el1
  25. /*
  26. * _mrrs - Move System register to two adjacent general-purpose
  27. * registers.
  28. * Instruction: MRRS <Xt>, <Xt+1>, (<systemreg>|S<op0>_<op1>_<Cn>_<Cm>_<op2>)
  29. *
  30. * Arguments/Opcode bit field:
  31. * regins: System register opcode.
  32. *
  33. * Clobbers: x0,x1,x2
  34. */
  35. .macro _mrrs regins:req
  36. #if ENABLE_FEAT_D128 == 2
  37. mrs x0, ID_AA64MMFR3_EL1
  38. tst x0, #(ID_AA64MMFR3_EL1_D128_MASK << ID_AA64MMFR3_EL1_D128_SHIFT)
  39. bne 1f
  40. /* If FEAT_D128 is not implemented then use mrs */
  41. .inst 0xD5300000 | (\regins)
  42. ret
  43. #endif
  44. 1:
  45. .inst 0xD5700000 | (\regins)
  46. ret
  47. .endm
  48. /*
  49. * _msrr - Move two adjacent general-purpose registers to System register.
  50. * Instruction: MSRR (<systemreg>|S<op0>_<op1>_<Cn>_<Cm>_<op2>), <Xt>, <Xt+1>
  51. *
  52. * Arguments/Opcode bit field:
  53. * regins: System register opcode.
  54. *
  55. * Clobbers: x0,x1,x2
  56. */
  57. .macro _msrr regins:req
  58. /* If FEAT_D128 is not implemented use msr, dont tamper
  59. * x0, x1 as they maybe used for mrrs */
  60. #if ENABLE_FEAT_D128 == 2
  61. mrs x2, ID_AA64MMFR3_EL1
  62. tst x2, #(ID_AA64MMFR3_EL1_D128_MASK << ID_AA64MMFR3_EL1_D128_SHIFT)
  63. bne 1f
  64. /* If FEAT_D128 is not implemented then use msr */
  65. .inst 0xD5100000 | (\regins)
  66. ret
  67. #endif
  68. 1:
  69. .inst 0xD5500000 | (\regins)
  70. ret
  71. .endm
  72. func read_par_el1
  73. _mrrs 0x87400 /* S3_0_C7_C4_0 */
  74. endfunc read_par_el1
  75. func write_par_el1
  76. _msrr 0x87400
  77. endfunc write_par_el1
  78. func read_ttbr0_el1
  79. _mrrs 0x82000 /* S3_0_C2_C0_0 */
  80. endfunc read_ttbr0_el1
  81. func write_ttbr0_el1
  82. _msrr 0x82000
  83. endfunc write_ttbr0_el1
  84. func read_ttbr1_el1
  85. _mrrs 0x82020 /* S3_0_C2_C0_1 */
  86. endfunc read_ttbr1_el1
  87. func write_ttbr1_el1
  88. _msrr 0x82020
  89. endfunc write_ttbr1_el1
  90. func read_ttbr0_el2
  91. _mrrs 0xC2000 /* S3_4_C2_C0_0 */
  92. endfunc read_ttbr0_el2
  93. func write_ttbr0_el2
  94. _msrr 0xC2000
  95. endfunc write_ttbr0_el2
  96. func read_ttbr1_el2
  97. _mrrs 0xC2020 /* S3_4_C2_C0_1 */
  98. endfunc read_ttbr1_el2
  99. func write_ttbr1_el2
  100. _msrr 0xC2020
  101. endfunc write_ttbr1_el2
  102. func read_vttbr_el2
  103. _mrrs 0xC2100 /* S3_4_C2_C1_0 */
  104. endfunc read_vttbr_el2
  105. func write_vttbr_el2
  106. _msrr 0xC2100
  107. endfunc write_vttbr_el2
  108. func read_rcwmask_el1
  109. _mrrs 0x8D0C0 /* S3_0_C13_C0_6 */
  110. endfunc read_rcwmask_el1
  111. func write_rcwmask_el1
  112. _msrr 0x8D0C0
  113. endfunc write_rcwmask_el1
  114. func read_rcwsmask_el1
  115. _mrrs 0x8D060 /* S3_0_C13_C0_3 */
  116. endfunc read_rcwsmask_el1
  117. func write_rcwsmask_el1
  118. _msrr 0x8D060
  119. endfunc write_rcwsmask_el1