xref: /titanic_51/usr/src/uts/sun4v/ml/hcall.s (revision 49f0e51890161901ae4f49c7a47602d97b52b934)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#pragma ident	"%Z%%M%	%I%	%E% SMI"
27
28/*
29 * Hypervisor calls
30 */
31
32#include <sys/asm_linkage.h>
33#include <sys/machasi.h>
34#include <sys/machparam.h>
35#include <sys/hypervisor_api.h>
36
37#if defined(lint) || defined(__lint)
38
39/*ARGSUSED*/
40int64_t
41hv_cnputchar(uint8_t ch)
42{ return (0); }
43
44/*ARGSUSED*/
45int64_t
46hv_cngetchar(uint8_t *ch)
47{ return (0); }
48
49/*ARGSUSED*/
50uint64_t
51hv_tod_get(uint64_t *seconds)
52{ return (0); }
53
54/*ARGSUSED*/
55uint64_t
56hv_tod_set(uint64_t seconds)
57{ return (0);}
58
59/*ARGSUSED*/
60uint64_t
61hv_mmu_map_perm_addr(void *vaddr, int ctx, uint64_t tte, int flags)
62{ return (0); }
63
64/*ARGSUSED*/
65uint64_t
66hv_mmu_unmap_perm_addr(void *vaddr, int ctx, int flags)
67{ return (0); }
68
69/*ARGSUSED*/
70uint64_t
71hv_set_ctx0(uint64_t ntsb_descriptor, uint64_t desc_ra)
72{ return (0); }
73
74/*ARGSUSED*/
75uint64_t
76hv_set_ctxnon0(uint64_t ntsb_descriptor, uint64_t desc_ra)
77{ return (0); }
78
79#ifdef SET_MMU_STATS
80/*ARGSUSED*/
81uint64_t
82hv_mmu_set_stat_area(uint64_t rstatarea, uint64_t size)
83{ return (0); }
84#endif /* SET_MMU_STATS */
85
86/*ARGSUSED*/
87uint64_t
88hv_cpu_qconf(int queue, uint64_t paddr, int size)
89{ return (0); }
90
91/*ARGSUSED*/
92uint64_t
93hvio_intr_devino_to_sysino(uint64_t dev_hdl, uint32_t devino, uint64_t *sysino)
94{ return (0); }
95
96/*ARGSUSED*/
97uint64_t
98hvio_intr_getvalid(uint64_t sysino, int *intr_valid_state)
99{ return (0); }
100
101/*ARGSUSED*/
102uint64_t
103hvio_intr_setvalid(uint64_t sysino, int intr_valid_state)
104{ return (0); }
105
106/*ARGSUSED*/
107uint64_t
108hvio_intr_getstate(uint64_t sysino, int *intr_state)
109{ return (0); }
110
111/*ARGSUSED*/
112uint64_t
113hvio_intr_setstate(uint64_t sysino, int intr_state)
114{ return (0); }
115
116/*ARGSUSED*/
117uint64_t
118hvio_intr_gettarget(uint64_t sysino, uint32_t *cpuid)
119{ return (0); }
120
121/*ARGSUSED*/
122uint64_t
123hvio_intr_settarget(uint64_t sysino, uint32_t cpuid)
124{ return (0); }
125
126uint64_t
127hv_cpu_yield(void)
128{ return (0); }
129
130/*ARGSUSED*/
131uint64_t
132hv_cpu_state(uint64_t cpuid, uint64_t *cpu_state)
133{ return (0); }
134
135/*ARGSUSED*/
136uint64_t
137hv_dump_buf_update(uint64_t paddr, uint64_t size, uint64_t *minsize)
138{ return (0); }
139
140/*ARGSUSED*/
141uint64_t
142hv_mem_scrub(uint64_t real_addr, uint64_t length, uint64_t *scrubbed_len)
143{ return (0); }
144
145/*ARGSUSED*/
146uint64_t
147hv_mem_sync(uint64_t real_addr, uint64_t length, uint64_t *flushed_len)
148{ return (0); }
149
150/*ARGSUSED*/
151uint64_t
152hv_ttrace_buf_conf(uint64_t paddr, uint64_t size, uint64_t *size1)
153{ return (0); }
154
155/*ARGSUSED*/
156uint64_t
157hv_ttrace_buf_info(uint64_t *paddr, uint64_t *size)
158{ return (0); }
159
160/*ARGSUSED*/
161uint64_t
162hv_ttrace_enable(uint64_t enable, uint64_t *prev_enable)
163{ return (0); }
164
165/*ARGSUSED*/
166uint64_t
167hv_ttrace_freeze(uint64_t freeze, uint64_t *prev_freeze)
168{ return (0); }
169
170/*ARGSUSED*/
171uint64_t
172hv_mach_desc(uint64_t buffer_ra, uint64_t *buffer_sizep)
173{ return (0); }
174
175/*ARGSUSED*/
176uint64_t
177hv_ra2pa(uint64_t ra)
178{ return (0); }
179
180/*ARGSUSED*/
181uint64_t
182hv_hpriv(void *func, uint64_t arg1, uint64_t arg2, uint64_t arg3)
183{ return (0); }
184
185#else	/* lint || __lint */
186
187	/*
188	 * %o0 - character
189	 */
190	ENTRY(hv_cnputchar)
191	mov	CONS_WRITE, %o5
192	ta	FAST_TRAP
193	tst	%o0
194	retl
195	movnz	%xcc, -1, %o0
196	SET_SIZE(hv_cnputchar)
197
198	/*
199	 * %o0 pointer to character buffer
200	 * return values:
201	 * 0 success
202	 * hv_errno failure
203	 */
204	ENTRY(hv_cngetchar)
205	mov	%o0, %o2
206	mov	CONS_READ, %o5
207	ta	FAST_TRAP
208	brnz,a	%o0, 1f		! failure, just return error
209	mov	1, %o0
210
211	cmp	%o1, H_BREAK
212	be	1f
213	mov	%o1, %o0
214
215	cmp	%o1, H_HUP
216	be	1f
217	mov	%o1, %o0
218
219	stb	%o1, [%o2]	! success, save character and return 0
220	mov	0, %o0
2211:
222	retl
223	nop
224	SET_SIZE(hv_cngetchar)
225
226	ENTRY(hv_tod_get)
227	mov	%o0, %o4
228	mov	TOD_GET, %o5
229	ta	FAST_TRAP
230	retl
231	  stx	%o1, [%o4]
232	SET_SIZE(hv_tod_get)
233
234	ENTRY(hv_tod_set)
235	mov	TOD_SET, %o5
236	ta	FAST_TRAP
237	retl
238	nop
239	SET_SIZE(hv_tod_set)
240
241	/*
242	 * Map permanent address
243	 * arg0 vaddr (%o0)
244	 * arg1 context (%o1)
245	 * arg2 tte (%o2)
246	 * arg3 flags (%o3)  0x1=d 0x2=i
247	 */
248	ENTRY(hv_mmu_map_perm_addr)
249	mov	MAP_PERM_ADDR, %o5
250	ta	FAST_TRAP
251	retl
252	nop
253	SET_SIZE(hv_mmu_map_perm_addr)
254
255	/*
256	 * Unmap permanent address
257	 * arg0 vaddr (%o0)
258	 * arg1 context (%o1)
259	 * arg2 flags (%o2)  0x1=d 0x2=i
260	 */
261	ENTRY(hv_mmu_unmap_perm_addr)
262	mov	UNMAP_PERM_ADDR, %o5
263	ta	FAST_TRAP
264	retl
265	nop
266	SET_SIZE(hv_mmu_unmap_perm_addr)
267
268	/*
269	 * Set TSB for context 0
270	 * arg0 ntsb_descriptor (%o0)
271	 * arg1 desc_ra (%o1)
272	 */
273	ENTRY(hv_set_ctx0)
274	mov	MMU_TSB_CTX0, %o5
275	ta	FAST_TRAP
276	retl
277	nop
278	SET_SIZE(hv_set_ctx0)
279
280	/*
281	 * Set TSB for context non0
282	 * arg0 ntsb_descriptor (%o0)
283	 * arg1 desc_ra (%o1)
284	 */
285	ENTRY(hv_set_ctxnon0)
286	mov	MMU_TSB_CTXNON0, %o5
287	ta	FAST_TRAP
288	retl
289	nop
290	SET_SIZE(hv_set_ctxnon0)
291
292#ifdef SET_MMU_STATS
293	/*
294	 * Returns old stat area on success
295	 */
296	ENTRY(hv_mmu_set_stat_area)
297	mov	MMU_STAT_AREA, %o5
298	ta	FAST_TRAP
299	retl
300	nop
301	SET_SIZE(hv_mmu_set_stat_area)
302#endif /* SET_MMU_STATS */
303
304	/*
305	 * CPU Q Configure
306	 * arg0 queue (%o0)
307	 * arg1 Base address RA (%o1)
308	 * arg2 Size (%o2)
309	 */
310	ENTRY(hv_cpu_qconf)
311	mov	CPU_QCONF, %o5
312	ta	FAST_TRAP
313	retl
314	nop
315	SET_SIZE(hv_cpu_qconf)
316
317	/*
318	 * arg0 - devhandle
319	 * arg1 - devino
320	 *
321	 * ret0 - status
322	 * ret1 - sysino
323	 */
324	ENTRY(hvio_intr_devino_to_sysino)
325	mov	HVIO_INTR_DEVINO2SYSINO, %o5
326	ta	FAST_TRAP
327	brz,a	%o0, 1f
328	stx	%o1, [%o2]
3291:	retl
330	nop
331	SET_SIZE(hvio_intr_devino_to_sysino)
332
333	/*
334	 * arg0 - sysino
335	 *
336	 * ret0 - status
337	 * ret1 - intr_valid_state
338	 */
339	ENTRY(hvio_intr_getvalid)
340	mov	%o1, %o2
341	mov	HVIO_INTR_GETVALID, %o5
342	ta	FAST_TRAP
343	brz,a	%o0, 1f
344	stuw	%o1, [%o2]
3451:	retl
346	nop
347	SET_SIZE(hvio_intr_getvalid)
348
349	/*
350	 * arg0 - sysino
351	 * arg1 - intr_valid_state
352	 *
353	 * ret0 - status
354	 */
355	ENTRY(hvio_intr_setvalid)
356	mov	HVIO_INTR_SETVALID, %o5
357	ta	FAST_TRAP
358	retl
359	nop
360	SET_SIZE(hvio_intr_setvalid)
361
362	/*
363	 * arg0 - sysino
364	 *
365	 * ret0 - status
366	 * ret1 - intr_state
367	 */
368	ENTRY(hvio_intr_getstate)
369	mov	%o1, %o2
370	mov	HVIO_INTR_GETSTATE, %o5
371	ta	FAST_TRAP
372	brz,a	%o0, 1f
373	stuw	%o1, [%o2]
3741:	retl
375	nop
376	SET_SIZE(hvio_intr_getstate)
377
378	/*
379	 * arg0 - sysino
380	 * arg1 - intr_state
381	 *
382	 * ret0 - status
383	 */
384	ENTRY(hvio_intr_setstate)
385	mov	HVIO_INTR_SETSTATE, %o5
386	ta	FAST_TRAP
387	retl
388	nop
389	SET_SIZE(hvio_intr_setstate)
390
391	/*
392	 * arg0 - sysino
393	 *
394	 * ret0 - status
395	 * ret1 - cpu_id
396	 */
397	ENTRY(hvio_intr_gettarget)
398	mov	%o1, %o2
399	mov	HVIO_INTR_GETTARGET, %o5
400	ta	FAST_TRAP
401	brz,a	%o0, 1f
402	stuw	%o1, [%o2]
4031:	retl
404	nop
405	SET_SIZE(hvio_intr_gettarget)
406
407	/*
408	 * arg0 - sysino
409	 * arg1 - cpu_id
410	 *
411	 * ret0 - status
412	 */
413	ENTRY(hvio_intr_settarget)
414	mov	HVIO_INTR_SETTARGET, %o5
415	ta	FAST_TRAP
416	retl
417	nop
418	SET_SIZE(hvio_intr_settarget)
419
420	/*
421	 * hv_cpu_yield(void)
422	 */
423	ENTRY(hv_cpu_yield)
424	mov	HV_CPU_YIELD, %o5
425	ta	FAST_TRAP
426	retl
427	nop
428	SET_SIZE(hv_cpu_yield)
429
430	/*
431	 * int hv_cpu_state(uint64_t cpuid, uint64_t *cpu_state);
432	 */
433	ENTRY(hv_cpu_state)
434	mov	%o1, %o4			! save datap
435	mov	HV_CPU_STATE, %o5
436	ta	FAST_TRAP
437	brz,a	%o0, 1f
438	stx	%o1, [%o4]
4391:
440	retl
441	nop
442	SET_SIZE(hv_cpu_state)
443
444	/*
445	 * HV state dump zone Configure
446	 * arg0 real adrs of dump buffer (%o0)
447	 * arg1 size of dump buffer (%o1)
448	 * ret0 status (%o0)
449	 * ret1 size of buffer on success and min size on EINVAL (%o1)
450	 * hv_dump_buf_update(uint64_t paddr, uint64_t size, uint64_t *ret_size)
451	 */
452	ENTRY(hv_dump_buf_update)
453	mov	DUMP_BUF_UPDATE, %o5
454	ta	FAST_TRAP
455	retl
456	stx	%o1, [%o2]
457	SET_SIZE(hv_dump_buf_update)
458
459
460	/*
461	 * For memory scrub
462	 * int hv_mem_scrub(uint64_t real_addr, uint64_t length,
463	 * 	uint64_t *scrubbed_len);
464	 * Retun %o0 -- status
465	 *       %o1 -- bytes scrubbed
466	 */
467	ENTRY(hv_mem_scrub)
468	mov	%o2, %o4
469	mov	HV_MEM_SCRUB, %o5
470	ta	FAST_TRAP
471	retl
472	stx	%o1, [%o4]
473	SET_SIZE(hv_mem_scrub)
474
475	/*
476	 * Flush ecache
477	 * int hv_mem_sync(uint64_t real_addr, uint64_t length,
478	 * 	uint64_t *flushed_len);
479	 * Retun %o0 -- status
480	 *       %o1 -- bytes flushed
481	 */
482	ENTRY(hv_mem_sync)
483	mov	%o2, %o4
484	mov	HV_MEM_SYNC, %o5
485	ta	FAST_TRAP
486	retl
487	stx	%o1, [%o4]
488	SET_SIZE(hv_mem_sync)
489
490	/*
491	 * TTRACE_BUF_CONF Configure
492	 * arg0 RA base of buffer (%o0)
493	 * arg1 buf size in no. of entries (%o1)
494	 * ret0 status (%o0)
495	 * ret1 minimum size in no. of entries on failure,
496	 * actual size in no. of entries on success (%o1)
497	 */
498	ENTRY(hv_ttrace_buf_conf)
499	mov	TTRACE_BUF_CONF, %o5
500	ta	FAST_TRAP
501	retl
502	stx	%o1, [%o2]
503	SET_SIZE(hv_ttrace_buf_conf)
504
505	 /*
506	 * TTRACE_BUF_INFO
507	 * ret0 status (%o0)
508	 * ret1 RA base of buffer (%o1)
509	 * ret2 size in no. of entries (%o2)
510	 */
511	ENTRY(hv_ttrace_buf_info)
512	mov	%o0, %o3
513	mov	%o1, %o4
514	mov	TTRACE_BUF_INFO, %o5
515	ta	FAST_TRAP
516	stx	%o1, [%o3]
517	retl
518	stx	%o2, [%o4]
519	SET_SIZE(hv_ttrace_buf_info)
520
521	/*
522	 * TTRACE_ENABLE
523	 * arg0 enable/ disable (%o0)
524	 * ret0 status (%o0)
525	 * ret1 previous enable state (%o1)
526	 */
527	ENTRY(hv_ttrace_enable)
528	mov	%o1, %o2
529	mov	TTRACE_ENABLE, %o5
530	ta	FAST_TRAP
531	retl
532	stx	%o1, [%o2]
533	SET_SIZE(hv_ttrace_enable)
534
535	/*
536	 * TTRACE_FREEZE
537	 * arg0 enable/ freeze (%o0)
538	 * ret0 status (%o0)
539	 * ret1 previous freeze state (%o1)
540	*/
541	ENTRY(hv_ttrace_freeze)
542	mov	%o1, %o2
543	mov	TTRACE_FREEZE, %o5
544	ta	FAST_TRAP
545	retl
546	stx	%o1, [%o2]
547	SET_SIZE(hv_ttrace_freeze)
548
549	/*
550	 * MACH_DESC
551	 * arg0 buffer real address
552	 * arg1 pointer to uint64_t for size of buffer
553	 * ret0 status
554	 * ret1 return required size of buffer / returned data size
555	 */
556	ENTRY(hv_mach_desc)
557	mov     %o1, %o4                ! save datap
558	ldx     [%o1], %o1
559	mov     HV_MACH_DESC, %o5
560	ta      FAST_TRAP
561	retl
562	stx   %o1, [%o4]
563	SET_SIZE(hv_mach_desc)
564
565	/*
566	 * hv_ra2pa(uint64_t ra)
567	 *
568	 * MACH_DESC
569	 * arg0 Real address to convert
570	 * ret0 Returned physical address or -1 on error
571	 */
572	ENTRY(hv_ra2pa)
573	mov	HV_RA2PA, %o5
574	ta	FAST_TRAP
575	cmp	%o0, 0
576	move	%xcc, %o1, %o0
577	movne	%xcc, -1, %o0
578	retl
579	nop
580	SET_SIZE(hv_ra2pa)
581
582	/*
583	 * hv_hpriv(void *func, uint64_t arg1, uint64_t arg2, uint64_t arg3)
584	 *
585	 * MACH_DESC
586	 * arg0 OS function to call
587	 * arg1 First arg to OS function
588	 * arg2 Second arg to OS function
589	 * arg3 Third arg to OS function
590	 * ret0 Returned value from function
591	 */
592
593	ENTRY(hv_hpriv)
594	mov	HV_HPRIV, %o5
595	ta	FAST_TRAP
596	retl
597	nop
598	SET_SIZE(hv_hpriv)
599
600#endif	/* lint || __lint */
601