summaryrefslogtreecommitdiff
path: root/arch/powerpc/boot/ps3-hvcall.S
blob: ff74102e8a7161d90c551f11e21f66eba2eba1be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 *  PS3 bootwrapper hvcalls.
 *
 *  Copyright (C) 2007 Sony Computer Entertainment Inc.
 *  Copyright 2007 Sony Corp.
 */

#include "ppc_asm.h"

	.machine "ppc64"

/*
 * The PS3 hypervisor uses a 64 bit "C" language calling convention.
 * The routines here marshal arguments between the 32 bit wrapper
 * program and the 64 bit hvcalls.
 *
 *  wrapper           lv1
 *  32-bit (h,l)      64-bit
 *
 *  1: r3,r4          <-> r3
 *  2: r5,r6          <-> r4
 *  3: r7,r8          <-> r5
 *  4: r9,r10         <-> r6
 *  5: 8(r1),12(r1)   <-> r7
 *  6: 16(r1),20(r1)  <-> r8
 *  7: 24(r1),28(r1)  <-> r9
 *  8: 32(r1),36(r1)  <-> r10
 *
 */

.macro GLOBAL name
	.section ".text"
	.balign 4
	.globl \name
\name:
.endm

.macro NO_SUPPORT name
	GLOBAL \name
	b ps3_no_support
.endm

.macro HVCALL num
	li r11, \num
	.long 0x44000022
	extsw r3, r3
.endm

.macro SAVE_LR offset=4
	mflr r0
	stw r0, \offset(r1)
.endm

.macro LOAD_LR offset=4
	lwz r0, \offset(r1)
	mtlr r0
.endm

.macro LOAD_64_REG target,high,low
	sldi r11, \high, 32
	or \target, r11, \low
.endm

.macro LOAD_64_STACK target,offset
	ld \target, \offset(r1)
.endm

.macro LOAD_R3
	LOAD_64_REG r3,r3,r4
.endm

.macro LOAD_R4
	LOAD_64_REG r4,r5,r6
.endm

.macro LOAD_R5
	LOAD_64_REG r5,r7,r8
.endm

.macro LOAD_R6
	LOAD_64_REG r6,r9,r10
.endm

.macro LOAD_R7
	LOAD_64_STACK r7,8
.endm

.macro LOAD_R8
	LOAD_64_STACK r8,16
.endm

.macro LOAD_R9
	LOAD_64_STACK r9,24
.endm

.macro LOAD_R10
	LOAD_64_STACK r10,32
.endm

.macro LOAD_REGS_0
	stwu 1,-16(1)
	stw 3, 8(1)
.endm

.macro LOAD_REGS_5
	LOAD_R3
	LOAD_R4
	LOAD_R5
	LOAD_R6
	LOAD_R7
.endm

.macro LOAD_REGS_6
	LOAD_REGS_5
	LOAD_R8
.endm

.macro LOAD_REGS_8
	LOAD_REGS_6
	LOAD_R9
	LOAD_R10
.endm

.macro STORE_REGS_0_1
	lwz r11, 8(r1)
	std r4, 0(r11)
	mr r4, r3
	li r3, 0
	addi r1,r1,16
.endm

.macro STORE_REGS_5_2
	lwz r11, 16(r1)
	std r4, 0(r11)
	lwz r11, 20(r1)
	std r5, 0(r11)
.endm

.macro STORE_REGS_6_1
	lwz r11, 24(r1)
	std r4, 0(r11)
.endm

GLOBAL lv1_get_logical_ppe_id
	SAVE_LR
	LOAD_REGS_0
	HVCALL 69
	STORE_REGS_0_1
	LOAD_LR
	blr

GLOBAL lv1_get_logical_partition_id
	SAVE_LR
	LOAD_REGS_0
	HVCALL 74
	STORE_REGS_0_1
	LOAD_LR
	blr

GLOBAL lv1_get_repository_node_value
	SAVE_LR
	LOAD_REGS_5
	HVCALL 91
	STORE_REGS_5_2
	LOAD_LR
	blr

GLOBAL lv1_panic
	SAVE_LR
	LOAD_REGS_8
	HVCALL 255
	LOAD_LR
	blr