]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/ppc/basic_regs.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
32 * File: architecture/ppc/basic_regs.h
33 * Author: Doug Mitchell, NeXT Software, Inc.
35 * Basic ppc registers.
38 * 22-May-97 Umesh Vaishampayan (umeshv@apple.com)
39 Updated to match MPCFPE32B/AD 1/97 REV. 1
40 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
42 * 05-Nov-92 Doug Mitchell at NeXT
46 #ifndef _ARCH_PPC_BASIC_REGS_H_
47 #define _ARCH_PPC_BASIC_REGS_H_
49 #include <architecture/ppc/reg_help.h>
50 #include <architecture/ppc/macro_help.h>
52 #if !defined(__ASSEMBLER__)
55 * Number of General Purpose registers.
57 #define PPC_NGP_REGS 32
60 * Common half-word used in Machine State Register and in
61 * various exception frames. Defined as a macro because the compiler
62 * will align a struct to a word boundary when used inside another struct.
65 unsigned ee:BIT_WIDTH(15), /* external intr enable */ \
66 pr:BIT_WIDTH(14), /* problem state */ \
67 fp:BIT_WIDTH(13), /* floating point avail */ \
68 me:BIT_WIDTH(12), /* machine check enable */ \
69 fe0:BIT_WIDTH(11), /* fp exception mode 0 */ \
70 se:BIT_WIDTH(10), /* single step enable */ \
71 be:BIT_WIDTH(9), /* branch trace enable */ \
72 fe1:BIT_WIDTH(8), /* fp exception mode 0 */ \
73 rsvd1:BIT_WIDTH(7), /* reserved */ \
74 ip:BIT_WIDTH(6), /* interrupt prefix */ \
75 ir:BIT_WIDTH(5), /* instruction relocate */ \
76 dr:BIT_WIDTH(4), /* data relocate */ \
77 rsvd2:BITS_WIDTH(3,2), /* reserved */ \
78 ri:BIT_WIDTH(1), /* recoverable exception */ \
79 le:BIT_WIDTH(0) /* Little-endian mode */
82 * Machine state register.
83 * Read and written via get_msr() and set_msr() inlines, below.
86 unsigned rsvd3
:BITS_WIDTH(31,19), // reserved
87 pow
:BIT_WIDTH(18), // Power management enable
88 rsvd0
: BIT_WIDTH(17), // reserved
89 ile
: BIT_WIDTH(16); // exception little endian
91 MSR_BITS
; // see above
95 * Data Storage Interrupt Status Register (DSISR)
98 unsigned dse
:BIT_WIDTH(31); // direct-store error
99 unsigned tnf
:BIT_WIDTH(30); // translation not found
100 unsigned :BITS_WIDTH(29,28);
101 unsigned pe
:BIT_WIDTH(27); // protection error
102 unsigned dsr
:BIT_WIDTH(26); // lwarx/stwcx to direct-store
103 unsigned rw
:BIT_WIDTH(25); // 1 => store, 0 => load
104 unsigned :BITS_WIDTH(24,23);
105 unsigned dab
:BIT_WIDTH(22); // data address bkpt (601)
106 unsigned ssf
:BIT_WIDTH(21); // seg table search failed
107 unsigned :BITS_WIDTH(20,0);
111 * Instruction Storage Interrupt Status Register (really SRR1)
114 unsigned :BIT_WIDTH(31);
115 unsigned tnf
:BIT_WIDTH(30); // translation not found
116 unsigned :BIT_WIDTH(29);
117 unsigned dse
:BIT_WIDTH(28); // direct-store fetch error
118 unsigned pe
:BIT_WIDTH(27); // protection error
119 unsigned :BITS_WIDTH(26,22);
120 unsigned ssf
:BIT_WIDTH(21); // seg table search failed
121 unsigned :BITS_WIDTH(20,16);
126 * Alignment Interrupt Status Register (really DSISR)
127 * NOTE: bit numbers in field *names* are in IBM'ese (0 is MSB).
128 * FIXME: Yuck!!! Double Yuck!!!
131 unsigned :BITS_WIDTH(31,20);
132 unsigned ds3031
:BITS_WIDTH(19,18);// bits 30:31 if DS form
133 unsigned :BIT_WIDTH(17);
134 unsigned x2930
:BITS_WIDTH(16,15); // bits 29:30 if X form
135 unsigned x25
:BIT_WIDTH(14); // bit 25 if X form or
136 // bit 5 if D or DS form
137 unsigned x2124
:BITS_WIDTH(13,10); // bits 21:24 if X form or
138 // bits 1:4 if D or DS form
139 unsigned all615
:BITS_WIDTH(9,0); // bits 6:15 of instr
144 * Program Interrupt Status Register (really SRR1)
147 unsigned :BITS_WIDTH(31,21);
148 unsigned fpee
:BIT_WIDTH(20); // floating pt enable exception
149 unsigned ill
:BIT_WIDTH(19); // illegal instruction
150 unsigned priv
:BIT_WIDTH(18); // privileged instruction
151 unsigned trap
:BIT_WIDTH(17); // trap program interrupt
152 unsigned subseq
:BIT_WIDTH(16); // 1 => SRR0 points to
153 // subsequent instruction
158 * Condition register. May not be useful in C, let's see...
161 unsigned lt
:BIT_WIDTH(31), // negative
162 gt
:BIT_WIDTH(30), // positive
163 eq
:BIT_WIDTH(29), // equal to zero
164 so
:BIT_WIDTH(28), // summary overflow
165 fx
:BIT_WIDTH(27), // floating point exception
166 fex
:BIT_WIDTH(26), // fp enabled exception
167 vx
:BIT_WIDTH(25), // fp invalid operation
169 ox
:BIT_WIDTH(24), // fp overflow exception
170 rsvd
:BITS_WIDTH(23,0); // reserved
174 * Abstract values representing fe0:fe1.
175 * See get_fp_exc_mode(), below.
178 FEM_IGNORE_EXCEP
, // ignore exceptions
179 FEM_IMPR_NONREC
, // imprecise nonrecoverable
180 FEM_IMPR_RECOV
, // imprecise recoverable
186 * Special purpose registers.
190 * Processor version register (special purpose register pvr).
193 unsigned version
:BITS_WIDTH(31,16),
194 revision
:BITS_WIDTH(15,0);
198 * Fixed point exception register (special purpose register xer)
201 unsigned so
:BIT_WIDTH(31), // summary overflow
202 ov
:BIT_WIDTH(30), // overflow
203 ca
:BIT_WIDTH(29), // carry
204 rsvd1
:BITS_WIDTH(28,7), // reserved
205 byte_count
:BITS_WIDTH(6,0);
209 * Inlines and macros to manipulate the above registers.
213 * Get/set machine state register.
215 static __inline__ msr_t
219 __asm__
volatile ("mfmsr %0 /* mfmsr */" : "=r" (__msr_tmp
));
223 static __inline__
void
226 __asm__
volatile ("mtmsr %0 /* mtmsr */ " : : "r" (msr
));
230 * Determine current fp_exc_mode_t given prog_mode.
232 static __inline__ fp_exc_mode_t
233 get_fp_exc_mode(pmr_t pmr
)
236 return pmr
.fe1
? FEM_PRECISE
: FEM_IMPR_RECOV
;
238 return pmr
.fe1
? FEM_IMPR_NONREC
: FEM_IGNORE_EXCEP
;
242 * Software definitions for special purpose registers.
243 * The same register is used as per_cpu data pointer and
244 * vector base register. This requires that the vector
245 * table be the first item in the per_cpu table.
247 #define SR_EXCEPTION_TMP_LR sprg0
248 #define SR_EXCEPTION_TMP_CR sprg1
249 #define SR_EXCEPTION_TMP_AT sprg2
250 #define SR_PER_CPU_DATA sprg3
254 * Get/set special purpose registers.
256 * GET_SPR - get SPR by name.
263 * some_xer = GET_SPR(xer_t, xer);
267 * This is a strange one. We're creating a list of C expressions within
268 * a set of curlies; the last expression ("__spr_tmp;") is the return value
269 * of the statement created by the curlies.
273 #define GET_SPR(type, spr) \
275 unsigned __spr_tmp; \
276 __asm__ volatile ("mfspr %0, " STRINGIFY(spr) : "=r" (__spr_tmp)); \
277 *(type *)&__spr_tmp; \
281 * Example usage of SET_SPR:
286 * ...set up some_xer...
287 * SET_SPR(xer, some_xer);
290 #define SET_SPR(spr, val) \
292 __typeof__ (val) __spr_tmp = (val); \
293 __asm__ volatile ("mtspr "STRINGIFY(spr) ", %0" : : "r" (__spr_tmp)); \
297 * Fully synchronize instruction stream.
299 static __inline__
void
302 __asm__
volatile ("sync /* sync */" : : );
305 #endif /* ! __ASSEMBLER__ */
307 #endif /* _ARCH_PPC_BASIC_REGS_H_ */