source: rtems/cpukit/score/cpu/mips/idtcpu.h @ f198c63

4.104.114.84.95
Last change on this file since f198c63 was f198c63, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/96 at 18:11:41

new file for MIPS port by Craig Lebakken (lebakken@…) and
Derrick Ostertag (ostertag@…).

  • Property mode set to 100644
File size: 14.3 KB
Line 
1/*
2
3Based upon IDT provided code with the following release:
4
5This source code has been made available to you by IDT on an AS-IS
6basis. Anyone receiving this source is licensed under IDT copyrights
7to use it in any way he or she deems fit, including copying it,
8modifying it, compiling it, and redistributing it either with or
9without modifications.  No license under IDT patents or patent
10applications is to be implied by the copyright license.
11
12Any user of this software should understand that IDT cannot provide
13technical support for this software and will not be responsible for
14any consequences resulting from the use of this software.
15
16Any person who transfers this source code or any derivative work must
17include the IDT copyright notice, this paragraph, and the preceeding
18two paragraphs in the transferred software.
19
20COPYRIGHT IDT CORPORATION 1996
21LICENSED MATERIAL - PROGRAM PROPERTY OF IDT
22
23*/
24
25/*
26** idtcpu.h -- cpu related defines
27*/
28
29#ifndef _IDTCPU_H__
30#define _IDTCPU_H__
31
32/*
33 * 950313: Ketan added Register definition for XContext reg.
34 *               added define for WAIT instruction.
35 * 950421: Ketan added Register definition for Config reg (R3081)
36 */
37
38/*
39** memory configuration and mapping
40*/
41#define K0BASE  0x80000000
42#define K0SIZE  0x20000000
43#define K1BASE  0xa0000000
44#define K1SIZE  0x20000000
45#define K2BASE  0xc0000000
46#define K2SIZE  0x20000000
47#if defined(CPU_R4000)
48#define KSBASE  0xe0000000
49#define KSSIZE  0x20000000
50#endif
51
52#define KUBASE  0
53#define KUSIZE  0x80000000
54
55/*
56** Exception Vectors
57*/
58#if defined(CPU_R3000)
59#define UT_VEC  K0BASE                  /* utlbmiss vector */
60#define E_VEC   (K0BASE+0x80)           /* exception vevtor */
61#endif
62#if defined(CPU_R4000)
63#define T_VEC   (K0BASE+0x000)          /* tlbmiss vector */
64#define X_VEC   (K0BASE+0x080)          /* xtlbmiss vector */
65#define C_VEC   (K0BASE+0x100)          /* cache error vector */
66#define E_VEC   (K0BASE+0x180)          /* exception vector */
67#endif
68#define R_VEC   (K1BASE+0x1fc00000)     /* reset vector */
69
70/*
71** Address conversion macros
72*/
73#ifdef CLANGUAGE
74#define CAST(as) (as)
75#else
76#define CAST(as)
77#endif
78#define K0_TO_K1(x)     (CAST(unsigned)(x)|0xA0000000)  /* kseg0 to kseg1 */
79#define K1_TO_K0(x)     (CAST(unsigned)(x)&0x9FFFFFFF)  /* kseg1 to kseg0 */
80#define K0_TO_PHYS(x)   (CAST(unsigned)(x)&0x1FFFFFFF)  /* kseg0 to physical */
81#define K1_TO_PHYS(x)   (CAST(unsigned)(x)&0x1FFFFFFF)  /* kseg1 to physical */
82#define PHYS_TO_K0(x)   (CAST(unsigned)(x)|0x80000000)  /* physical to kseg0 */
83#define PHYS_TO_K1(x)   (CAST(unsigned)(x)|0xA0000000)  /* physical to kseg1 */
84
85/*
86**      Cache size constants
87*/
88#define MINCACHE        0x200           /* 512       For 3041. */
89#define MAXCACHE        0x40000         /* 256*1024   256k */   
90
91#if defined(CPU_R4000)
92/* R4000 configuration register definitions */
93#define CFG_CM          0x80000000      /* Master-Checker mode */
94#define CFG_ECMASK      0x70000000      /* System Clock Ratio */
95#define CFG_ECBY2       0x00000000      /* divide by 2 */
96#define CFG_ECBY3       0x10000000      /* divide by 3 */
97#define CFG_ECBY4       0x20000000      /* divide by 4 */
98#define CFG_EPMASK      0x0f000000      /* Transmit data pattern */
99#define CFG_EPD         0x00000000      /* D */
100#define CFG_EPDDX       0x01000000      /* DDX */
101#define CFG_EPDDXX      0x02000000      /* DDXX */
102#define CFG_EPDXDX      0x03000000      /* DXDX */
103#define CFG_EPDDXXX     0x04000000      /* DDXXX */
104#define CFG_EPDDXXXX    0x05000000      /* DDXXXX */
105#define CFG_EPDXXDXX    0x06000000      /* DXXDXX */
106#define CFG_EPDDXXXXX   0x07000000      /* DDXXXXX */
107#define CFG_EPDXXXDXXX  0x08000000      /* DXXXDXXX */
108#define CFG_SBMASK      0x00c00000      /* Secondary cache block size */
109#define CFG_SBSHIFT     22
110#define CFG_SB4         0x00000000      /* 4 words */
111#define CFG_SB8         0x00400000      /* 8 words */
112#define CFG_SB16        0x00800000      /* 16 words */
113#define CFG_SB32        0x00c00000      /* 32 words */
114#define CFG_SS          0x00200000      /* Split secondary cache */
115#define CFG_SW          0x00100000      /* Secondary cache port width */
116#define CFG_EWMASK      0x000c0000      /* System port width */
117#define CFG_EWSHIFT     18
118#define CFG_EW64        0x00000000      /* 64 bit */
119#define CFG_EW32        0x00010000      /* 32 bit */
120#define CFG_SC          0x00020000      /* Secondary cache absent */
121#define CFG_SM          0x00010000      /* Dirty Shared mode disabled */
122#define CFG_BE          0x00008000      /* Big Endian */
123#define CFG_EM          0x00004000      /* ECC mode enable */
124#define CFG_EB          0x00002000      /* Block ordering */
125#define CFG_ICMASK      0x00000e00      /* Instruction cache size */
126#define CFG_ICSHIFT     9
127#define CFG_DCMASK      0x000001c0      /* Data cache size */
128#define CFG_DCSHIFT     6
129#define CFG_IB          0x00000020      /* Instruction cache block size */
130#define CFG_DB          0x00000010      /* Data cache block size */
131#define CFG_CU          0x00000008      /* Update on Store Conditional */
132#define CFG_K0MASK      0x00000007      /* KSEG0 coherency algorithm */
133
134/*
135 * R4000 primary cache mode
136 */
137#define CFG_C_UNCACHED          2
138#define CFG_C_NONCOHERENT       3
139#define CFG_C_COHERENTXCL       4
140#define CFG_C_COHERENTXCLW      5
141#define CFG_C_COHERENTUPD       6
142
143/*
144 * R4000 cache operations (should be in assembler...?)
145 */
146#define Index_Invalidate_I               0x0         /* 0       0 */
147#define Index_Writeback_Inv_D            0x1         /* 0       1 */
148#define Index_Invalidate_SI              0x2         /* 0       2 */
149#define Index_Writeback_Inv_SD           0x3         /* 0       3 */
150#define Index_Load_Tag_I                 0x4         /* 1       0 */
151#define Index_Load_Tag_D                 0x5         /* 1       1 */
152#define Index_Load_Tag_SI                0x6         /* 1       2 */
153#define Index_Load_Tag_SD                0x7         /* 1       3 */
154#define Index_Store_Tag_I                0x8         /* 2       0 */
155#define Index_Store_Tag_D                0x9         /* 2       1 */
156#define Index_Store_Tag_SI               0xA         /* 2       2 */
157#define Index_Store_Tag_SD               0xB         /* 2       3 */
158#define Create_Dirty_Exc_D               0xD         /* 3       1 */
159#define Create_Dirty_Exc_SD              0xF         /* 3       3 */
160#define Hit_Invalidate_I                 0x10        /* 4       0 */
161#define Hit_Invalidate_D                 0x11        /* 4       1 */
162#define Hit_Invalidate_SI                0x12        /* 4       2 */
163#define Hit_Invalidate_SD                0x13        /* 4       3 */
164#define Hit_Writeback_Inv_D              0x15        /* 5       1 */
165#define Hit_Writeback_Inv_SD             0x17        /* 5       3 */
166#define Fill_I                           0x14        /* 5       0 */
167#define Hit_Writeback_D                  0x19        /* 6       1 */
168#define Hit_Writeback_SD                 0x1B        /* 6       3 */
169#define Hit_Writeback_I                  0x18        /* 6       0 */
170#define Hit_Set_Virtual_SI               0x1E        /* 7       2 */
171#define Hit_Set_Virtual_SD               0x1F        /* 7       3 */
172
173#ifndef WAIT
174#define WAIT .word 0x42000020
175#endif WAIT
176
177#ifndef wait
178#define wait .word 0x42000020
179#endif wait
180
181#endif
182
183/*
184** TLB resource defines
185*/
186#if defined(CPU_R3000)
187#define N_TLB_ENTRIES   64
188#define TLB_PGSIZE      0x1000
189#define RANDBASE        8
190#define TLBLO_PFNMASK   0xfffff000
191#define TLBLO_PFNSHIFT  12
192#define TLBLO_N         0x800   /* non-cacheable */
193#define TLBLO_D         0x400   /* writeable */
194#define TLBLO_V         0x200   /* valid bit */
195#define TLBLO_G         0x100   /* global access bit */
196
197#define TLBHI_VPNMASK   0xfffff000
198#define TLBHI_VPNSHIFT  12
199#define TLBHI_PIDMASK   0xfc0
200#define TLBHI_PIDSHIFT  6
201#define TLBHI_NPID      64
202
203#define TLBINX_PROBE    0x80000000
204#define TLBINX_INXMASK  0x00003f00
205#define TLBINX_INXSHIFT 8
206
207#define TLBRAND_RANDMASK        0x00003f00
208#define TLBRAND_RANDSHIFT       8
209
210#define TLBCTXT_BASEMASK        0xffe00000
211#define TLBCTXT_BASESHIFT       21
212
213#define TLBCTXT_VPNMASK         0x001ffffc
214#define TLBCTXT_VPNSHIFT        2
215#endif
216#if defined(CPU_R4000)
217#define N_TLB_ENTRIES   48
218
219#define TLBHI_VPN2MASK  0xffffe000
220#define TLBHI_PIDMASK   0x000000ff
221#define TLBHI_NPID      256
222
223#define TLBLO_PFNMASK   0x3fffffc0
224#define TLBLO_PFNSHIFT  6
225#define TLBLO_D         0x00000004      /* writeable */
226#define TLBLO_V         0x00000002      /* valid bit */
227#define TLBLO_G         0x00000001      /* global access bit */
228#define TLBLO_CMASK     0x00000038      /* cache algorithm mask */
229#define TLBLO_CSHIFT    3
230
231#define TLBLO_UNCACHED          (CFG_C_UNCACHED<<TLBLO_CSHIFT)
232#define TLBLO_NONCOHERENT       (CFG_C_NONCOHERENT<<TLBLO_CSHIFT)
233#define TLBLO_COHERENTXCL       (CFG_C_COHERENTXCL<<TLBLO_CSHIFT)
234#define TLBLO_COHERENTXCLW      (CFG_C_COHERENTXCLW<<TLBLO_CSHIFT)
235#define TLBLO_COHERENTUPD       (CFG_C_COHERENTUPD<<TLBLO_CSHIFT)
236
237#define TLBINX_PROBE    0x80000000
238#define TLBINX_INXMASK  0x0000003f
239
240#define TLBRAND_RANDMASK        0x0000003f
241
242#define TLBCTXT_BASEMASK        0xff800000
243#define TLBCTXT_BASESHIFT       23
244
245#define TLBCTXT_VPN2MASK        0x007ffff0
246#define TLBCTXT_VPN2SHIFT       4
247
248#define TLBPGMASK_MASK          0x01ffe000
249#endif
250
251#if defined(CPU_R3000)
252#define SR_CUMASK       0xf0000000      /* coproc usable bits */
253#define SR_CU3          0x80000000      /* Coprocessor 3 usable */
254#define SR_CU2          0x40000000      /* Coprocessor 2 usable */
255#define SR_CU1          0x20000000      /* Coprocessor 1 usable */
256#define SR_CU0          0x10000000      /* Coprocessor 0 usable */
257
258#define SR_BEV          0x00400000      /* use boot exception vectors */
259
260/* Cache control bits */
261#define SR_TS           0x00200000      /* TLB shutdown */
262#define SR_PE           0x00100000      /* cache parity error */
263#define SR_CM           0x00080000      /* cache miss */
264#define SR_PZ           0x00040000      /* cache parity zero */
265#define SR_SWC          0x00020000      /* swap cache */
266#define SR_ISC          0x00010000      /* Isolate data cache */
267
268/*
269**      status register interrupt masks and bits
270*/
271
272#define SR_IMASK        0x0000ff00      /* Interrupt mask */
273#define SR_IMASK8       0x00000000      /* mask level 8 */
274#define SR_IMASK7       0x00008000      /* mask level 7 */
275#define SR_IMASK6       0x0000c000      /* mask level 6 */
276#define SR_IMASK5       0x0000e000      /* mask level 5 */
277#define SR_IMASK4       0x0000f000      /* mask level 4 */
278#define SR_IMASK3       0x0000f800      /* mask level 3 */
279#define SR_IMASK2       0x0000fc00      /* mask level 2 */
280#define SR_IMASK1       0x0000fe00      /* mask level 1 */
281#define SR_IMASK0       0x0000ff00      /* mask level 0 */
282
283#define SR_IMASKSHIFT   8
284
285#define SR_IBIT8        0x00008000      /* bit level 8 */
286#define SR_IBIT7        0x00004000      /* bit level 7 */
287#define SR_IBIT6        0x00002000      /* bit level 6 */
288#define SR_IBIT5        0x00001000      /* bit level 5 */
289#define SR_IBIT4        0x00000800      /* bit level 4 */
290#define SR_IBIT3        0x00000400      /* bit level 3 */
291#define SR_IBIT2        0x00000200      /* bit level 2 */
292#define SR_IBIT1        0x00000100      /* bit level 1 */
293
294#define SR_KUO          0x00000020      /* old kernel/user, 0 => k, 1 => u */
295#define SR_IEO          0x00000010      /* old interrupt enable, 1 => enable */
296#define SR_KUP          0x00000008      /* prev kernel/user, 0 => k, 1 => u */
297#define SR_IEP          0x00000004      /* prev interrupt enable, 1 => enable */
298#define SR_KUC          0x00000002      /* cur kernel/user, 0 => k, 1 => u */
299#define SR_IEC          0x00000001      /* cur interrupt enable, 1 => enable */
300#endif
301
302#if defined(CPU_R4000)
303#define SR_CUMASK       0xf0000000      /* coproc usable bits */
304#define SR_CU3          0x80000000      /* Coprocessor 3 usable */
305#define SR_CU2          0x40000000      /* Coprocessor 2 usable */
306#define SR_CU1          0x20000000      /* Coprocessor 1 usable */
307#define SR_CU0          0x10000000      /* Coprocessor 0 usable */
308
309#define SR_RP           0x08000000      /* Reduced power operation */
310#define SR_FR           0x04000000      /* Additional floating point registers */
311#define SR_RE           0x02000000      /* Reverse endian in user mode */
312
313#define SR_BEV          0x00400000      /* Use boot exception vectors */
314#define SR_TS           0x00200000      /* TLB shutdown */
315#define SR_SR           0x00100000      /* Soft reset */
316#define SR_CH           0x00040000      /* Cache hit */
317#define SR_CE           0x00020000      /* Use cache ECC  */
318#define SR_DE           0x00010000      /* Disable cache exceptions */
319
320/*
321**      status register interrupt masks and bits
322*/
323
324#define SR_IMASK        0x0000ff00      /* Interrupt mask */
325#define SR_IMASK8       0x00000000      /* mask level 8 */
326#define SR_IMASK7       0x00008000      /* mask level 7 */
327#define SR_IMASK6       0x0000c000      /* mask level 6 */
328#define SR_IMASK5       0x0000e000      /* mask level 5 */
329#define SR_IMASK4       0x0000f000      /* mask level 4 */
330#define SR_IMASK3       0x0000f800      /* mask level 3 */
331#define SR_IMASK2       0x0000fc00      /* mask level 2 */
332#define SR_IMASK1       0x0000fe00      /* mask level 1 */
333#define SR_IMASK0       0x0000ff00      /* mask level 0 */
334
335#define SR_IMASKSHIFT   8
336
337#define SR_IBIT8        0x00008000      /* bit level 8 */
338#define SR_IBIT7        0x00004000      /* bit level 7 */
339#define SR_IBIT6        0x00002000      /* bit level 6 */
340#define SR_IBIT5        0x00001000      /* bit level 5 */
341#define SR_IBIT4        0x00000800      /* bit level 4 */
342#define SR_IBIT3        0x00000400      /* bit level 3 */
343#define SR_IBIT2        0x00000200      /* bit level 2 */
344#define SR_IBIT1        0x00000100      /* bit level 1 */
345
346#define SR_KSMASK       0x00000018      /* Kernel mode mask */
347#define SR_KSUSER       0x00000010      /* User mode */
348#define SR_KSSUPER      0x00000008      /* Supervisor mode */
349#define SR_KSKERNEL     0x00000000      /* Kernel mode */
350#define SR_ERL          0x00000004      /* Error level */
351#define SR_EXL          0x00000002      /* Exception level */
352#define SR_IE           0x00000001      /* Interrupts enabled */
353#endif
354
355
356
357/*
358 * Cause Register
359 */
360#define CAUSE_BD        0x80000000      /* Branch delay slot */
361#define CAUSE_CEMASK    0x30000000      /* coprocessor error */
362#define CAUSE_CESHIFT   28
363
364
365#define CAUSE_IPMASK    0x0000FF00      /* Pending interrupt mask */
366#define CAUSE_IPSHIFT   8
367
368#define CAUSE_EXCMASK   0x0000003C      /* Cause code bits */
369#define CAUSE_EXCSHIFT  2
370
371#ifndef XDS
372/*
373**  Coprocessor 0 registers
374*/
375#define C0_INX          $0              /* tlb index */
376#define C0_RAND         $1              /* tlb random */
377#if defined(CPU_R3000)
378#define C0_TLBLO        $2              /* tlb entry low */
379#endif
380#if defined(CPU_R4000)
381#define C0_TLBLO0       $2              /* tlb entry low 0 */
382#define C0_TLBLO1       $3              /* tlb entry low 1 */
383#endif
384
385#define C0_CTXT         $4              /* tlb context */
386
387#if defined(CPU_R4000)
388#define C0_PAGEMASK     $5              /* tlb page mask */
389#define C0_WIRED        $6              /* number of wired tlb entries */
390#endif
391
392#define C0_BADVADDR     $8              /* bad virtual address */
393
394#if defined(CPU_R4000)
395#define C0_COUNT        $9              /* cycle count */
396#endif
397
398#define C0_TLBHI        $10             /* tlb entry hi */
399
400#if defined(CPU_R4000)
401#define C0_COMPARE      $11             /* cyccle count comparator  */
402#endif
403
404#define C0_SR           $12             /* status register */
405#define C0_CAUSE        $13             /* exception cause */
406#define C0_EPC          $14             /* exception pc */
407#define C0_PRID         $15             /* revision identifier */
408
409#if defined(CPU_R3000)
410#define C0_CONFIG   $3     /* configuration register R3081*/
411#endif
412
413#if defined(CPU_R4000)
414#define C0_CONFIG       $16             /* configuration register */
415#define C0_LLADDR       $17             /* linked load address */
416#define C0_WATCHLO      $18             /* watchpoint trap register */
417#define C0_WATCHHI      $19             /* watchpoint trap register */
418#define C0_XCTXT    $20     /* extended tlb context */
419#define C0_ECC          $26             /* secondary cache ECC control */
420#define C0_CACHEERR     $27             /* cache error status */
421#define C0_TAGLO        $28             /* cache tag lo */
422#define C0_TAGHI        $29             /* cache tag hi */
423#define C0_ERRPC        $30             /* cache error pc */
424#endif
425
426#endif XDS
427
428#ifdef R4650
429#define IWATCH $18
430#define DWATCH $19
431#define IBASE  $0
432#define IBOUND $1
433#define DBASE  $2
434#define DBOUND $3
435#define CALG    $17
436#endif
437
438#endif /* _IDTCPU_H__ */
439
Note: See TracBrowser for help on using the repository browser.