2 * Memory and machine-specific definitions. Used in C and assembler.
15 #define BI2BY 8 /* bits per byte */
16 #define BI2WD 32 /* bits per word */
17 #define BY2WD 4 /* bytes per word */
18 #define BY2V 8 /* bytes per vlong */
19 #define BY2PG 4096 /* bytes per page */
20 #define WD2PG (BY2PG/BY2WD) /* words per page */
21 #define PGSHIFT 12 /* log(BY2PG) */
22 #define ROUND(s, sz) (((s)+(sz-1))&~(sz-1))
23 #define PGROUND(s) ROUND(s, BY2PG)
24 #define CACHELINELOG 5
25 #define CACHELINESZ (1<<CACHELINELOG)
26 #define BLOCKALIGN CACHELINESZ
30 #define BY2PTE 8 /* bytes per pte entry */
31 #define BY2PTEG 64 /* bytes per pte group */
33 #define MAXMACH 1 /* max # cpus system can run */
34 #define MACHSIZE BY2PG
35 #define KSTACK 4096 /* Size of kernel stack */
40 #define HZ 1000 /* clock frequency */
41 #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
44 * Standard PPC Special Purpose Registers (OEA and VEA)
47 #define DAR 19 /* Data Address Register */
48 #define DEC 22 /* Decrementer */
50 #define SRR0 26 /* Saved Registers (exception) */
53 #define TBRU 269 /* Time base Upper/Lower (Reading) */
54 #define SPRG0 272 /* Supervisor Private Registers */
62 #define ASR 280 /* Address Space Register */
63 #define EAR 282 /* External Access Register (optional) */
64 #define TBWU 284 /* Time base Upper/Lower (Writing) */
66 #define PVR 287 /* Processor Version */
67 #define IABR 1010 /* Instruction Address Breakpoint Register (optional) */
68 #define DABR 1013 /* Data Address Breakpoint Register (optional) */
69 #define FPECR 1022 /* Floating-Point Exception Cause Register (optional) */
70 #define PIR 1023 /* Processor Identification Register (optional) */
72 #define IBATU(i) (528+2*(i)) /* Instruction BAT register (upper) */
73 #define IBATL(i) (529+2*(i)) /* Instruction BAT register (lower) */
74 #define DBATU(i) (536+2*(i)) /* Data BAT register (upper) */
75 #define DBATL(i) (537+2*(i)) /* Data BAT register (lower) */
78 * PPC604e-specific Special Purpose Registers (OEA)
80 #define MMCR0 952 /* Monitor Control Register 0 */
81 #define PMC1 953 /* Performance Monitor Counter 1 */
82 #define PMC2 954 /* Performance Monitor Counter 2 */
83 #define SIA 955 /* Sampled Instruction Address */
84 #define MMCR1 956 /* Monitor Control Register 0 */
85 #define PMC3 957 /* Performance Monitor Counter 3 */
86 #define PMC4 958 /* Performance Monitor Counter 4 */
87 #define SDA 959 /* Sampled Data Address */
89 * PPC603e-specific Special Purpose Registers
91 #define DMISS 976 /* Data Miss Address Register */
92 #define DCMP 977 /* Data Miss Address Register */
95 #define IMISS 980 /* Instruction Miss Address Register */
96 #define iCMP 981 /* Instruction Miss Address Register */
98 #define HID0 1008 /* Hardware Implementation Dependent Register 0 */
99 #define HID1 1009 /* Hardware Implementation Dependent Register 1 */
101 * PowerQUICC II (MPC 8260) Special Purpose Registers
103 #define HID2 1011 /* Hardware Implementation Dependent Register 2 */
105 #define BIT(i) (1<<(31-(i))) /* Silly backwards register bit numbering scheme */
106 #define SBIT(n) ((ushort)1<<(15-(n)))
107 #define RBIT(b,n) (1<<(8*sizeof(n)-1-(b)))
110 * Bit encodings for Machine State Register (MSR)
112 #define MSR_POW BIT(13) /* Enable Power Management */
113 #define MSR_TGPR BIT(14) /* Temporary GPR Registers in use (603e) */
114 #define MSR_ILE BIT(15) /* Interrupt Little-Endian enable */
115 #define MSR_EE BIT(16) /* External Interrupt enable */
116 #define MSR_PR BIT(17) /* Supervisor/User privilege */
117 #define MSR_FP BIT(18) /* Floating Point enable */
118 #define MSR_ME BIT(19) /* Machine Check enable */
119 #define MSR_FE0 BIT(20) /* Floating Exception mode 0 */
120 #define MSR_SE BIT(21) /* Single Step (optional) */
121 #define MSR_BE BIT(22) /* Branch Trace (optional) */
122 #define MSR_FE1 BIT(23) /* Floating Exception mode 1 */
123 #define MSR_IP BIT(25) /* Exception prefix 0x000/0xFFF */
124 #define MSR_IR BIT(26) /* Instruction MMU enable */
125 #define MSR_DR BIT(27) /* Data MMU enable */
126 #define MSR_PM BIT(29) /* Performance Monitor marked mode (604e specific) */
127 #define MSR_RI BIT(30) /* Recoverable Exception */
128 #define MSR_LE BIT(31) /* Little-Endian enable */
129 /* SRR1 bits for TLB operations */
130 #define MSR_SR0 0xf0000000 /* Saved bits from CR register */
131 #define MSR_KEY BIT(12) /* Copy of Ks or Kp bit */
132 #define MSR_IMISS BIT(13) /* It was an I miss */
133 #define MSR_WAY BIT(14) /* TLB set to be replaced */
134 #define MSR_STORE BIT(15) /* Miss caused by a store */
137 * Exception codes (trap vectors)
148 #define CSYSCALL 0x0C
149 #define CTRACE 0x0D /* optional */
150 #define CFPA 0x0E /* not implemented in 603e */
152 /* PPC603e-specific: */
153 #define CIMISS 0x10 /* Instruction TLB miss */
154 #define CLMISS 0x11 /* Data load TLB miss */
155 #define CSMISS 0x12 /* Data store TLB miss */
163 #define MACH 30 /* R30 is m-> */
164 #define USER 29 /* R29 is up-> */
170 #define PTEMAPMEM (1024*1024)
171 #define PTEPERTAB (PTEMAPMEM/BY2PG)
172 #define SEGMAPSIZE 1984
173 #define SSEGMAPSIZE 16
174 #define PPN(x) ((x)&~(BY2PG-1))
179 #define PTE0(v, vsid, h, va) (((v)<<31)|((vsid)<<7)|((h)<<6)|(((va)>>22)&0x3f))
182 * Second pte word; WIMG & PP(RW/RO) common to page table and BATs
184 #define PTE1_R BIT(23)
185 #define PTE1_C BIT(24)
187 #define PTE1_W BIT(25)
188 #define PTE1_I BIT(26)
189 #define PTE1_M BIT(27)
190 #define PTE1_G BIT(28)
192 #define PTE1_RW BIT(30)
193 #define PTE1_RO BIT(31)
195 /* HID0 register bits */
196 #define HID_ICE BIT(16)
197 #define HID_DCE BIT(17)
198 #define HID_ILOCK BIT(18)
199 #define HID_DLOCK BIT(19)
200 #define HID_ICFI BIT(20)
201 #define HID_DCFI BIT(21)
202 #define HID_IFEM BIT(24)
208 #define KZERO 0x80000000 /* base of kernel address space */
209 #define KTZERO 0x80100000 /* first address in kernel text */
210 #define UZERO 0 /* base of user address space */
211 #define UTZERO (UZERO+BY2PG) /* first address in user text */
212 #define USTKTOP (TSTKTOP-TSTKSIZ*BY2PG) /* byte just beyond user stack */
213 #define TSTKTOP KZERO /* top of temporary stack */
215 #define USTKSIZE (4*1024*1024) /* size of user stack */
216 #define UREGSIZE ((8+40)*4)
217 #define MACHADDR (KTZERO-MAXMACH*MACHSIZE)
218 #define MACHPADDR (MACHADDR&~KZERO)
219 #define MACHP(n) ((Mach *)(MACHADDR+(n)*MACHSIZE))
221 #define isphys(x) (((ulong)x&KZERO)!=0)
226 #define INTMEM 0xf0000000
227 #define IOMEM (INTMEM+0x10000)
229 #define getpgcolor(a) 0