KallistiOS
git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1
/* KallistiOS ##version##
2
3
kernel/arch/dreamcast/include/arch/memory.h
4
Copyright (C) 2023 Donald Haase
5
6
*/
7
8
/** \file arch/memory.h
9
\brief Constants for areas of the system memory map.
10
\ingroup memory
11
12
Various addresses and masks that are set by the SH7750. None of the values
13
here are Dreamcast-specific.
14
15
These values are drawn from the Hitatchi SH7750 Series Hardware Manual rev 6.0.
16
17
\author Donald Haase
18
*/
19
20
#ifndef __ARCH_MEMORY_H
21
#define __ARCH_MEMORY_H
22
23
#include <sys/cdefs.h>
24
__BEGIN_DECLS
25
26
/** \defgroup memory Address Space
27
\brief Basics of the SH4 Memory Map
28
\ingroup system
29
30
The SH7750 Series physical address space is mapped onto a 29-bit external
31
memory space, with the upper 3 bits of the address indicating which memory
32
region will be used. The P0/U0 memory region spans a 2GB space with the
33
bottom 512MB mirrored to the P1, P2, and P3 regions.
34
35
*/
36
37
/** \brief Mask a cache-agnostic address.
38
\ingroup memory
39
40
This masks out the upper 3 bits of an address. This is used when it is
41
necessary to access memory with a specified caching mode. This is needed for
42
DMA and SQ usage as well as various MMU functions.
43
44
*/
45
#define MEM_AREA_CACHE_MASK 0x1fffffff
46
47
/** \brief U0 memory region base (cacheable).
48
\ingroup memory
49
50
This is the base user mode memory address. It is cacheable as determined
51
by the WT bit of the cache control register. By default KOS sets this to
52
copy-back mode.
53
54
KOS runs in privileged mode, so this is here merely for completeness.
55
56
*/
57
#define MEM_AREA_U0_BASE 0x00000000
58
59
/** \brief P0 memory region base (cacheable).
60
\ingroup memory
61
62
This is the base privileged mode memory address. It is cacheable as determined
63
by the WT bit of the cache control register. By default KOS sets this to
64
copy-back mode.
65
66
*/
67
#define MEM_AREA_P0_BASE 0x00000000
68
69
/** \brief P1 memory region base (cacheable).
70
\ingroup memory
71
72
This is a modularly cachable memory region. It is cacheable as determined by
73
the CB bit of the cache control register. That allows it to function in a
74
different caching mode (copy-back v write-through) than the U0, P0, and P3
75
regions, whose cache mode are governed by the WT bit. By default KOS sets this
76
to the same copy-back mode as the other cachable regions.
77
78
*/
79
#define MEM_AREA_P1_BASE 0x80000000
80
81
/** \brief P2 memory region base (non-cacheable).
82
\ingroup memory
83
84
This is the non-cachable memory region. It is most frequently for DMA
85
transactions to ensure reads are not cached.
86
87
*/
88
#define MEM_AREA_P2_BASE 0xa0000000
89
90
/** \brief P3 memory region base (cacheable).
91
\ingroup memory
92
93
This functions as the lower 512MB of P0.
94
95
*/
96
#define MEM_AREA_P3_BASE 0xc0000000
97
98
/** \brief P4 memory region base (non-cacheable)
99
\ingroup memory
100
101
This offset maps to on-chip I/O channels.
102
*/
103
#define MEM_AREA_P4_BASE 0xe0000000
104
105
/** \defgroup p4mem P4 memory region
106
\brief P4 SH-internal memory region (non-cacheable).
107
\ingroup memory
108
*/
109
110
/** \brief Store Queue (SQ) memory base.
111
\ingroup p4mem
112
113
This offset maps to the SQ memory region. RW to addresses from
114
0xe0000000-0xe3ffffff follow SQ rules.
115
116
\see dc\sq.h
117
118
*/
119
#define MEM_AREA_SQ_BASE 0xe0000000
120
121
/** \brief Instruction cache address array base.
122
\ingroup p4mem
123
124
This offset is used for direct access to the instruction cache address array.
125
126
*/
127
#define MEM_AREA_ICACHE_ADDRESS_ARRAY_BASE 0xf0000000
128
129
/** \brief Instruction cache data array base.
130
\ingroup p4mem
131
132
This offset is used for direct access to the instruction cache data array.
133
134
*/
135
#define MEM_AREA_ICACHE_DATA_ARRAY_BASE 0xf1000000
136
137
/** \brief Instruction TLB address array base.
138
\ingroup p4mem
139
140
This offset is used for direct access to the instruction TLB address array.
141
142
*/
143
#define MEM_AREA_ITLB_ADDRESS_ARRAY_BASE 0xf2000000
144
145
/** \brief Instruction TLB data array 1 base.
146
\ingroup p4mem
147
148
This offset is used for direct access to the instruction TLB data array 1.
149
150
*/
151
#define MEM_AREA_ITLB_DATA_ARRAY1_BASE 0xf3000000
152
153
/** \brief Instruction TLB data array 2 base.
154
\ingroup p4mem
155
156
This offset is used for direct access to the instruction TLB data array 2.
157
158
*/
159
#define MEM_AREA_ITLB_DATA_ARRAY2_BASE 0xf3800000
160
161
/** \brief Operand cache address array base.
162
\ingroup p4mem
163
164
This offset is used for direct access to the operand cache address array.
165
166
*/
167
#define MEM_AREA_OCACHE_ADDRESS_ARRAY_BASE 0xf4000000
168
169
/** \brief Instruction cache data array base.
170
\ingroup p4mem
171
172
This offset is used for direct access to the operand cache data array.
173
174
*/
175
#define MEM_AREA_OCACHE_DATA_ARRAY_BASE 0xf5000000
176
177
/** \brief Unified TLB address array base.
178
\ingroup p4mem
179
180
This offset is used for direct access to the unified TLB address array.
181
182
*/
183
#define MEM_AREA_UTLB_ADDRESS_ARRAY_BASE 0xf6000000
184
185
/** \brief Unified TLB data array 1 base.
186
\ingroup p4mem
187
188
This offset is used for direct access to the unified TLB data array 1.
189
190
*/
191
#define MEM_AREA_UTLB_DATA_ARRAY1_BASE 0xf7000000
192
193
/** \brief Unified TLB data array 2 base.
194
\ingroup p4mem
195
196
This offset is used for direct access to the unified TLB data array 2.
197
198
*/
199
#define MEM_AREA_UTLB_DATA_ARRAY2_BASE 0xf7800000
200
201
/** \brief Control Register base.
202
\ingroup p4mem
203
204
This is the base address of all control registers
205
206
*/
207
#define MEM_AREA_CTRL_REG_BASE 0xff000000
208
209
/** \defgroup sh4_cr_regs Control Registers
210
\brief Addresses of control registers within the P4 area
211
\ingroup p4mem
212
*/
213
214
/** \defgroup sh4_mmu_regs MMU
215
\brief MMU Control Registers
216
\ingroup sh4_cr_regs
217
218
\see arch\mmu.h
219
220
These are registers for controlling the MMU as defined in table 3.1
221
of Hitatchi SH7750 Series Hardware Manual rev 6.0, titled "MMU Registers".
222
All are accessed as 32-bit values.
223
224
*/
225
226
/** \brief MMU Page table entry high.
227
\ingroup sh4_mmu_regs
228
229
When an MMU exception or address error exception occurs, the virtual page number (VPN)
230
(the upper 22-bits of the virtual address causing the exception) is written
231
to the register. The bottom 8 bits of the register are software-fillable as
232
an 8 bit ID (ASID) of the process causing the exception.
233
*/
234
#define SH4_REG_MMU_PTEH 0xff000000
235
236
/** \brief MMU Page table entry low.
237
\ingroup sh4_mmu_regs
238
239
Holds the physical page number (PPN) in bits 10-28 and page management flags in 0-8.
240
*/
241
#define SH4_REG_MMU_PTEL 0xff000004
242
243
/** \brief MMU Translation table base.
244
\ingroup sh4_mmu_regs
245
246
Holds the base address of the currently used page table.
247
*/
248
#define SH4_REG_MMU_TTB 0xff000008
249
250
/** \brief MMU TLB Exception address.
251
\ingroup sh4_mmu_regs
252
253
After an MMU exception or address error exception occurs, the virtual address where the
254
exception occurred is stored here.
255
*/
256
#define SH4_REG_MMU_TEA 0xff00000c
257
258
/** \brief MMU Control Register.
259
\ingroup sh4_mmu_regs
260
261
Holds configuration values including enable/disable of MMU Address Translation (at bit 0)
262
*/
263
#define SH4_REG_MMU_CR 0xff000010
264
265
/** \brief MMU Page table entry assistance.
266
\ingroup sh4_mmu_regs
267
268
Stores assistance bits for PCMCIA access to the UTLB via LDTLB. This is currently unused by KOS.
269
*/
270
#define SH4_REG_MMU_PTEA 0xff000034
271
272
/** \defgroup sh4_ubc_regs UBC
273
\brief UBC Control Registers
274
\ingroup sh4_cr_regs
275
276
\see dc\ubc.h
277
278
These are registers for controlling the UBC as defined in table 20.1
279
of Hitatchi SH7750 Series Hardware Manual rev 6.0, titled "UBC Registers"
280
281
*/
282
283
/** \brief UBC Break ASID register A
284
\ingroup sh4_ubc_regs
285
286
Specifies the ASID used in the channel A break condition. 8-bit RW.
287
*/
288
#define SH4_REG_UBC_BASRA 0xff000014
289
290
/** \brief UBC Break ASID register B
291
\ingroup sh4_ubc_regs
292
293
Specifies the ASID used in the channel B break condition. 8-bit RW.
294
*/
295
#define SH4_REG_UBC_BASRB 0xff000018
296
297
/** \brief UBC Break address register A
298
\ingroup sh4_ubc_regs
299
300
Specifies the virtual address used in the channel A break conditions. 32-bit RW.
301
*/
302
#define SH4_REG_UBC_BARA 0xff200000
303
304
/** \brief UBC Break address mask register A
305
\ingroup sh4_ubc_regs
306
307
Specifies the settings for masking the ASID in channel A. 8-bit RW.
308
*/
309
#define SH4_REG_UBC_BAMRA 0xff200004
310
311
/** \brief UBC Break bus cycle register A
312
\ingroup sh4_ubc_regs
313
314
Sets three conditions: 1) instruction/operand access 2) RW 3) Operand size. 16-bit RW.
315
*/
316
#define SH4_REG_UBC_BBRA 0xff200008
317
318
/** \brief UBC Break address register B
319
\ingroup sh4_ubc_regs
320
321
Specifies the virtual address used in the channel B break conditions. 32-bit RW.
322
*/
323
#define SH4_REG_UBC_BARB 0xff20000c
324
325
/** \brief UBC Break address mask register B
326
\ingroup sh4_ubc_regs
327
328
Specifies the settings for masking the ASID in channel B. 8-bit RW.
329
*/
330
#define SH4_REG_UBC_BAMRB 0xff200010
331
332
/** \brief UBC Break bus cycle register B
333
\ingroup sh4_ubc_regs
334
335
Sets three conditions: 1) instruction/operand access 2) RW 3) Operand size. 16-bit RW.
336
*/
337
#define SH4_REG_UBC_BBRB 0xff200014
338
339
340
/** \brief UBC Break data register B
341
\ingroup sh4_ubc_regs
342
343
Specifies the data to be used in the channel B break conditions. 32-bit RW.
344
Currently unused by KOS
345
*/
346
#define SH4_REG_UBC_BDRB 0xff200018
347
348
/** \brief UBC Break mask register B
349
\ingroup sh4_ubc_regs
350
351
Specifies which bits of the break data set in SH4_REG_UBC_BDRB are to be masked. 32-bit RW.
352
Currently unused by KOS
353
*/
354
#define SH4_REG_UBC_BDMRB 0xff20001c
355
356
/** \brief UBC Break control register
357
\ingroup sh4_ubc_regs
358
359
Specifies various settings for UBC as well as condition match flags. 16-bit RW.
360
*/
361
#define SH4_REG_UBC_BRCR 0xff200020
362
363
__END_DECLS
364
365
#endif
/* __ARCH_MEMORY_H */
kernel
arch
dreamcast
include
arch
memory.h
Generated by
1.12.0