1255643Snwhitehorn/*-
2255643Snwhitehorn * Copyright (C) 2010 Andreas Tobler
3255643Snwhitehorn * All rights reserved.
4255643Snwhitehorn *
5255643Snwhitehorn * Redistribution and use in source and binary forms, with or without
6255643Snwhitehorn * modification, are permitted provided that the following conditions
7255643Snwhitehorn * are met:
8255643Snwhitehorn * 1. Redistributions of source code must retain the above copyright
9255643Snwhitehorn *    notice, this list of conditions and the following disclaimer.
10255643Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
11255643Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
12255643Snwhitehorn *    documentation and/or other materials provided with the distribution.
13255643Snwhitehorn *
14255643Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15255643Snwhitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16255643Snwhitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17255643Snwhitehorn * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18255643Snwhitehorn * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19255643Snwhitehorn * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20255643Snwhitehorn * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21255643Snwhitehorn * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22255643Snwhitehorn * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23255643Snwhitehorn * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24255643Snwhitehorn *
25255643Snwhitehorn * $FreeBSD$
26255643Snwhitehorn */
27255643Snwhitehorn#include <machine/asm.h>
28255643Snwhitehorn
29255643Snwhitehorn/* Hypervisor entry call. */
30255643Snwhitehorn#define  hc  .long 0x44000022
31255643Snwhitehorn
32255643Snwhitehorn/*
33255643Snwhitehorn * Simple HV calls take the same arguments, with the same ABI, as this
34255643Snwhitehorn * C function
35255643Snwhitehorn */
36255643SnwhitehornASENTRY(phyp_hcall)
37255643Snwhitehorn	mflr	%r0
38255643Snwhitehorn	std	%r0,16(%r1)
39256777Snwhitehorn	ld	%r11,112(%r1)		/* Last couple args into volatile regs*/
40256777Snwhitehorn	ld	%r12,120(%r1)
41255643Snwhitehorn	hc				/* invoke the hypervisor */
42255643Snwhitehorn	ld	%r0,16(%r1)
43255643Snwhitehorn	mtlr	%r0
44255643Snwhitehorn	blr				/* return r3 = status */
45255643Snwhitehorn
46255643Snwhitehorn/*
47255643Snwhitehorn * PFT HV calls take a special ABI (see PAPR 14.5.4.1)
48255643Snwhitehorn *
49255643Snwhitehorn * r3-r7 arguments passed unchanged, r8-r10 are addresses of return values
50255643Snwhitehorn * HV takes the same r3-r7, but returns values in r3, r4-r6
51255643Snwhitehorn */
52255643SnwhitehornASENTRY(phyp_pft_hcall)
53255643Snwhitehorn	mflr	%r0
54255643Snwhitehorn	std	%r0,16(%r1)
55255643Snwhitehorn	stdu	%r1,-80(%r1)
56255643Snwhitehorn	std	%r8,48(%r1)		/* save arguments */
57255643Snwhitehorn	std	%r9,56(%r1)
58255643Snwhitehorn	std	%r10,64(%r1)
59255643Snwhitehorn	hc				/* invoke the hypervisor */
60255643Snwhitehorn	ld	%r11,48(%r1)		/* store results */
61255643Snwhitehorn	std	%r4,0(%r11)
62255643Snwhitehorn	ld	%r11,56(%r1)
63255643Snwhitehorn	std	%r5,0(%r11)
64255643Snwhitehorn	ld	%r11,64(%r1)
65255643Snwhitehorn	std	%r6,0(%r11)
66255643Snwhitehorn	ld	%r1,0(%r1)		/* exit */
67255643Snwhitehorn	ld	%r0,16(%r1)
68255643Snwhitehorn	mtlr	%r0
69255643Snwhitehorn	blr				/* return r3 = status */
70255643Snwhitehorn
71