ipl4.h
7.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/********************************************************************************
ipl4.h: NINTENDO64 Disk Drive IPL4 header.
February 4, 1987
********************************************************************************/
#ifndef IPL4_H
#define IPL4_H
#include "buffer.h"
#ifdef _LANGUAGE_C
#define Align128(n) (((uint)(n)+15)&0xfffffff0)
#define Align64(n) (((uint)(n)+ 7)&0xfffffff8)
#define Align32(n) (((uint)(n)+ 3)&0xfffffffc)
#define Align16(n) (((uint)(n)+ 1)&0xfffffffe)
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long uwlong;
typedef signed long long wlong;
typedef union {
long word;
short half[2];
char byte[4];
} SPacked;
/********************************************************************************/
/* */
/* */
/* Drive ROM data */
/* */
/* */
/********************************************************************************/
#define FONTDATA_ROMADDR 0x0A0000
#define WAVEDATA_ROMADDR 0x140000
/********************************************************************************/
/* */
/* */
/* Thread ID and thread priority */
/* */
/* */
/********************************************************************************/
#define IDLE_THREAD_ID 1
#define MAIN_THREAD_ID 2
#define GRPH_THREAD_ID 3
#define DISK_THREAD_ID 4
#define BOOT_PRIORITY 20
#define MAIN_PRIORITY 10
#define DISK_PRIORITY 11
#define GRPH_PRIORITY 12
/********************************************************************************/
/* */
/* */
/* OS messages */
/* */
/* */
/********************************************************************************/
#define MESG_GRPH_STOPGFX ((OSMesg)100)
#define MESG_GRPH_RESTART ((OSMesg)101)
#define MESG_GRPH_PRENMI ((OSMesg)102)
#define MESG_GRPH_RETRACE ((OSMesg)110)
#define MESG_GRPH_RSPDONE ((OSMesg)111)
#define MESG_GRPH_RDPDONE ((OSMesg)112)
#define MESG_GRPH_SIMDONE ((OSMesg)113)
#define MESG_MAIN_LOADDONE ((OSMesg)200)
#define MESG_MAIN_GRPHDONE ((OSMesg)201)
#define MESG_DISK_START ((OSMesg)300)
#define MESG_DISK_HANGUP ((OSMesg)301)
#define NUM_PIMG_MESGS 16
#define NUM_MAIN_MESGS 1
#define NUM_GRPH_MESGS 4
#define NUM_DISK_MESGS 1
extern OSMesgQueue mainMesgque; /* main thread message queue */
extern OSMesgQueue grphMesgque; /* graphics thread message queue */
extern OSMesgQueue diskMesgque; /* disk drive thread message queue */
extern OSMesgQueue PimgMesgque; /* PI manager message queue */
/********************************************************************************/
/* */
/* IPL Header record */
/* */
/* This is the structure that should be placed on the system area */
/* of the disk. This structure will probably change. For example, */
/* should we use nbytes or nblocks? */
/* */
/********************************************************************************/
typedef struct IPLHeader {
void * location; /* copy from disk to this location */
void * entry; /* entry point of program */
long skip; /* number of bytes on disk to skip */
long nbytes; /* number of bytes to copy from disk */
long nblocks; /* number of logical blocks to copy */
long firstlba; /* where program resides on disk */
} IPLHeader;
extern IPLHeader bootHeader;
/********************************************************************************/
/* */
/* */
/* Disk Drive clock */
/* */
/* */
/********************************************************************************/
#define CLOCK_STAT_INACTIVE 0
#define CLOCK_STAT_ACTIVE 1
typedef struct DDClock {
uchar year;
uchar month;
uchar day;
uchar hour;
uchar minute;
uchar second;
ushort status;
} DDClock;
extern DDClock diskClock;
/********************************************************************************/
/* */
/* */
/* Disk status */
/* */
/* */
/********************************************************************************/
typedef enum DiskStatus {
DISK_STAT_WAITING,
DISK_STAT_WORKING,
DISK_STAT_LOADING,
DISK_STAT_LOADEND,
DISK_STAT_NODISK,
DISK_STAT_NOCONNECT,
DISK_STAT_BADINSERT,
DISK_STAT_DISKEJECT,
DISK_STAT_DISKERROR
} DiskStatus;
extern DiskStatus diskStatus;
/********************************************************************************/
/* */
/* */
/* Error message */
/* */
/* */
/********************************************************************************/
#define ERRMSG_KINDMASK 0xFF00
#define ERRMSG_NUMMASK 0x00FF
#define ERRMSG_NOERROR 0x0000
#define ERRMSG_NORAMPACK 0x0100
#define ERRMSG_NOCONNECT 0x0200
#define ERRMSG_BADINSERT 0x0300
#define ERRMSG_DISKEJECT 0x0400
#define ERRMSG_DISKERROR 0x0500
#define ERRMSG_CLOCKSTOP 0x0600
/********************************************************************************/
/* */
/* */
/* Main thread status */
/* */
/* */
/********************************************************************************/
#define MAIN_STAT_LOADDONE 0x0001
#define MAIN_STAT_GRPHDONE 0x0002
/********************************************************************************/
/* */
/* */
/* Global variables */
/* */
/* */
/********************************************************************************/
extern int diskErrorNo;
extern int memoryPack;
extern int clockSetting;
extern int systemReset;
extern ulong frameCounter;
/********************************************************************************/
/* */
/* */
/* Disk routines */
/* */
/* */
/********************************************************************************/
extern void DiskProcess(void *arg);
extern void ResetDiskDriver(void);
extern void WriteDDClock(DDClock *time);
extern void BootDiskImage(IPLHeader *header);
extern void FinalBoot(void *);
/********************************************************************************/
/* */
/* Graphics routines */
/* */
/********************************************************************************/
extern char *AllocDynamic(long size);
extern void SetClearColor(uchar red, uchar green, uchar blue);
extern void GrphProcess(void *arg);
extern int DisplayGraphics(OSMesg event);
extern void InitErrorMessage(void);
extern void DrawErrorMessage(int status);
extern char _CodeSegmentEnd[];
extern char _FontSegmentRomStart[];
extern char _ShapeSegmentRomStart[];
extern char _ShapeSegmentRomEnd[];
extern uwlong frameBuffer[2][FRAMEBUFF_SIZE64];
extern uwlong depthBuffer[FRAMEBUFF_SIZE64];
extern uwlong rspDramStack[SP_DRAM_STACK_SIZE64]; /* RSP DRAM stack */
extern uwlong rspFifoBuffer[SP_FIFO_SIZE64];
extern uwlong dynamicMemory[2][DYNAMIC_SIZE64];
/* EPI routine */
extern long osPiStartDma_DriveRomOnly(OSIoMesg *IOMesg, long prio, long dir, ulong romStart, void *ramAddr, ulong size, OSMesgQueue *mesgque);
#endif
#endif