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