Initial import from FreeBSD RELENG_4:
[games.git] / sys / boot / alpha / libalpha / pal.S
1 /*
2  * $FreeBSD: src/sys/boot/alpha/libalpha/pal.S,v 1.2.2.1 2001/08/03 07:14:52 obrien Exp $
3  * From: $NetBSD: pal.s,v 1.12 1998/02/27 03:44:53 thorpej Exp $ 
4  */
5
6 /*
7  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
8  * All rights reserved.
9  *
10  * Author: Chris G. Demetriou
11  * 
12  * Permission to use, copy, modify and distribute this software and
13  * its documentation is hereby granted, provided that both the copyright
14  * notice and this permission notice appear in all copies of the
15  * software, derivative works or modified versions, and any portions
16  * thereof, and that both notices appear in supporting documentation.
17  * 
18  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
19  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
20  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21  * 
22  * Carnegie Mellon requests users of this software to return to
23  *
24  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
25  *  School of Computer Science
26  *  Carnegie Mellon University
27  *  Pittsburgh PA 15213-3890
28  *
29  * any improvements or extensions that they make and grant Carnegie the
30  * rights to redistribute these changes.
31  */
32
33 /*
34  * The various OSF PALcode routines.
35  *
36  * The following code is originally derived from pages: (I) 6-5 - (I) 6-7
37  * and (III) 2-1 - (III) 2-25 of "Alpha Architecture Reference Manual" by
38  * Richard L. Sites.
39  *
40  * Updates taken from pages: (II-B) 2-1 - (II-B) 2-33 of "Alpha AXP
41  * Architecture Reference Manual, Second Edition" by Richard L. Sites
42  * and Richard T. Witek.
43  */
44
45 #include <machine/asm.h>
46
47 /*inc2: .stabs  __FILE__,132,0,0,inc2; .loc     1 __LINE__*/
48 inc2:   .stabs  __FILE__,132,0,0,inc2
49 /*
50  * alpha_rpcc: read process cycle counter (XXX INSTRUCTION, NOT PALcode OP)
51  */
52         .text
53 LEAF(alpha_rpcc,1)
54         rpcc    v0
55         RET
56         END(alpha_rpcc)
57
58 /*
59  * alpha_mb: memory barrier (XXX INSTRUCTION, NOT PALcode OP)
60  */
61         .text
62 LEAF(alpha_mb,0)
63         mb
64         RET
65         END(alpha_mb)
66
67 /*
68  * alpha_wmb: write memory barrier (XXX INSTRUCTION, NOT PALcode OP)
69  */
70         .text
71 LEAF(alpha_wmb,0)
72         /* wmb XXX */
73         mb /* XXX */
74         RET
75         END(alpha_wmb)
76
77 /*
78  * alpha_amask: read architecture features (XXX INSTRUCTION, NOT PALcode OP)
79  *
80  * Arguments:
81  *      a0      bitmask of features to test
82  *
83  * Returns:
84  *      v0      bitmask - bit is _cleared_ if feature is supported
85  */
86         .text
87 LEAF(alpha_amask,1)
88         amask   a0, v0
89         RET
90         END(alpha_amask)
91
92 /*
93  * alpha_implver: read implementation version (XXX INSTRUCTION, NOT PALcode OP)
94  *
95  * Returns:
96  *      v0      implementation version - see <machine/alpha_cpu.h>
97  */
98         .text
99 LEAF(alpha_implver,0)
100 #if 0
101         implver 0x1, v0
102 #else
103         .long   0x47e03d80      /* XXX gas(1) does the Wrong Thing */
104 #endif
105         RET
106         END(alpha_implver)
107
108 /*
109  * alpha_pal_imb: I-Stream memory barrier. [UNPRIVILEGED]
110  * (Makes instruction stream coherent with data stream.)
111  */
112         .text
113 LEAF(alpha_pal_imb,0)
114         call_pal PAL_imb
115         RET
116         END(alpha_pal_imb)
117
118 /*
119  * alpha_pal_cflush: Cache flush [PRIVILEGED]
120  *
121  * Flush the entire physical page specified by the PFN specified in
122  * a0 from any data caches associated with the current processor.
123  *
124  * Arguments:
125  *      a0      page frame number of page to flush
126  */
127         .text
128 LEAF(alpha_pal_cflush,1)
129         call_pal PAL_cflush
130         RET
131         END(alpha_pal_cflush)
132
133 /*
134  * alpha_pal_draina: Drain aborts. [PRIVILEGED]
135  */
136         .text
137 LEAF(alpha_pal_draina,0)
138         call_pal PAL_draina
139         RET
140         END(alpha_pal_draina)
141
142 /*
143  * alpha_pal_halt: Halt the processor. [PRIVILEGED]
144  */
145         .text
146 LEAF(alpha_pal_halt,0)
147         call_pal PAL_halt
148         br      zero,alpha_pal_halt     /* Just in case */
149         RET
150         END(alpha_pal_halt)
151
152 /*
153  * alpha_pal_rdmces: Read MCES processor register. [PRIVILEGED]
154  *
155  * Return:
156  *      v0      current MCES value
157  */
158         .text
159 LEAF(alpha_pal_rdmces,1)
160         call_pal PAL_OSF1_rdmces
161         RET
162         END(alpha_pal_rdmces)
163
164 /*
165  * alpha_pal_rdps: Read processor status. [PRIVILEGED]
166  *
167  * Return:
168  *      v0      current PS value
169  */
170         .text
171 LEAF(alpha_pal_rdps,0)
172         call_pal PAL_OSF1_rdps
173         RET
174         END(alpha_pal_rdps)
175
176 /*
177  * alpha_pal_rdusp: Read user stack pointer. [PRIVILEGED]
178  *
179  * Return:
180  *      v0      current user stack pointer
181  */
182         .text
183 LEAF(alpha_pal_rdusp,0)
184         call_pal PAL_OSF1_rdusp
185         RET
186         END(alpha_pal_rdusp)
187
188 /*
189  * alpha_pal_rdval: Read system value. [PRIVILEGED]
190  *
191  * Returns the sysvalue in v0, allowing access to a 64-bit
192  * per-processor value for use by the operating system.
193  *
194  * Return:
195  *      v0      sysvalue
196  */
197         .text
198 LEAF(alpha_pal_rdval,0)
199         call_pal PAL_OSF1_rdval
200         RET
201         END(alpha_pal_rdval)
202
203 /*
204  * alpha_pal_swpipl: Swap Interrupt priority level. [PRIVILEGED]
205  * _alpha_pal_swpipl: Same, from profiling code. [PRIVILEGED]
206  *
207  * Arguments:
208  *      a0      new IPL
209  *
210  * Return:
211  *      v0      old IPL
212  */
213         .text
214 LEAF(alpha_pal_swpipl,1)
215         call_pal PAL_OSF1_swpipl
216         RET
217         END(alpha_pal_swpipl)
218
219 LEAF_NOPROFILE(_alpha_pal_swpipl,1)
220         call_pal PAL_OSF1_swpipl
221         RET
222         END(_alpha_pal_swpipl)
223
224 /*
225  * alpha_pal_tbi: Translation buffer invalidate. [PRIVILEGED]
226  *
227  * Arguments:
228  *      a0      operation selector
229  *      a1      address to operate on (if necessary)
230  */
231         .text
232 LEAF(alpha_pal_tbi,2)
233         call_pal PAL_OSF1_tbi
234         RET
235         END(alpha_pal_tbi)
236
237 /*
238  * alpha_pal_whami: Who am I? [PRIVILEGED]
239  *
240  * Return:
241  *      v0      processor number
242  */
243         .text
244 LEAF(alpha_pal_whami,0)
245         call_pal PAL_OSF1_whami
246         RET
247         END(alpha_pal_whami)
248
249 /*
250  * alpha_pal_wrent: Write system entry address. [PRIVILEGED]
251  *
252  * Arguments:
253  *      a0      new vector
254  *      a1      vector selector
255  */
256         .text
257 LEAF(alpha_pal_wrent,2)
258         call_pal PAL_OSF1_wrent
259         RET
260         END(alpha_pal_wrent)
261
262 /*
263  * alpha_pal_wrfen: Write floating-point enable. [PRIVILEGED]
264  *
265  * Arguments:
266  *      a0      new enable value (val & 0x1 -> enable).
267  */
268         .text
269 LEAF(alpha_pal_wrfen,1)
270         call_pal PAL_OSF1_wrfen
271         RET
272         END(alpha_pal_wrfen)
273
274 /*
275  * alpha_pal_wripir: Write interprocessor interrupt request. [PRIVILEGED]
276  *
277  * Generate an interprocessor interrupt on the processor specified by
278  * processor number in a0.
279  *
280  * Arguments:
281  *      a0      processor to interrupt
282  */
283         .text
284 LEAF(alpha_pal_wripir,1)
285         call_pal PAL_ipir
286         RET
287         END(alpha_pal_wripir)
288
289 /*
290  * alpha_pal_wrusp: Write user stack pointer. [PRIVILEGED]
291  *
292  * Arguments:
293  *      a0      new user stack pointer
294  */
295         .text
296 LEAF(alpha_pal_wrusp,1)
297         call_pal PAL_OSF1_wrusp
298         RET
299         END(alpha_pal_wrusp)
300
301 /*
302  * alpha_pal_wrvptptr: Write virtual page table pointer. [PRIVILEGED]
303  *
304  * Arguments:
305  *      a0      new virtual page table pointer
306  */
307         .text
308 LEAF(alpha_pal_wrvptptr,1)
309         call_pal PAL_OSF1_wrvptptr
310         RET
311         END(alpha_pal_wrvptptr)
312
313 /*
314  * alpha_pal_wrmces: Write MCES processor register. [PRIVILEGED]
315  *
316  * Arguments:
317  *      a0      value to write to MCES
318  */
319         .text
320 LEAF(alpha_pal_wrmces,1)
321         call_pal PAL_OSF1_wrmces
322         RET
323         END(alpha_pal_wrmces)
324
325 /*
326  * alpha_pal_wrval: Write system value. [PRIVILEGED]
327  *
328  * Write the value passed in a0 to this processor's sysvalue.
329  *
330  * Arguments:
331  *      a0      value to write to sysvalue
332  */
333 LEAF(alpha_pal_wrval,1)
334         call_pal PAL_OSF1_wrval
335         RET
336         END(alpha_pal_wrval)
337
338 /*
339  * alpha_pal_swpctx: Swap context. [PRIVILEGED]
340  *
341  * Switch to a new process context.
342  *
343  * Arguments:
344  *      a0      physical address of hardware PCB describing context
345  *
346  * Returns:
347  *      v0      physical address of hardware PCB describing previous context
348  */
349 LEAF(alpha_pal_swpctx,1)
350         call_pal PAL_OSF1_swpctx
351         RET
352         END(alpha_pal_swpctx)