xref: /DragonStub/lib/ia64/palproc.S (revision 803b49c40bb0b720b90d9c31d372911f1b946aa7)
1530d68baSNigel Croxon//++
2530d68baSNigel Croxon//      Copyright (c) 1996-99 Intel Corp.
3530d68baSNigel Croxon//
4530d68baSNigel Croxon//
5530d68baSNigel Croxon// Module Name:
6530d68baSNigel Croxon//
7530d68baSNigel Croxon//  palproc.s
8530d68baSNigel Croxon//
9530d68baSNigel Croxon// Abstract:
10530d68baSNigel Croxon//
11530d68baSNigel Croxon//  Contains an implementation for making PAL PROC calls on
12530d68baSNigel Croxon//  IA-64 architecture.
13530d68baSNigel Croxon//
14530d68baSNigel Croxon//
15530d68baSNigel Croxon//
16530d68baSNigel Croxon// Revision History:
17530d68baSNigel Croxon//
18530d68baSNigel Croxon//--
19530d68baSNigel Croxon
20530d68baSNigel Croxon	.file	"palproc.s"
21530d68baSNigel Croxon
22530d68baSNigel Croxon#include "palproc.h"
23530d68baSNigel Croxon
24530d68baSNigel Croxon
25530d68baSNigel Croxon//-----------------------------------------------------------------------------
26530d68baSNigel Croxon//++
27530d68baSNigel Croxon// MakeStaticPALCall
28530d68baSNigel Croxon//
29530d68baSNigel Croxon// This routine is called whenever an architected static calling convention
30530d68baSNigel Croxon// based PAL call is to be made. This call does use RSE actually, but our policy
31530d68baSNigel Croxon// in making static PAL calls before memory is available is to make sure that
32530d68baSNigel Croxon// we do not nest too deep and allocate beyond 96 banked registers. In other
33530d68baSNigel Croxon// words we carefully code calls and control flow before memory is available.
34530d68baSNigel Croxon//
35530d68baSNigel Croxon// Arguments : All parameters set up to do static PAL call.
36530d68baSNigel Croxon//
37530d68baSNigel Croxon// On Entry :
38530d68baSNigel Croxon//
39530d68baSNigel Croxon// Return Value:
40530d68baSNigel Croxon//
41530d68baSNigel Croxon// As per static calling conventions.
42530d68baSNigel Croxon//
43530d68baSNigel Croxon//--
44530d68baSNigel Croxon//---------------------------------------------------------------------------
45530d68baSNigel CroxonPROCEDURE_ENTRY(MakeStaticPALCall)
46530d68baSNigel Croxon
47530d68baSNigel Croxon        NESTED_SETUP (5,8,0,0)
48530d68baSNigel Croxon        mov         loc3 = b5
49530d68baSNigel Croxon        mov         loc4 = r2
50530d68baSNigel Croxon        mov         loc7 = r1;;
51530d68baSNigel Croxon
52530d68baSNigel Croxon        movl        loc6 = PAL_MC_CLEAR_LOG
53530d68baSNigel Croxon        mov         r2 = psr;;
54530d68baSNigel Croxon        mov         loc5 = r2
55530d68baSNigel Croxon
56530d68baSNigel Croxon        cmp.eq      p6,p7 = r28,loc6;;
57530d68baSNigel Croxon    (p7)movl        loc6 = PAL_MC_DYNAMIC_STATE;;
58530d68baSNigel Croxon    (p7)cmp.eq      p6,p7 = r28,loc6;;
59530d68baSNigel Croxon
60530d68baSNigel Croxon    (p7)movl        loc6 = PAL_MC_ERROR_INFO;;
61530d68baSNigel Croxon    (p7)cmp.eq      p6,p7 = r28,loc6;;
62530d68baSNigel Croxon
63530d68baSNigel Croxon    (p7)movl        loc6 = PAL_MC_RESUME;;
64530d68baSNigel Croxon    (p7)cmp.eq      p6,p7 = r28,loc6
65530d68baSNigel Croxon
66530d68baSNigel Croxon        mov         loc6 = 0x1;;
67530d68baSNigel Croxon    (p7)dep         r2 = loc6,r2,13,1;;         // psr.ic = 1
68530d68baSNigel Croxon
69530d68baSNigel Croxon// p6 will be true, if it is one of the MCHK calls. There has been lots of debate
70530d68baSNigel Croxon// on psr.ic for these values. For now, do not do any thing to psr.ic
71530d68baSNigel Croxon
72530d68baSNigel Croxon//    (p6)dep         r2 = r0,r2,13,1;;         // psr.ic = 0
73530d68baSNigel Croxon        dep         r2 = r0,r2,14,1;;           // psr.i = 0
74530d68baSNigel Croxon
75530d68baSNigel Croxon        mov         psr.l = r2
76530d68baSNigel Croxon        srlz.d;;                                // Needs data serailization.
77530d68baSNigel Croxon        srlz.i;;                                // Needs instruction serailization.
78530d68baSNigel Croxon
79530d68baSNigel CroxonStaticGetPALLocalIP:
80530d68baSNigel Croxon        mov         loc2 = ip;;
81530d68baSNigel Croxon        add         loc2 = StaticComeBackFromPALCall - StaticGetPALLocalIP,loc2;;
82530d68baSNigel Croxon        mov         b0 = loc2                   // return address after Pal call
83530d68baSNigel Croxon        mov         r28 = in1                   // get the input parameters to PAL call
84530d68baSNigel Croxon        mov         r29 = in2
85530d68baSNigel Croxon        mov         r30 = in3;;
86530d68baSNigel Croxon        mov         r31 = in4
87530d68baSNigel Croxon        mov         b5 =  in0;;                 // get the PalProcEntrypt from input
88530d68baSNigel Croxon        br.sptk     b5                          // Take the plunge.
89530d68baSNigel Croxon
90530d68baSNigel CroxonStaticComeBackFromPALCall:
91530d68baSNigel Croxon
92530d68baSNigel Croxon        mov         psr.l = loc5;;
93530d68baSNigel Croxon        srlz.d;;                                // Needs data serailization.
94530d68baSNigel Croxon        srlz.i;;                                // Needs instruction serailization.
95530d68baSNigel Croxon
96530d68baSNigel Croxon        mov         b5 = loc3
97530d68baSNigel Croxon        mov         r2 = loc4
98530d68baSNigel Croxon        mov         r1 = loc7
99530d68baSNigel Croxon
100530d68baSNigel Croxon        NESTED_RETURN
101530d68baSNigel Croxon
102530d68baSNigel CroxonPROCEDURE_EXIT(MakeStaticPALCall)
103530d68baSNigel Croxon
104530d68baSNigel Croxon
105530d68baSNigel Croxon//-----------------------------------------------------------------------------
106530d68baSNigel Croxon//++
107530d68baSNigel Croxon// MakeStackedPALCall
108530d68baSNigel Croxon//
109530d68baSNigel Croxon// This routine is called whenever an architected stacked calling convention
110530d68baSNigel Croxon// based PAL call is to be made. This call is made after memory is available.
111530d68baSNigel Croxon// Although stacked calls could be made directly from 'C', there is a PAL
112530d68baSNigel Croxon// requirement which forces the index to be in GR28 and hence this stub is
113530d68baSNigel Croxon// needed
114530d68baSNigel Croxon//
115530d68baSNigel Croxon// Arguments : All parameters set up to do stacted PAL call.
116530d68baSNigel Croxon//
117530d68baSNigel Croxon// On Entry :
118530d68baSNigel Croxon//          in0:  PAL_PROC entrypoint
119530d68baSNigel Croxon//          in1-in4 : PAL_PROC arguments
120530d68baSNigel Croxon//
121530d68baSNigel Croxon// Return Value:
122530d68baSNigel Croxon//
123530d68baSNigel Croxon// As per stacked calling conventions.
124530d68baSNigel Croxon//
125530d68baSNigel Croxon//--
126530d68baSNigel Croxon//---------------------------------------------------------------------------
127530d68baSNigel CroxonPROCEDURE_ENTRY(MakeStackedPALCall)
128530d68baSNigel Croxon
129530d68baSNigel Croxon        NESTED_SETUP (5,8,4,0)
130530d68baSNigel Croxon        mov         loc3 = b5
131530d68baSNigel Croxon        mov         loc4 = r2
132530d68baSNigel Croxon        mov         loc7 = r1
133530d68baSNigel Croxon        mov         r2 = psr;;
134530d68baSNigel Croxon        mov         loc5 = r2;;
135530d68baSNigel Croxon        dep         r2 = r0,r2,14,1;;           // psr.i = 0
136530d68baSNigel Croxon        mov         psr.l = r2
137530d68baSNigel Croxon        srlz.d;;                                // Needs data serailization.
138530d68baSNigel Croxon        srlz.i;;                                // Needs instruction serailization.
139530d68baSNigel Croxon
140530d68baSNigel CroxonStackedGetPALLocalIP:
141530d68baSNigel Croxon        mov         r28 = in1                   // get the input parameters to PAL call
142530d68baSNigel Croxon        mov         out0 = in1
143530d68baSNigel Croxon        mov         out1 = in2;;
144530d68baSNigel Croxon        mov         out2 = in3
145530d68baSNigel Croxon        mov         out3 = in4
146530d68baSNigel Croxon        mov         b5 =  in0;;                 // get the PalProcEntrypt from input
147530d68baSNigel Croxon        br.call.dpnt b0=b5;;                    // Take the plunge.
148530d68baSNigel Croxon
149530d68baSNigel CroxonStackedComeBackFromPALCall:
150530d68baSNigel Croxon
151530d68baSNigel Croxon        mov         psr.l = loc5;;
152530d68baSNigel Croxon        srlz.d;;                                // Needs data serailization.
153530d68baSNigel Croxon        srlz.i;;                                // Needs instruction serailization.
154530d68baSNigel Croxon        mov         b5 = loc3
155530d68baSNigel Croxon        mov         r2 = loc4
156530d68baSNigel Croxon        mov         r1 = loc7
157530d68baSNigel Croxon
158530d68baSNigel Croxon        NESTED_RETURN
159530d68baSNigel Croxon
160530d68baSNigel CroxonPROCEDURE_EXIT(MakeStackedPALCall)
161530d68baSNigel Croxon
162*803b49c4SSergei Trofimovich#if defined(__ELF__) && defined(__linux__)
163*803b49c4SSergei Trofimovich	.section .note.GNU-stack,"",%progbits
164*803b49c4SSergei Trofimovich#endif
165