N64FlashcartMenu
Loading...
Searching...
No Matches
boot_io.h
Go to the documentation of this file.
1
7#ifndef BOOT_IO_H__
8#define BOOT_IO_H__
9
10
11#include <stddef.h>
12#include <stdint.h>
13
14
15typedef volatile uint8_t io8_t;
16typedef volatile uint32_t io32_t;
17
18
19#define UNCACHED(address) ((typeof(address)) (((io32_t) (address)) | (0xA0000000UL)))
20
22typedef struct {
23 io32_t DMEM[1024];
24 io32_t IMEM[1024];
25} sp_mem_t;
26
27#define SP_MEM_BASE (0x04000000UL)
28#define SP_MEM ((sp_mem_t *) SP_MEM_BASE)
29
31typedef struct {
32 io32_t PADDR;
33 io32_t MADDR;
34 io32_t RD_LEN;
35 io32_t WR_LEN;
36 io32_t SR;
37 io32_t DMA_FULL;
38 io32_t DMA_BUSY;
39 io32_t SEMAPHORE;
40 io32_t __reserved[0xFFF8];
41 io32_t PC;
42} sp_regs_t;
43
44#define SP_BASE (0x04040000UL)
45#define SP ((sp_regs_t *) SP_BASE)
46
47#define SP_SR_HALT (1 << 0)
48#define SP_SR_BROKE (1 << 1)
49#define SP_SR_DMA_BUSY (1 << 2)
50#define SP_SR_DMA_FULL (1 << 3)
51#define SP_SR_IO_FULL (1 << 4)
52#define SP_SR_SSTEP (1 << 5)
53#define SP_SR_INTR_BREAK (1 << 6)
54#define SP_SR_SIG0 (1 << 7)
55#define SP_SR_SIG1 (1 << 8)
56#define SP_SR_SIG2 (1 << 9)
57#define SP_SR_SIG3 (1 << 10)
58#define SP_SR_SIG4 (1 << 11)
59#define SP_SR_SIG5 (1 << 12)
60#define SP_SR_SIG6 (1 << 13)
61#define SP_SR_SIG7 (1 << 14)
62#define SP_SR_CLR_HALT (1 << 0)
63#define SP_SR_SET_HALT (1 << 1)
64#define SP_SR_CLR_BROKE (1 << 2)
65#define SP_SR_CLR_INTR (1 << 3)
66#define SP_SR_SET_INTR (1 << 4)
67#define SP_SR_CLR_SSTEP (1 << 5)
68#define SP_SR_SET_SSTEP (1 << 6)
69#define SP_SR_CLR_INTR_BREAK (1 << 7)
70#define SP_SR_SET_INTR_BREAK (1 << 8)
71#define SP_SR_CLR_SIG0 (1 << 9)
72#define SP_SR_SET_SIG0 (1 << 10)
73#define SP_SR_CLR_SIG1 (1 << 11)
74#define SP_SR_SET_SIG1 (1 << 12)
75#define SP_SR_CLR_SIG2 (1 << 13)
76#define SP_SR_SET_SIG2 (1 << 14)
77#define SP_SR_CLR_SIG3 (1 << 15)
78#define SP_SR_SET_SIG3 (1 << 16)
79#define SP_SR_CLR_SIG4 (1 << 17)
80#define SP_SR_SET_SIG4 (1 << 18)
81#define SP_SR_CLR_SIG5 (1 << 19)
82#define SP_SR_SET_SIG5 (1 << 20)
83#define SP_SR_CLR_SIG6 (1 << 21)
84#define SP_SR_SET_SIG6 (1 << 22)
85#define SP_SR_CLR_SIG7 (1 << 23)
86#define SP_SR_SET_SIG7 (1 << 24)
87
88
90typedef struct {
91 io32_t START;
92 io32_t END;
93 io32_t CURRENT;
94 io32_t SR;
95 io32_t CLOCK;
96 io32_t BUF_BUSY;
97 io32_t PIPE_BUSY;
98 io32_t TMEM;
100
101#define DPC_BASE (0x04100000UL)
102#define DPC ((dpc_regs_t *) DPC_BASE)
103
104#define DPC_SR_XBUS_DMEM_DMA (1 << 0)
105#define DPC_SR_FREEZE (1 << 1)
106#define DPC_SR_FLUSH (1 << 2)
107#define DPC_SR_START_GCLK (1 << 3)
108#define DPC_SR_TMEM_BUSY (1 << 4)
109#define DPC_SR_PIPE_BUSY (1 << 5)
110#define DPC_SR_CMD_BUSY (1 << 6)
111#define DPC_SR_CBUF_READY (1 << 7)
112#define DPC_SR_DMA_BUSY (1 << 8)
113#define DPC_SR_END_VALID (1 << 9)
114#define DPC_SR_START_VALID (1 << 10)
115#define DPC_SR_CLR_XBUS_DMEM_DMA (1 << 0)
116#define DPC_SR_SET_XBUS_DMEM_DMA (1 << 1)
117#define DPC_SR_CLR_FREEZE (1 << 2)
118#define DPC_SR_SET_FREEZE (1 << 3)
119#define DPC_SR_CLR_FLUSH (1 << 4)
120#define DPC_SR_SET_FLUSH (1 << 5)
121#define DPC_SR_CLR_TMEM_CTR (1 << 6)
122#define DPC_SR_CLR_PIPE_CTR (1 << 7)
123#define DPC_SR_CLR_CMD_CTR (1 << 8)
124#define DPC_SR_CLR_CLOCK_CTR (1 << 9)
125
126
128typedef struct {
130 io32_t CR;
132 io32_t MADDR;
134 io32_t H_WIDTH;
136 io32_t V_INTR;
138 io32_t CURR_LINE;
140 io32_t TIMING;
142 io32_t V_SYNC;
144 io32_t H_SYNC;
148 io32_t H_LIMITS;
150 io32_t V_LIMITS;
154 io32_t H_SCALE;
156 io32_t V_SCALE;
157} vi_regs_t;
158
159#define VI_BASE (0x04400000UL)
160#define VI ((vi_regs_t *) VI_BASE)
161
162#define VI_CR_TYPE_16 (2 << 0)
163#define VI_CR_TYPE_32 (3 << 0)
164#define VI_CR_GAMMA_DITHER_ON (1 << 2)
165#define VI_CR_GAMMA_ON (1 << 3)
166#define VI_CR_DIVOT_ON (1 << 4)
167#define VI_CR_SERRATE_ON (1 << 6)
168#define VI_CR_ANTIALIAS_0 (1 << 8)
169#define VI_CR_ANTIALIAS_1 (1 << 9)
170#define VI_CR_PIXEL_ADVANCE_0 (1 << 12)
171#define VI_CR_PIXEL_ADVANCE_1 (1 << 13)
172#define VI_CR_PIXEL_ADVANCE_2 (1 << 14)
173#define VI_CR_PIXEL_ADVANCE_3 (1 << 15)
174#define VI_CR_DITHER_FILTER_ON (1 << 16)
175
176#define VI_CURR_LINE_FIELD (1 << 0)
177
179typedef struct {
181 io32_t MADDR;
183 io32_t LEN;
185 io32_t CR;
187 io32_t SR;
189 io32_t DACRATE;
191 io32_t BITRATE;
192} ai_regs_t;
193
194#define AI_BASE (0x04500000UL)
195#define AI ((ai_regs_t *) AI_BASE)
196
197#define AI_SR_DMA_BUSY (1 << 30)
198#define AI_SR_FIFO_FULL (1 << 31)
199#define AI_CR_DMA_ON (1 << 0)
200
201
203typedef struct {
205 io32_t MADDR;
207 io32_t PADDR;
209 io32_t RDMA;
211 io32_t WDMA;
213 io32_t SR;
215 struct {
217 io32_t LAT;
219 io32_t PWD;
221 io32_t PGS;
223 io32_t RLS;
224 } DOM[2];
225} pi_regs_t;
226
227#define PI_BASE (0x04600000UL)
228#define PI ((pi_regs_t *) PI_BASE)
229
230#define PI_SR_DMA_BUSY (1 << 0)
231#define PI_SR_IO_BUSY (1 << 1)
232#define PI_SR_DMA_ERROR (1 << 2)
233#define PI_SR_RESET (1 << 0)
234#define PI_SR_CLR_INTR (1 << 1)
235
236
237#define ROM_DDIPL_BASE (0x06000000UL)
238#define ROM_DDIPL ((io32_t *) ROM_DDIPL_BASE)
239
240
241#define ROM_CART_BASE (0x10000000UL)
242#define ROM_CART ((io32_t *) ROM_CART_BASE)
243
245typedef struct {
246 uint32_t tv_type;
247 uint32_t device_type;
248 uint32_t device_base;
249 uint32_t reset_type;
250 uint32_t cic_id;
251 uint32_t version;
252 uint32_t mem_size;
253 uint8_t app_nmi_buffer[64];
254 uint32_t __reserved_1[37];
255 uint32_t mem_size_6105;
256} os_info_t;
257
258#define OS_INFO_BASE (0x80000300UL)
259#define OS_INFO ((os_info_t *) OS_INFO_BASE)
260
262#define OS_INFO_RESET_TYPE_COLD (0)
264#define OS_INFO_RESET_TYPE_NMI (1)
265
266
267static inline uint32_t cpu_io_read (io32_t *address) {
268 io32_t *uncached = UNCACHED(address);
269 uint32_t value = *uncached;
270 return value;
271}
272
273static inline void cpu_io_write (io32_t *address, uint32_t value) {
274 io32_t *uncached = UNCACHED(address);
275 *uncached = value;
276}
277
278
279#endif
io32_t DACRATE
The DAC rate.
Definition: boot_io.h:189
io32_t CURR_LINE
The Current Line.
Definition: boot_io.h:138
io32_t PADDR
The Cart Address.
Definition: boot_io.h:207
io32_t BITRATE
The bit rate.
Definition: boot_io.h:191
io32_t TIMING
The Timings.
Definition: boot_io.h:140
io32_t H_SYNC
The Horizontal Sync.
Definition: boot_io.h:144
io32_t SR
The Status Register.
Definition: boot_io.h:213
io32_t RDMA
The Read Length.
Definition: boot_io.h:209
io32_t WDMA
The Write Length.
Definition: boot_io.h:211
io32_t V_LIMITS
The Virtical Limits.
Definition: boot_io.h:150
io32_t SR
The Status Register.
Definition: boot_io.h:187
io32_t H_LIMITS
The Horizontal Limits.
Definition: boot_io.h:148
io32_t MADDR
The Memory Address.
Definition: boot_io.h:205
io32_t H_SYNC_LEAP
The Horizontal Sync Leap.
Definition: boot_io.h:146
io32_t H_SCALE
The Horizontal Scale.
Definition: boot_io.h:154
io32_t LEN
The Length of bytes.
Definition: boot_io.h:183
io32_t COLOR_BURST
The Colour Burst.
Definition: boot_io.h:152
io32_t V_SYNC
The Virtical Sync.
Definition: boot_io.h:142
io32_t CR
The Control Register.
Definition: boot_io.h:130
io32_t CR
The Control Register.
Definition: boot_io.h:185
io32_t V_SCALE
The Virtical Scale.
Definition: boot_io.h:156
io32_t MADDR
The Memory Address.
Definition: boot_io.h:181
io32_t H_WIDTH
The Horizontal Width.
Definition: boot_io.h:134
io32_t V_INTR
The Virtical Interupt.
Definition: boot_io.h:136
io32_t MADDR
The Memory Address.
Definition: boot_io.h:132
Audio Interface Registers Structure.
Definition: boot_io.h:179
DPC Registers Structure.
Definition: boot_io.h:90
OS Information Structure.
Definition: boot_io.h:245
Peripheral Interface Register Structure.
Definition: boot_io.h:203
Memory Structure.
Definition: boot_io.h:22
SP Registers Structure.
Definition: boot_io.h:31
Video Interface Registers Structure.
Definition: boot_io.h:128