ia64_cpu.h revision 1.1 1 1.1 cherry /* $NetBSD: ia64_cpu.h,v 1.1 2006/04/07 14:21:18 cherry Exp $ */
2 1.1 cherry
3 1.1 cherry /*-
4 1.1 cherry * Copyright (c) 2000 Doug Rabson
5 1.1 cherry * All rights reserved.
6 1.1 cherry *
7 1.1 cherry * Redistribution and use in source and binary forms, with or without
8 1.1 cherry * modification, are permitted provided that the following conditions
9 1.1 cherry * are met:
10 1.1 cherry * 1. Redistributions of source code must retain the above copyright
11 1.1 cherry * notice, this list of conditions and the following disclaimer.
12 1.1 cherry * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cherry * notice, this list of conditions and the following disclaimer in the
14 1.1 cherry * documentation and/or other materials provided with the distribution.
15 1.1 cherry *
16 1.1 cherry * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1 cherry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 cherry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 cherry * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1 cherry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 cherry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 cherry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 cherry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 cherry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 cherry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 cherry * SUCH DAMAGE.
27 1.1 cherry *
28 1.1 cherry * $FreeBSD$
29 1.1 cherry */
30 1.1 cherry
31 1.1 cherry #ifndef _MACHINE_IA64_CPU_H_
32 1.1 cherry #define _MACHINE_IA64_CPU_H_
33 1.1 cherry
34 1.1 cherry /*
35 1.1 cherry * Definition of PSR and IPSR bits.
36 1.1 cherry */
37 1.1 cherry #define IA64_PSR_BE 0x0000000000000002
38 1.1 cherry #define IA64_PSR_UP 0x0000000000000004
39 1.1 cherry #define IA64_PSR_AC 0x0000000000000008
40 1.1 cherry #define IA64_PSR_MFL 0x0000000000000010
41 1.1 cherry #define IA64_PSR_MFH 0x0000000000000020
42 1.1 cherry #define IA64_PSR_IC 0x0000000000002000
43 1.1 cherry #define IA64_PSR_I 0x0000000000004000
44 1.1 cherry #define IA64_PSR_PK 0x0000000000008000
45 1.1 cherry #define IA64_PSR_DT 0x0000000000020000
46 1.1 cherry #define IA64_PSR_DFL 0x0000000000040000
47 1.1 cherry #define IA64_PSR_DFH 0x0000000000080000
48 1.1 cherry #define IA64_PSR_SP 0x0000000000100000
49 1.1 cherry #define IA64_PSR_PP 0x0000000000200000
50 1.1 cherry #define IA64_PSR_DI 0x0000000000400000
51 1.1 cherry #define IA64_PSR_SI 0x0000000000800000
52 1.1 cherry #define IA64_PSR_DB 0x0000000001000000
53 1.1 cherry #define IA64_PSR_LP 0x0000000002000000
54 1.1 cherry #define IA64_PSR_TB 0x0000000004000000
55 1.1 cherry #define IA64_PSR_RT 0x0000000008000000
56 1.1 cherry #define IA64_PSR_CPL 0x0000000300000000
57 1.1 cherry #define IA64_PSR_CPL_KERN 0x0000000000000000
58 1.1 cherry #define IA64_PSR_CPL_1 0x0000000100000000
59 1.1 cherry #define IA64_PSR_CPL_2 0x0000000200000000
60 1.1 cherry #define IA64_PSR_CPL_USER 0x0000000300000000
61 1.1 cherry #define IA64_PSR_IS 0x0000000400000000
62 1.1 cherry #define IA64_PSR_MC 0x0000000800000000
63 1.1 cherry #define IA64_PSR_IT 0x0000001000000000
64 1.1 cherry #define IA64_PSR_ID 0x0000002000000000
65 1.1 cherry #define IA64_PSR_DA 0x0000004000000000
66 1.1 cherry #define IA64_PSR_DD 0x0000008000000000
67 1.1 cherry #define IA64_PSR_SS 0x0000010000000000
68 1.1 cherry #define IA64_PSR_RI 0x0000060000000000
69 1.1 cherry #define IA64_PSR_RI_0 0x0000000000000000
70 1.1 cherry #define IA64_PSR_RI_1 0x0000020000000000
71 1.1 cherry #define IA64_PSR_RI_2 0x0000040000000000
72 1.1 cherry #define IA64_PSR_ED 0x0000080000000000
73 1.1 cherry #define IA64_PSR_BN 0x0000100000000000
74 1.1 cherry #define IA64_PSR_IA 0x0000200000000000
75 1.1 cherry
76 1.1 cherry /*
77 1.1 cherry * Definition of ISR bits.
78 1.1 cherry */
79 1.1 cherry #define IA64_ISR_CODE 0x000000000000ffff
80 1.1 cherry #define IA64_ISR_VECTOR 0x0000000000ff0000
81 1.1 cherry #define IA64_ISR_X 0x0000000100000000
82 1.1 cherry #define IA64_ISR_W 0x0000000200000000
83 1.1 cherry #define IA64_ISR_R 0x0000000400000000
84 1.1 cherry #define IA64_ISR_NA 0x0000000800000000
85 1.1 cherry #define IA64_ISR_SP 0x0000001000000000
86 1.1 cherry #define IA64_ISR_RS 0x0000002000000000
87 1.1 cherry #define IA64_ISR_IR 0x0000004000000000
88 1.1 cherry #define IA64_ISR_NI 0x0000008000000000
89 1.1 cherry #define IA64_ISR_SO 0x0000010000000000
90 1.1 cherry #define IA64_ISR_EI 0x0000060000000000
91 1.1 cherry #define IA64_ISR_EI_0 0x0000000000000000
92 1.1 cherry #define IA64_ISR_EI_1 0x0000020000000000
93 1.1 cherry #define IA64_ISR_EI_2 0x0000040000000000
94 1.1 cherry #define IA64_ISR_ED 0x0000080000000000
95 1.1 cherry
96 1.1 cherry /*
97 1.1 cherry * Vector numbers for various ia64 interrupts.
98 1.1 cherry */
99 1.1 cherry #define IA64_VEC_VHPT 0
100 1.1 cherry #define IA64_VEC_ITLB 1
101 1.1 cherry #define IA64_VEC_DTLB 2
102 1.1 cherry #define IA64_VEC_ALT_ITLB 3
103 1.1 cherry #define IA64_VEC_ALT_DTLB 4
104 1.1 cherry #define IA64_VEC_NESTED_DTLB 5
105 1.1 cherry #define IA64_VEC_IKEY_MISS 6
106 1.1 cherry #define IA64_VEC_DKEY_MISS 7
107 1.1 cherry #define IA64_VEC_DIRTY_BIT 8
108 1.1 cherry #define IA64_VEC_INST_ACCESS 9
109 1.1 cherry #define IA64_VEC_DATA_ACCESS 10
110 1.1 cherry #define IA64_VEC_BREAK 11
111 1.1 cherry #define IA64_VEC_EXT_INTR 12
112 1.1 cherry #define IA64_VEC_PAGE_NOT_PRESENT 20
113 1.1 cherry #define IA64_VEC_KEY_PERMISSION 21
114 1.1 cherry #define IA64_VEC_INST_ACCESS_RIGHTS 22
115 1.1 cherry #define IA64_VEC_DATA_ACCESS_RIGHTS 23
116 1.1 cherry #define IA64_VEC_GENERAL_EXCEPTION 24
117 1.1 cherry #define IA64_VEC_DISABLED_FP 25
118 1.1 cherry #define IA64_VEC_NAT_CONSUMPTION 26
119 1.1 cherry #define IA64_VEC_SPECULATION 27
120 1.1 cherry #define IA64_VEC_DEBUG 29
121 1.1 cherry #define IA64_VEC_UNALIGNED_REFERENCE 30
122 1.1 cherry #define IA64_VEC_UNSUPP_DATA_REFERENCE 31
123 1.1 cherry #define IA64_VEC_FLOATING_POINT_FAULT 32
124 1.1 cherry #define IA64_VEC_FLOATING_POINT_TRAP 33
125 1.1 cherry #define IA64_VEC_LOWER_PRIVILEGE_TRANSFER 34
126 1.1 cherry #define IA64_VEC_TAKEN_BRANCH_TRAP 35
127 1.1 cherry #define IA64_VEC_SINGLE_STEP_TRAP 36
128 1.1 cherry #define IA64_VEC_IA32_EXCEPTION 45
129 1.1 cherry #define IA64_VEC_IA32_INTERCEPT 46
130 1.1 cherry #define IA64_VEC_IA32_INTERRUPT 47
131 1.1 cherry
132 1.1 cherry /*
133 1.1 cherry * IA-32 exceptions.
134 1.1 cherry */
135 1.1 cherry #define IA32_EXCEPTION_DIVIDE 0
136 1.1 cherry #define IA32_EXCEPTION_DEBUG 1
137 1.1 cherry #define IA32_EXCEPTION_BREAK 3
138 1.1 cherry #define IA32_EXCEPTION_OVERFLOW 4
139 1.1 cherry #define IA32_EXCEPTION_BOUND 5
140 1.1 cherry #define IA32_EXCEPTION_DNA 7
141 1.1 cherry #define IA32_EXCEPTION_NOT_PRESENT 11
142 1.1 cherry #define IA32_EXCEPTION_STACK_FAULT 12
143 1.1 cherry #define IA32_EXCEPTION_GPFAULT 13
144 1.1 cherry #define IA32_EXCEPTION_FPERROR 16
145 1.1 cherry #define IA32_EXCEPTION_ALIGNMENT_CHECK 17
146 1.1 cherry #define IA32_EXCEPTION_STREAMING_SIMD 19
147 1.1 cherry
148 1.1 cherry #define IA32_INTERCEPT_INSTRUCTION 0
149 1.1 cherry #define IA32_INTERCEPT_GATE 1
150 1.1 cherry #define IA32_INTERCEPT_SYSTEM_FLAG 2
151 1.1 cherry #define IA32_INTERCEPT_LOCK 4
152 1.1 cherry
153 1.1 cherry #ifndef _LOCORE
154 1.1 cherry
155 1.1 cherry /*
156 1.1 cherry * Various special ia64 instructions.
157 1.1 cherry */
158 1.1 cherry
159 1.1 cherry /*
160 1.1 cherry * Memory Fence.
161 1.1 cherry */
162 1.1 cherry static __inline void
163 1.1 cherry ia64_mf(void)
164 1.1 cherry {
165 1.1 cherry __asm __volatile("mf");
166 1.1 cherry }
167 1.1 cherry
168 1.1 cherry static __inline void
169 1.1 cherry ia64_mf_a(void)
170 1.1 cherry {
171 1.1 cherry __asm __volatile("mf.a");
172 1.1 cherry }
173 1.1 cherry
174 1.1 cherry /*
175 1.1 cherry * Flush Cache.
176 1.1 cherry */
177 1.1 cherry static __inline void
178 1.1 cherry ia64_fc(u_int64_t va)
179 1.1 cherry {
180 1.1 cherry __asm __volatile("fc %0" :: "r"(va));
181 1.1 cherry }
182 1.1 cherry
183 1.1 cherry /*
184 1.1 cherry * Flush Instruction Cache
185 1.1 cherry */
186 1.1 cherry
187 1.1 cherry static __inline void
188 1.1 cherry ia64_fc_i(u_int64_t va)
189 1.1 cherry {
190 1.1 cherry __asm __volatile("fc.i %0" :: "r"(va));
191 1.1 cherry }
192 1.1 cherry
193 1.1 cherry /*
194 1.1 cherry * Sync instruction stream.
195 1.1 cherry */
196 1.1 cherry static __inline void
197 1.1 cherry ia64_sync_i(void)
198 1.1 cherry {
199 1.1 cherry __asm __volatile("sync.i");
200 1.1 cherry }
201 1.1 cherry
202 1.1 cherry /*
203 1.1 cherry * Calculate address in VHPT for va.
204 1.1 cherry */
205 1.1 cherry static __inline u_int64_t
206 1.1 cherry ia64_thash(u_int64_t va)
207 1.1 cherry {
208 1.1 cherry u_int64_t result;
209 1.1 cherry __asm __volatile("thash %0=%1" : "=r" (result) : "r" (va));
210 1.1 cherry return result;
211 1.1 cherry }
212 1.1 cherry
213 1.1 cherry /*
214 1.1 cherry * Calculate VHPT tag for va.
215 1.1 cherry */
216 1.1 cherry static __inline u_int64_t
217 1.1 cherry ia64_ttag(u_int64_t va)
218 1.1 cherry {
219 1.1 cherry u_int64_t result;
220 1.1 cherry __asm __volatile("ttag %0=%1" : "=r" (result) : "r" (va));
221 1.1 cherry return result;
222 1.1 cherry }
223 1.1 cherry
224 1.1 cherry /*
225 1.1 cherry * Convert virtual address to physical.
226 1.1 cherry */
227 1.1 cherry static __inline u_int64_t
228 1.1 cherry ia64_tpa(u_int64_t va)
229 1.1 cherry {
230 1.1 cherry u_int64_t result;
231 1.1 cherry __asm __volatile("tpa %0=%1" : "=r" (result) : "r" (va));
232 1.1 cherry return result;
233 1.1 cherry }
234 1.1 cherry
235 1.1 cherry /*
236 1.1 cherry * Generate a ptc.e instruction.
237 1.1 cherry */
238 1.1 cherry static __inline void
239 1.1 cherry ia64_ptc_e(u_int64_t v)
240 1.1 cherry {
241 1.1 cherry __asm __volatile("ptc.e %0;; srlz.d;;" :: "r"(v));
242 1.1 cherry }
243 1.1 cherry
244 1.1 cherry /*
245 1.1 cherry * Generate a ptc.g instruction.
246 1.1 cherry */
247 1.1 cherry static __inline void
248 1.1 cherry ia64_ptc_g(u_int64_t va, u_int64_t log2size)
249 1.1 cherry {
250 1.1 cherry __asm __volatile("ptc.g %0,%1;; srlz.d;;" :: "r"(va), "r"(log2size));
251 1.1 cherry }
252 1.1 cherry
253 1.1 cherry /*
254 1.1 cherry * Generate a ptc.ga instruction.
255 1.1 cherry */
256 1.1 cherry static __inline void
257 1.1 cherry ia64_ptc_ga(u_int64_t va, u_int64_t log2size)
258 1.1 cherry {
259 1.1 cherry __asm __volatile("ptc.ga %0,%1;; srlz.d;;" :: "r"(va), "r"(log2size));
260 1.1 cherry }
261 1.1 cherry
262 1.1 cherry /*
263 1.1 cherry * Generate a ptc.l instruction.
264 1.1 cherry */
265 1.1 cherry static __inline void
266 1.1 cherry ia64_ptc_l(u_int64_t va, u_int64_t log2size)
267 1.1 cherry {
268 1.1 cherry __asm __volatile("ptc.l %0,%1;; srlz.d;;" :: "r"(va), "r"(log2size));
269 1.1 cherry }
270 1.1 cherry
271 1.1 cherry /*
272 1.1 cherry * Read the value of psr.
273 1.1 cherry */
274 1.1 cherry static __inline u_int64_t
275 1.1 cherry ia64_get_psr(void)
276 1.1 cherry {
277 1.1 cherry u_int64_t result;
278 1.1 cherry __asm __volatile("mov %0=psr;;" : "=r" (result));
279 1.1 cherry return result;
280 1.1 cherry }
281 1.1 cherry
282 1.1 cherry /*
283 1.1 cherry * Define accessors for application registers.
284 1.1 cherry */
285 1.1 cherry
286 1.1 cherry #define IA64_AR(name) \
287 1.1 cherry \
288 1.1 cherry static __inline u_int64_t \
289 1.1 cherry ia64_get_##name(void) \
290 1.1 cherry { \
291 1.1 cherry u_int64_t result; \
292 1.1 cherry __asm __volatile("mov %0=ar." #name : "=r" (result)); \
293 1.1 cherry return result; \
294 1.1 cherry } \
295 1.1 cherry \
296 1.1 cherry static __inline void \
297 1.1 cherry ia64_set_##name(u_int64_t v) \
298 1.1 cherry { \
299 1.1 cherry __asm __volatile("mov ar." #name "=%0;;" :: "r" (v)); \
300 1.1 cherry }
301 1.1 cherry
302 1.1 cherry IA64_AR(k0)
303 1.1 cherry IA64_AR(k1)
304 1.1 cherry IA64_AR(k2)
305 1.1 cherry IA64_AR(k3)
306 1.1 cherry IA64_AR(k4)
307 1.1 cherry IA64_AR(k5)
308 1.1 cherry IA64_AR(k6)
309 1.1 cherry IA64_AR(k7)
310 1.1 cherry
311 1.1 cherry IA64_AR(rsc)
312 1.1 cherry IA64_AR(bsp)
313 1.1 cherry IA64_AR(bspstore)
314 1.1 cherry IA64_AR(rnat)
315 1.1 cherry
316 1.1 cherry IA64_AR(fcr)
317 1.1 cherry
318 1.1 cherry IA64_AR(eflag)
319 1.1 cherry IA64_AR(csd)
320 1.1 cherry IA64_AR(ssd)
321 1.1 cherry IA64_AR(cflg)
322 1.1 cherry IA64_AR(fsr)
323 1.1 cherry IA64_AR(fir)
324 1.1 cherry IA64_AR(fdr)
325 1.1 cherry
326 1.1 cherry IA64_AR(ccv)
327 1.1 cherry
328 1.1 cherry IA64_AR(unat)
329 1.1 cherry
330 1.1 cherry IA64_AR(fpsr)
331 1.1 cherry
332 1.1 cherry IA64_AR(itc)
333 1.1 cherry
334 1.1 cherry IA64_AR(pfs)
335 1.1 cherry IA64_AR(lc)
336 1.1 cherry IA64_AR(ec)
337 1.1 cherry
338 1.1 cherry /*
339 1.1 cherry * Define accessors for control registers.
340 1.1 cherry */
341 1.1 cherry
342 1.1 cherry #define IA64_CR(name) \
343 1.1 cherry \
344 1.1 cherry static __inline u_int64_t \
345 1.1 cherry ia64_get_##name(void) \
346 1.1 cherry { \
347 1.1 cherry u_int64_t result; \
348 1.1 cherry __asm __volatile("mov %0=cr." #name : "=r" (result)); \
349 1.1 cherry return result; \
350 1.1 cherry } \
351 1.1 cherry \
352 1.1 cherry static __inline void \
353 1.1 cherry ia64_set_##name(u_int64_t v) \
354 1.1 cherry { \
355 1.1 cherry __asm __volatile("mov cr." #name "=%0;;" :: "r" (v)); \
356 1.1 cherry }
357 1.1 cherry
358 1.1 cherry IA64_CR(dcr)
359 1.1 cherry IA64_CR(itm)
360 1.1 cherry IA64_CR(iva)
361 1.1 cherry
362 1.1 cherry IA64_CR(pta)
363 1.1 cherry
364 1.1 cherry IA64_CR(ipsr)
365 1.1 cherry IA64_CR(isr)
366 1.1 cherry
367 1.1 cherry IA64_CR(iip)
368 1.1 cherry IA64_CR(ifa)
369 1.1 cherry IA64_CR(itir)
370 1.1 cherry IA64_CR(iipa)
371 1.1 cherry IA64_CR(ifs)
372 1.1 cherry IA64_CR(iim)
373 1.1 cherry IA64_CR(iha)
374 1.1 cherry
375 1.1 cherry IA64_CR(lid)
376 1.1 cherry IA64_CR(ivr)
377 1.1 cherry IA64_CR(tpr)
378 1.1 cherry IA64_CR(eoi)
379 1.1 cherry IA64_CR(irr0)
380 1.1 cherry IA64_CR(irr1)
381 1.1 cherry IA64_CR(irr2)
382 1.1 cherry IA64_CR(irr3)
383 1.1 cherry IA64_CR(itv)
384 1.1 cherry IA64_CR(pmv)
385 1.1 cherry IA64_CR(cmcv)
386 1.1 cherry
387 1.1 cherry IA64_CR(lrr0)
388 1.1 cherry IA64_CR(lrr1)
389 1.1 cherry
390 1.1 cherry /*
391 1.1 cherry * Write a region register.
392 1.1 cherry */
393 1.1 cherry static __inline void
394 1.1 cherry ia64_set_rr(u_int64_t rrbase, u_int64_t v)
395 1.1 cherry {
396 1.1 cherry __asm __volatile("mov rr[%0]=%1;; srlz.d;;"
397 1.1 cherry :: "r"(rrbase), "r"(v) : "memory");
398 1.1 cherry }
399 1.1 cherry
400 1.1 cherry /*
401 1.1 cherry * Read a CPUID register.
402 1.1 cherry */
403 1.1 cherry static __inline u_int64_t
404 1.1 cherry ia64_get_cpuid(int i)
405 1.1 cherry {
406 1.1 cherry u_int64_t result;
407 1.1 cherry __asm __volatile("mov %0=cpuid[%1]"
408 1.1 cherry : "=r" (result) : "r"(i));
409 1.1 cherry return result;
410 1.1 cherry }
411 1.1 cherry
412 1.1 cherry static __inline void
413 1.1 cherry ia64_disable_highfp(void)
414 1.1 cherry {
415 1.1 cherry __asm __volatile("ssm psr.dfh;; srlz.d");
416 1.1 cherry }
417 1.1 cherry
418 1.1 cherry static __inline void
419 1.1 cherry ia64_enable_highfp(void)
420 1.1 cherry {
421 1.1 cherry __asm __volatile("rsm psr.dfh;; srlz.d");
422 1.1 cherry }
423 1.1 cherry
424 1.1 cherry #endif /* !_LOCORE */
425 1.1 cherry
426 1.1 cherry #endif /* _MACHINE_IA64_CPU_H_ */
427 1.1 cherry
428