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