Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / include / c / hpv_calls.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: hpv_calls.s
5* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
6* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
7*
8* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9*
10* This program is free software; you can redistribute it and/or modify
11* it under the terms of the GNU General Public License as published by
12* the Free Software Foundation; version 2 of the License.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License
20* along with this program; if not, write to the Free Software
21* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*
23* For the avoidance of doubt, and except that if any non-GPL license
24* choice is available it will apply instead, Sun elects to use only
25* the General Public License version 2 (GPLv2) at this time for any
26* software where a choice of GPL license versions is made
27* available with the language indicating that GPLv2 or any later version
28* may be used, or where a choice of which version of the GPL is applied is
29* otherwise unspecified.
30*
31* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
32* CA 95054 USA or visit www.sun.com if you need additional information or
33* have any questions.
34*
35*
36* ========== Copyright Header End ============================================
37*/
38#ident "@(#) hpv_calls.s 1.1 04/10/11 16:44:05"
39#include <sys/asm_linkage.h>
40
41#pragma ident "@(#) hpv_calls.s 1.1 04/10/11 16:44:05 SMI"
42
43/*
44 * Hypervisor calls
45 */
46
47#include <sys/asm_linkage.h>
48#define HPV_CALL_TRAP 0x90
49#define CONS_READ 0x60
50#define CONS_WRITE 0x61
51#define TOD_GET 0x50
52#define MAP_PERM_ADDR 0x25
53#define MMU_SET_INFOPTR 0x26
54
55#define DISK_READ 0xf0
56#define DISK_WRITE 0xf1
57#define CPU_QCONF 0x14
58#define HACK_XCALL 0xf6 /* XXX */
59#define FAKE_INTR 0xf7 /* XXX */
60#define CONS_STATUS 0xf8
61#define CONS_SETINTR 0xf9
62
63#if defined(lint) || defined(__lint)
64
65/*ARGSUSED*/
66uint64_t
67hv_mmu_set_infoptr(uint64_t rmissarea)
68{ return (0); }
69
70/*ARGSUSED*/
71uint64_t
72hv_tod_get(void)
73{ return (0); }
74
75uint64_t
76hv_ld_scratch0(void)
77{ return (0); }
78
79/*ARGSUSED*/
80void
81hv_st_scratch0(uint64_t v)
82{ }
83
84/*ARGSUSED*/
85int
86hv_mmu_map_perm_addr(void *vaddr, int ctx, uint64_t tte, int flags)
87{ return (0); }
88
89/*ARGSUSED*/
90int
91hv_cpu_qconf(int queue, uint64_t paddr, int size)
92{ return (0); }
93
94int
95hv_fake_intr(void)
96{ return (0); }
97
98#else /* lint || __lint */
99
100#define ASI_SCRATCHPAD 0x20 /* XXX */
101/* XXXQ - sun4v OBP/OS convention: va0x0/ASI_SCRATCHPAD contains miss area */
102
103 /*
104 * XXX These do not belong here
105 */
106 ENTRY(hv_ld_scratch0)
107 retl
108 ldxa [%g0]ASI_SCRATCHPAD, %o0
109 SET_SIZE(hv_ld_scratch0)
110
111 ENTRY(hv_st_scratch0)
112 retl
113 stxa %o0, [%g0]ASI_SCRATCHPAD
114 SET_SIZE(hv_st_scratch0)
115
116 /*
117 * Returns old infoptr on success, -1 on failure
118 */
119 ENTRY(hv_mmu_set_infoptr)
120 mov MMU_SET_INFOPTR, %o5
121 ta HPV_CALL_TRAP
122 tst %o0
123 movz %xcc, %o1, %o0
124 retl
125 movnz %xcc, -1, %o0
126 SET_SIZE(hv_mmu_set_infoptr)
127
128 ENTRY(hv_debug)
129 ta 0x70
130 retl
131 nop
132 SET_SIZE(hv_debug)
133
134 /*
135 * %o0 - disk offset
136 * %o1 - target real address
137 * %o2 - size
138 */
139 ENTRY(hv_disk_read)
140 mov DISK_READ, %o5
141 ta HPV_CALL_TRAP
142 tst %o0
143 movz %xcc, %o1, %o0
144 retl
145 movnz %xcc, -1, %o0
146 SET_SIZE(hv_disk_read)
147
148 /*
149 * %o0 - disk offset
150 * %o1 - target real address
151 * %o2 - size
152 */
153 ENTRY(hv_disk_write)
154 mov DISK_WRITE, %o5
155 ta HPV_CALL_TRAP
156 tst %o0
157 movz %xcc, %o1, %o0
158 retl
159 movnz %xcc, -1, %o0
160 SET_SIZE(hv_disk_write)
161
162 /*
163 * %o0 - character
164 */
165 ENTRY(hv_cnputchar)
166 ta T_CHANGE_PRIV
167 mov CONS_WRITE, %o5
168 ta HPV_CALL_TRAP
169 ta T_CHANGE_NONPRIV
170 tst %o0
171 movz %xcc, %o1, %o0
172 retl
173 movnz %xcc, -1, %o0
174 SET_SIZE(hv_cnputchar)
175
176 /*
177 * %o0 pointer to character buffer
178 * return values:
179 * 0 success
180 * hv_errno failure
181 * (int64_t)-1 BREAK
182 */
183 ENTRY(hv_cngetchar)
184 mov %o0, %o2
185 mov CONS_READ, %o5
186 ta HPV_CALL_TRAP
187 brnz,a %o0, 1f ! failure, just return error
188 mov 1, %o0
189
190 cmp %o1, -1 ! BREAK, return -1
191 be 1f
192 mov %o1, %o0
193
194 stb %o1, [%o2] ! success, save character and return 0
195 mov 0, %o0
1961:
197 retl
198 nop
199 SET_SIZE(hv_cngetchar)
200
201 /*
202 * %o0 pointer to character buffer
203 * return values:
204 * 0 success
205 * hv_errno failure
206 * (int64_t)-1 BREAK
207 */
208 ENTRY(hv_cngetstatus)
209 mov %o0, %o2
210 mov CONS_STATUS, %o5
211 ta HPV_CALL_TRAP
212 brnz,a %o0, 1f ! failure, just return error
213 mov 1, %o0
214
215 stb %o1, [%o2] ! success, save character and return 0
216 mov 0, %o0
2171:
218 retl
219 nop
220 SET_SIZE(hv_cngetstatus)
221
222 /*
223 * %o0 - character
224 */
225 ENTRY(hv_cnsetintr)
226 mov CONS_SETINTR, %o5
227 ta HPV_CALL_TRAP
228 tst %o0
229 movz %xcc, %o1, %o0
230 retl
231 movnz %xcc, -1, %o0
232 SET_SIZE(hv_cnsetintr)
233
234 ENTRY(hv_tod_get)
235 mov TOD_GET, %o5
236 ta HPV_CALL_TRAP
237 tst %o0
238 movz %xcc, %o1, %o0
239 retl
240 movnz %xcc, -1, %o0
241 SET_SIZE(hv_tod_get)
242
243
244 /*
245 * Map permanent address
246 * arg0 vaddr (%o0)
247 * arg1 context (%o1)
248 * arg2 tte (%o2)
249 * arg3 flags (%o3) 0x1=d 0x2=i
250 */
251 ENTRY(hv_mmu_map_perm_addr)
252 mov MAP_PERM_ADDR, %o5
253 ta HPV_CALL_TRAP
254 tst %o0
255 movz %xcc, %o1, %o0
256 retl
257 movnz %xcc, -1, %o0
258 SET_SIZE(hv_mmu_map_perm_addr)
259
260
261 /*
262 * CPU Q Configure
263 * arg0 queue (%o0)
264 * arg1 Base address RA (%o1)
265 * arg2 Size (%o2)
266 */
267 ENTRY(hv_cpu_qconf)
268 mov CPU_QCONF, %o5
269 ta HPV_CALL_TRAP
270 retl
271 nop
272 SET_SIZE(hv_cpu_qconf)
273
274 /*
275 * XXXQ temporary
276 */
277 ENTRY(hv_fake_intr)
278 mov FAKE_INTR, %o5
279 ta HPV_CALL_TRAP
280 retl
281 nop
282 SET_SIZE(hv_fake_intr)
283
284 ENTRY(hv_hack_xcall)
285 mov HACK_XCALL, %o5
286 ta HPV_CALL_TRAP
287 retl
288 nop
289 SET_SIZE(hv_hack_xcall)
290
291
292 /*
293 * %o0 - addr, %o1 data
294 */
295 ENTRY(hv_poke_little)
296 ta T_CHANGE_PRIV
297 mov VPCI_IO_POKE, %o5
298 ta HPV_CALL_TRAP
299 ta T_CHANGE_NONPRIV
300 retl
301 SET_SIZE(hv_poke_little)
302
303 /*
304 * %o0 - addr, %o0 returned w/ data
305 */
306 ENTRY(hv_peek_little)
307 ta T_CHANGE_PRIV
308 mov VPCI_IO_PEEK, %o5
309 ta HPV_CALL_TRAP
310 ta T_CHANGE_NONPRIV
311 retl
312 SET_SIZE(hv_peek_little)
313
314 /*
315 * %o0 - addr, %o1 data
316 */
317 ENTRY(hv_poke)
318 ta T_CHANGE_PRIV
319 mov IO_POKE, %o5
320 ta HPV_CALL_TRAP
321 ta T_CHANGE_NONPRIV
322 retl
323 SET_SIZE(hv_poke)
324
325 /*
326 * %o0 - addr, %o0 returned w/ data
327 */
328 ENTRY(hv_peek)
329 ta T_CHANGE_PRIV
330 mov IO_PEEK, %o5
331 ta HPV_CALL_TRAP
332 ta T_CHANGE_NONPRIV
333 retl
334 SET_SIZE(hv_peek)
335
336#endif /* lint || __lint */