]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/powerpc/pseries/phyp-hvcall.S
MFHead @347527
[FreeBSD/FreeBSD.git] / sys / powerpc / pseries / phyp-hvcall.S
1 /*-
2  * Copyright (C) 2010 Andreas Tobler
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27 #include <machine/asm.h>
28
29 /* Hypervisor entry call. */
30 #define  hc  .long 0x44000022
31
32 /*
33  * Simple HV calls take the same arguments, with the same ABI, as this
34  * C function
35  */
36 ASENTRY(phyp_hcall)
37         mflr    %r0
38         std     %r0,16(%r1)
39 #if defined(_CALL_ELF) && _CALL_ELF == 2
40         ld      %r11,96(%r1)            /* Last couple args into volatile regs*/
41         ld      %r12,104(%r1)
42 #else
43         ld      %r11,112(%r1)           /* Last couple args into volatile regs*/
44         ld      %r12,120(%r1)
45 #endif
46         hc                              /* invoke the hypervisor */
47         ld      %r0,16(%r1)
48         mtlr    %r0
49         blr                             /* return r3 = status */
50
51 /*
52  * PFT HV calls take a special ABI (see PAPR 14.5.4.1)
53  *
54  * r3-r7 arguments passed unchanged, r8-r10 are addresses of return values
55  * HV takes the same r3-r7, but returns values in r3, r4-r6
56  */
57 ASENTRY(phyp_pft_hcall)
58         mflr    %r0
59         std     %r0,16(%r1)
60         stdu    %r1,-80(%r1)
61         std     %r8,48(%r1)             /* save arguments */
62         std     %r9,56(%r1)
63         std     %r10,64(%r1)
64         hc                              /* invoke the hypervisor */
65         ld      %r11,48(%r1)            /* store results */
66         std     %r4,0(%r11)
67         ld      %r11,56(%r1)
68         std     %r5,0(%r11)
69         ld      %r11,64(%r1)
70         std     %r6,0(%r11)
71         ld      %r1,0(%r1)              /* exit */
72         ld      %r0,16(%r1)
73         mtlr    %r0
74         blr                             /* return r3 = status */
75