Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  PS3 bootwrapper hvcalls.
0004  *
0005  *  Copyright (C) 2007 Sony Computer Entertainment Inc.
0006  *  Copyright 2007 Sony Corp.
0007  */
0008 
0009 #include "ppc_asm.h"
0010 
0011     .machine "ppc64"
0012 
0013 /*
0014  * The PS3 hypervisor uses a 64 bit "C" language calling convention.
0015  * The routines here marshal arguments between the 32 bit wrapper
0016  * program and the 64 bit hvcalls.
0017  *
0018  *  wrapper           lv1
0019  *  32-bit (h,l)      64-bit
0020  *
0021  *  1: r3,r4          <-> r3
0022  *  2: r5,r6          <-> r4
0023  *  3: r7,r8          <-> r5
0024  *  4: r9,r10         <-> r6
0025  *  5: 8(r1),12(r1)   <-> r7
0026  *  6: 16(r1),20(r1)  <-> r8
0027  *  7: 24(r1),28(r1)  <-> r9
0028  *  8: 32(r1),36(r1)  <-> r10
0029  *
0030  */
0031 
0032 .macro GLOBAL name
0033     .section ".text"
0034     .balign 4
0035     .globl \name
0036 \name:
0037 .endm
0038 
0039 .macro NO_SUPPORT name
0040     GLOBAL \name
0041     b ps3_no_support
0042 .endm
0043 
0044 .macro HVCALL num
0045     li r11, \num
0046     .long 0x44000022
0047     extsw r3, r3
0048 .endm
0049 
0050 .macro SAVE_LR offset=4
0051     mflr r0
0052     stw r0, \offset(r1)
0053 .endm
0054 
0055 .macro LOAD_LR offset=4
0056     lwz r0, \offset(r1)
0057     mtlr r0
0058 .endm
0059 
0060 .macro LOAD_64_REG target,high,low
0061     sldi r11, \high, 32
0062     or \target, r11, \low
0063 .endm
0064 
0065 .macro LOAD_64_STACK target,offset
0066     ld \target, \offset(r1)
0067 .endm
0068 
0069 .macro LOAD_R3
0070     LOAD_64_REG r3,r3,r4
0071 .endm
0072 
0073 .macro LOAD_R4
0074     LOAD_64_REG r4,r5,r6
0075 .endm
0076 
0077 .macro LOAD_R5
0078     LOAD_64_REG r5,r7,r8
0079 .endm
0080 
0081 .macro LOAD_R6
0082     LOAD_64_REG r6,r9,r10
0083 .endm
0084 
0085 .macro LOAD_R7
0086     LOAD_64_STACK r7,8
0087 .endm
0088 
0089 .macro LOAD_R8
0090     LOAD_64_STACK r8,16
0091 .endm
0092 
0093 .macro LOAD_R9
0094     LOAD_64_STACK r9,24
0095 .endm
0096 
0097 .macro LOAD_R10
0098     LOAD_64_STACK r10,32
0099 .endm
0100 
0101 .macro LOAD_REGS_0
0102     stwu 1,-16(1)
0103     stw 3, 8(1)
0104 .endm
0105 
0106 .macro LOAD_REGS_5
0107     LOAD_R3
0108     LOAD_R4
0109     LOAD_R5
0110     LOAD_R6
0111     LOAD_R7
0112 .endm
0113 
0114 .macro LOAD_REGS_6
0115     LOAD_REGS_5
0116     LOAD_R8
0117 .endm
0118 
0119 .macro LOAD_REGS_8
0120     LOAD_REGS_6
0121     LOAD_R9
0122     LOAD_R10
0123 .endm
0124 
0125 .macro STORE_REGS_0_1
0126     lwz r11, 8(r1)
0127     std r4, 0(r11)
0128     mr r4, r3
0129     li r3, 0
0130     addi r1,r1,16
0131 .endm
0132 
0133 .macro STORE_REGS_5_2
0134     lwz r11, 16(r1)
0135     std r4, 0(r11)
0136     lwz r11, 20(r1)
0137     std r5, 0(r11)
0138 .endm
0139 
0140 .macro STORE_REGS_6_1
0141     lwz r11, 24(r1)
0142     std r4, 0(r11)
0143 .endm
0144 
0145 GLOBAL lv1_get_logical_ppe_id
0146     SAVE_LR
0147     LOAD_REGS_0
0148     HVCALL 69
0149     STORE_REGS_0_1
0150     LOAD_LR
0151     blr
0152 
0153 GLOBAL lv1_get_logical_partition_id
0154     SAVE_LR
0155     LOAD_REGS_0
0156     HVCALL 74
0157     STORE_REGS_0_1
0158     LOAD_LR
0159     blr
0160 
0161 GLOBAL lv1_get_repository_node_value
0162     SAVE_LR
0163     LOAD_REGS_5
0164     HVCALL 91
0165     STORE_REGS_5_2
0166     LOAD_LR
0167     blr
0168 
0169 GLOBAL lv1_panic
0170     SAVE_LR
0171     LOAD_REGS_8
0172     HVCALL 255
0173     LOAD_LR
0174     blr