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