ps3-hvcall.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. .machine "ppc64"
  22. /*
  23. * The PS3 hypervisor uses a 64 bit "C" language calling convention.
  24. * The routines here marshal arguments between the 32 bit wrapper
  25. * program and the 64 bit hvcalls.
  26. *
  27. * wrapper lv1
  28. * 32-bit (h,l) 64-bit
  29. *
  30. * 1: r3,r4 <-> r3
  31. * 2: r5,r6 <-> r4
  32. * 3: r7,r8 <-> r5
  33. * 4: r9,r10 <-> r6
  34. * 5: 8(r1),12(r1) <-> r7
  35. * 6: 16(r1),20(r1) <-> r8
  36. * 7: 24(r1),28(r1) <-> r9
  37. * 8: 32(r1),36(r1) <-> r10
  38. *
  39. */
  40. .macro GLOBAL name
  41. .section ".text"
  42. .balign 4
  43. .globl \name
  44. \name:
  45. .endm
  46. .macro NO_SUPPORT name
  47. GLOBAL \name
  48. b ps3_no_support
  49. .endm
  50. .macro HVCALL num
  51. li r11, \num
  52. .long 0x44000022
  53. extsw r3, r3
  54. .endm
  55. .macro SAVE_LR offset=4
  56. mflr r0
  57. stw r0, \offset(r1)
  58. .endm
  59. .macro LOAD_LR offset=4
  60. lwz r0, \offset(r1)
  61. mtlr r0
  62. .endm
  63. .macro LOAD_64_REG target,high,low
  64. sldi r11, \high, 32
  65. or \target, r11, \low
  66. .endm
  67. .macro LOAD_64_STACK target,offset
  68. ld \target, \offset(r1)
  69. .endm
  70. .macro LOAD_R3
  71. LOAD_64_REG r3,r3,r4
  72. .endm
  73. .macro LOAD_R4
  74. LOAD_64_REG r4,r5,r6
  75. .endm
  76. .macro LOAD_R5
  77. LOAD_64_REG r5,r7,r8
  78. .endm
  79. .macro LOAD_R6
  80. LOAD_64_REG r6,r9,r10
  81. .endm
  82. .macro LOAD_R7
  83. LOAD_64_STACK r7,8
  84. .endm
  85. .macro LOAD_R8
  86. LOAD_64_STACK r8,16
  87. .endm
  88. .macro LOAD_R9
  89. LOAD_64_STACK r9,24
  90. .endm
  91. .macro LOAD_R10
  92. LOAD_64_STACK r10,32
  93. .endm
  94. .macro LOAD_REGS_0
  95. stwu 1,-16(1)
  96. stw 3, 8(1)
  97. .endm
  98. .macro LOAD_REGS_5
  99. LOAD_R3
  100. LOAD_R4
  101. LOAD_R5
  102. LOAD_R6
  103. LOAD_R7
  104. .endm
  105. .macro LOAD_REGS_6
  106. LOAD_REGS_5
  107. LOAD_R8
  108. .endm
  109. .macro LOAD_REGS_8
  110. LOAD_REGS_6
  111. LOAD_R9
  112. LOAD_R10
  113. .endm
  114. .macro STORE_REGS_0_1
  115. lwz r11, 8(r1)
  116. std r4, 0(r11)
  117. mr r4, r3
  118. li r3, 0
  119. addi r1,r1,16
  120. .endm
  121. .macro STORE_REGS_5_2
  122. lwz r11, 16(r1)
  123. std r4, 0(r11)
  124. lwz r11, 20(r1)
  125. std r5, 0(r11)
  126. .endm
  127. .macro STORE_REGS_6_1
  128. lwz r11, 24(r1)
  129. std r4, 0(r11)
  130. .endm
  131. GLOBAL lv1_get_logical_ppe_id
  132. SAVE_LR
  133. LOAD_REGS_0
  134. HVCALL 69
  135. STORE_REGS_0_1
  136. LOAD_LR
  137. blr
  138. GLOBAL lv1_get_logical_partition_id
  139. SAVE_LR
  140. LOAD_REGS_0
  141. HVCALL 74
  142. STORE_REGS_0_1
  143. LOAD_LR
  144. blr
  145. GLOBAL lv1_get_repository_node_value
  146. SAVE_LR
  147. LOAD_REGS_5
  148. HVCALL 91
  149. STORE_REGS_5_2
  150. LOAD_LR
  151. blr
  152. GLOBAL lv1_panic
  153. SAVE_LR
  154. LOAD_REGS_8
  155. HVCALL 255
  156. LOAD_LR
  157. blr