From b2f29992a367c19c9a356bce4841354feecdd4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Dec 2012 08:52:40 +0100 Subject: [PATCH] Wrap some functions, clean some stuff --- Core/Core.cpp | 6 +-- Core/HLE/FunctionWrappers.h | 5 +++ Core/HLE/sceImpose.cpp | 38 +++++++++++----- Core/HLE/sceKernelMemory.cpp | 77 +++++++++++++++++---------------- Core/HLE/sceKernelModule.cpp | 11 ++--- Core/HLE/sceKernelMutex.cpp | 2 +- Core/HLE/sceKernelSemaphore.cpp | 11 +---- 7 files changed, 79 insertions(+), 71 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index e1c553eff2..33124240f6 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -81,7 +81,7 @@ void Core_SingleStep() // Some platforms, like Android, do not call this function but handle things on their own. void Core_Run() { -#if _DEBUG +#if defined(_DEBUG) host->UpdateDisassembly(); #endif @@ -129,14 +129,14 @@ void Core_EnableStepping(bool step) //PowerPC::Pause(); // Sleep(1); sleep_ms(1); -#if _DEBUG +#if defined(_DEBUG) host->SetDebugMode(true); #endif coreState=CORE_STEPPING; } else { -#if _DEBUG +#if defined(_DEBUG) host->SetDebugMode(false); #endif coreState = CORE_RUNNING; diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 0a511e71ae..4185bdcdae 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -182,6 +182,11 @@ template void WrapU_UU() { RETURN(retval); } +template void WrapU_CUUU() { + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); + RETURN(retval); +} + template void WrapV_UIUII() { func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); } diff --git a/Core/HLE/sceImpose.cpp b/Core/HLE/sceImpose.cpp index 4122d1e40b..8e098f3d70 100644 --- a/Core/HLE/sceImpose.cpp +++ b/Core/HLE/sceImpose.cpp @@ -33,13 +33,15 @@ const int PSP_LANGUAGE_KOREAN = 9; const int PSP_LANGUAGE_TRADITIONAL_CHINESE = 10; const int PSP_LANGUAGE_SIMPLIFIED_CHINESE = 11; -static u32 iLanguage = PSP_LANGUAGE_ENGLISH; -static u32 iButtonValue = 0; +static u32 language = PSP_LANGUAGE_ENGLISH; +static u32 buttonValue = 0; +static u32 umdPopup = 0; void __ImposeInit() { - iLanguage = PSP_LANGUAGE_ENGLISH; - iButtonValue = 0; + language = PSP_LANGUAGE_ENGLISH; + buttonValue = 0; + umdPopup = 0; } u32 sceImposeGetBatteryIconStatus(u32 chargingPtr, u32 iconStatusPtr) @@ -55,8 +57,8 @@ u32 sceImposeGetBatteryIconStatus(u32 chargingPtr, u32 iconStatusPtr) u32 sceImposeSetLanguageMode(u32 languageVal, u32 buttonVal) { DEBUG_LOG(HLE, "sceImposeSetLanguageMode(%08x, %08x)", languageVal, buttonVal); - iLanguage = languageVal; - iButtonValue = buttonVal; + language = languageVal; + buttonValue = buttonVal; return 0; } @@ -64,20 +66,32 @@ u32 sceImposeGetLanguageMode(u32 languagePtr, u32 btnPtr) { DEBUG_LOG(HLE, "sceImposeGetLanguageMode(%08x, %08x)", languagePtr, btnPtr); if (Memory::IsValidAddress(languagePtr)) - Memory::Write_U32(iLanguage, languagePtr); + Memory::Write_U32(language, languagePtr); if (Memory::IsValidAddress(btnPtr)) - Memory::Write_U32(iButtonValue, btnPtr); + Memory::Write_U32(buttonValue, btnPtr); return 0; } +u32 sceImposeSetUMDPopup(int value) { + DEBUG_LOG(HLE, "sceImposeSetUMDPopup(%i)", value); + umdPopup = value; + return 0; +} + +u32 sceImposeGetUMDPopup() { + DEBUG_LOG(HLE, "sceImposeGetUMDPopup()"); + return umdPopup; +} + //OSD stuff? home button? const HLEFunction sceImpose[] = { - {0x36aa6e91, &WrapU_UU, "sceImposeSetLanguageMode"}, // Seen + {0x36aa6e91, WrapU_UU, "sceImposeSetLanguageMode"}, // Seen {0x381bd9e7, 0, "sceImposeHomeButton"}, - {0x24fd7bcf, &WrapU_UU, "sceImposeGetLanguageMode"}, - {0x8c943191, &WrapU_UU, "sceImposeGetBatteryIconStatus"}, - {0x72189C48, 0, "sceImposeSetUMDPopup"}, + {0x24fd7bcf, WrapU_UU, "sceImposeGetLanguageMode"}, + {0x8c943191, WrapU_UU, "sceImposeGetBatteryIconStatus"}, + {0x72189C48, WrapU_I, "sceImposeSetUMDPopup"}, + {0xE0887BC8, WrapU_V, "sceImposeGetUMDPopup"}, }; void Register_sceImpose() diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 452196087b..4034b096dd 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -439,18 +439,6 @@ void sceKernelPrintf() RETURN(0); } -void sceKernelSetCompiledSdkVersion() -{ - //pretty sure this only takes one arg - ERROR_LOG(HLE,"UNIMPL sceKernelSetCompiledSdkVersion(%08x)", PARAM(0)); - RETURN(0); -} - -void sceKernelSetCompilerVersion() -{ - ERROR_LOG(HLE,"UNIMPL sceKernelSetCompilerVersion(%08x, %08x, %08x, %08x)", PARAM(0),PARAM(1),PARAM(2),PARAM(3)); - RETURN(0); -} // VPL = variable length memory pool @@ -642,13 +630,11 @@ void sceKernelReferVplStatus() RETURN(0); } -void AllocMemoryBlock() { - const char *pname = Memory::GetCharPointer(PARAM(0)); - int type = PARAM(1); - u32 size = PARAM(2); - int paramsAddr = PARAM(3); - - DEBUG_LOG(HLE,"AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %i, %08x)", pname, type, size, paramsAddr); + +// TODO: Make proper kernel objects for these instead of using the UID as a pointer. + +u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAddr) { + INFO_LOG(HLE,"AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %i, %08x)", pname, type, size, paramsAddr); // Just support allocating a block in the user region. @@ -656,44 +642,59 @@ void AllocMemoryBlock() { // Create a UID object??? Nah, let's just us the UID itself (hack!) - RETURN(blockPtr); + return blockPtr; } -void FreeMemoryBlock() { - SceUID uid = PARAM(0); - DEBUG_LOG(HLE, "FreeMemoryBlock(%i)", uid); +u32 FreeMemoryBlock(u32 uid) { + INFO_LOG(HLE, "FreeMemoryBlock(%i)", uid); userMemory.Free(uid); - RETURN(0); + return 0; } -void GetMemoryBlockPtr() { - SceUID uid = PARAM(0); - DEBUG_LOG(HLE, "GetMemoryBlockPtr(%i)", uid); - RETURN(uid); +u32 GetMemoryBlockPtr(u32 uid) { + INFO_LOG(HLE, "GetMemoryBlockPtr(%i)", uid); + return uid; } -const HLEFunction SysMemUserForUser[] = -{ +u32 sceKernelSetCompiledSdkVersion(u32 param) { + // pretty sure this only takes one arg + ERROR_LOG(HLE,"UNIMPL sceKernelSetCompiledSdkVersion(%08x)", param); + return 0; +} + +u32 sceKernelSetCompiledSdkVersion395(u32 param) { + // pretty sure this only takes one arg + ERROR_LOG(HLE,"UNIMPL sceKernelSetCompiledSdkVersion395(%08x)", param); + return 0; +} + +u32 sceKernelSetCompilerVersion(u32 a, u32 b, u32 c, u32 d) { + ERROR_LOG(HLE,"UNIMPL sceKernelSetCompilerVersion(%08x, %08x, %08x, %08x)", a, b, c, d); + return 0; +} + +const HLEFunction SysMemUserForUser[] = { {0xA291F107,sceKernelMaxFreeMemSize, "sceKernelMaxFreeMemSize"}, {0xF919F628,sceKernelTotalFreeMemSize,"sceKernelTotalFreeMemSize"}, - {0x3FC9AE6A,sceKernelDevkitVersion, "sceKernelDevkitVersion"}, + {0x3FC9AE6A,sceKernelDevkitVersion, "sceKernelDevkitVersion"}, {0x237DBD4F,sceKernelAllocPartitionMemory,"sceKernelAllocPartitionMemory"}, //(int size) ? {0xB6D61D02,sceKernelFreePartitionMemory,"sceKernelFreePartitionMemory"}, //(void *ptr) ? {0x9D9A5BA1,sceKernelGetBlockHeadAddr,"sceKernelGetBlockHeadAddr"}, //(void *ptr) ? {0x13a5abef,sceKernelPrintf,"sceKernelPrintf 0x13a5abef"}, - {0x7591c7db,sceKernelSetCompiledSdkVersion,"sceKernelSetCompiledSdkVersion"}, + {0x7591c7db,WrapU_U,"sceKernelSetCompiledSdkVersion"}, {0x342061E5,0,"sceKernelSetCompiledSdkVersion370"}, {0x315AD3A0,0,"sceKernelSetCompiledSdkVersion380_390"}, - {0xEBD5C3E6,0,"sceKernelSetCompiledSdkVersion395"}, - {0xf77d77cb,sceKernelSetCompilerVersion,"sceKernelSetCompilerVersion"}, + {0xEBD5C3E6,WrapU_U,"sceKernelSetCompiledSdkVersion395"}, + {0xf77d77cb,WrapU_UUUU,"sceKernelSetCompilerVersion"}, {0x35669d4c,0,"sceKernelSetCompiledSdkVersion600_602"}, //?? {0x1b4217bc,0,"sceKernelSetCompiledSdkVersion603_605"}, - {0x358ca1bb,0,"sceKernelSetCompiledSdkVersion606"}, + {0x358ca1bb,0,"sceKernelSetCompiledSdkVersion606"}, + // Obscure raw block API - {0xDB83A952,GetMemoryBlockPtr,"SysMemUserForUser_DB83A952"}, // GetMemoryBlockAddr + {0xDB83A952,WrapU_U,"SysMemUserForUser_DB83A952"}, // GetMemoryBlockAddr {0x91DE343C,0,"SysMemUserForUser_91DE343C"}, - {0x50F61D8A,FreeMemoryBlock,"SysMemUserForUser_50F61D8A"}, // FreeMemoryBlock - {0xFE707FDF,AllocMemoryBlock,"SysMemUserForUser_FE707FDF"}, // AllocMemoryBlock + {0x50F61D8A,WrapU_U,"SysMemUserForUser_50F61D8A"}, // FreeMemoryBlock + {0xFE707FDF,WrapU_CUUU,"SysMemUserForUser_FE707FDF"}, // AllocMemoryBlock }; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4303eca9e2..46305fe375 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -599,8 +599,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags) return SCE_KERNEL_ERROR_NOFILE; } - if (!size) - { + if (!size) { ERROR_LOG(LOADER, "sceKernelLoadModule(%s, %08x): Module file is size 0", name, flags); return SCE_KERNEL_ERROR_ILLEGAL_OBJECT; } @@ -610,10 +609,8 @@ u32 sceKernelLoadModule(const char *name, u32 flags) SceKernelLMOption *lmoption = 0; int position = 0; // TODO: Use position to decide whether to load high or low - if (PARAM(2)) - { + if (PARAM(2)) { lmoption = (SceKernelLMOption *)Memory::GetPointer(PARAM(2)); - } Module *module = 0; @@ -635,9 +632,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags) INFO_LOG(HLE,"%i=sceKernelLoadModule(name=%s,flag=%08x,%08x,%08x,%08x,position = %08x)", module->GetUID(),name,flags, lmoption->size,lmoption->mpidtext,lmoption->mpiddata,lmoption->position); - } - else - { + } else { INFO_LOG(HLE,"%i=sceKernelLoadModule(name=%s,flag=%08x,(...))", module->GetUID(), name, flags); } diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 345693540c..e3d048e545 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -128,7 +128,7 @@ void __KernelMutexShutdown() void __KernelMutexAcquireLock(Mutex *mutex, int count, SceUID thread) { -#if _DEBUG +#if defined(_DEBUG) std::pair locked = mutexHeldLocks.equal_range(thread); for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter) _dbg_assert_msg_(HLE, (*iter).second != mutex->GetUID(), "Thread %d / mutex %d wasn't removed from mutexHeldLocks properly.", thread, mutex->GetUID()); diff --git a/Core/HLE/sceKernelSemaphore.cpp b/Core/HLE/sceKernelSemaphore.cpp index 39dc209928..2fd575d0d4 100644 --- a/Core/HLE/sceKernelSemaphore.cpp +++ b/Core/HLE/sceKernelSemaphore.cpp @@ -135,7 +135,6 @@ std::vector::iterator __KernelSemaFindPriority(std::vector &wait return best; } -// int sceKernelCancelSema(SceUID id, int newCount, int *numWaitThreads); int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr) { DEBUG_LOG(HLE, "sceKernelCancelSema(%i)", id); @@ -168,7 +167,6 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr) } } -//SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option); int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr) { if (!name) @@ -204,7 +202,6 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 return id; } -//int sceKernelDeleteSema(SceUID semaid); int sceKernelDeleteSema(SceUID id) { DEBUG_LOG(HLE, "sceKernelDeleteSema(%i)", id); @@ -226,7 +223,6 @@ int sceKernelDeleteSema(SceUID id) } } -//int sceKernelDeleteSema(SceUID semaid, SceKernelSemaInfo *info); int sceKernelReferSemaStatus(SceUID id, u32 infoPtr) { u32 error; @@ -243,8 +239,7 @@ int sceKernelReferSemaStatus(SceUID id, u32 infoPtr) return error; } } - -//int sceKernelSignalSema(SceUID semaid, int signal); + int sceKernelSignalSema(SceUID id, int signal) { u32 error; @@ -359,15 +354,13 @@ int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, const char *bad } } -//int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout); int sceKernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr) { DEBUG_LOG(HLE, "sceKernelWaitSema(%i, %i, %i)", id, wantedCount, timeoutPtr); return __KernelWaitSema(id, wantedCount, timeoutPtr, "sceKernelWaitSema: Trying to wait for invalid semaphore %i", false); -} +} -//int sceKernelWaitSemaCB(SceUID semaid, int signal, SceUInt *timeout); int sceKernelWaitSemaCB(SceUID id, int wantedCount, u32 timeoutPtr) { DEBUG_LOG(HLE, "sceKernelWaitSemaCB(%i, %i, %i)", id, wantedCount, timeoutPtr);