Mario Kart 64
Loading...
Searching...
No Matches
os.h
Go to the documentation of this file.
1
2/*====================================================================
3 * os.h
4 *
5 * Copyright 1995, Silicon Graphics, Inc.
6 * All Rights Reserved.
7 *
8 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
9 * Inc.; the contents of this file may not be disclosed to third
10 * parties, copied or duplicated in any form, in whole or in part,
11 * without the prior written permission of Silicon Graphics, Inc.
12 *
13 * RESTRICTED RIGHTS LEGEND:
14 * Use, duplication or disclosure by the Government is subject to
15 * restrictions as set forth in subdivision (c)(1)(ii) of the Rights
16 * in Technical Data and Computer Software clause at DFARS
17 * 252.227-7013, and/or in similar or successor clauses in the FAR,
18 * DOD or NASA FAR Supplement. Unpublished - rights reserved under the
19 * Copyright Laws of the United States.
20 *====================================================================*/
21
22/**************************************************************************
23 *
24 * $Revision: 1.149 $
25 * $Date: 1997/12/15 04:30:52 $
26 * $Source: /disk6/Master/cvsmdev2/PR/include/os.h,v $
27 *
28 **************************************************************************/
29
30#ifndef _OS_H_
31#define _OS_H_
32
33#ifdef _LANGUAGE_C_PLUS_PLUS
34extern "C" {
35#endif
36
37#include <PR/ultratypes.h>
38#include <PR/os_message.h>
39
40#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
41
42/**************************************************************************
43 *
44 * Type definitions
45 *
46 */
47
48/*
49 * Structure for device manager block
50 */
51typedef struct {
52 s32 active; /* Status flag */
53 OSThread* thread; /* Calling thread */
54 OSMesgQueue* cmdQueue; /* Command queue */
55 OSMesgQueue* evtQueue; /* Event queue */
56 OSMesgQueue* acsQueue; /* Access queue */
57 /* Raw DMA routine */
58 s32 (*dma)(s32, u32, void*, u32);
59 s32 (*edma)(OSPiHandle*, s32, u32, void*, u32);
60} OSDevMgr;
61
62/*
63 * Structure for file system
64 */
65
66typedef struct {
67 int status;
68 OSMesgQueue* queue;
69 int channel;
70 u8 id[32];
71 u8 label[32];
72 int version;
73 int dir_size;
74 int inode_table; /* block location */
75 int minode_table; /* mirrioring inode_table */
76 int dir_table; /* block location */
77 int inode_start_page; /* page # */
78 u8 banks;
79 u8 activebank;
80} OSPfs;
81
82typedef struct {
83 u32 file_size; /* bytes */
84 u32 game_code;
85 u16 company_code;
86 char ext_name[4];
87 char game_name[16];
88} OSPfsState;
89
90/*
91 * Structure for Profiler
92 */
93typedef struct {
94 u16* histo_base; /* histogram base */
95 u32 histo_size; /* histogram size */
96 u32* text_start; /* start of text segment */
97 u32* text_end; /* end of text segment */
98} OSProf;
99
100#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
101
102/**************************************************************************
103 *
104 * Global definitions
105 *
106 */
107
108/* Thread states */
109
110#define OS_STATE_STOPPED 1
111#define OS_STATE_RUNNABLE 2
112#define OS_STATE_RUNNING 4
113#define OS_STATE_WAITING 8
114
115/* Events */
116#ifdef _FINALROM
117#define OS_NUM_EVENTS 15
118#else
119#define OS_NUM_EVENTS 23
120#endif
121
122#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */
123#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */
124#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */
125#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */
126#define OS_EVENT_SP 4 /* SP task done interrupt */
127#define OS_EVENT_SI 5 /* SI (controller) interrupt */
128#define OS_EVENT_AI 6 /* AI interrupt */
129#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */
130#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */
131#define OS_EVENT_DP 9 /* DP full sync interrupt */
132#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */
133#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */
134#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */
135#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */
136#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */
137#ifndef _FINALROM
138#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */
139#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */
140#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */
141#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */
142#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */
143#define OS_EVENT_RDB_DBG_DONE 20
144#define OS_EVENT_RDB_FLUSH_PROF 21
145#define OS_EVENT_RDB_ACK_PROF 22
146#endif
147
148/* Flags for debugging purpose */
149
150#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */
151#define OS_FLAG_FAULT 2 /* CPU fault has occurred */
152
153/* Interrupt masks */
154
155#define OS_IM_NONE 0x00000001
156#define OS_IM_SW1 0x00000501
157#define OS_IM_SW2 0x00000601
158#define OS_IM_CART 0x00000c01
159#define OS_IM_PRENMI 0x00001401
160#define OS_IM_RDBWRITE 0x00002401
161#define OS_IM_RDBREAD 0x00004401
162#define OS_IM_COUNTER 0x00008401
163#define OS_IM_CPU 0x0000ff01
164#define OS_IM_SP 0x00010401
165#define OS_IM_SI 0x00020401
166#define OS_IM_AI 0x00040401
167#define OS_IM_VI 0x00080401
168#define OS_IM_PI 0x00100401
169#define OS_IM_DP 0x00200401
170#define OS_IM_ALL 0x003fff01
171#define RCP_IMASK 0x003f0000
172#define RCP_IMASKSHIFT 16
173
174/* Recommended thread priorities for the system threads */
175
176#define OS_PRIORITY_MAX 255
177#define OS_PRIORITY_VIMGR 254
178#define OS_PRIORITY_RMON 250
179#define OS_PRIORITY_RMONSPIN 200
180#define OS_PRIORITY_PIMGR 150
181#define OS_PRIORITY_SIMGR 140
182#define OS_PRIORITY_APPMAX 127
183#define OS_PRIORITY_IDLE 0 /* Must be 0 */
184
185/* Flags to turn blocking on/off when sending/receiving message */
186
187#define OS_MESG_NOBLOCK 0
188#define OS_MESG_BLOCK 1
189
190/* Flags to indicate direction of data transfer */
191
192#define OS_READ 0 /* device -> RDRAM */
193#define OS_WRITE 1 /* device <- RDRAM */
194#define OS_OTHERS 2 /* for Leo disk only */
195
196/*
197 * I/O message types
198 */
199#define OS_MESG_TYPE_BASE (10)
200#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE + 0)
201#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE + 1)
202#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE + 2)
203#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE + 3)
204#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE + 4)
205#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE + 5)
206#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE + 6)
207
208/*
209 * I/O message priority
210 */
211#define OS_MESG_PRI_NORMAL 0
212#define OS_MESG_PRI_HIGH 1
213
214/*
215 * Page size argument for TLB routines
216 */
217#define OS_PM_4K 0x0000000
218#define OS_PM_16K 0x0006000
219#define OS_PM_64K 0x001e000
220#define OS_PM_256K 0x007e000
221#define OS_PM_1M 0x01fe000
222#define OS_PM_4M 0x07fe000
223#define OS_PM_16M 0x1ffe000
224
225/*
226 * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager),
227 * SIM (SI Manager)
228 *
229 */
230#define OS_PIM_STACKSIZE 4096
231#define OS_VIM_STACKSIZE 4096
232#define OS_SIM_STACKSIZE 4096
233
234#define OS_MIN_STACKSIZE 72
235
236/*
237 * Values for osTvType
238 */
239#define OS_TV_PAL 0
240#define OS_TV_NTSC 1
241#define OS_TV_MPAL 2
242
243/*
244 * Video Interface (VI) mode type
245 */
246#define OS_VI_NTSC_LPN1 0 /* NTSC */
247#define OS_VI_NTSC_LPF1 1
248#define OS_VI_NTSC_LAN1 2
249#define OS_VI_NTSC_LAF1 3
250#define OS_VI_NTSC_LPN2 4
251#define OS_VI_NTSC_LPF2 5
252#define OS_VI_NTSC_LAN2 6
253#define OS_VI_NTSC_LAF2 7
254#define OS_VI_NTSC_HPN1 8
255#define OS_VI_NTSC_HPF1 9
256#define OS_VI_NTSC_HAN1 10
257#define OS_VI_NTSC_HAF1 11
258#define OS_VI_NTSC_HPN2 12
259#define OS_VI_NTSC_HPF2 13
260
261#define OS_VI_PAL_LPN1 14 /* PAL */
262#define OS_VI_PAL_LPF1 15
263#define OS_VI_PAL_LAN1 16
264#define OS_VI_PAL_LAF1 17
265#define OS_VI_PAL_LPN2 18
266#define OS_VI_PAL_LPF2 19
267#define OS_VI_PAL_LAN2 20
268#define OS_VI_PAL_LAF2 21
269#define OS_VI_PAL_HPN1 22
270#define OS_VI_PAL_HPF1 23
271#define OS_VI_PAL_HAN1 24
272#define OS_VI_PAL_HAF1 25
273#define OS_VI_PAL_HPN2 26
274#define OS_VI_PAL_HPF2 27
275
276#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */
277#define OS_VI_MPAL_LPF1 29
278#define OS_VI_MPAL_LAN1 30
279#define OS_VI_MPAL_LAF1 31
280#define OS_VI_MPAL_LPN2 32
281#define OS_VI_MPAL_LPF2 33
282#define OS_VI_MPAL_LAN2 34
283#define OS_VI_MPAL_LAF2 35
284#define OS_VI_MPAL_HPN1 36
285#define OS_VI_MPAL_HPF1 37
286#define OS_VI_MPAL_HAN1 38
287#define OS_VI_MPAL_HAF1 39
288#define OS_VI_MPAL_HPN2 40
289#define OS_VI_MPAL_HPF2 41
290
291/*
292 * Video Interface (VI) special features
293 */
294#define OS_VI_GAMMA_ON 0x0001
295#define OS_VI_GAMMA_OFF 0x0002
296#define OS_VI_GAMMA_DITHER_ON 0x0004
297#define OS_VI_GAMMA_DITHER_OFF 0x0008
298#define OS_VI_DIVOT_ON 0x0010
299#define OS_VI_DIVOT_OFF 0x0020
300#define OS_VI_DITHER_FILTER_ON 0x0040
301#define OS_VI_DITHER_FILTER_OFF 0x0080
302
303/*
304 * Video Interface (VI) mode attribute bit
305 */
306#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */
307#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */
308#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */
309#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */
310#define OS_VI_BIT_ANTIALIAS 0x0010
311#define OS_VI_BIT_POINTSAMPLE 0x0020
312#define OS_VI_BIT_16PIXEL 0x0040
313#define OS_VI_BIT_32PIXEL 0x0080
314#define OS_VI_BIT_LORES 0x0100
315#define OS_VI_BIT_HIRES 0x0200
316#define OS_VI_BIT_NTSC 0x0400
317#define OS_VI_BIT_PAL 0x0800
318
319/*
320 * Leo Disk
321 */
322
323/* transfer mode */
324
325#define LEO_BLOCK_MODE 1
326#define LEO_TRACK_MODE 2
327#define LEO_SECTOR_MODE 3
328
329/*
330 * Controllers number
331 */
332
333#ifndef _HW_VERSION_1
334#define MAXCONTROLLERS 4
335#else
336#define MAXCONTROLLERS 6
337#endif
338
339/* controller errors */
340#define CONT_NO_RESPONSE_ERROR 0x8
341#define CONT_OVERRUN_ERROR 0x4
342#ifdef _HW_VERSION_1
343#define CONT_FRAME_ERROR 0x2
344#define CONT_COLLISION_ERROR 0x1
345#endif
346
347/* Controller type */
348
349#define CONT_ABSOLUTE 0x0001
350#define CONT_RELATIVE 0x0002
351#define CONT_JOYPORT 0x0004
352#define CONT_EEPROM 0x8000
353#define CONT_EEP16K 0x4000
354#define CONT_TYPE_MASK 0x1f07
355#define CONT_TYPE_NORMAL 0x0005
356#define CONT_TYPE_MOUSE 0x0002
357
358/* Controller status */
359
360#define CONT_CARD_ON 0x01
361#define CONT_CARD_PULL 0x02
362#define CONT_ADDR_CRC_ER 0x04
363#define CONT_EEPROM_BUSY 0x80
364
365/* EEPROM TYPE */
366
367#define EEPROM_TYPE_4K 0x01
368#define EEPROM_TYPE_16K 0x02
369
370/* Buttons */
371
372#define CONT_A 0x8000
373#define CONT_B 0x4000
374#define CONT_G 0x2000
375#define CONT_START 0x1000
376#define CONT_UP 0x0800
377#define CONT_DOWN 0x0400
378#define CONT_LEFT 0x0200
379#define CONT_RIGHT 0x0100
380#define CONT_L 0x0020
381#define CONT_R 0x0010
382#define CONT_E 0x0008
383#define CONT_D 0x0004
384#define CONT_C 0x0002
385#define CONT_F 0x0001
386
387/* Nintendo's official button names */
388
389#define A_BUTTON CONT_A
390#define B_BUTTON CONT_B
391#define L_TRIG CONT_L
392#define R_TRIG CONT_R
393#define Z_TRIG CONT_G
394#define START_BUTTON CONT_START
395#define U_JPAD CONT_UP
396#define L_JPAD CONT_LEFT
397#define R_JPAD CONT_RIGHT
398#define D_JPAD CONT_DOWN
399#define U_CBUTTONS CONT_E
400#define L_CBUTTONS CONT_C
401#define R_CBUTTONS CONT_F
402#define D_CBUTTONS CONT_D
403
404/* File System size */
405#define OS_PFS_VERSION 0x0200
406#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8)
407#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255)
408
409#define PFS_FILE_NAME_LEN 16
410#define PFS_FILE_EXT_LEN 4
411#define BLOCKSIZE 32 /* bytes */
412#define PFS_ONE_PAGE 8 /* blocks */
413#define PFS_MAX_BANKS 62
414
415/* File System flag */
416
417#define PFS_READ 0
418#define PFS_WRITE 1
419#define PFS_CREATE 2
420
421/* File System status */
422#define PFS_INITIALIZED 0x1
423#define PFS_CORRUPTED 0x2 /* File system was corrupted */
424
425/* File System error number */
426
427#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */
428#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */
429 /* different one */
430#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */
431#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR
432#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/
433#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/
434#define PFS_DATA_FULL 7 /* no free pages on ram pack */
435#define PFS_DIR_FULL 8 /* no free directories on ram pack*/
436#define PFS_ERR_EXIST 9 /* file exists */
437#define PFS_ERR_ID_FATAL 10 /* dead ram pack */
438#define PFS_ERR_DEVICE 11 /* wrong device type*/
439
440/* definition for EEPROM */
441
442#define EEPROM_MAXBLOCKS 64
443#define EEP16K_MAXBLOCKS 256
444#define EEPROM_BLOCK_SIZE 8
445
446/*
447 * PI/EPI
448 */
449#define PI_DOMAIN1 0
450#define PI_DOMAIN2 1
451
452/*
453 * Profiler constants
454 */
455#define PROF_MIN_INTERVAL 50 /* microseconds */
456
457/*
458 * Boot addresses
459 */
460#define BOOT_ADDRESS_ULTRA 0x80000400
461#define BOOT_ADDRESS_COSIM 0x80002000
462#define BOOT_ADDRESS_EMU 0x20010000
463#define BOOT_ADDRESS_INDY 0x88100000
464
465/*
466 * Size of buffer the retains contents after NMI
467 */
468#define OS_APP_NMI_BUFSIZE 64
469
470#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
471
472/**************************************************************************
473 *
474 * Macro definitions
475 *
476 */
477
478/* PARTNER-N64 */
479#ifdef PTN64
480#define osReadHost osReadHost_pt
481#define osWriteHost osWriteHost_pt
482#endif
483
484/* Get count of valid messages in queue */
485#define MQ_GET_COUNT(mq) ((mq)->validCount)
486
487/* Figure out if message queue is empty or full */
488#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0)
489#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount)
490
491/*
492 * CPU counter increments at 3/4 of bus clock rate:
493 *
494 * Bus Clock Proc Clock Counter (1/2 Proc Clock)
495 * --------- ---------- ------------------------
496 * 62.5 Mhz 93.75 Mhz 46.875 Mhz
497 */
498extern u64 osClockRate;
499
500#define OS_CLOCK_RATE 62500000LL
501#define OS_CPU_COUNTER (OS_CLOCK_RATE * 3 / 4)
502#define OS_NSEC_TO_CYCLES(n) (((u64) (n) * (OS_CPU_COUNTER / 15625000LL)) / (1000000000LL / 15625000LL))
503#define OS_USEC_TO_CYCLES(n) (((u64) (n) * (OS_CPU_COUNTER / 15625LL)) / (1000000LL / 15625LL))
504#define OS_CYCLES_TO_NSEC(c) (((u64) (c) * (1000000000LL / 15625000LL)) / (OS_CPU_COUNTER / 15625000LL))
505#define OS_CYCLES_TO_USEC(c) (((u64) (c) * (1000000LL / 15625LL)) / (OS_CPU_COUNTER / 15625LL))
506
507/**************************************************************************
508 *
509 * Extern variables
510 *
511 */
512extern OSViMode osViModeTable[]; /* Global VI mode table */
513
514extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */
515extern OSViMode osViModeNtscLpf1;
517extern OSViMode osViModeNtscLaf1;
518extern OSViMode osViModeNtscLpn2;
519extern OSViMode osViModeNtscLpf2;
520extern OSViMode osViModeNtscLan2;
521extern OSViMode osViModeNtscLaf2;
522extern OSViMode osViModeNtscHpn1;
523extern OSViMode osViModeNtscHpf1;
524extern OSViMode osViModeNtscHan1;
525extern OSViMode osViModeNtscHaf1;
526extern OSViMode osViModeNtscHpn2;
527extern OSViMode osViModeNtscHpf2;
528
529extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */
530extern OSViMode osViModePalLpf1;
532extern OSViMode osViModePalLaf1;
533extern OSViMode osViModePalLpn2;
534extern OSViMode osViModePalLpf2;
535extern OSViMode osViModePalLan2;
536extern OSViMode osViModePalLaf2;
537extern OSViMode osViModePalHpn1;
538extern OSViMode osViModePalHpf1;
539extern OSViMode osViModePalHan1;
540extern OSViMode osViModePalHaf1;
541extern OSViMode osViModePalHpn2;
542extern OSViMode osViModePalHpf2;
543
544extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */
545extern OSViMode osViModeMpalLpf1;
547extern OSViMode osViModeMpalLaf1;
548extern OSViMode osViModeMpalLpn2;
549extern OSViMode osViModeMpalLpf2;
550extern OSViMode osViModeMpalLan2;
551extern OSViMode osViModeMpalLaf2;
552extern OSViMode osViModeMpalHpn1;
553extern OSViMode osViModeMpalHpf1;
554extern OSViMode osViModeMpalHan1;
555extern OSViMode osViModeMpalHaf1;
556extern OSViMode osViModeMpalHpn2;
557extern OSViMode osViModeMpalHpf2;
558
559extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */
560extern u32 osRomBase; /* Rom base address of the game image */
561extern u32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */
562extern u32 osResetType; /* 0 = cold reset, 1 = NMI */
563extern s32 osCicId;
564extern s32 osVersion;
565extern u32 osMemSize; /* Memory Size */
566extern s32 osAppNMIBuffer[];
567
568extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */
569extern OSPiHandle* __osPiTable; /* The head of OSPiHandle link list */
570extern OSPiHandle* __osDiskHandle; /* For exceptasm to get disk info*/
571
572/**************************************************************************
573 *
574 * Function prototypes
575 *
576 */
577
578/* Thread operations */
579
580extern void osCreateThread(OSThread*, OSId, void (*)(void*), void*, void*, OSPri);
581extern void osDestroyThread(OSThread*);
582extern void osYieldThread(void);
583extern void osStartThread(OSThread*);
584extern void osStopThread(OSThread*);
586extern void osSetThreadPri(OSThread*, OSPri);
588
589/* Message operations */
590
591extern void osCreateMesgQueue(OSMesgQueue*, OSMesg*, s32);
592extern s32 osSendMesg(OSMesgQueue*, OSMesg, s32);
593extern s32 osJamMesg(OSMesgQueue*, OSMesg, s32);
594extern s32 osRecvMesg(OSMesgQueue*, OSMesg*, s32);
595
596/* Event operations */
597
598extern void osSetEventMesg(OSEvent, OSMesgQueue*, OSMesg);
599
600/* Interrupt operations */
601
602extern OSIntMask osGetIntMask(void);
603extern OSIntMask osSetIntMask(OSIntMask);
604
605/* RDB port operations */
606
607extern void osInitRdb(u8* sendBuf, u32 sendSize);
608
609/* Cache operations and macros */
610
611extern void osInvalDCache(void*, size_t);
612extern void osInvalICache(void*, size_t);
613extern void osWritebackDCache(void*, size_t);
614extern void osWritebackDCacheAll(void);
615
616#define OS_DCACHE_ROUNDUP_ADDR(x) (void*) (((((u32) (x) + 0xf) / 0x10) * 0x10))
617#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32) (x) + 0xf) / 0x10) * 0x10))
618
619/* TLB management routines */
620
621extern void osMapTLB(s32, OSPageMask, void*, u32, u32, s32);
622extern void osMapTLBRdb(void);
623extern void osUnmapTLB(s32);
624extern void osUnmapTLBAll(void);
625extern void osSetTLBASID(s32);
626
627/* Address translation routines and macros */
628
629extern u32 osVirtualToPhysical(void*);
630extern void* osPhysicalToVirtual(u32);
631
632#define OS_K0_TO_PHYSICAL(x) (u32)(((char*) (x) - 0x80000000))
633#define OS_K1_TO_PHYSICAL(x) (u32)(((char*) (x) - 0xa0000000))
634
635#define OS_PHYSICAL_TO_K0(x) (void*) (((u32) (x) + 0x80000000))
636#define OS_PHYSICAL_TO_K1(x) (void*) (((u32) (x) + 0xa0000000))
637
638/* I/O operations */
639
640/* Audio interface (Ai) */
641extern u32 osAiGetStatus(void);
642extern u32 osAiGetLength(void);
643extern s32 osAiSetFrequency(u32);
644extern s32 osAiSetNextBuffer(void*, u32);
645
646/* Display processor interface (Dp) */
647extern u32 osDpGetStatus(void);
648extern void osDpSetStatus(u32);
649extern void osDpGetCounters(u32*);
650extern s32 osDpSetNextBuffer(void*, u64);
651
652/* Peripheral interface (Pi) */
653extern u32 osPiGetStatus(void);
654extern s32 osPiGetDeviceType(void);
655extern s32 osPiRawWriteIo(u32, u32);
656extern s32 osPiRawReadIo(u32, u32*);
657extern s32 osPiRawStartDma(s32, u32, void*, u32);
658extern s32 osPiWriteIo(u32, u32);
659extern s32 osPiReadIo(u32, u32*);
660extern s32 osPiStartDma(OSIoMesg*, s32, s32, u32, void*, u32, OSMesgQueue*);
661extern void osCreatePiManager(OSPri, OSMesgQueue*, OSMesg*, s32);
662
663/* Video interface (Vi) */
664extern u32 osViGetStatus(void);
665extern u32 osViGetCurrentMode(void);
666extern u32 osViGetCurrentLine(void);
667extern u32 osViGetCurrentField(void);
668extern void* osViGetCurrentFramebuffer(void);
669extern void* osViGetNextFramebuffer(void);
670extern void osViSetXScale(f32);
671extern void osViSetYScale(f32);
672extern void osViSetSpecialFeatures(u32);
673extern void osViSetMode(OSViMode*);
674extern void osViSetEvent(OSMesgQueue*, OSMesg, u32);
675extern void osViSwapBuffer(void*);
676extern void osViBlack(u8);
677extern void osViFade(u8, u16);
678extern void osViRepeatLine(u8);
679extern void osCreateViManager(OSPri);
680
681/* Timer interface */
682
683extern OSTime osGetTime(void);
684extern void osSetTime(OSTime);
685extern u32 osSetTimer(OSTimer*, OSTime, OSTime, OSMesgQueue*, OSMesg);
686extern int osStopTimer(OSTimer*);
687
688/* Controller interface */
689
690extern s32 osContInit(OSMesgQueue*, u8*, OSContStatus*);
691extern s32 osContReset(OSMesgQueue*, OSContStatus*);
692extern s32 osContStartQuery(OSMesgQueue*);
693extern s32 osContStartReadData(OSMesgQueue*);
694#ifndef _HW_VERSION_1
695extern s32 osContSetCh(u8);
696#endif
697extern void osContGetQuery(OSContStatus*);
698extern void osContGetReadData(OSContPad*);
699
700/* file system interface */
701
702extern s32 osPfsInitPak(OSMesgQueue*, OSPfs*, int);
703extern s32 osPfsRepairId(OSPfs*);
704extern s32 osPfsInit(OSMesgQueue*, OSPfs*, int);
705extern s32 osPfsReFormat(OSPfs*, OSMesgQueue*, int);
706extern s32 osPfsChecker(OSPfs*);
707extern s32 osPfsAllocateFile(OSPfs*, u16, u32, u8*, u8*, int, s32*);
708extern s32 osPfsFindFile(OSPfs*, u16, u32, u8*, u8*, s32*);
709extern s32 osPfsDeleteFile(OSPfs*, u16, u32, u8*, u8*);
710extern s32 osPfsReadWriteFile(OSPfs*, s32, u8, int, int, u8*);
711extern s32 osPfsFileState(OSPfs*, s32, OSPfsState*);
712extern s32 osPfsGetLabel(OSPfs*, u8*, int*);
713extern s32 osPfsSetLabel(OSPfs*, u8*);
714extern s32 osPfsIsPlug(OSMesgQueue*, u8*);
715extern s32 osPfsFreeBlocks(OSPfs*, s32*);
716extern s32 osPfsNumFiles(OSPfs*, s32*, s32*);
717
718/* EEPROM interface */
719
720extern s32 osEepromProbe(OSMesgQueue*);
721extern s32 osEepromRead(OSMesgQueue*, u8, u8*);
722extern s32 osEepromWrite(OSMesgQueue*, u8, u8*);
723extern s32 osEepromLongRead(OSMesgQueue*, u8, u8*, s32);
724extern s32 osEepromLongWrite(OSMesgQueue*, u8, u8*, s32);
725
726/* MOTOR interface */
727
728extern s32 osMotorInit(OSMesgQueue*, OSPfs*, int);
729extern s32 osMotorStop(OSPfs*);
730extern s32 osMotorStart(OSPfs*);
731
732/* Enhanced PI interface */
733
734extern OSPiHandle* osCartRomInit(void);
735extern OSPiHandle* osLeoDiskInit(void);
736extern OSPiHandle* osDriveRomInit(void);
737
738extern s32 osEPiDeviceType(OSPiHandle*, OSPiInfo*);
739extern s32 osEPiRawWriteIo(OSPiHandle*, u32, u32);
740extern s32 osEPiRawReadIo(OSPiHandle*, u32, u32*);
741extern s32 osEPiRawStartDma(OSPiHandle*, s32, u32, void*, u32);
743extern s32 osEPiReadIo(OSPiHandle*, u32, u32*);
744extern s32 osEPiStartDma(OSPiHandle*, OSIoMesg*, s32);
745extern s32 osEPiLinkHandle(OSPiHandle*);
746
747/* Profiler Interface */
748
749extern void osProfileInit(OSProf*, u32 profcnt);
750extern void osProfileStart(u32);
751extern void osProfileFlush(void);
752extern void osProfileStop(void);
753
754/* Game <> Host data transfer functions */
755
756extern s32 osTestHost(void);
757extern void osReadHost(void*, u32);
758extern void osWriteHost(void*, u32);
759extern void osAckRamromRead(void);
760extern void osAckRamromWrite(void);
761
762/* byte string operations */
763
764extern void bcopy(const void*, void*, size_t);
765extern int bcmp(const void*, const void*, int);
766extern void bzero(void*, size_t);
767
768/* Miscellaneous operations */
769
770extern void osInitialize(void);
771extern u32 osGetCount(void);
772extern void osExit(void);
773extern u32 osGetMemSize(void);
774
775/* Printf */
776
777extern int sprintf(char* s, const char* fmt, ...);
778extern void osSyncPrintf(const char* fmt, ...);
779extern void osAsyncPrintf(const char* fmt, ...);
780extern int osSyncGetChars(char* buf);
781extern int osAsyncGetChars(char* buf);
782
783#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
784
785#ifdef _LANGUAGE_C_PLUS_PLUS
786}
787#endif
788
789#endif /* !_OS_H */
void osYieldThread(void)
Definition osYieldThread.c:4
u32 osTvType
OSViMode osViModePalLan1
Definition osViData.c:3
OSViMode osViModeNtscLan1
Definition osViData.c:62
OSViMode osViModeMpalLan1
Definition osViData.c:37
int bcmp(const void *, const void *, int)
void bcopy(const void *, void *, size_t)
void bzero(void *, size_t)
s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32)
Definition osRecvMesg.c:3
void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg)
Definition osSetEventMesg.c:10
u64 osClockRate
Definition osInitialize.c:16
void osSyncPrintf(const char *fmt,...)
Definition is_debug.c:74
s32 osEPiWriteIo(OSPiHandle *handle, u32 devAddr, u32 data)
Definition is_debug.c:48
s32 osEPiReadIo(OSPiHandle *handle, u32 devAddr, u32 *data)
Definition is_debug.c:38
u32 osMemSize
s32 osPiRawReadIo(u32 a0, u32 *a1)
Definition osPiRawReadIo.c:6
unsigned long long int u64
Definition llconv.c:2
s32 osEPiRawStartDma(OSPiHandle *arg0, s32 dir, u32 cart_addr, void *dram_addr, u32 size)
Definition osEPiRawStartDma.c:14
volatile u32 __OSGlobalIntMask
Definition osInitialize.c:18
OSPiHandle * __osDiskHandle
Definition osLeoDiskInit.c:12
s32 osAiSetNextBuffer(void *, u32)
Definition osAiSetNextBuffer.c:21
s32 osAiSetFrequency(u32)
Definition osAiSetFrequency.c:7
u32 osAiGetLength(void)
Definition osAiGetLength.c:5
OSPiHandle * osCartRomInit(void)
Definition osCartRomInit.c:12
s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status)
Definition osContInit.c:18
void osContGetReadData(OSContPad *pad)
Definition osContStartReadData.c:33
s32 osContStartReadData(OSMesgQueue *mesg)
Definition osContStartReadData.c:9
void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msgBuf, s32 count)
Definition osCreateMesgQueue.c:3
void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt)
Definition osCreatePiManager.c:23
OSPiHandle * __osPiTable
Definition osCreatePiManager.c:12
void osCreateThread(OSThread *thread, OSId id, void(*entry)(void *), void *arg, void *sp, OSPri pri)
Definition osCreateThread.c:9
void osCreateViManager(OSPri pri)
Definition osCreateViManager.c:22
void osDestroyThread(OSThread *thread)
Definition osDestroyThread.c:3
s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, s32 nbytes)
Definition osEepromLongRead.c:10
s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, s32 nbytes)
Definition osEepromLongWrite.c:10
s32 osEepromProbe(OSMesgQueue *mq)
Definition osEepromProbe.c:6
s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer)
Definition osEepromRead.c:12
s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer)
Definition osEepromWrite.c:12
OSPri osGetThreadPri(OSThread *thread)
Definition osGetThreadPri.c:3
OSTime osGetTime()
Definition osGetTime.c:6
u32 osResetType
void osInitialize(void)
Definition osInitialize.c:29
s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag)
Definition osJamMesg.c:3
OSPiHandle * osLeoDiskInit(void)
Definition osLeoDiskInit.c:14
s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, int file_size_in_bytes, s32 *file_no)
Definition osPfsAllocateFile.c:5
s32 osPfsChecker(OSPfs *pfs)
Definition osPfsChecker.c:6
s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name)
Definition osPfsDeleteFile.c:4
s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state)
Definition osPfsFileState.c:4
s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used)
Definition osPfsFreeBlocks.c:4
s32 osPfsInit(OSMesgQueue *queue, OSPfs *pfs, int channel)
Definition osPfsInit.c:5
s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern)
Definition osPfsIsPlug.c:8
s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used)
Definition osPfsNumFiles.c:5
s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8 *data_buffer)
Definition osPfsReadWriteFile.c:20
s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, s32 *file_no)
Definition osPfsSearchFile.c:4
u32 osRomBase
s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size)
Definition osPiRawStartDma.c:7
s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQueue *mq)
Definition osPiStartDma.c:5
s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag)
Definition osSendMesg.c:3
void osSetThreadPri(OSThread *thread, OSPri pri)
Definition osSetThreadPri.c:3
void osSetTime(OSTime time)
Definition osSetTime.c:5
u32 osSetTimer(OSTimer *a0, OSTime a1, u64 a2, OSMesgQueue *a3, OSMesg a4)
Definition osSetTimer.c:6
void osStartThread(OSThread *thread)
Definition osStartThread.c:3
void osViBlack(u8 active)
Definition osViBlack.c:6
void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount)
Definition osViSetEvent.c:5
void osViSetMode(OSViMode *mode)
Definition osViSetMode.c:5
void osViSetSpecialFeatures(u32 func)
Definition osViSetSpecialFeatures.c:5
void osViSwapBuffer(void *vaddr)
Definition osViSwapBuffer.c:5
OSViMode osViModeTable[]
Definition osViTable.c:3
uintptr_t osVirtualToPhysical(void *addr)
Definition osVirtualToPhysical.c:3
u32 osGetCount(void)
s32 osPiWriteIo(uintptr_t devAddr, u32 data)
s32 osPiReadIo(uintptr_t devAddr, u32 *data)
void osStopThread(OSThread *thread)
s32 OSId
Definition os_thread.h:22
OSId osGetThreadId(OSThread *thread)
s32 OSPri
Definition os_thread.h:21
u64 OSTime
Definition os_time.h:18
int sprintf(char *dst, const char *fmt,...)
Definition sprintf.c:8
Definition os_pi.h:53
Definition os_pi.h:28
Definition os_pi.h:41
Definition os_thread.h:50
Definition os_time.h:9
Definition os_vi.h:48
signed int s32
Definition ultratypes.h:15
unsigned int u32
Definition ultratypes.h:16
float f32
Definition ultratypes.h:34
unsigned short int u16
Definition ultratypes.h:14
unsigned char u8
Definition ultratypes.h:12