alpha_cpu.h revision 1.11.2.2 1 1.11.2.2 thorpej /* $NetBSD: alpha_cpu.h,v 1.11.2.2 1997/09/03 23:09:06 thorpej Exp $ */
2 1.11.2.2 thorpej
3 1.11.2.2 thorpej /*
4 1.11.2.2 thorpej * Copyright (c) 1996 Carnegie-Mellon University.
5 1.11.2.2 thorpej * All rights reserved.
6 1.11.2.2 thorpej *
7 1.11.2.2 thorpej * Author: Chris G. Demetriou
8 1.11.2.2 thorpej *
9 1.11.2.2 thorpej * Permission to use, copy, modify and distribute this software and
10 1.11.2.2 thorpej * its documentation is hereby granted, provided that both the copyright
11 1.11.2.2 thorpej * notice and this permission notice appear in all copies of the
12 1.11.2.2 thorpej * software, derivative works or modified versions, and any portions
13 1.11.2.2 thorpej * thereof, and that both notices appear in supporting documentation.
14 1.11.2.2 thorpej *
15 1.11.2.2 thorpej * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.11.2.2 thorpej * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.11.2.2 thorpej * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.11.2.2 thorpej *
19 1.11.2.2 thorpej * Carnegie Mellon requests users of this software to return to
20 1.11.2.2 thorpej *
21 1.11.2.2 thorpej * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.11.2.2 thorpej * School of Computer Science
23 1.11.2.2 thorpej * Carnegie Mellon University
24 1.11.2.2 thorpej * Pittsburgh PA 15213-3890
25 1.11.2.2 thorpej *
26 1.11.2.2 thorpej * any improvements or extensions that they make and grant Carnegie the
27 1.11.2.2 thorpej * rights to redistribute these changes.
28 1.11.2.2 thorpej */
29 1.11.2.2 thorpej
30 1.11.2.2 thorpej #ifndef __ALPHA_ALPHA_CPU_H__
31 1.11.2.2 thorpej #define __ALPHA_ALPHA_CPU_H__
32 1.11.2.2 thorpej
33 1.11.2.2 thorpej /*
34 1.11.2.2 thorpej * Alpha CPU + OSF/1 PALcode definitions for use by the kernel.
35 1.11.2.2 thorpej *
36 1.11.2.2 thorpej * Definitions for:
37 1.11.2.2 thorpej *
38 1.11.2.2 thorpej * Process Control Block
39 1.11.2.2 thorpej * Interrupt/Exception/Syscall Stack Frame
40 1.11.2.2 thorpej * Processor Status Register
41 1.11.2.2 thorpej * Machine Check Error Summary Register
42 1.11.2.2 thorpej * Machine Check Logout Area
43 1.11.2.2 thorpej * Virtual Memory Management
44 1.11.2.2 thorpej * Kernel Entry Vectors
45 1.11.2.2 thorpej * MMCSR Fault Type Codes
46 1.11.2.2 thorpej * Translation Buffer Invalidation
47 1.11.2.2 thorpej *
48 1.11.2.2 thorpej * and miscellaneous PALcode operations.
49 1.11.2.2 thorpej */
50 1.11.2.2 thorpej
51 1.11.2.2 thorpej
52 1.11.2.2 thorpej /*
53 1.11.2.2 thorpej * Process Control Block definitions [OSF/1 PALcode Specific]
54 1.11.2.2 thorpej */
55 1.11.2.2 thorpej
56 1.11.2.2 thorpej struct alpha_pcb {
57 1.11.2.2 thorpej unsigned long apcb_ksp; /* kernel stack ptr */
58 1.11.2.2 thorpej unsigned long apcb_usp; /* user stack ptr */
59 1.11.2.2 thorpej unsigned long apcb_ptbr; /* page table base reg */
60 1.11.2.2 thorpej unsigned int apcb_cpc; /* charged process cycles */
61 1.11.2.2 thorpej unsigned int apcb_asn; /* address space number */
62 1.11.2.2 thorpej unsigned long apcb_unique; /* process unique value */
63 1.11.2.2 thorpej unsigned long apcb_flags; /* flags; see below */
64 1.11.2.2 thorpej unsigned long apcb_decrsv0; /* DEC reserved */
65 1.11.2.2 thorpej unsigned long apcb_decrsv1; /* DEC reserved */
66 1.11.2.2 thorpej };
67 1.11.2.2 thorpej
68 1.11.2.2 thorpej #define ALPHA_PCB_FLAGS_FEN 0x0000000000000001
69 1.11.2.2 thorpej #define ALPHA_PCB_FLAGS_PME 0x4000000000000000
70 1.11.2.2 thorpej
71 1.11.2.2 thorpej /*
72 1.11.2.2 thorpej * Interrupt/Exception/Syscall "Hardware" (really PALcode)
73 1.11.2.2 thorpej * Stack Frame definitions
74 1.11.2.2 thorpej *
75 1.11.2.2 thorpej * These are quadword offsets from the sp on kernel entry, i.e.
76 1.11.2.2 thorpej * to get to the value in question you access (sp + (offset * 8)).
77 1.11.2.2 thorpej *
78 1.11.2.2 thorpej * On syscall entry, A0-A2 aren't written to memory but space
79 1.11.2.2 thorpej * _is_ reserved for them.
80 1.11.2.2 thorpej */
81 1.11.2.2 thorpej
82 1.11.2.2 thorpej #define ALPHA_HWFRAME_PS 0 /* processor status register */
83 1.11.2.2 thorpej #define ALPHA_HWFRAME_PC 1 /* program counter */
84 1.11.2.2 thorpej #define ALPHA_HWFRAME_GP 2 /* global pointer */
85 1.11.2.2 thorpej #define ALPHA_HWFRAME_A0 3 /* a0 */
86 1.11.2.2 thorpej #define ALPHA_HWFRAME_A1 4 /* a1 */
87 1.11.2.2 thorpej #define ALPHA_HWFRAME_A2 5 /* a2 */
88 1.11.2.2 thorpej
89 1.11.2.2 thorpej #define ALPHA_HWFRAME_SIZE 6 /* 6 8-byte words */
90 1.11.2.2 thorpej
91 1.11.2.2 thorpej /*
92 1.11.2.2 thorpej * Processor Status Register [OSF/1 PALcode Specific]
93 1.11.2.2 thorpej *
94 1.11.2.2 thorpej * Includes user/kernel mode bit, interrupt priority levels, etc.
95 1.11.2.2 thorpej */
96 1.11.2.2 thorpej
97 1.11.2.2 thorpej #define ALPHA_PSL_USERMODE 0x0008 /* set -> user mode */
98 1.11.2.2 thorpej #define ALPHA_PSL_IPL_MASK 0x0007 /* interrupt level mask */
99 1.11.2.2 thorpej
100 1.11.2.2 thorpej #define ALPHA_PSL_IPL_0 0x0000 /* all interrupts enabled */
101 1.11.2.2 thorpej #define ALPHA_PSL_IPL_SOFT 0x0001 /* software ints disabled */
102 1.11.2.2 thorpej #define ALPHA_PSL_IPL_IO 0x0004 /* I/O dev ints disabled */
103 1.11.2.2 thorpej #define ALPHA_PSL_IPL_CLOCK 0x0005 /* clock ints disabled */
104 1.11.2.2 thorpej #define ALPHA_PSL_IPL_HIGH 0x0006 /* all but mchecks disabled */
105 1.11.2.2 thorpej
106 1.11.2.2 thorpej #define ALPHA_PSL_MUST_BE_ZERO 0xfffffffffffffff0
107 1.11.2.2 thorpej
108 1.11.2.2 thorpej /* Convenience constants: what must be set/clear in user mode */
109 1.11.2.2 thorpej #define ALPHA_PSL_USERSET ALPHA_PSL_USERMODE
110 1.11.2.2 thorpej #define ALPHA_PSL_USERCLR (ALPHA_PSL_MUST_BE_ZERO | ALPHA_PSL_IPL_MASK)
111 1.11.2.2 thorpej
112 1.11.2.2 thorpej /*
113 1.11.2.2 thorpej * Machine Check Error Summary Register definitions [OSF/1 PALcode Specific]
114 1.11.2.2 thorpej *
115 1.11.2.2 thorpej * The following bits are values as read. On write, _PCE, _SCE, and
116 1.11.2.2 thorpej * _MIP are "write 1 to clear."
117 1.11.2.2 thorpej */
118 1.11.2.2 thorpej
119 1.11.2.2 thorpej #define ALPHA_MCES_IMP \
120 1.11.2.2 thorpej 0xffffffff00000000 /* impl. dependent */
121 1.11.2.2 thorpej #define ALPHA_MCES_RSVD \
122 1.11.2.2 thorpej 0x00000000ffffffe0 /* reserved */
123 1.11.2.2 thorpej #define ALPHA_MCES_DSC \
124 1.11.2.2 thorpej 0x0000000000000010 /* disable system correctable error reporting */
125 1.11.2.2 thorpej #define ALPHA_MCES_DPC \
126 1.11.2.2 thorpej 0x0000000000000008 /* disable processor correctable error reporting */
127 1.11.2.2 thorpej #define ALPHA_MCES_PCE \
128 1.11.2.2 thorpej 0x0000000000000004 /* processor correctable error in progress */
129 1.11.2.2 thorpej #define ALPHA_MCES_SCE \
130 1.11.2.2 thorpej 0x0000000000000002 /* system correctable error in progress */
131 1.11.2.2 thorpej #define ALPHA_MCES_MIP \
132 1.11.2.2 thorpej 0x0000000000000001 /* machine check in progress */
133 1.11.2.2 thorpej
134 1.11.2.2 thorpej /*
135 1.11.2.2 thorpej * Machine Check Error Summary Register definitions [OSF/1 PALcode Specific]
136 1.11.2.2 thorpej */
137 1.11.2.2 thorpej
138 1.11.2.2 thorpej struct alpha_logout_area {
139 1.11.2.2 thorpej unsigned int la_frame_size; /* frame size */
140 1.11.2.2 thorpej unsigned int la_flags; /* flags; see below */
141 1.11.2.2 thorpej unsigned int la_cpu_offset; /* offset to cpu area */
142 1.11.2.2 thorpej unsigned int la_system_offset; /* offset to system area */
143 1.11.2.2 thorpej };
144 1.11.2.2 thorpej
145 1.11.2.2 thorpej #define ALPHA_LOGOUT_FLAGS_RETRY 0x80000000 /* OK to continue */
146 1.11.2.2 thorpej #define ALPHA_LOGOUT_FLAGS_SE 0x40000000 /* second error */
147 1.11.2.2 thorpej #define ALPHA_LOGOUT_FLAGS_SBZ 0x3fffffff /* should be zero */
148 1.11.2.2 thorpej
149 1.11.2.2 thorpej #define ALPHA_LOGOUT_NOT_BUILT \
150 1.11.2.2 thorpej (struct alpha_logout_area *)0xffffffffffffffff)
151 1.11.2.2 thorpej
152 1.11.2.2 thorpej #define ALPHA_LOGOUT_PAL_AREA(lap) \
153 1.11.2.2 thorpej (unsigned long *)((unsigned char *)(lap) + 16)
154 1.11.2.2 thorpej #define ALPHA_LOGOUT_PAL_SIZE(lap) \
155 1.11.2.2 thorpej ((lap)->la_cpu_offset - 16)
156 1.11.2.2 thorpej #define ALPHA_LOGOUT_CPU_AREA(lap) \
157 1.11.2.2 thorpej (unsigned long *)((unsigned char *)(lap) + (lap)->la_cpu_offset)
158 1.11.2.2 thorpej #define ALPHA_LOGOUT_CPU_SIZE(lap) \
159 1.11.2.2 thorpej ((lap)->la_system_offset - (lap)->la_cpu_offset)
160 1.11.2.2 thorpej #define ALPHA_LOGOUT_SYSTEM_AREA(lap) \
161 1.11.2.2 thorpej (unsigned long *)((unsigned char *)(lap) + (lap)->la_system_offset)
162 1.11.2.2 thorpej #define ALPHA_LOGOUT_SYSTEM_SIZE(lap) \
163 1.11.2.2 thorpej ((lap)->la_frame_size - (lap)->la_system_offset)
164 1.11.2.2 thorpej
165 1.11.2.2 thorpej /*
166 1.11.2.2 thorpej * Virtual Memory Management definitions [OSF/1 PALcode Specific]
167 1.11.2.2 thorpej *
168 1.11.2.2 thorpej * Includes user and kernel space addresses and information,
169 1.11.2.2 thorpej * page table entry definitions, etc.
170 1.11.2.2 thorpej *
171 1.11.2.2 thorpej * NOTE THAT THESE DEFINITIONS MAY CHANGE IN FUTURE ALPHA CPUS!
172 1.11.2.2 thorpej */
173 1.11.2.2 thorpej
174 1.11.2.2 thorpej #define ALPHA_PGSHIFT 13
175 1.11.2.2 thorpej #define ALPHA_PGBYTES (1 << ALPHA_PGSHIFT)
176 1.11.2.2 thorpej
177 1.11.2.2 thorpej #define ALPHA_USEG_BASE 0 /* virtual */
178 1.11.2.2 thorpej #define ALPHA_USEG_END 0x000003ffffffffff
179 1.11.2.2 thorpej
180 1.11.2.2 thorpej #define ALPHA_K0SEG_BASE 0xfffffc0000000000 /* direct-mapped */
181 1.11.2.2 thorpej #define ALPHA_K0SEG_END 0xfffffdffffffffff
182 1.11.2.2 thorpej #define ALPHA_K1SEG_BASE 0xfffffe0000000000 /* virtual */
183 1.11.2.2 thorpej #define ALPHA_K1SEG_END 0xffffffffffffffff
184 1.11.2.2 thorpej
185 1.11.2.2 thorpej #define ALPHA_K0SEG_TO_PHYS(x) ((x) & ~ALPHA_K0SEG_BASE)
186 1.11.2.2 thorpej #define ALPHA_PHYS_TO_K0SEG(x) ((x) | ALPHA_K0SEG_BASE)
187 1.11.2.2 thorpej
188 1.11.2.2 thorpej #define ALPHA_PTE_VALID 0x0001
189 1.11.2.2 thorpej
190 1.11.2.2 thorpej #define ALPHA_PTE_FAULT_ON_READ 0x0002
191 1.11.2.2 thorpej #define ALPHA_PTE_FAULT_ON_WRITE 0x0004
192 1.11.2.2 thorpej #define ALPHA_PTE_FAULT_ON_EXECUTE 0x0008
193 1.11.2.2 thorpej
194 1.11.2.2 thorpej #define ALPHA_PTE_ASM 0x0010 /* addr. space match */
195 1.11.2.2 thorpej #define ALPHA_PTE_GRANULARITY 0x0060 /* granularity hint */
196 1.11.2.2 thorpej
197 1.11.2.2 thorpej #define ALPHA_PTE_PROT 0xff00
198 1.11.2.2 thorpej #define ALPHA_PTE_KR 0x0100
199 1.11.2.2 thorpej #define ALPHA_PTE_UR 0x0200
200 1.11.2.2 thorpej #define ALPHA_PTE_KW 0x1000
201 1.11.2.2 thorpej #define ALPHA_PTE_UW 0x2000
202 1.11.2.2 thorpej
203 1.11.2.2 thorpej #define ALPHA_PTE_WRITE (ALPHA_PTE_KW | ALPHA_PTE_UW)
204 1.11.2.2 thorpej
205 1.11.2.2 thorpej #define ALPHA_PTE_SOFTWARE 0xffff0000
206 1.11.2.2 thorpej
207 1.11.2.2 thorpej #define ALPHA_PTE_PFN 0xffffffff00000000
208 1.11.2.2 thorpej
209 1.11.2.2 thorpej #define ALPHA_PTE_TO_PFN(pte) ((pte) >> 32)
210 1.11.2.2 thorpej #define ALPHA_PTE_FROM_PFN(pfn) ((pfn) << 32)
211 1.11.2.2 thorpej
212 1.11.2.2 thorpej typedef unsigned long alpha_pt_entry_t;
213 1.11.2.2 thorpej
214 1.11.2.2 thorpej /*
215 1.11.2.2 thorpej * Kernel Entry Vectors. [OSF/1 PALcode Specific]
216 1.11.2.2 thorpej */
217 1.11.2.2 thorpej
218 1.11.2.2 thorpej #define ALPHA_KENTRY_INT 0
219 1.11.2.2 thorpej #define ALPHA_KENTRY_ARITH 1
220 1.11.2.2 thorpej #define ALPHA_KENTRY_MM 2
221 1.11.2.2 thorpej #define ALPHA_KENTRY_IF 3
222 1.11.2.2 thorpej #define ALPHA_KENTRY_UNA 4
223 1.11.2.2 thorpej #define ALPHA_KENTRY_SYS 5
224 1.11.2.2 thorpej
225 1.11.2.2 thorpej /*
226 1.11.2.2 thorpej * MMCSR Fault Type Codes. [OSF/1 PALcode Specific]
227 1.11.2.2 thorpej */
228 1.11.2.2 thorpej
229 1.11.2.2 thorpej #define ALPHA_MMCSR_INVALTRANS 0
230 1.11.2.2 thorpej #define ALPHA_MMCSR_ACCESS 1
231 1.11.2.2 thorpej #define ALPHA_MMCSR_FOR 2
232 1.11.2.2 thorpej #define ALPHA_MMCSR_FOE 3
233 1.11.2.2 thorpej #define ALPHA_MMCSR_FOW 4
234 1.11.2.2 thorpej
235 1.11.2.2 thorpej /*
236 1.11.2.2 thorpej * Instruction Fault Type Codes. [OSF/1 PALcode Specific]
237 1.11.2.2 thorpej */
238 1.11.2.2 thorpej
239 1.11.2.2 thorpej #define ALPHA_IF_CODE_BPT 0
240 1.11.2.2 thorpej #define ALPHA_IF_CODE_BUGCHK 1
241 1.11.2.2 thorpej #define ALPHA_IF_CODE_GENTRAP 2
242 1.11.2.2 thorpej #define ALPHA_IF_CODE_FEN 3
243 1.11.2.2 thorpej #define ALPHA_IF_CODE_OPDEC 4
244 1.11.2.2 thorpej
245 1.11.2.2 thorpej /*
246 1.11.2.2 thorpej * Translation Buffer Invalidation definitions [OSF/1 PALcode Specific]
247 1.11.2.2 thorpej */
248 1.11.2.2 thorpej
249 1.11.2.2 thorpej #define ALPHA_TBIA() alpha_pal_tbi(-2, 0) /* all TB entries */
250 1.11.2.2 thorpej #define ALPHA_TBIAP() alpha_pal_tbi(-1, 0) /* all per-process */
251 1.11.2.2 thorpej #define ALPHA_TBISI(va) alpha_pal_tbi(1, (va)) /* ITB entry for va */
252 1.11.2.2 thorpej #define ALPHA_TBISD(va) alpha_pal_tbi(2, (va)) /* DTB entry for va */
253 1.11.2.2 thorpej #define ALPHA_TBIS(va) alpha_pal_tbi(3, (va)) /* all for va */
254 1.11.2.2 thorpej
255 1.11.2.2 thorpej /*
256 1.11.2.2 thorpej * Stubs for Alpha instructions normally inaccessible from C.
257 1.11.2.2 thorpej */
258 1.11.2.2 thorpej unsigned long alpha_rpcc __P((void));
259 1.11.2.2 thorpej void alpha_mb __P((void));
260 1.11.2.2 thorpej void alpha_wmb __P((void));
261 1.11.2.2 thorpej
262 1.11.2.2 thorpej /*
263 1.11.2.2 thorpej * Stubs for OSF/1 PALcode operations.
264 1.11.2.2 thorpej */
265 1.11.2.2 thorpej void alpha_pal_imb __P((void));
266 1.11.2.2 thorpej void alpha_pal_cflush __P((unsigned long));
267 1.11.2.2 thorpej void alpha_pal_draina __P((void));
268 1.11.2.2 thorpej void alpha_pal_halt __P((void)) __attribute__((__noreturn__));
269 1.11.2.2 thorpej unsigned long alpha_pal_rdmces __P((void));
270 1.11.2.2 thorpej unsigned long alpha_pal_rdps __P((void));
271 1.11.2.2 thorpej unsigned long alpha_pal_rdusp __P((void));
272 1.11.2.2 thorpej unsigned long alpha_pal_rdval __P((void));
273 1.11.2.2 thorpej unsigned long alpha_pal_swpipl __P((unsigned long));
274 1.11.2.2 thorpej unsigned long _alpha_pal_swpipl __P((unsigned long)); /* for profiling */
275 1.11.2.2 thorpej void alpha_pal_tbi __P((unsigned long, vm_offset_t));
276 1.11.2.2 thorpej unsigned long alpha_pal_whami __P((void));
277 1.11.2.2 thorpej void alpha_pal_wrent __P((void *, unsigned long));
278 1.11.2.2 thorpej void alpha_pal_wrfen __P((unsigned long));
279 1.11.2.2 thorpej void alpha_pal_wripir __P((unsigned long));
280 1.11.2.2 thorpej void alpha_pal_wrusp __P((unsigned long));
281 1.11.2.2 thorpej void alpha_pal_wrvptptr __P((unsigned long));
282 1.11.2.2 thorpej void alpha_pal_wrmces __P((unsigned long));
283 1.11.2.2 thorpej void alpha_pal_wrval __P((unsigned long));
284 1.11.2.2 thorpej
285 1.11.2.2 thorpej #endif /* __ALPHA_ALPHA_CPU_H__ */
286