ps3-hvcall.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * PS3 bootwrapper hvcalls.
  3. *
  4. * Copyright (C) 2007 Sony Computer Entertainment Inc.
  5. * Copyright 2007 Sony Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include "ppc_asm.h"
  21. /*
  22. * The PS3 hypervisor uses a 64 bit "C" language calling convention.
  23. * The routines here marshal arguments between the 32 bit wrapper
  24. * program and the 64 bit hvcalls.
  25. *
  26. * wrapper lv1
  27. * 32-bit (h,l) 64-bit
  28. *
  29. * 1: r3,r4 <-> r3
  30. * 2: r5,r6 <-> r4
  31. * 3: r7,r8 <-> r5
  32. * 4: r9,r10 <-> r6
  33. * 5: 8(r1),12(r1) <-> r7
  34. * 6: 16(r1),20(r1) <-> r8
  35. * 7: 24(r1),28(r1) <-> r9
  36. * 8: 32(r1),36(r1) <-> r10
  37. *
  38. */
  39. .macro GLOBAL name
  40. .section ".text"
  41. .balign 4
  42. .globl \name
  43. \name:
  44. .endm
  45. .macro NO_SUPPORT name
  46. GLOBAL \name
  47. b ps3_no_support
  48. .endm
  49. .macro HVCALL num
  50. li r11, \num
  51. .long 0x44000022
  52. extsw r3, r3
  53. .endm
  54. .macro SAVE_LR offset=4
  55. mflr r0
  56. stw r0, \offset(r1)
  57. .endm
  58. .macro LOAD_LR offset=4
  59. lwz r0, \offset(r1)
  60. mtlr r0
  61. .endm
  62. .macro LOAD_64_REG target,high,low
  63. sldi r11, \high, 32
  64. or \target, r11, \low
  65. .endm
  66. .macro LOAD_64_STACK target,offset
  67. ld \target, \offset(r1)
  68. .endm
  69. .macro LOAD_R3
  70. LOAD_64_REG r3,r3,r4
  71. .endm
  72. .macro LOAD_R4
  73. LOAD_64_REG r4,r5,r6
  74. .endm
  75. .macro LOAD_R5
  76. LOAD_64_REG r5,r7,r8
  77. .endm
  78. .macro LOAD_R6
  79. LOAD_64_REG r6,r9,r10
  80. .endm
  81. .macro LOAD_R7
  82. LOAD_64_STACK r7,8
  83. .endm
  84. .macro LOAD_R8
  85. LOAD_64_STACK r8,16
  86. .endm
  87. .macro LOAD_R9
  88. LOAD_64_STACK r9,24
  89. .endm
  90. .macro LOAD_R10
  91. LOAD_64_STACK r10,32
  92. .endm
  93. .macro LOAD_REGS_0
  94. stwu 1,-16(1)
  95. stw 3, 8(1)
  96. .endm
  97. .macro LOAD_REGS_5
  98. LOAD_R3
  99. LOAD_R4
  100. LOAD_R5
  101. LOAD_R6
  102. LOAD_R7
  103. .endm
  104. .macro LOAD_REGS_6
  105. LOAD_REGS_5
  106. LOAD_R8
  107. .endm
  108. .macro LOAD_REGS_8
  109. LOAD_REGS_6
  110. LOAD_R9
  111. LOAD_R10
  112. .endm
  113. .macro STORE_REGS_0_1
  114. lwz r11, 8(r1)
  115. std r4, 0(r11)
  116. mr r4, r3
  117. li r3, 0
  118. addi r1,r1,16
  119. .endm
  120. .macro STORE_REGS_5_2
  121. lwz r11, 16(r1)
  122. std r4, 0(r11)
  123. lwz r11, 24(r1)
  124. std r5, 0(r11)
  125. .endm
  126. .macro STORE_REGS_6_1
  127. lwz r11, 24(r1)
  128. std r4, 0(r11)
  129. .endm
  130. GLOBAL lv1_get_logical_ppe_id
  131. SAVE_LR
  132. LOAD_REGS_0
  133. HVCALL 69
  134. STORE_REGS_0_1
  135. LOAD_LR
  136. blr
  137. GLOBAL lv1_get_logical_partition_id
  138. SAVE_LR
  139. LOAD_REGS_0
  140. HVCALL 74
  141. STORE_REGS_0_1
  142. LOAD_LR
  143. blr
  144. GLOBAL lv1_get_repository_node_value
  145. SAVE_LR
  146. LOAD_REGS_5
  147. HVCALL 91
  148. STORE_REGS_5_2
  149. LOAD_LR
  150. blr
  151. GLOBAL lv1_panic
  152. SAVE_LR
  153. LOAD_REGS_8
  154. HVCALL 255
  155. LOAD_LR
  156. blr