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