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