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