/[pcsx2_0.9.7]/trunk/fps2bios/kernel/eeload/include/eekernel.h
ViewVC logotype

Contents of /trunk/fps2bios/kernel/eeload/include/eekernel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Mon Sep 6 11:40:06 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 12461 byte(s)
exported r3113 from ./upstream/trunk
1 #ifndef __EEKERNEL_H__
2 #define __EEKERNEL_H__
3
4 #include <tamtypes.h>
5 #include <kernel.h>
6
7
8 #define RCNT0_COUNT *(volatile int*)0xB0000000
9 #define RCNT0_MODE *(volatile int*)0xB0000010
10 #define RCNT0_TARGET *(volatile int*)0xB0000020
11 #define RCNT0_HOLD *(volatile int*)0xB0000030
12
13 #define RCNT1_COUNT *(volatile int*)0xB0000800
14 #define RCNT1_MODE *(volatile int*)0xB0000810
15 #define RCNT1_TARGET *(volatile int*)0xB0000820
16 #define RCNT1_HOLD *(volatile int*)0xB0000830
17
18 #define RCNT2_COUNT *(volatile int*)0xB0001000
19 #define RCNT2_MODE *(volatile int*)0xB0001010
20 #define RCNT2_TARGET *(volatile int*)0xB0001020
21
22 #define RCNT3_COUNT *(volatile int*)0xB0001800
23 #define RCNT3_MODE *(volatile int*)0xB0001810
24 #define RCNT3_TARGET *(volatile int*)0xB0001820
25
26 #define GIF_CTRL *(volatile int*)0xB0003000
27
28 #define GIF_FIFO *(volatile u128*)0xB0006000
29
30 //SIF0
31 #define D5_CHCR *(volatile int*)0xB000C000
32 #define D5_MADR *(volatile int*)0xB000C010
33 #define D5_QWC *(volatile int*)0xB000C020
34
35 //SIF1
36 #define D6_CHCR *(volatile int*)0xB000C400
37 #define D6_MADR *(volatile int*)0xB000C410
38 #define D6_QWC *(volatile int*)0xB000C420
39 #define D6_TAG *(volatile int*)0xB000C430
40
41 #define DMAC_CTRL *(volatile int*)0xB000E000
42 #define DMAC_STAT *(volatile int*)0xB000E010
43 #define DMAC_PCR *(volatile int*)0xB000E020
44 #define DMAC_SQWC *(volatile int*)0xB000E030
45 #define DMAC_RBSR *(volatile int*)0xB000E040
46 #define DMAC_RBOR *(volatile int*)0xB000E050
47 #define DMAC_STADR *(volatile int*)0xB000E060
48
49 #define INTC_STAT *(volatile int*)0xB000F000
50 #define INTC_MASK *(volatile int*)0xB000F010
51
52 #define SBUS_MSFLG *(volatile int*)0xB000F220
53 #define SBUS_SMFLG *(volatile int*)0xB000F230
54 #define SBUS_F240 *(volatile int*)0xB000F240
55
56 #define DMAC_ENABLER *(volatile int*)0xB000F520
57 #define DMAC_ENABLEW *(volatile int*)0xB000F590
58
59 #define SBFLG_IOPALIVE 0x10000
60 #define SBFLG_IOPSYNC 0x40000
61
62 #define GS_PMODE *(volatile u64*)0xB2000000
63 #define GS_SMODE1 *(volatile u64*)0xB2000010
64 #define GS_SMODE2 *(volatile u64*)0xB2000020
65 #define GS_SRFSH *(volatile u64*)0xB2000030
66 #define GS_SYNCH1 *(volatile u64*)0xB2000040
67 #define GS_SYNCH2 *(volatile u64*)0xB2000050
68 #define GS_SYNCV *(volatile u64*)0xB2000060
69 #define GS_DISPFB1 *(volatile u64*)0xB2000070
70 #define GS_DISPLAY1 *(volatile u64*)0xB2000080
71 #define GS_DISPFB2 *(volatile u64*)0xB2000090
72 #define GS_DISPLAY2 *(volatile u64*)0xB20000A0
73 #define GS_EXTBUF *(volatile u64*)0xB20000B0
74 #define GS_EXTDATA *(volatile u64*)0xB20000C0
75 #define GS_EXTWRITE *(volatile u64*)0xB20000D0
76 #define GS_BGCOLOR *(volatile u64*)0xB20000E0
77 #define GS_CSR *(volatile u64*)0xB2001000
78 #define GS_IMR *(volatile u64*)0xB2001010
79 #define GS_BUSDIR *(volatile u64*)0xB2001040
80 #define GS_SIGLBLID *(volatile u64*)0xB2001080
81
82 #define INTC_GS 0
83 #define INTC_SBUS 1
84 #define INTC_VBLANK_S 2
85 #define INTC_VBLANK_E 3
86 #define INTC_VIF0 4
87 #define INTC_VIF1 5
88 #define INTC_VU0 6
89 #define INTC_VU1 7
90 #define INTC_IPU 8
91 #define INTC_TIM0 9
92 #define INTC_TIM1 10
93 #define INTC_TIM2 11
94 #define INTC_TIM3 12 //threads
95 //#define INTC_13 13 //not used
96 //#define INTC_14 14 //not used
97
98 #define DMAC_VIF0 0
99 #define DMAC_VIF1 1
100 #define DMAC_GIF 2
101 #define DMAC_FROM_IPU 3
102 #define DMAC_TO_IPU 4
103 #define DMAC_SIF0 5
104 #define DMAC_SIF1 6
105 #define DMAC_SIF2 7
106 #define DMAC_FROM_SPR 8
107 #define DMAC_TO_SPR 9
108 //#define DMAC_10 10 //not used
109 //#define DMAC_11 11 //not used
110 //#define DMAC_12 12 //not used
111 //#define DMAC_13 13 //not used
112 //#define DMAC_14 14 //not used
113 #define DMAC_ERROR 15
114
115 ///////////////////////
116 // DMA TAG REGISTERS //
117 ///////////////////////
118 #define DMA_TAG_REFE 0x00
119 #define DMA_TAG_CNT 0x01
120 #define DMA_TAG_NEXT 0x02
121 #define DMA_TAG_REF 0x03
122 #define DMA_TAG_REFS 0x04
123 #define DMA_TAG_CALL 0x05
124 #define DMA_TAG_RET 0x06
125 #define DMA_TAG_END 0x07
126
127 // Modes for DMA transfers
128 #define SIF_DMA_FROM_IOP 0x0
129 #define SIF_DMA_TO_IOP 0x1
130 #define SIF_DMA_FROM_EE 0x0
131 #define SIF_DMA_TO_EE 0x1
132
133 #define SIF_DMA_INT_I 0x2
134 #define SIF_DMA_INT_O 0x4
135 #define SIF_DMA_SPR 0x8
136 #define SIF_DMA_BSN 0x10 /* ? what is this? */
137 #define SIF_DMA_TAG 0x20
138 #define SIF_DMA_ERT 0x40
139 #define DMA_TAG_IRQ 0x80000000
140 #define DMA_TAG_PCE 0x0C000000
141
142 #define KSEG1_ADDR(x) (((u32)(x))|0xA0000000)
143 #define KUSEG_ADDR(x) (((u32)(x))&0x1FFFFFFF)
144
145 #define MAX_SEMAS 256
146 #define STACK_RES 0x2A0
147
148 //?
149 #define SRInitVal 0x70030C13
150 #define ConfigInitVal 0x73003
151
152 enum {
153 THS_RUN = 0x01,
154 THS_READY = 0x02,
155 THS_WAIT = 0x04,
156 THS_SUSPEND = 0x08,
157 THS_DORMANT = 0x10,
158 };
159
160 typedef struct {
161 u128 gpr[24]; // v0-t9 (skip r0,at,k0-ra)
162 u128 gp;
163 u128 fp;
164 u128 hi;
165 u128 lo;
166 u32 sa;
167 } eeRegs;
168
169 struct ThreadParam {
170 int status;
171 void (*entry)(void*);
172 void *stack;
173 int stackSize;
174 void *gpReg;
175 int initPriority;
176 int currentPriority;
177 u32 attr;
178 u32 option;
179 int waitSema; // waitType?
180 int waitId;
181 int wakeupCount;
182 };
183
184 struct TCB { //internal struct
185 struct TCB *next; //+00
186 struct TCB *prev; //+04
187 int status;//+08
188 void (*entry)(void*); //+0C
189 void *stack_res; //+10 initial $sp
190 void *gpReg; //+14
191 short currentPriority; //+18
192 short initPriority; //+1A
193 int waitSema, //+1C waitType?
194 semaId, //+20
195 wakeupCount, //+24
196 attr, //+28
197 option; //+2C
198 void (*entry_)(void*); //+30
199 int argc; //+34
200 char *argstring;//+38
201 void *stack;//+3C
202 int stackSize; //+40
203 int (*root)(); //+44
204 void* heap_base; //+48
205 };
206
207 struct threadCtx {
208 u128 gpr[25]; // at-t9, (skip r0,k0-ra)
209 u128 gp; //+190
210 u128 sp; //+1A0
211 u128 fp; //+1B0
212 u128 ra; //+1C0
213 u128 hi; //+1D0
214 u128 lo; //+1E0
215 u32 sa; //+1F0
216 u32 cf31;//+1F4
217 u32 acc; //+1F8
218 u32 res; //+1FC
219 u32 fpr[32];//+200
220 };
221
222 typedef struct tag_ARGS{
223 int argc;
224 char *argv[16];
225 char args[256];
226 } ARGS;
227
228 struct SemaParam {
229 int count;
230 int max_count;
231 int init_count;
232 int wait_threads;
233 int attr;
234 u32 option;
235 };
236
237 struct kSema { // internal struct
238 struct kSema *free;//+00
239 int count;//+04
240 int max_count;//+08
241 int attr;//+0C
242 int option;//+10
243 int wait_threads;//+14
244 struct TCB *wait_next,//+18
245 *wait_prev;//+1C
246 };
247
248 struct ll { struct ll *next, *prev; }; //linked list
249
250 //internal struct
251 struct IDhandl { //intc dmac handler
252 struct ll *next, //+00
253 *prev; //+04
254 int (*handler)(int); //+08
255 u32 gp; //+0C
256 void *arg; //+10
257 int flag; //+14
258 };
259
260 //internal struct
261 struct HCinfo{ //handler cause info
262 int count;
263 struct ll l;
264 };
265
266 extern u128 SavedSP;
267 extern u128 SavedRA;
268 extern u128 SavedAT;
269 extern u64 SavedT9;
270
271 extern eeRegs SavedRegs;
272
273 extern u32 excepRA;
274 extern u32 excepSP;
275
276 extern u32 (*table_CpuConfig[6])(u32);
277 extern void (*table_SYSCALL[0x80])();
278
279 extern void (*VCRTable[14])();
280 extern void (*VIntTable[8])();
281 extern void (*INTCTable[16])(int);
282 extern void (*DMACTable[16])(int);
283
284 extern int threadId;
285 extern int threadPrio;
286 extern int threadStatus;
287
288 extern u64 hvParam;
289
290 extern u32 machineType;
291 extern u64 gsIMR;
292 extern u32 memorySize;
293
294 extern u32 g_kernelstackend;
295
296 extern u32 dmac_CHCR[10];
297
298 extern int VSyncFlag0;
299 extern int VSyncFlag1;
300
301 extern int _HandlersCount;
302 extern struct ll handler_ll_free, *ihandlers_last, *ihandlers_first;
303 extern struct HCinfo intcs_array[14];
304 extern struct ll *dhandlers_last, *dhandlers_first;
305 extern struct HCinfo dmacs_array[15];
306 extern struct IDhandl pgifhandlers_array[161];
307 extern void (*sbus_handlers[32])(int ca);
308
309 extern int rcnt3Code;
310 extern int rcnt3TargetTable[0x142];
311 extern u8 rcnt3TargetNum[0x40];
312 extern int threads_count;
313 extern struct ll thread_ll_free;
314 extern struct ll thread_ll_priorities[128];
315 extern int semas_count;
316 extern struct kSema* semas_last;
317
318 extern struct TCB threads_array[256];
319 extern struct kSema semas_array[256];
320
321 extern char tagindex;
322 extern short transferscount;
323 extern struct TAG{
324 int id_qwc;
325 int addr;
326 int unk[2];
327 } tadrptr[31];
328 extern int extrastorage[(16/4) * 8][31];
329
330 extern int osdConfigParam;
331
332 // syscalls
333 // Every syscall is officially prefixed with _ (to avoid clashing with ps2sdk)
334 void _SetSYSCALL(int num, int address);
335 int __EnableIntc(int ch);
336 int __DisableIntc(int ch);
337 int __EnableDmac(int ch);
338 int __DisableDmac(int ch);
339 void *_SetVTLBRefillHandler(int cause, void (*handler)());
340 void *_SetVCommonHandler(int cause, void (*handler)());
341 void *_SetVInterruptHandler(int cause, void (*handler)());
342 void _PSMode();
343 u32 _MachineType();
344 u32 _SetMemorySize(u32 size);
345 u32 _GetMemorySize();
346 u64 _GsGetIMR();
347 u64 _GsPutIMR(u64 val);
348 int _Exit(); // 3
349 void _RFU___(); // 0
350 void _SetVSyncFlag(int flag0, int flag1);
351 int _AddIntcHandler(int cause, int (*handler)(int), int next, void *arg);
352 int _AddIntcHandler2(int cause, int (*handler)(int), int next, void *arg);
353 int _RemoveIntcHandler(int cause, int hid);
354 int _AddDmacHandler(int cause, int (*handler)(int), int next, void *arg);
355 int _AddDmacHandler2(int cause, int (*handler)(int), int next, void *arg);
356 int _RemoveDmacHandler(int code, int hid);
357 int _AddSbusIntcHandler(int cause, void (*handler)(int ca));
358 int _RemoveSbusIntcHandler(int cause);
359 int _Interrupt2Iop(int cause);
360 void _RFU005();
361 int _GetCop0(int reg);
362 int _ExecPS2(void *, void *, int, char **);
363 int _DeleteThread(int tid);
364 int _StartThread(int tid, void *arg);
365 int _ExitThread();
366 int _ExitDeleteThread();
367 int _SleepThread();
368 int _WakeupThread(int tid);
369 int _WaitSema(int sid);
370 void _ChangeThreadPriority(int tid, int prio);
371 int _CreateThread(struct ThreadParam *param);
372 int _iChangeThreadPriority(int tid, int prio);
373 int _GetThreadId();
374 int _ReferThreadStatus(int tid, struct ThreadParam *info);
375 int _iWakeupThread(int tid);
376 int _SuspendThread(int thid);
377 int _iResumeThread(int tid);
378 int _CancelWakeupThread(int tid);
379 int _CreateEventFlag();
380 int _CreateSema(struct SemaParam *sema);
381 int _RFU073(int sid);
382 int _iSignalSema(int sid);
383 int _PollSema(int sid);
384 int _ReferSemaStatus(int sid, struct SemaParam *sema);
385 int _DeleteEventFlag();
386 void*_InitializeMainThread(u32 gp, void *stack, int stack_size,
387 char *args, int root);
388 void *_InitializeHeapArea(void *heap_base, int heap_size);
389 void *_EndOfHeap();
390 int _LoadPS2Exe(char *filename, int argc, char **argv);
391 int _ExecOSD(int argc, char **argv);
392 void _SifSetDChain();
393 void _SifStopDma();
394 u32 _SifSetDma(SifDmaTransfer_t *sdd, int len);
395 void _SetGsCrt(short arg0, short arg1, short arg2); // 2
396 void _GetGsHParam(int *p0, int *p1, int *p2, int *p3);
397 int _GetGsVParam();
398 void _SetGsVParam(int VParam);
399 void _GetOsdConfigParam(int *result);
400 void _SetOsdConfigParam(int *param);
401 int _ResetEE(int init); // 1
402 int _TlbWriteRandom(u32 PageMask, u32 EntryHi, u32 EntryLo0, u32 EntryLo1);
403 int _SetAlarm(short a0, int a1, int a2);
404 void _ReleaseAlarm();
405 int _TerminateThread(int tid);
406 void _RotateThreadReadyQueue(int prio);
407 int _iTerminateThread(int tid);
408 int _DisableDispatchThread();
409 int _EnableDispatchThread();
410 int _iRotateThreadReadyQueue(int prio);
411 void _ReleaseWaitThread(int tid);
412 int _iReleaseWaitThread(int tid);
413 int _ResumeThread(int tid);
414 int _iResumeThread(int tid);
415 void _JoinThread();
416 int _DeleteSema(int sid);
417 int _iDeleteSema(int sid);
418 void _SignalSema(int sid);
419 void _SetGsHParam(int a0, int a1, int a2, int a3);
420 int _SetEventFlag(int ef, u32 bits); // bits is EF_X
421 int _iSetEventFlag(int ef, u32 bits);
422 void _EnableIntcHandler(u32 id);
423 void _DisableIntcHandler(u32 id);
424 void _EnableDmacHandler(u32 id);
425 void _DisableDmacHandler(u32 id);
426 void _KSeg0(u32 arg);
427 int _EnableCache(int cache);
428 int _DisableCache(int cache);
429 void _FlushCache(int op);
430 void _105(int op1, int op2);
431 u32 _CpuConfig(u32 op);
432 void _SetCPUTimerHandler(void (*handler)());
433 void _SetCPUTimer(int compval);
434 void _SetPgifHandler(void (*handler)(int));
435 void _print();
436 int _SifDmaStat(int id);
437
438 int _SifGetReg(int reg);
439 int _SifSetReg(int reg, u32 val);
440
441 ////////////////////////////////////////////////////////////////////
442 // KERNEL BSS //
443 ////////////////////////////////////////////////////////////////////
444
445
446 #endif
447

  ViewVC Help
Powered by ViewVC 1.1.22