1 |
/* GXemul: $Id: sh4_cache.h,v 1.1 2006/09/23 03:51:06 debug Exp $ */ |
2 |
/* $NetBSD: cache_sh4.h,v 1.11 2006/03/04 01:55:03 uwe Exp $ */ |
3 |
|
4 |
#ifndef _SH3_CACHE_SH4_H_ |
5 |
#define _SH3_CACHE_SH4_H_ |
6 |
|
7 |
/*- |
8 |
* Copyright (c) 2002 The NetBSD Foundation, Inc. |
9 |
* All rights reserved. |
10 |
* |
11 |
* This code is derived from software contributed to The NetBSD Foundation |
12 |
* by UCHIYAMA Yasushi. |
13 |
* |
14 |
* Redistribution and use in source and binary forms, with or without |
15 |
* modification, are permitted provided that the following conditions |
16 |
* are met: |
17 |
* 1. Redistributions of source code must retain the above copyright |
18 |
* notice, this list of conditions and the following disclaimer. |
19 |
* 2. Redistributions in binary form must reproduce the above copyright |
20 |
* notice, this list of conditions and the following disclaimer in the |
21 |
* documentation and/or other materials provided with the distribution. |
22 |
* 3. All advertising materials mentioning features or use of this software |
23 |
* must display the following acknowledgement: |
24 |
* This product includes software developed by the NetBSD |
25 |
* Foundation, Inc. and its contributors. |
26 |
* 4. Neither the name of The NetBSD Foundation nor the names of its |
27 |
* contributors may be used to endorse or promote products derived |
28 |
* from this software without specific prior written permission. |
29 |
* |
30 |
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
31 |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
32 |
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
33 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
34 |
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
35 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
36 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
37 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
38 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
39 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
40 |
* POSSIBILITY OF SUCH DAMAGE. |
41 |
*/ |
42 |
|
43 |
/* |
44 |
* SH4: SH7750 SH7750S SH7750R SH7751 SH7751R |
45 |
*/ |
46 |
|
47 |
/* #include <sh3/devreg.h> */ |
48 |
/* #ifdef _KERNEL */ |
49 |
|
50 |
#define SH4_ICACHE_SIZE 8192 |
51 |
#define SH4_DCACHE_SIZE 16384 |
52 |
#define SH4_EMODE_ICACHE_SIZE 16384 |
53 |
#define SH4_EMODE_DCACHE_SIZE 32768 |
54 |
#define SH4_CACHE_LINESZ 32 |
55 |
|
56 |
#define SH4_CCR 0xff00001c |
57 |
#define SH4_CCR_EMODE 0x80000000 |
58 |
#define SH4_CCR_IIX 0x00008000 |
59 |
#define SH4_CCR_ICI 0x00000800 |
60 |
#define SH4_CCR_ICE 0x00000100 |
61 |
#define SH4_CCR_OIX 0x00000080 |
62 |
#define SH4_CCR_ORA 0x00000020 |
63 |
#define SH4_CCR_OCI 0x00000008 |
64 |
#define SH4_CCR_CB 0x00000004 |
65 |
#define SH4_CCR_WT 0x00000002 |
66 |
#define SH4_CCR_OCE 0x00000001 |
67 |
|
68 |
#define SH4_QACR0 0xff000038 |
69 |
#define SH4_QACR1 0xff00003c |
70 |
#define SH4_QACR_AREA_SHIFT 2 |
71 |
#define SH4_QACR_AREA_MASK 0x0000001c |
72 |
|
73 |
/* I-cache address/data array */ |
74 |
#define SH4_CCIA 0xf0000000 |
75 |
/* address specification */ |
76 |
#define CCIA_A 0x00000008 /* associate bit */ |
77 |
#define CCIA_ENTRY_SHIFT 5 /* line size 32B */ |
78 |
#define CCIA_ENTRY_MASK 0x00001fe0 /* [12:5] 256-entries */ |
79 |
#define CCIA_EMODE_ENTRY_MASK 0x00003fe0 /* [13:5] 512-entries */ |
80 |
/* data specification */ |
81 |
#define CCIA_V 0x00000001 |
82 |
#define CCIA_TAGADDR_MASK 0xfffffc00 /* [31:10] */ |
83 |
|
84 |
#define SH4_CCID 0xf1000000 |
85 |
/* address specification */ |
86 |
#define CCID_L_SHIFT 2 |
87 |
#define CCID_L_MASK 0x1c /* line-size is 32B */ |
88 |
#define CCID_ENTRY_MASK 0x00001fe0 /* [12:5] 256-entries */ |
89 |
|
90 |
/* D-cache address/data array */ |
91 |
#define SH4_CCDA 0xf4000000 |
92 |
/* address specification */ |
93 |
#define CCDA_A 0x00000008 /* associate bit */ |
94 |
#define CCDA_ENTRY_SHIFT 5 /* line size 32B */ |
95 |
#define CCDA_ENTRY_MASK 0x00003fe0 /* [13:5] 512-entries */ |
96 |
/* data specification */ |
97 |
#define CCDA_V 0x00000001 |
98 |
#define CCDA_U 0x00000002 |
99 |
#define CCDA_TAGADDR_MASK 0xfffffc00 /* [31:10] */ |
100 |
|
101 |
#define SH4_CCDD 0xf5000000 |
102 |
|
103 |
/* Store Queue */ |
104 |
#define SH4_SQ 0xe0000000 |
105 |
|
106 |
/* |
107 |
* cache flush macro for locore level code. |
108 |
*/ |
109 |
#define SH4_CACHE_FLUSH() \ |
110 |
do { \ |
111 |
uint32_t __e, __a; \ |
112 |
\ |
113 |
/* D-cache */ \ |
114 |
for (__e = 0; __e < (SH4_DCACHE_SIZE / SH4_CACHE_LINESZ); __e++) {\ |
115 |
__a = SH4_CCDA | (__e << CCDA_ENTRY_SHIFT); \ |
116 |
(*(volatile uint32_t *)__a) &= ~(CCDA_U | CCDA_V); \ |
117 |
} \ |
118 |
/* I-cache */ \ |
119 |
for (__e = 0; __e < (SH4_ICACHE_SIZE / SH4_CACHE_LINESZ); __e++) {\ |
120 |
__a = SH4_CCIA | (__e << CCIA_ENTRY_SHIFT); \ |
121 |
(*(volatile uint32_t *)__a) &= ~(CCIA_V); \ |
122 |
} \ |
123 |
} while(/*CONSTCOND*/0) |
124 |
|
125 |
#define SH4_EMODE_CACHE_FLUSH() \ |
126 |
do { \ |
127 |
uint32_t __e, __a; \ |
128 |
\ |
129 |
/* D-cache */ \ |
130 |
for (__e = 0;__e < (SH4_EMODE_DCACHE_SIZE / SH4_CACHE_LINESZ);__e++) {\ |
131 |
__a = SH4_CCDA | (__e << CCDA_ENTRY_SHIFT); \ |
132 |
(*(volatile uint32_t *)__a) &= ~(CCDA_U | CCDA_V); \ |
133 |
} \ |
134 |
/* I-cache */ \ |
135 |
for (__e = 0;__e < (SH4_EMODE_ICACHE_SIZE / SH4_CACHE_LINESZ);__e++) {\ |
136 |
__a = SH4_CCIA | (__e << CCIA_ENTRY_SHIFT); \ |
137 |
(*(volatile uint32_t *)__a) &= ~(CCIA_V); \ |
138 |
} \ |
139 |
} while(/*CONSTCOND*/0) |
140 |
|
141 |
#define SH7750_CACHE_FLUSH() SH4_CACHE_FLUSH() |
142 |
#define SH7750S_CACHE_FLUSH() SH4_CACHE_FLUSH() |
143 |
#define SH7751_CACHE_FLUSH() SH4_CACHE_FLUSH() |
144 |
#if defined(SH4_CACHE_DISABLE_EMODE) |
145 |
#define SH7750R_CACHE_FLUSH() SH4_CACHE_FLUSH() |
146 |
#define SH7751R_CACHE_FLUSH() SH4_CACHE_FLUSH() |
147 |
#else |
148 |
#define SH7750R_CACHE_FLUSH() SH4_EMODE_CACHE_FLUSH() |
149 |
#define SH7751R_CACHE_FLUSH() SH4_EMODE_CACHE_FLUSH() |
150 |
#endif |
151 |
|
152 |
#if 0 |
153 |
#ifndef _LOCORE |
154 |
extern void sh4_cache_config(void); |
155 |
#endif |
156 |
#endif |
157 |
|
158 |
/* #endif _KERNEL */ |
159 |
|
160 |
#endif /* !_SH3_CACHE_SH4_H_ */ |