SSBM Decomp
Loading...
Searching...
No Matches
os.h
Go to the documentation of this file.
1#ifndef _DOLPHIN_OS_H_
2#define _DOLPHIN_OS_H_
3
4#include <dolphin/types.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10typedef s64 OSTime;
11typedef u32 OSTick;
12
15
17
18typedef void (*__OSInterruptHandler)(__OSInterrupt interrupt,
19 OSContext* context);
20
21#include <dolphin/os/OSAlarm.h>
22#include <dolphin/os/OSAlloc.h>
23#include <dolphin/os/OSCache.h>
24#include <dolphin/os/OSDC.h>
25#include <dolphin/os/OSError.h>
27#include <dolphin/os/OSFont.h>
28#include <dolphin/os/OSIC.h>
30#include <dolphin/os/OSL2.h>
31#include <dolphin/os/OSLC.h>
33#include <dolphin/os/OSModule.h>
34#include <dolphin/os/OSMutex.h>
35#include <dolphin/os/OSReboot.h>
36#include <dolphin/os/OSReset.h>
38#include <dolphin/os/OSRtc.h>
39#include <dolphin/os/OSSerial.h>
41#include <dolphin/os/OSThread.h>
42#include <dolphin/os/OSTime.h>
43
44// private macro, maybe shouldn't be defined here?
45#define OFFSET(addr, align) (((u32) (addr) & ((align) - 1)))
46#define ROUND(n, a) (((u32) (n) + (a) - 1) & ~((a) - 1))
47#define TRUNC(n, a) (((u32) (n)) & ~((a) - 1))
48
51
52// Upper words of the masks, since UIMM is only 16 bits
53#define OS_CACHED_REGION_PREFIX 0x8000
54#define OS_UNCACHED_REGION_PREFIX 0xC000
55#define OS_PHYSICAL_MASK 0x3FFF
56
57#define OS_BASE_CACHED (OS_CACHED_REGION_PREFIX << 16)
58#define OS_BASE_UNCACHED (OS_UNCACHED_REGION_PREFIX << 16)
59
60#if defined(__MWERKS__) && !defined(M2CTX)
61u32 __OSPhysicalMemSize : (OS_BASE_CACHED | 0x0028);
62volatile int __OSTVMode : (OS_BASE_CACHED | 0x00CC);
63OSThread* __gUnkThread1 : (OS_BASE_CACHED | 0x00D8);
65OSThread* __gCurrentThread : (OS_BASE_CACHED | 0x00E4);
66u32 __OSSimulatedMemSize : (OS_BASE_CACHED | 0x00F0);
69int __EXIProbeStartTime[2] : (OS_BASE_CACHED | 0x30C0);
70#else
71#define __OSBusClock (*(u32*) (OS_BASE_CACHED | 0x00F8))
72#define __OSCoreClock (*(u32*) (OS_BASE_CACHED | 0x00FC))
73#endif
74#define OS_BUS_CLOCK __OSBusClock
75#define OS_CORE_CLOCK __OSCoreClock
76#define OS_TIMER_CLOCK (OS_BUS_CLOCK / 4)
77
78#define OSTicksToSeconds(ticks) ((ticks) / (OS_TIMER_CLOCK))
79#define OSTicksToMilliseconds(ticks) ((ticks) / (OS_TIMER_CLOCK / 1000))
80#define OSTicksToMicroseconds(ticks) ((ticks) * 8 / (OS_TIMER_CLOCK / 125000))
81#define OSSecondsToTicks(sec) ((sec) * (OS_TIMER_CLOCK))
82#define OSMillisecondsToTicks(msec) ((msec) * (OS_TIMER_CLOCK / 1000))
83#define OSNanosecondsToTicks(nsec) \
84 (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
85#define OSMicrosecondsToTicks(usec) (((usec) * (OS_TIMER_CLOCK / 125000)) / 8)
86
87unsigned long OSGetConsoleType(void);
88void OSInit(void);
89
90void* OSGetArenaHi(void);
91void* OSGetArenaLo(void);
92void OSSetArenaHi(void*);
93void OSSetArenaLo(void*);
94void* OSAllocFromArenaLo(u32 size, u32 align);
95void* OSAllocFromArenaHi(u32 size, u32 align);
96
98
101
102typedef struct OSCalendarTime {
103 /*0x00*/ int sec;
104 /*0x04*/ int min;
105 /*0x08*/ int hour;
106 /*0x0C*/ int mday;
107 /*0x10*/ int mon;
108 /*0x14*/ int year;
109 /*0x18*/ int wday;
110 /*0x1C*/ int yday;
111 /*0x20*/ int msec;
112 /*0x24*/ int usec;
114
115#include <dolphin/dvd.h>
116
117typedef struct OSBootInfo_s {
118 // total size: 0x40
119 DVDDiskID DVDDiskID; // offset 0x0, size 0x20
120 unsigned long magic; // offset 0x20, size 0x4
121 unsigned long version; // offset 0x24, size 0x4
122 unsigned long memorySize; // offset 0x28, size 0x4
123 unsigned long consoleType; // offset 0x2C, size 0x4
124 void* arenaLo; // offset 0x30, size 0x4
125 void* arenaHi; // offset 0x34, size 0x4
126 void* FSTLocation; // offset 0x38, size 0x4
127 unsigned long FSTMaxLength; // offset 0x3C, size 0x4
128} OSBootInfo;
129
137
138#define OS_CONSOLE_MASK 0xf0000000
139#define OS_CONSOLE_RETAIL 0x00000000
140#define OS_CONSOLE_DEVELOPMENT 0x10000000
141#define OS_CONSOLE_TDEV 0x20000000
142
143#define OS_CONSOLE_RETAIL4 0x00000004
144#define OS_CONSOLE_RETAIL3 0x00000003
145#define OS_CONSOLE_RETAIL2 0x00000002
146#define OS_CONSOLE_RETAIL1 0x00000001
147#define OS_CONSOLE_TDEVHW4 0x20000007
148#define OS_CONSOLE_TDEVHW3 0x20000006
149#define OS_CONSOLE_TDEVHW2 0x20000005
150#define OS_CONSOLE_TDEVHW1 0x20000004
151#define OS_CONSOLE_DEVHW4 0x10000007
152#define OS_CONSOLE_DEVHW3 0x10000006
153#define OS_CONSOLE_DEVHW2 0x10000005
154#define OS_CONSOLE_DEVHW1 0x10000004
155#define OS_CONSOLE_MINNOW 0x10000003
156#define OS_CONSOLE_ARTHUR 0x10000002
157#define OS_CONSOLE_PC_EMULATOR 0x10000001
158#define OS_CONSOLE_EMULATOR 0x10000000
159
160#define OS_SOUND_MODE_MONO 0
161#define OS_SOUND_MODE_STEREO 1
162
165
166#ifndef DOLPHIN_ATTRIBUTE_NORETURN
167#if defined(__clang__) || defined(__GNUC__)
168#define DOLPHIN_ATTRIBUTE_NORETURN __attribute__((noreturn))
169#else
170#define DOLPHIN_ATTRIBUTE_NORETURN
171#endif
172#endif
173
174void OSReport(char*, ...);
175DOLPHIN_ATTRIBUTE_NORETURN void OSPanic(char* file, int line, char* msg, ...);
176
177#define OSRoundUp32B(x) (((u32) (x) + 32 - 1) & ~(32 - 1))
178#define OSRoundDown32B(x) (((u32) (x)) & ~(32 - 1))
179
184void* OSCachedToUncached(void* caddr);
185void* OSUncachedToCached(void* ucaddr);
186#if !DEBUG
187#define OSPhysicalToCached(paddr) \
188 ((void*) ((u32) (OS_BASE_CACHED + (u32) (paddr))))
189#define OSPhysicalToUncached(paddr) \
190 ((void*) ((u32) (OS_BASE_UNCACHED + (u32) (paddr))))
191#define OSCachedToPhysical(caddr) ((u32) ((u32) (caddr) - OS_BASE_CACHED))
192#define OSUncachedToPhysical(ucaddr) \
193 ((u32) ((u32) (ucaddr) - OS_BASE_UNCACHED))
194#define OSCachedToUncached(caddr) \
195 ((void*) ((u8*) (caddr) + (OS_BASE_UNCACHED - OS_BASE_CACHED)))
196#define OSUncachedToCached(ucaddr) \
197 ((void*) ((u8*) (ucaddr) - (OS_BASE_UNCACHED - OS_BASE_CACHED)))
198#endif
199
200#ifdef __cplusplus
201}
202#endif
203
204#endif
int BOOL
Definition types.h:20
unsigned long u32
Definition types.h:9
signed short int s16
Definition types.h:6
signed long long int s64
Definition types.h:10
BOOL OSDisableInterrupts(void)
#define OS_BASE_CACHED
Definition os.h:57
OSTime OSGetTime(void)
#define OSUncachedToCached(ucaddr)
Definition os.h:196
BOOL OSRestoreInterrupts(BOOL level)
#define OSCachedToPhysical(caddr)
Definition os.h:191
#define __OSBusClock
Definition os.h:71
void(* __OSInterruptHandler)(__OSInterrupt interrupt, OSContext *context)
Definition os.h:18
#define OSPhysicalToUncached(paddr)
Definition os.h:189
unsigned long OSGetConsoleType(void)
void OSSetArenaLo(void *)
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime *td)
u32 OSGetConsoleSimulatedMemSize(void)
void OSReport(char *,...)
u32 OSGetPhysicalMemSize(void)
s64 OSTime
Definition os.h:10
void OSSetSoundMode(u32 mode)
BOOL OSEnableInterrupts(void)
void * OSAllocFromArenaHi(u32 size, u32 align)
s16 __OSInterrupt
Definition os.h:13
void __OSPSInit()
#define OSCachedToUncached(caddr)
Definition os.h:194
#define DOLPHIN_ATTRIBUTE_NORETURN
Definition os.h:170
u32 OSGetSoundMode(void)
u32 OSTick
Definition os.h:11
#define __OSCoreClock
Definition os.h:72
void * OSGetArenaLo(void)
DOLPHIN_ATTRIBUTE_NORETURN void OSPanic(char *file, int line, char *msg,...)
void OSSetArenaHi(void *)
OSTick OSGetTick(void)
#define OSPhysicalToCached(paddr)
Definition os.h:187
void * OSAllocFromArenaLo(u32 size, u32 align)
void * OSGetArenaHi(void)
OSTime OSCalendarTimeToTicks(OSCalendarTime *td)
#define OSUncachedToPhysical(ucaddr)
Definition os.h:192
u32 __OSGetDIConfig(void)
u32 OSInterruptMask
Definition os.h:14
void OSInit(void)
int td
Definition os.h:117
unsigned long magic
Definition os.h:120
void * arenaHi
Definition os.h:125
DVDDiskID DVDDiskID
Definition os.h:119
unsigned long consoleType
Definition os.h:123
void * FSTLocation
Definition os.h:126
unsigned long FSTMaxLength
Definition os.h:127
void * arenaLo
Definition os.h:124
unsigned long version
Definition os.h:121
unsigned long memorySize
Definition os.h:122
Definition os.h:102
int msec
Definition os.h:111
int mday
Definition os.h:106
int sec
Definition os.h:103
int yday
Definition os.h:110
int mon
Definition os.h:107
int wday
Definition os.h:109
int year
Definition os.h:108
int usec
Definition os.h:112
int min
Definition os.h:104
int hour
Definition os.h:105
Definition OSContext.h:138
Definition OSThread.h:15
Definition OSThread.h:39
OSThreadQueue __OSActiveThreadQueue
Definition targimpl.c:7