mirror of
https://github.com/zeldaret/tp
synced 2026-08-11 03:26:25 -04:00
Continue robbing prime github dolphin libs blind (#254)
* Continue work on dolphin libs * tp.py pull-request should print rels by default
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "dolphin/dvd/dvdlow.h"
|
||||
#include "dol2asm.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "dolphin/os/OSAlarm.h"
|
||||
|
||||
//
|
||||
// Forward References:
|
||||
@@ -46,13 +47,21 @@ void OSClearContext();
|
||||
void OSDisableInterrupts();
|
||||
void OSRestoreInterrupts();
|
||||
void __OSMaskInterrupts();
|
||||
void __OSGetSystemTime();
|
||||
OSTime __OSGetSystemTime();
|
||||
void DVDGetCurrentDiskID();
|
||||
|
||||
//
|
||||
// Declarations:
|
||||
//
|
||||
|
||||
typedef struct DVDCommand {
|
||||
s32 _0;
|
||||
u32 _4;
|
||||
u32 _8;
|
||||
u32 _c;
|
||||
DVDLowCallback callback;
|
||||
} DVDCommand;
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 8044C830-8044C870 079550 003C+04 6/6 0/0 0/0 .bss CommandList */
|
||||
static u8 CommandList[60 + 4 /* padding */];
|
||||
@@ -106,7 +115,7 @@ static u8 data_8045174C[4];
|
||||
static u8 LastCommandWasRead[4];
|
||||
|
||||
/* 80451754-80451758 000C54 0004+00 5/5 0/0 0/0 .sbss NextCommandNumber */
|
||||
static u8 NextCommandNumber[4];
|
||||
static u32 NextCommandNumber;
|
||||
|
||||
/* 80347674-803476B4 341FB4 0040+00 0/0 1/1 0/0 .text __DVDInitWA */
|
||||
#pragma push
|
||||
@@ -161,6 +170,20 @@ asm void __DVDInterruptHandler() {
|
||||
#pragma pop
|
||||
|
||||
/* 80347994-80347A18 3422D4 0084+00 1/1 0/0 0/0 .text AlarmHandler */
|
||||
#ifdef NONMATCHING
|
||||
static void AlarmHandler(OSAlarm* alarm, OSContext* context) {
|
||||
DVDCommand* cmd;
|
||||
cmd = &CommandList[NextCommandNumber];
|
||||
|
||||
if (cmd->_0 == 1) {
|
||||
++NextCommandNumber;
|
||||
Read(cmd->_4, cmd->_8, cmd->_c, cmd->callback);
|
||||
} else if (cmd->_0 == 2) {
|
||||
++NextCommandNumber;
|
||||
DVDLowSeek(cmd->_c, cmd->callback);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
@@ -169,16 +192,23 @@ static asm void AlarmHandler() {
|
||||
#include "asm/dolphin/dvd/dvdlow/AlarmHandler.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 80347A18-80347A88 342358 0070+00 9/9 0/0 0/0 .text AlarmHandlerForTimeout */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
static asm void AlarmHandlerForTimeout() {
|
||||
nofralloc
|
||||
#include "asm/dolphin/dvd/dvdlow/AlarmHandlerForTimeout.s"
|
||||
static void AlarmHandlerForTimeout(OSAlarm* alarm, OSContext* context) {
|
||||
OSContext tmpContext;
|
||||
DVDLowCallback callback;
|
||||
__OSMaskInterrupts(0x400);
|
||||
OSClearContext(&tmpContext);
|
||||
OSSetCurrentContext(&tmpContext);
|
||||
callback = Callback;
|
||||
Callback = NULL;
|
||||
if (callback != NULL) {
|
||||
callback(0x10);
|
||||
}
|
||||
OSClearContext(&tmpContext);
|
||||
OSSetCurrentContext(context);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 80347A88-80347B98 3423C8 0110+00 3/3 0/0 0/0 .text Read */
|
||||
#pragma push
|
||||
|
||||
@@ -127,25 +127,18 @@ void GXEnableTexOffsets(GXTexCoordID coord, GXBool line, GXBool point) {
|
||||
}
|
||||
|
||||
/* 8035C984-8035C9AC 3572C4 0028+00 0/0 33/33 5/5 .text GXSetCullMode */
|
||||
// extra mr
|
||||
#ifdef NONMATCHING
|
||||
void GXSetCullMode(GXCullMode mode) {
|
||||
GXData* data = __GXData;
|
||||
GXData* data;
|
||||
GXCullMode mode2;
|
||||
data = __GXData;
|
||||
|
||||
mode = (mode << 1 & 2 | mode >> 1 & 1);
|
||||
GX_BITFIELD_SET(data->field_0x204, 16, 2, mode);
|
||||
// Useless set
|
||||
mode2 = (mode >> 1) & 1;
|
||||
GX_BITFIELD_SET(mode2, 30, 1, mode);
|
||||
|
||||
GX_BITFIELD_SET(data->field_0x204, 16, 2, mode2);
|
||||
data->field_0x5ac |= 4;
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void GXSetCullMode(GXCullMode mode) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/gx/GXGeometry/GXSetCullMode.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 8035C9AC-8035C9E0 3572EC 0034+00 0/0 6/6 0/0 .text GXSetCoPlanar */
|
||||
void GXSetCoPlanar(GXBool enable) {
|
||||
|
||||
+14
-11
@@ -199,14 +199,13 @@ extern u32 BOOT_REGION_START : 0x812FDFF0; //(*(u32 *)0x812fdff0)
|
||||
extern u32 BOOT_REGION_END : 0x812FDFEC; //(*(u32 *)0x812fdfec)
|
||||
|
||||
inline void ClearArena(void) {
|
||||
if ((u32)(OSGetResetCode() + 0x80000000) != 0U) {
|
||||
__OSSavedRegionStart = 0U;
|
||||
__OSSavedRegionEnd = 0U;
|
||||
u32 resetCode = OSGetResetCode();
|
||||
BOOL val = resetCode != 0U ? TRUE : FALSE;
|
||||
if (val) {
|
||||
memset(OSGetArenaLo(), 0U, (u32)OSGetArenaHi() - (u32)OSGetArenaLo());
|
||||
return;
|
||||
}
|
||||
__OSSavedRegionStart = (void*)BOOT_REGION_START;
|
||||
__OSSavedRegionEnd = (void*)BOOT_REGION_END;
|
||||
|
||||
if (BOOT_REGION_START == 0U) {
|
||||
memset(OSGetArenaLo(), 0U, (u32)OSGetArenaHi() - (u32)OSGetArenaLo());
|
||||
return;
|
||||
@@ -404,7 +403,7 @@ void OSInit(void) {
|
||||
// HEAP //
|
||||
// set up bottom of heap (ArenaLo)
|
||||
// grab address from BootInfo if it exists, otherwise use default __ArenaLo
|
||||
OSSetArenaLo((BootInfo->arena_lo == NULL) ? /* __ArenaLo */ 0 : BootInfo->arena_lo);
|
||||
OSSetArenaLo((BootInfo->arena_lo == NULL) ? /* __ArenaLo */ _stack_end : BootInfo->arena_lo);
|
||||
|
||||
// if the input arenaLo is null, and debug flag location exists (and flag is < 2),
|
||||
// set arenaLo to just past the end of the db stack
|
||||
@@ -415,7 +414,7 @@ void OSInit(void) {
|
||||
|
||||
// set up top of heap (ArenaHi)
|
||||
// grab address from BootInfo if it exists, otherwise use default __ArenaHi
|
||||
OSSetArenaHi((BootInfo->arena_hi == NULL) ? /* __ArenaHi */ 0 : BootInfo->arena_hi);
|
||||
OSSetArenaHi((BootInfo->arena_hi == NULL) ? __ArenaHi : BootInfo->arena_hi);
|
||||
|
||||
// OS INIT AND REPORT //
|
||||
// initialise a whole bunch of OS stuff
|
||||
@@ -455,12 +454,13 @@ void OSInit(void) {
|
||||
|
||||
// work out what console type this corresponds to and report it
|
||||
// consoleTypeSwitchHi = inputConsoleType & 0xF0000000;
|
||||
switch (inputConsoleType & 0xffff0000) { // check "first" byte
|
||||
switch (inputConsoleType & 0xf0000000) { // check "first" byte
|
||||
case OS_CONSOLE_RETAIL:
|
||||
OSReport("Retail %d\n", inputConsoleType);
|
||||
break;
|
||||
default:
|
||||
switch (inputConsoleType & 0x0000ffff) { // if "first" byte is 2, check "the rest"
|
||||
case OS_CONSOLE_DEVELOPMENT:
|
||||
case OS_CONSOLE_TDEV:
|
||||
switch (inputConsoleType & 0x0fffffff) { // if "first" byte is 2, check "the rest"
|
||||
case OS_CONSOLE_EMULATOR:
|
||||
OSReport("Mac Emulator\n");
|
||||
break;
|
||||
@@ -474,11 +474,14 @@ void OSInit(void) {
|
||||
OSReport("EPPC Minnow\n");
|
||||
break;
|
||||
default:
|
||||
tdev = ((u32)inputConsoleType & 0x0000ffff);
|
||||
tdev = ((u32)inputConsoleType & 0x0fffffff);
|
||||
OSReport("Development HW%d (%08x)\n", tdev - 3, inputConsoleType);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
OSReport("%08x\n", inputConsoleType);
|
||||
break;
|
||||
}
|
||||
|
||||
// report memory size
|
||||
|
||||
@@ -28,8 +28,8 @@ extern OSTime __OSLastInterruptTime;
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 8044BAD0-8044BB20 0787F0 0044+0C 2/2 2/2 0/0 .bss __OSErrorTable */
|
||||
extern OSErrorHandler __OSErrorTable[17];
|
||||
OSErrorHandler __OSErrorTable[17];
|
||||
extern OSErrorHandlerEx __OSErrorTable[17];
|
||||
OSErrorHandlerEx __OSErrorTable[17];
|
||||
|
||||
/* 804509A0-804509A4 000420 0004+00 1/1 2/2 0/0 .sdata __OSFpscrEnableBits */
|
||||
#define FPSCR_ENABLE (FPSCR_VE | FPSCR_OE | FPSCR_UE | FPSCR_ZE | FPSCR_XE)
|
||||
@@ -37,12 +37,12 @@ SECTION_SDATA extern u32 __OSFpscrEnableBits = FPSCR_ENABLE;
|
||||
|
||||
/* 8033C580-8033C798 336EC0 0218+00 0/0 4/4 0/0 .text OSSetErrorHandler */
|
||||
OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler) {
|
||||
OSErrorHandler oldHandler;
|
||||
OSErrorHandlerEx oldHandler;
|
||||
BOOL enabled;
|
||||
|
||||
enabled = OSDisableInterrupts();
|
||||
oldHandler = __OSErrorTable[error];
|
||||
__OSErrorTable[error] = handler;
|
||||
__OSErrorTable[error] = (OSErrorHandlerEx) handler;
|
||||
|
||||
if (error == EXCEPTION_FLOATING_POINT_EXCEPTION) {
|
||||
u32 msr;
|
||||
|
||||
@@ -17,7 +17,7 @@ vu16 __MEMRegs[64] : 0xCC004000;
|
||||
// External References:
|
||||
//
|
||||
|
||||
extern OSErrorHandler __OSErrorTable[16];
|
||||
extern OSErrorHandlerEx __OSErrorTable[16];
|
||||
|
||||
//
|
||||
// Declarations:
|
||||
@@ -34,7 +34,6 @@ static asm s32 OnReset(s32 param_0) {
|
||||
#pragma pop
|
||||
|
||||
/* 8033ECA8-8033ED14 3395E8 006C+00 1/1 0/0 0/0 .text MEMIntrruptHandler */
|
||||
#ifdef NONMATCHING
|
||||
static void MEMIntrruptHandler(OSInterrupt interrupt, OSContext* context) {
|
||||
u32 addr;
|
||||
u32 cause;
|
||||
@@ -51,16 +50,6 @@ static void MEMIntrruptHandler(OSInterrupt interrupt, OSContext* context) {
|
||||
|
||||
__OSUnhandledException(EXCEPTION_MEMORY_PROTECTION, context, cause, addr);
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
static asm void MEMIntrruptHandler(OSInterrupt interrupt, struct OSContext* context) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMemory/MEMIntrruptHandler.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 8033ED14-8033EDD8 339654 00C4+00 0/0 1/1 0/0 .text OSProtectRange */
|
||||
void OSProtectRange(u32 chan, void* addr, u32 nBytes, u32 control) {
|
||||
|
||||
+118
-81
@@ -65,8 +65,6 @@ void OSInitMutex(OSMutex* mutex) {
|
||||
}
|
||||
|
||||
/* 8033F040-8033F11C 339980 00DC+00 1/1 62/62 0/0 .text OSLockMutex */
|
||||
// needs compiler epilogue patch
|
||||
#ifdef NONMATCHING
|
||||
void OSLockMutex(OSMutex* mutex) {
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
OSThread* currentThread = OSGetCurrentThread();
|
||||
@@ -91,19 +89,8 @@ void OSLockMutex(OSMutex* mutex) {
|
||||
}
|
||||
OSRestoreInterrupts(enabled);
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSLockMutex(OSMutex* mutex) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/OSLockMutex.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 8033F11C-8033F1E4 339A5C 00C8+00 0/0 71/71 0/0 .text OSUnlockMutex */
|
||||
#ifdef NONMATCHING
|
||||
void OSUnlockMutex(OSMutex* mutex) {
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
OSThread* currentThread = OSGetCurrentThread();
|
||||
@@ -111,7 +98,7 @@ void OSUnlockMutex(OSMutex* mutex) {
|
||||
if (mutex->thread == currentThread && --mutex->count == 0) {
|
||||
PopItem(¤tThread->owned_mutexes, mutex, link);
|
||||
mutex->thread = NULL;
|
||||
if (currentThread->effective_priority < currentThread->base_priority) {
|
||||
if ((s32)currentThread->effective_priority < (s32)currentThread->base_priority) {
|
||||
currentThread->effective_priority = __OSGetEffectivePriority(currentThread);
|
||||
}
|
||||
|
||||
@@ -119,93 +106,143 @@ void OSUnlockMutex(OSMutex* mutex) {
|
||||
}
|
||||
OSRestoreInterrupts(enabled);
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSUnlockMutex(OSMutex* mutex) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/OSUnlockMutex.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 8033F1E4-8033F254 339B24 0070+00 0/0 2/2 0/0 .text __OSUnlockAllMutex */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void __OSUnlockAllMutex(OSThread* thread) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/__OSUnlockAllMutex.s"
|
||||
void __OSUnlockAllMutex(OSThread* thread) {
|
||||
OSMutex* mutex;
|
||||
|
||||
while (thread->owned_mutexes.head) {
|
||||
PopHead(&thread->owned_mutexes, mutex, link);
|
||||
mutex->count = 0;
|
||||
mutex->thread = NULL;
|
||||
OSWakeupThread(&mutex->queue);
|
||||
}
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8033F254-8033F310 339B94 00BC+00 0/0 9/9 0/0 .text OSTryLockMutex */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm s32 OSTryLockMutex(OSMutex* mutex) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/OSTryLockMutex.s"
|
||||
|
||||
BOOL OSTryLockMutex(OSMutex* mutex) {
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
OSThread* currentThread = OSGetCurrentThread();
|
||||
BOOL locked;
|
||||
if (mutex->thread == 0) {
|
||||
mutex->thread = currentThread;
|
||||
mutex->count++;
|
||||
PushTail(¤tThread->owned_mutexes, mutex, link);
|
||||
locked = TRUE;
|
||||
} else if (mutex->thread == currentThread) {
|
||||
mutex->count++;
|
||||
locked = TRUE;
|
||||
} else {
|
||||
locked = FALSE;
|
||||
}
|
||||
OSRestoreInterrupts(enabled);
|
||||
return locked;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8033F310-8033F330 339C50 0020+00 0/0 1/1 0/0 .text OSInitCond */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSInitCond(OSCond* cond) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/OSInitCond.s"
|
||||
}
|
||||
#pragma pop
|
||||
void OSInitCond(OSCond* cond) { OSInitThreadQueue(&cond->queue); }
|
||||
|
||||
/* 8033F330-8033F404 339C70 00D4+00 0/0 1/1 0/0 .text OSWaitCond */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSWaitCond(OSCond* cond, OSMutex* mutex) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/OSWaitCond.s"
|
||||
void OSWaitCond(OSCond* cond, OSMutex* mutex) {
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
OSThread* currentThread = OSGetCurrentThread();
|
||||
s32 count;
|
||||
|
||||
if (mutex->thread == currentThread) {
|
||||
count = mutex->count;
|
||||
mutex->count = 0;
|
||||
PopItem(¤tThread->owned_mutexes, mutex, link);
|
||||
mutex->thread = NULL;
|
||||
|
||||
if (currentThread->effective_priority < (s32)currentThread->base_priority) {
|
||||
currentThread->effective_priority = __OSGetEffectivePriority(currentThread);
|
||||
}
|
||||
|
||||
OSDisableScheduler();
|
||||
OSWakeupThread(&mutex->queue);
|
||||
OSEnableScheduler();
|
||||
OSSleepThread(&cond->queue);
|
||||
OSLockMutex(mutex);
|
||||
mutex->count = count;
|
||||
}
|
||||
|
||||
OSRestoreInterrupts(enabled);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8033F404-8033F424 339D44 0020+00 0/0 5/5 0/0 .text OSSignalCond */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSSignalCond(OSCond* con) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/OSSignalCond.s"
|
||||
void OSSignalCond(OSCond* cond) {
|
||||
OSWakeupThread(&cond->queue);
|
||||
}
|
||||
|
||||
static BOOL IsMember(OSMutexQueue* queue, OSMutex* mutex) {
|
||||
OSMutex* member;
|
||||
|
||||
for (member = queue->head; member; member = member->link.next) {
|
||||
if (mutex == member)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8033F424-8033F524 339D64 0100+00 1/1 0/0 0/0 .text __OSCheckMutex */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm s32 __OSCheckMutex(OSThread* thread) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/__OSCheckMutex.s"
|
||||
BOOL __OSCheckMutex(OSMutex* mutex) {
|
||||
OSThread* thread;
|
||||
OSThreadQueue* queue;
|
||||
OSPriority priority = 0;
|
||||
|
||||
queue = &mutex->queue;
|
||||
if (!(queue->head == NULL || queue->head->link.prev == NULL))
|
||||
return FALSE;
|
||||
if (!(queue->tail == NULL || queue->tail->link.next == NULL))
|
||||
return FALSE;
|
||||
for (thread = queue->head; thread; thread = thread->link.next) {
|
||||
if (!(thread->link.next == NULL || thread == thread->link.next->link.prev))
|
||||
return FALSE;
|
||||
if (!(thread->link.prev == NULL || thread == thread->link.prev->link.next))
|
||||
return FALSE;
|
||||
|
||||
if (thread->state != OS_THREAD_STATE_WAITING)
|
||||
return FALSE;
|
||||
|
||||
if (thread->effective_priority < priority)
|
||||
return FALSE;
|
||||
priority = thread->effective_priority;
|
||||
}
|
||||
|
||||
if (mutex->thread) {
|
||||
if (mutex->count <= 0)
|
||||
return FALSE;
|
||||
} else {
|
||||
if (0 != mutex->count)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8033F524-8033F55C 339E64 0038+00 0/0 1/1 0/0 .text __OSCheckDeadLock */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm BOOL __OSCheckDeadLock(OSThread* thread) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/__OSCheckDeadLock.s"
|
||||
BOOL __OSCheckDeadLock(OSThread* thread) {
|
||||
OSMutex* mutex;
|
||||
|
||||
mutex = thread->mutex;
|
||||
while (mutex && mutex->thread) {
|
||||
if (mutex->thread == thread)
|
||||
return TRUE;
|
||||
mutex = mutex->thread->mutex;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8033F55C-8033F5D0 339E9C 0074+00 0/0 1/1 0/0 .text __OSCheckMutexes */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm BOOL __OSCheckMutexes(OSThread* thread) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSMutex/__OSCheckMutexes.s"
|
||||
BOOL __OSCheckMutexes(OSThread* thread) {
|
||||
OSMutex* mutex;
|
||||
|
||||
for (mutex = thread->owned_mutexes.head; mutex; mutex = mutex->link.next) {
|
||||
if (mutex->thread != thread)
|
||||
return FALSE;
|
||||
if (!__OSCheckMutex(mutex))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
+134
-99
@@ -87,55 +87,73 @@ void __OSInitSram(void) {
|
||||
OSSetGbsMode(OSGetGbsMode());
|
||||
}
|
||||
|
||||
/* 80340144-803401A0 33AA84 005C+00 0/0 3/3 0/0 .text __OSLockSram */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm OSSram* __OSLockSram(void) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/__OSLockSram.s"
|
||||
static void* LockSram(u32 offset) {
|
||||
BOOL enabled;
|
||||
enabled = OSDisableInterrupts();
|
||||
|
||||
if (Scb.locked != FALSE) {
|
||||
OSRestoreInterrupts(enabled);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Scb.enabled = enabled;
|
||||
Scb.locked = TRUE;
|
||||
|
||||
return Scb.sram + offset;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 80340144-803401A0 33AA84 005C+00 0/0 3/3 0/0 .text __OSLockSram */
|
||||
OSSram* __OSLockSram() { return LockSram(0); }
|
||||
|
||||
/* 803401A0-803401FC 33AAE0 005C+00 0/0 4/4 0/0 .text __OSLockSramEx */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm OSSramEx* __OSLockSramEx(void) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/__OSLockSramEx.s"
|
||||
}
|
||||
#pragma pop
|
||||
OSSramEx* __OSLockSramEx() { return LockSram(sizeof(OSSram)); }
|
||||
|
||||
/* 803401FC-80340538 33AB3C 033C+00 10/10 0/0 0/0 .text UnlockSram */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
static asm BOOL UnlockSram(BOOL commit, u32 offset) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/UnlockSram.s"
|
||||
static BOOL UnlockSram(BOOL commit, u32 offset) {
|
||||
u16* p;
|
||||
|
||||
if (commit) {
|
||||
if (offset == 0) {
|
||||
OSSram* sram = (OSSram*)Scb.sram;
|
||||
|
||||
if (2u < (sram->flags & 3)) {
|
||||
sram->flags &= ~3;
|
||||
}
|
||||
|
||||
sram->checkSum = sram->checkSumInv = 0;
|
||||
for (p = (u16*)&sram->counterBias; p < (u16*)(Scb.sram + sizeof(OSSram)); p++) {
|
||||
sram->checkSum += *p;
|
||||
sram->checkSumInv += ~*p;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset < Scb.offset) {
|
||||
Scb.offset = offset;
|
||||
}
|
||||
|
||||
if (Scb.offset <= 0x14) {
|
||||
OSSramEx* sram = (OSSramEx*)(Scb.sram + sizeof(OSSram));
|
||||
if (((u32)sram->gbs & 0x7c00) == 0x5000 || ((u32)sram->gbs & 0xc0) == 0xc0) {
|
||||
sram->gbs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Scb.sync = WriteSram(Scb.sram + Scb.offset, Scb.offset, RTC_SRAM_SIZE - Scb.offset);
|
||||
if (Scb.sync) {
|
||||
Scb.offset = RTC_SRAM_SIZE;
|
||||
}
|
||||
}
|
||||
Scb.locked = FALSE;
|
||||
OSRestoreInterrupts(Scb.enabled);
|
||||
return Scb.sync;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
|
||||
/* 80340538-8034055C 33AE78 0024+00 0/0 3/3 0/0 .text __OSUnlockSram */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm BOOL __OSUnlockSram(BOOL commit) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/__OSUnlockSram.s"
|
||||
}
|
||||
#pragma pop
|
||||
BOOL __OSUnlockSram(BOOL commit) { return UnlockSram(commit, 0); }
|
||||
|
||||
/* 8034055C-80340580 33AE9C 0024+00 0/0 4/4 0/0 .text __OSUnlockSramEx */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm BOOL __OSUnlockSramEx(BOOL commit) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/__OSUnlockSramEx.s"
|
||||
}
|
||||
#pragma pop
|
||||
BOOL __OSUnlockSramEx(BOOL commit) { return UnlockSram(commit, sizeof(OSSram)); }
|
||||
|
||||
/* 80340580-80340590 33AEC0 0010+00 0/0 2/2 0/0 .text __OSSyncSram */
|
||||
BOOL __OSSyncSram(void) {
|
||||
@@ -143,57 +161,74 @@ BOOL __OSSyncSram(void) {
|
||||
}
|
||||
|
||||
/* 80340590-80340610 33AED0 0080+00 0/0 4/4 0/0 .text OSGetSoundMode */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm u32 OSGetSoundMode(void) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSGetSoundMode.s"
|
||||
u32 OSGetSoundMode() {
|
||||
OSSram* sram;
|
||||
u32 mode;
|
||||
|
||||
sram = __OSLockSram();
|
||||
mode = (sram->flags & 0x4) ? OS_SOUND_MODE_STEREO : OS_SOUND_MODE_MONO;
|
||||
__OSUnlockSram(FALSE);
|
||||
return mode;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 80340610-803406B4 33AF50 00A4+00 0/0 1/1 0/0 .text OSSetSoundMode */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSSetSoundMode(OSSoundMode mode) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSSetSoundMode.s"
|
||||
void OSSetSoundMode(u32 mode) {
|
||||
OSSram* sram;
|
||||
mode <<= 2;
|
||||
mode &= 4;
|
||||
|
||||
sram = __OSLockSram();
|
||||
if (mode == (sram->flags & 4)) {
|
||||
__OSUnlockSram(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
sram->flags &= ~4;
|
||||
sram->flags |= mode;
|
||||
__OSUnlockSram(TRUE);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 803406B4-80340724 33AFF4 0070+00 0/0 3/3 0/0 .text OSGetProgressiveMode */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm u32 OSGetProgressiveMode(void) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSGetProgressiveMode.s"
|
||||
u32 OSGetProgressiveMode() {
|
||||
OSSram* sram;
|
||||
u32 mode;
|
||||
|
||||
sram = __OSLockSram();
|
||||
mode = (sram->flags & 0x80) >> 7;
|
||||
__OSUnlockSram(FALSE);
|
||||
return mode;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 80340724-803407C8 33B064 00A4+00 0/0 2/2 0/0 .text OSSetProgressiveMode */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSSetProgressiveMode(u32 mode) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSSetProgressiveMode.s"
|
||||
|
||||
void OSSetProgressiveMode(u32 mode) {
|
||||
OSSram* sram;
|
||||
mode <<= 7;
|
||||
mode &= 0x80;
|
||||
|
||||
sram = __OSLockSram();
|
||||
if (mode == (sram->flags & 0x80)) {
|
||||
__OSUnlockSram(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
sram->flags &= ~0x80;
|
||||
sram->flags |= mode;
|
||||
__OSUnlockSram(TRUE);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 803407C8-8034084C 33B108 0084+00 0/0 1/1 0/0 .text OSGetWirelessID */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm u16 OSGetWirelessID(s32 channel) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSGetWirelessID.s"
|
||||
u16 OSGetWirelessID(s32 channel) {
|
||||
OSSramEx* sram;
|
||||
u16 id;
|
||||
|
||||
sram = __OSLockSramEx();
|
||||
id = sram->wirelessPadID[channel];
|
||||
__OSUnlockSramEx(FALSE);
|
||||
return id;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 8034084C-803408F8 33B18C 00AC+00 0/0 4/4 0/0 .text OSSetWirelessID */
|
||||
#ifdef NONMATCHING
|
||||
void OSSetWirelessID(s32 channel, u16 id) {
|
||||
OSSramEx* sram;
|
||||
|
||||
@@ -206,33 +241,33 @@ void OSSetWirelessID(s32 channel, u16 id) {
|
||||
|
||||
__OSUnlockSramEx(FALSE);
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void OSSetWirelessID(s32 channel, u16 id) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSSetWirelessID.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 803408F8-80340968 33B238 0070+00 1/1 0/0 0/0 .text OSGetGbsMode */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
static asm u16 OSGetGbsMode(void) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSGetGbsMode.s"
|
||||
u16 OSGetGbsMode() {
|
||||
OSSramEx* sram;
|
||||
u16 gbs;
|
||||
|
||||
sram = __OSLockSramEx();
|
||||
gbs = sram->gbs;
|
||||
__OSUnlockSramEx(FALSE);
|
||||
return gbs;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 80340968-80340A20 33B2A8 00B8+00 1/1 0/0 0/0 .text OSSetGbsMode */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
static asm void OSSetGbsMode(u16 mode) {
|
||||
nofralloc
|
||||
#include "asm/dolphin/os/OSRtc/OSSetGbsMode.s"
|
||||
void OSSetGbsMode(u16 mode) {
|
||||
OSSramEx* sram;
|
||||
|
||||
if (((u32)mode & 0x7c00) == 0x5000 || ((u32)mode & 0xc0) == 0xc0) {
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
sram = __OSLockSramEx();
|
||||
|
||||
if (mode == sram->gbs) {
|
||||
__OSUnlockSramEx(FALSE);
|
||||
return;
|
||||
}
|
||||
sram->gbs = mode;
|
||||
|
||||
__OSUnlockSramEx(TRUE);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
@@ -273,7 +273,7 @@ s32 __OSGetEffectivePriority(OSThread* thread) {
|
||||
s32 prio = thread->base_priority;
|
||||
|
||||
OSMutex* mutex;
|
||||
for (mutex = thread->owned_mutexes.head; mutex != NULL; mutex = mutex->link.prev) {
|
||||
for (mutex = thread->owned_mutexes.head; mutex != NULL; mutex = mutex->link.next) {
|
||||
OSThread* mutexThread = mutex->queue.head;
|
||||
if (mutexThread != NULL && mutexThread->effective_priority < prio) {
|
||||
prio = mutexThread->effective_priority;
|
||||
|
||||
@@ -135,6 +135,8 @@ static void GetDates(s32 days, OSCalendarTime* cal) {
|
||||
|
||||
/* 80342974-80342B78 33D2B4 0204+00 0/0 4/4 0/0 .text OSTicksToCalendarTime */
|
||||
#ifdef NONMATCHING
|
||||
#pragma push
|
||||
#pragma dont_inline on
|
||||
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td) {
|
||||
int days;
|
||||
int secs;
|
||||
@@ -161,6 +163,7 @@ void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td) {
|
||||
td->minutes = (secs / 60) % 60;
|
||||
td->seconds = secs % 60;
|
||||
}
|
||||
#pragma pop
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
|
||||
Reference in New Issue
Block a user