Kernel: Rename conflicting kernel object names.
These are names that can often conflict with system headers in ports. Let's just simplify by prefixing with PSP. No actual functional/code changes, just syntax and names.
This commit is contained in:
parent
a540274435
commit
7d36b70a8e
11 changed files with 327 additions and 418 deletions
|
@ -21,7 +21,7 @@
|
|||
|
||||
class KernelThreadDebugInterface : public MIPSDebugInterface {
|
||||
public:
|
||||
KernelThreadDebugInterface(MIPSState *c, ThreadContext &t) : MIPSDebugInterface(c), ctx(t) {
|
||||
KernelThreadDebugInterface(MIPSState *c, PSPThreadContext &t) : MIPSDebugInterface(c), ctx(t) {
|
||||
}
|
||||
|
||||
unsigned int getPC() override { return ctx.pc; }
|
||||
|
@ -86,5 +86,5 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
ThreadContext &ctx;
|
||||
PSPThreadContext &ctx;
|
||||
};
|
||||
|
|
|
@ -764,10 +764,10 @@ typedef struct {
|
|||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
class AfterMatchingMipsCall : public Action {
|
||||
class AfterMatchingMipsCall : public PSPAction {
|
||||
public:
|
||||
AfterMatchingMipsCall() {}
|
||||
static Action *Create() { return new AfterMatchingMipsCall(); }
|
||||
static PSPAction *Create() { return new AfterMatchingMipsCall(); }
|
||||
void DoState(PointerWrap &p) override {
|
||||
auto s = p.Section("AfterMatchingMipsCall", 1, 2);
|
||||
if (!s)
|
||||
|
|
|
@ -338,10 +338,10 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(LoadedFont);
|
||||
};
|
||||
|
||||
class PostAllocCallback : public Action {
|
||||
class PostAllocCallback : public PSPAction {
|
||||
public:
|
||||
PostAllocCallback() {}
|
||||
static Action *Create() { return new PostAllocCallback(); }
|
||||
static PSPAction *Create() { return new PostAllocCallback(); }
|
||||
void DoState(PointerWrap &p) override {
|
||||
auto s = p.Section("PostAllocCallback", 1, 2);
|
||||
if (!s)
|
||||
|
@ -360,10 +360,10 @@ private:
|
|||
u32 errorCodePtr_;
|
||||
};
|
||||
|
||||
class PostOpenCallback : public Action {
|
||||
class PostOpenCallback : public PSPAction {
|
||||
public:
|
||||
PostOpenCallback() {}
|
||||
static Action *Create() { return new PostOpenCallback(); }
|
||||
static PSPAction *Create() { return new PostOpenCallback(); }
|
||||
void DoState(PointerWrap &p) override {
|
||||
auto s = p.Section("PostOpenCallback", 1);
|
||||
if (!s)
|
||||
|
|
|
@ -37,16 +37,14 @@ struct NativeAlarm
|
|||
u32_le commonPtr;
|
||||
};
|
||||
|
||||
struct Alarm : public KernelObject
|
||||
{
|
||||
struct PSPAlarm : public KernelObject {
|
||||
const char *GetName() override {return "[Alarm]";}
|
||||
const char *GetTypeName() override {return "Alarm";}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_ALMID; }
|
||||
static int GetStaticIDType() { return SCE_KERNEL_TMID_Alarm; }
|
||||
int GetIDType() const override { return SCE_KERNEL_TMID_Alarm; }
|
||||
|
||||
void DoState(PointerWrap &p) override
|
||||
{
|
||||
void DoState(PointerWrap &p) override {
|
||||
auto s = p.Section("Alarm", 1);
|
||||
if (!s)
|
||||
return;
|
||||
|
@ -57,7 +55,7 @@ struct Alarm : public KernelObject
|
|||
NativeAlarm alm;
|
||||
};
|
||||
|
||||
void __KernelScheduleAlarm(Alarm *alarm, u64 micro);
|
||||
void __KernelScheduleAlarm(PSPAlarm *alarm, u64 micro);
|
||||
|
||||
class AlarmIntrHandler : public IntrHandler
|
||||
{
|
||||
|
@ -69,7 +67,7 @@ public:
|
|||
u32 error;
|
||||
int alarmID = triggeredAlarm.front();
|
||||
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(alarmID, error);
|
||||
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(alarmID, error);
|
||||
if (error)
|
||||
{
|
||||
WARN_LOG(SCEKERNEL, "Ignoring deleted alarm %08x", alarmID);
|
||||
|
@ -95,7 +93,7 @@ public:
|
|||
{
|
||||
DEBUG_LOG(SCEKERNEL, "Rescheduling alarm %08x for +%dms", alarmID, result);
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(alarmID, error);
|
||||
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(alarmID, error);
|
||||
__KernelScheduleAlarm(alarm, result);
|
||||
}
|
||||
else
|
||||
|
@ -106,21 +104,19 @@ public:
|
|||
DEBUG_LOG(SCEKERNEL, "Finished alarm %08x", alarmID);
|
||||
|
||||
// Delete the alarm if it's not rescheduled.
|
||||
kernelObjects.Destroy<Alarm>(alarmID);
|
||||
kernelObjects.Destroy<PSPAlarm>(alarmID);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int alarmTimer = -1;
|
||||
|
||||
static void __KernelTriggerAlarm(u64 userdata, int cyclesLate)
|
||||
{
|
||||
static void __KernelTriggerAlarm(u64 userdata, int cyclesLate) {
|
||||
int uid = (int) userdata;
|
||||
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(uid, error);
|
||||
if (alarm)
|
||||
{
|
||||
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(uid, error);
|
||||
if (alarm) {
|
||||
triggeredAlarm.push_back(uid);
|
||||
__TriggerInterrupt(PSP_INTR_IMMEDIATE, PSP_SYSTIMER0_INTR);
|
||||
}
|
||||
|
@ -144,14 +140,12 @@ void __KernelAlarmDoState(PointerWrap &p)
|
|||
CoreTiming::RestoreRegisterEvent(alarmTimer, "Alarm", __KernelTriggerAlarm);
|
||||
}
|
||||
|
||||
KernelObject *__KernelAlarmObject()
|
||||
{
|
||||
KernelObject *__KernelAlarmObject() {
|
||||
// Default object to load from state.
|
||||
return new Alarm;
|
||||
return new PSPAlarm;
|
||||
}
|
||||
|
||||
void __KernelScheduleAlarm(Alarm *alarm, u64 micro)
|
||||
{
|
||||
void __KernelScheduleAlarm(PSPAlarm *alarm, u64 micro) {
|
||||
alarm->alm.schedule = CoreTiming::GetGlobalTimeUs() + micro;
|
||||
CoreTiming::ScheduleEvent(usToCycles(micro), alarmTimer, alarm->GetUID());
|
||||
}
|
||||
|
@ -161,7 +155,7 @@ static SceUID __KernelSetAlarm(u64 micro, u32 handlerPtr, u32 commonPtr)
|
|||
if (!Memory::IsValidAddress(handlerPtr))
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
|
||||
Alarm *alarm = new Alarm;
|
||||
PSPAlarm *alarm = new PSPAlarm();
|
||||
SceUID uid = kernelObjects.Create(alarm);
|
||||
|
||||
alarm->alm.size = NATIVEALARM_SIZE;
|
||||
|
@ -197,13 +191,13 @@ int sceKernelCancelAlarm(SceUID uid)
|
|||
|
||||
CoreTiming::UnscheduleEvent(alarmTimer, uid);
|
||||
|
||||
return kernelObjects.Destroy<Alarm>(uid);
|
||||
return kernelObjects.Destroy<PSPAlarm>(uid);
|
||||
}
|
||||
|
||||
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
||||
{
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(uid, error);
|
||||
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(uid, error);
|
||||
if (!alarm)
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelReferAlarmStatus(%08x, %08x): invalid alarm", uid, infoPtr);
|
||||
|
|
|
@ -48,15 +48,13 @@ static const u32 PSP_NUMBER_SUBINTERRUPTS = 32;
|
|||
// INTERRUPT MANAGEMENT
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class InterruptState
|
||||
{
|
||||
class InterruptState {
|
||||
public:
|
||||
void save();
|
||||
void restore();
|
||||
void clear();
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
void DoState(PointerWrap &p) {
|
||||
auto s = p.Section("InterruptState", 1);
|
||||
if (!s)
|
||||
return;
|
||||
|
@ -64,7 +62,7 @@ public:
|
|||
p.Do(savedCpu);
|
||||
}
|
||||
|
||||
ThreadContext savedCpu;
|
||||
PSPThreadContext savedCpu;
|
||||
};
|
||||
|
||||
// STATE
|
||||
|
|
|
@ -155,8 +155,8 @@ void ImportFuncSymbol(const FuncSymbolImport &func, bool reimporting);
|
|||
void ExportFuncSymbol(const FuncSymbolExport &func);
|
||||
void UnexportFuncSymbol(const FuncSymbolExport &func);
|
||||
|
||||
class Module;
|
||||
static bool KernelImportModuleFuncs(Module *module, u32 *firstImportStubAddr, bool reimporting = false);
|
||||
class PSPModule;
|
||||
static bool KernelImportModuleFuncs(PSPModule *module, u32 *firstImportStubAddr, bool reimporting = false);
|
||||
|
||||
struct NativeModule {
|
||||
u32_le next;
|
||||
|
@ -228,10 +228,10 @@ enum NativeModuleStatus {
|
|||
MODULE_STATUS_UNLOADING = 8,
|
||||
};
|
||||
|
||||
class Module : public KernelObject {
|
||||
class PSPModule : public KernelObject {
|
||||
public:
|
||||
Module() : textStart(0), textEnd(0), libstub(0), libstubend(0), memoryBlockAddr(0), isFake(false) {}
|
||||
~Module() {
|
||||
PSPModule() : textStart(0), textEnd(0), libstub(0), libstubend(0), memoryBlockAddr(0), isFake(false) {}
|
||||
~PSPModule() {
|
||||
if (memoryBlockAddr) {
|
||||
// If it's either below user memory, or using a high kernel bit, it's in kernel.
|
||||
if (memoryBlockAddr < PSP_GetUserMemoryBase() || memoryBlockAddr > PSP_GetUserMemoryEnd()) {
|
||||
|
@ -421,10 +421,10 @@ public:
|
|||
|
||||
KernelObject *__KernelModuleObject()
|
||||
{
|
||||
return new Module;
|
||||
return new PSPModule;
|
||||
}
|
||||
|
||||
class AfterModuleEntryCall : public Action {
|
||||
class AfterModuleEntryCall : public PSPAction {
|
||||
public:
|
||||
AfterModuleEntryCall() {}
|
||||
SceUID moduleID_;
|
||||
|
@ -438,7 +438,7 @@ public:
|
|||
p.Do(moduleID_);
|
||||
p.Do(retValAddr);
|
||||
}
|
||||
static Action *Create() {
|
||||
static PSPAction *Create() {
|
||||
return new AfterModuleEntryCall;
|
||||
}
|
||||
};
|
||||
|
@ -507,7 +507,7 @@ void __KernelModuleDoState(PointerWrap &p)
|
|||
u32 error;
|
||||
// We process these late, since they depend on loadedModules for interlinking.
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (module && module->libstub != 0) {
|
||||
if (!KernelImportModuleFuncs(module, nullptr, true)) {
|
||||
ERROR_LOG(LOADER, "Something went wrong loading imports on load state");
|
||||
|
@ -655,7 +655,7 @@ void ImportVarSymbol(const VarSymbolImport &var) {
|
|||
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module || !module->ImportsOrExportsModuleName(var.moduleName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ void ImportVarSymbol(const VarSymbolImport &var) {
|
|||
void ExportVarSymbol(const VarSymbolExport &var) {
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module || !module->ImportsOrExportsModuleName(var.moduleName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ void ExportVarSymbol(const VarSymbolExport &var) {
|
|||
void UnexportVarSymbol(const VarSymbolExport &var) {
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module || !module->ImportsOrExportsModuleName(var.moduleName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ void ImportFuncSymbol(const FuncSymbolImport &func, bool reimporting) {
|
|||
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module || !module->ImportsOrExportsModuleName(func.moduleName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ void ExportFuncSymbol(const FuncSymbolExport &func) {
|
|||
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module || !module->ImportsOrExportsModuleName(func.moduleName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ void UnexportFuncSymbol(const FuncSymbolExport &func) {
|
|||
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module || !module->ImportsOrExportsModuleName(func.moduleName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ void UnexportFuncSymbol(const FuncSymbolExport &func) {
|
|||
}
|
||||
}
|
||||
|
||||
void Module::Cleanup() {
|
||||
void PSPModule::Cleanup() {
|
||||
MIPSAnalyst::ForgetFunctions(textStart, textEnd);
|
||||
|
||||
loadedModules.erase(GetUID());
|
||||
|
@ -909,7 +909,7 @@ static bool IsHLEVersionedModule(const char *name) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool KernelImportModuleFuncs(Module *module, u32 *firstImportStubAddr, bool reimporting) {
|
||||
static bool KernelImportModuleFuncs(PSPModule *module, u32 *firstImportStubAddr, bool reimporting) {
|
||||
struct PspLibStubEntry {
|
||||
u32_le name;
|
||||
u16_le version;
|
||||
|
@ -1090,8 +1090,8 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) {
|
|||
return stream.total_out;
|
||||
}
|
||||
|
||||
static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) {
|
||||
Module *module = new Module;
|
||||
static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) {
|
||||
PSPModule *module = new PSPModule();
|
||||
kernelObjects.Create(module);
|
||||
loadedModules.insert(module->GetUID());
|
||||
memset(&module->nm, 0, sizeof(module->nm));
|
||||
|
@ -1133,7 +1133,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
|
|||
if (size > elfSize) {
|
||||
*error_string = StringFromFormat("ELF/PRX truncated: %d > %d", (int)size, (int)elfSize);
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(module->GetUID());
|
||||
kernelObjects.Destroy<PSPModule>(module->GetUID());
|
||||
return nullptr;
|
||||
}
|
||||
const auto maxElfSize = std::max(head->elf_size, head->psp_size);
|
||||
|
@ -1166,7 +1166,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
|
|||
if (addr == (u32)-1) {
|
||||
error = SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED;
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(module->GetUID());
|
||||
kernelObjects.Destroy<PSPModule>(module->GetUID());
|
||||
} else {
|
||||
error = 0;
|
||||
module->memoryBlockAddr = addr;
|
||||
|
@ -1207,7 +1207,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
|
|||
if (newptr)
|
||||
delete [] newptr;
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(module->GetUID());
|
||||
kernelObjects.Destroy<PSPModule>(module->GetUID());
|
||||
error = SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
|
|||
if (newptr)
|
||||
delete [] newptr;
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(module->GetUID());
|
||||
kernelObjects.Destroy<PSPModule>(module->GetUID());
|
||||
error = result;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1536,8 +1536,8 @@ static Module *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAdd
|
|||
return module;
|
||||
}
|
||||
|
||||
static Module *__KernelLoadModule(u8 *fileptr, size_t fileSize, SceKernelLMOption *options, std::string *error_string) {
|
||||
Module *module = 0;
|
||||
static PSPModule *__KernelLoadModule(u8 *fileptr, size_t fileSize, SceKernelLMOption *options, std::string *error_string) {
|
||||
PSPModule *module = nullptr;
|
||||
// Check for PBP
|
||||
if (memcmp(fileptr, "\0PBP", 4) == 0) {
|
||||
// PBP!
|
||||
|
@ -1583,8 +1583,7 @@ static Module *__KernelLoadModule(u8 *fileptr, size_t fileSize, SceKernelLMOptio
|
|||
return module;
|
||||
}
|
||||
|
||||
static void __KernelStartModule(Module *m, int args, const char *argp, SceKernelSMOption *options)
|
||||
{
|
||||
static void __KernelStartModule(PSPModule *m, int args, const char *argp, SceKernelSMOption *options) {
|
||||
m->nm.status = MODULE_STATUS_STARTED;
|
||||
if (m->nm.module_start_func != 0 && m->nm.module_start_func != (u32)-1)
|
||||
{
|
||||
|
@ -1599,16 +1598,12 @@ static void __KernelStartModule(Module *m, int args, const char *argp, SceKernel
|
|||
}
|
||||
|
||||
|
||||
u32 __KernelGetModuleGP(SceUID uid)
|
||||
{
|
||||
u32 __KernelGetModuleGP(SceUID uid) {
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(uid, error);
|
||||
if (module)
|
||||
{
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(uid, error);
|
||||
if (module) {
|
||||
return module->nm.gp_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1619,7 +1614,7 @@ void __KernelLoadReset() {
|
|||
u32 error;
|
||||
while (!loadedModules.empty()) {
|
||||
SceUID moduleID = *loadedModules.begin();
|
||||
Module *module = kernelObjects.Get<Module>(moduleID, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleID, error);
|
||||
if (module) {
|
||||
module->Cleanup();
|
||||
} else {
|
||||
|
@ -1686,12 +1681,12 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
|
|||
pspFileSystem.ReadFile(handle, temp, (size_t)info.size);
|
||||
|
||||
PSP_SetLoading("Loading modules...");
|
||||
Module *module = __KernelLoadModule(temp, (size_t)info.size, 0, error_string);
|
||||
PSPModule *module = __KernelLoadModule(temp, (size_t)info.size, 0, error_string);
|
||||
|
||||
if (!module || module->isFake) {
|
||||
if (module) {
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(module->GetUID());
|
||||
kernelObjects.Destroy<PSPModule>(module->GetUID());
|
||||
}
|
||||
ERROR_LOG(LOADER, "Failed to load module %s", filename);
|
||||
*error_string = "Failed to load executable: " + *error_string;
|
||||
|
@ -1770,7 +1765,7 @@ bool __KernelLoadGEDump(const std::string &base_filename, std::string *error_str
|
|||
Memory::WriteUnchecked_U32(runDumpCode[i], mipsr4k.pc + (int)i * sizeof(u32_le));
|
||||
}
|
||||
|
||||
Module *module = new Module;
|
||||
PSPModule *module = new PSPModule();
|
||||
kernelObjects.Create(module);
|
||||
loadedModules.insert(module->GetUID());
|
||||
memset(&module->nm, 0, sizeof(module->nm));
|
||||
|
@ -1847,7 +1842,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
|||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(lieAboutSuccessModules); i++) {
|
||||
if (!strcmp(name, lieAboutSuccessModules[i])) {
|
||||
Module *module = new Module;
|
||||
PSPModule *module = new PSPModule();
|
||||
kernelObjects.Create(module);
|
||||
loadedModules.insert(module->GetUID());
|
||||
memset(&module->nm, 0, sizeof(module->nm));
|
||||
|
@ -1898,7 +1893,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
|||
WARN_LOG_REPORT(LOADER, "sceKernelLoadModule: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext);
|
||||
}
|
||||
|
||||
Module *module = 0;
|
||||
PSPModule *module = nullptr;
|
||||
u8 *temp = new u8[(int)size];
|
||||
u32 handle = pspFileSystem.OpenFile(name, FILEACCESS_READ);
|
||||
pspFileSystem.ReadFile(handle, temp, (size_t)size);
|
||||
|
@ -1961,7 +1956,7 @@ static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 ret
|
|||
Memory::ReadStruct(optionAddr, &smoption);
|
||||
}
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module) {
|
||||
INFO_LOG(SCEMODULE, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): error %08x", moduleId, argsize, argAddr, returnValueAddr, optionAddr, error);
|
||||
RETURN(error);
|
||||
|
@ -2060,7 +2055,7 @@ static u32 sceKernelStopModule(u32 moduleId, u32 argSize, u32 argAddr, u32 retur
|
|||
// TODO: In a lot of cases (even for errors), this should resched. Needs testing.
|
||||
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module)
|
||||
{
|
||||
ERROR_LOG(SCEMODULE, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x): invalid module id", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
|
@ -2133,12 +2128,12 @@ static u32 sceKernelUnloadModule(u32 moduleId)
|
|||
{
|
||||
INFO_LOG(SCEMODULE,"sceKernelUnloadModule(%i)", moduleId);
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module)
|
||||
return hleDelayResult(error, "module unloaded", 150);
|
||||
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(moduleId);
|
||||
kernelObjects.Destroy<PSPModule>(moduleId);
|
||||
return hleDelayResult(moduleId, "module unloaded", 500);
|
||||
}
|
||||
|
||||
|
@ -2155,7 +2150,7 @@ u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize,
|
|||
// TODO: In a lot of cases (even for errors), this should resched. Needs testing.
|
||||
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(moduleID, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleID, error);
|
||||
if (!module) {
|
||||
if (WithStatus)
|
||||
ERROR_LOG(SCEMODULE, "sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): invalid module id", exitCode, argSize, argp, statusAddr, optionAddr);
|
||||
|
@ -2204,7 +2199,7 @@ u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize,
|
|||
INFO_LOG(SCEMODULE, "sceKernelSelfStopUnloadModule(%08x, %08x, %08x): no stop func", exitCode, argSize, argp);
|
||||
sceKernelExitDeleteThread(exitCode);
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(moduleID);
|
||||
kernelObjects.Destroy<PSPModule>(moduleID);
|
||||
} else {
|
||||
if (WithStatus)
|
||||
ERROR_LOG_REPORT(SCEMODULE, "sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): bad stop func address", exitCode, argSize, argp, statusAddr, optionAddr);
|
||||
|
@ -2212,7 +2207,7 @@ u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize,
|
|||
ERROR_LOG_REPORT(SCEMODULE, "sceKernelSelfStopUnloadModule(%08x, %08x, %08x): bad stop func address", exitCode, argSize, argp);
|
||||
sceKernelExitDeleteThread(exitCode);
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(moduleID);
|
||||
kernelObjects.Destroy<PSPModule>(moduleID);
|
||||
}
|
||||
} else {
|
||||
if (WithStatus)
|
||||
|
@ -2248,7 +2243,7 @@ void __KernelReturnFromModuleFunc()
|
|||
sceKernelDeleteThread(leftThreadID);
|
||||
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(leftModuleID, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(leftModuleID, error);
|
||||
if (!module) {
|
||||
ERROR_LOG_REPORT(SCEMODULE, "Returned from deleted module start/stop func");
|
||||
return;
|
||||
|
@ -2278,7 +2273,7 @@ void __KernelReturnFromModuleFunc()
|
|||
if (module->nm.status == MODULE_STATUS_UNLOADING) {
|
||||
// TODO: Delete the waiting thread?
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<Module>(leftModuleID);
|
||||
kernelObjects.Destroy<PSPModule>(leftModuleID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2288,11 +2283,9 @@ struct GetModuleIdByAddressArg
|
|||
SceUID result;
|
||||
};
|
||||
|
||||
static bool __GetModuleIdByAddressIterator(Module *module, GetModuleIdByAddressArg *state)
|
||||
{
|
||||
static bool __GetModuleIdByAddressIterator(PSPModule *module, GetModuleIdByAddressArg *state) {
|
||||
const u32 start = module->memoryBlockAddr, size = module->memoryBlockSize;
|
||||
if (start != 0 && start <= state->addr && start + size > state->addr)
|
||||
{
|
||||
if (start != 0 && start <= state->addr && start + size > state->addr) {
|
||||
state->result = module->GetUID();
|
||||
return false;
|
||||
}
|
||||
|
@ -2351,7 +2344,7 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
|||
size_t size = pspFileSystem.SeekFile(handle, 0, FILEMOVE_END);
|
||||
std::string error_string;
|
||||
pspFileSystem.SeekFile(handle, pos, FILEMOVE_BEGIN);
|
||||
Module *module = 0;
|
||||
PSPModule *module = nullptr;
|
||||
u8 *temp = new u8[size - pos];
|
||||
pspFileSystem.ReadFile(handle, temp, size - pos);
|
||||
u32 magic;
|
||||
|
@ -2409,7 +2402,7 @@ static SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags,
|
|||
WARN_LOG_REPORT(LOADER, "sceKernelLoadModuleBufferUsbWlan: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext);
|
||||
}
|
||||
std::string error_string;
|
||||
Module *module = 0;
|
||||
PSPModule *module = nullptr;
|
||||
u32 magic;
|
||||
u32 error;
|
||||
module = __KernelLoadELFFromPtr(Memory::GetPointer(bufPtr), size, 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, error);
|
||||
|
@ -2451,7 +2444,7 @@ static u32 sceKernelQueryModuleInfo(u32 uid, u32 infoAddr)
|
|||
{
|
||||
INFO_LOG(SCEMODULE, "sceKernelQueryModuleInfo(%i, %08x)", uid, infoAddr);
|
||||
u32 error;
|
||||
Module *module = kernelObjects.Get<Module>(uid, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(uid, error);
|
||||
if (!module)
|
||||
return error;
|
||||
if (!Memory::IsValidAddress(infoAddr)) {
|
||||
|
@ -2492,7 +2485,7 @@ static u32 sceKernelGetModuleIdList(u32 resultBuffer, u32 resultBufferSize, u32
|
|||
|
||||
u32 error;
|
||||
for (SceUID moduleId : loadedModules) {
|
||||
Module *module = kernelObjects.Get<Module>(moduleId, error);
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module->isFake) {
|
||||
if (resultBufferOffset < resultBufferSize) {
|
||||
Memory::Write_U32(module->GetUID(), resultBuffer + resultBufferOffset);
|
||||
|
|
|
@ -62,7 +62,7 @@ struct NativeMutex
|
|||
s32_le numWaitThreads;
|
||||
};
|
||||
|
||||
struct Mutex : public KernelObject
|
||||
struct PSPMutex : public KernelObject
|
||||
{
|
||||
const char *GetName() override { return nm.name; }
|
||||
const char *GetTypeName() override { return "Mutex"; }
|
||||
|
@ -189,7 +189,7 @@ void __KernelMutexDoState(PointerWrap &p)
|
|||
|
||||
KernelObject *__KernelMutexObject()
|
||||
{
|
||||
return new Mutex;
|
||||
return new PSPMutex;
|
||||
}
|
||||
|
||||
KernelObject *__KernelLwMutexObject()
|
||||
|
@ -202,8 +202,7 @@ void __KernelMutexShutdown()
|
|||
mutexHeldLocks.clear();
|
||||
}
|
||||
|
||||
static void __KernelMutexAcquireLock(Mutex *mutex, int count, SceUID thread)
|
||||
{
|
||||
static void __KernelMutexAcquireLock(PSPMutex *mutex, int count, SceUID thread) {
|
||||
#if defined(_DEBUG)
|
||||
auto locked = mutexHeldLocks.equal_range(thread);
|
||||
for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter)
|
||||
|
@ -216,13 +215,11 @@ static void __KernelMutexAcquireLock(Mutex *mutex, int count, SceUID thread)
|
|||
mutex->nm.lockThread = thread;
|
||||
}
|
||||
|
||||
static void __KernelMutexAcquireLock(Mutex *mutex, int count)
|
||||
{
|
||||
static void __KernelMutexAcquireLock(PSPMutex *mutex, int count) {
|
||||
__KernelMutexAcquireLock(mutex, count, __KernelGetCurThread());
|
||||
}
|
||||
|
||||
static void __KernelMutexEraseLock(Mutex *mutex)
|
||||
{
|
||||
static void __KernelMutexEraseLock(PSPMutex *mutex) {
|
||||
if (mutex->nm.lockThread != -1)
|
||||
{
|
||||
SceUID id = mutex->GetUID();
|
||||
|
@ -259,8 +256,7 @@ static std::vector<SceUID>::iterator __KernelMutexFindPriority(std::vector<SceUI
|
|||
return best;
|
||||
}
|
||||
|
||||
static bool __KernelUnlockMutexForThread(Mutex *mutex, SceUID threadID, u32 &error, int result)
|
||||
{
|
||||
static bool __KernelUnlockMutexForThread(PSPMutex *mutex, SceUID threadID, u32 &error, int result) {
|
||||
if (!HLEKernel::VerifyWait(threadID, WAITTYPE_MUTEX, mutex->GetUID()))
|
||||
return false;
|
||||
|
||||
|
@ -283,8 +279,7 @@ static bool __KernelUnlockMutexForThread(Mutex *mutex, SceUID threadID, u32 &err
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool __KernelUnlockMutexForThreadCheck(Mutex *mutex, SceUID threadID, u32 &error, int result, bool &wokeThreads)
|
||||
{
|
||||
static bool __KernelUnlockMutexForThreadCheck(PSPMutex *mutex, SceUID threadID, u32 &error, int result, bool &wokeThreads) {
|
||||
if (mutex->nm.lockThread == -1 && __KernelUnlockMutexForThread(mutex, threadID, error, 0))
|
||||
return true;
|
||||
return false;
|
||||
|
@ -292,7 +287,7 @@ static bool __KernelUnlockMutexForThreadCheck(Mutex *mutex, SceUID threadID, u32
|
|||
|
||||
void __KernelMutexBeginCallback(SceUID threadID, SceUID prevCallbackId)
|
||||
{
|
||||
auto result = HLEKernel::WaitBeginCallback<Mutex, WAITTYPE_MUTEX, SceUID>(threadID, prevCallbackId, mutexWaitTimer);
|
||||
auto result = HLEKernel::WaitBeginCallback<PSPMutex, WAITTYPE_MUTEX, SceUID>(threadID, prevCallbackId, mutexWaitTimer);
|
||||
if (result == HLEKernel::WAIT_CB_SUCCESS)
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelLockMutexCB: Suspending lock wait for callback");
|
||||
else
|
||||
|
@ -301,7 +296,7 @@ void __KernelMutexBeginCallback(SceUID threadID, SceUID prevCallbackId)
|
|||
|
||||
void __KernelMutexEndCallback(SceUID threadID, SceUID prevCallbackId)
|
||||
{
|
||||
auto result = HLEKernel::WaitEndCallback<Mutex, WAITTYPE_MUTEX, SceUID>(threadID, prevCallbackId, mutexWaitTimer, __KernelUnlockMutexForThreadCheck);
|
||||
auto result = HLEKernel::WaitEndCallback<PSPMutex, WAITTYPE_MUTEX, SceUID>(threadID, prevCallbackId, mutexWaitTimer, __KernelUnlockMutexForThreadCheck);
|
||||
if (result == HLEKernel::WAIT_CB_RESUMED_WAIT)
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelLockMutexCB: Resuming lock wait for callback");
|
||||
}
|
||||
|
@ -324,7 +319,7 @@ int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optio
|
|||
if ((attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && initialCount > 1)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
|
||||
Mutex *mutex = new Mutex();
|
||||
PSPMutex *mutex = new PSPMutex();
|
||||
SceUID id = kernelObjects.Create(mutex);
|
||||
|
||||
mutex->nm.size = sizeof(mutex->nm);
|
||||
|
@ -357,7 +352,7 @@ int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optio
|
|||
int sceKernelDeleteMutex(SceUID id)
|
||||
{
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
|
||||
if (mutex)
|
||||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelDeleteMutex(%i)", id);
|
||||
|
@ -373,7 +368,7 @@ int sceKernelDeleteMutex(SceUID id)
|
|||
if (wokeThreads)
|
||||
hleReSchedule("mutex deleted");
|
||||
|
||||
return kernelObjects.Destroy<Mutex>(id);
|
||||
return kernelObjects.Destroy<PSPMutex>(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -382,8 +377,7 @@ int sceKernelDeleteMutex(SceUID id)
|
|||
}
|
||||
}
|
||||
|
||||
static bool __KernelLockMutexCheck(Mutex *mutex, int count, u32 &error)
|
||||
{
|
||||
static bool __KernelLockMutexCheck(PSPMutex *mutex, int count, u32 &error) {
|
||||
if (error)
|
||||
return false;
|
||||
|
||||
|
@ -411,8 +405,7 @@ static bool __KernelLockMutexCheck(Mutex *mutex, int count, u32 &error)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool __KernelLockMutex(Mutex *mutex, int count, u32 &error)
|
||||
{
|
||||
static bool __KernelLockMutex(PSPMutex *mutex, int count, u32 &error) {
|
||||
if (!__KernelLockMutexCheck(mutex, count, error))
|
||||
return false;
|
||||
|
||||
|
@ -433,8 +426,7 @@ static bool __KernelLockMutex(Mutex *mutex, int count, u32 &error)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool __KernelUnlockMutex(Mutex *mutex, u32 &error)
|
||||
{
|
||||
static bool __KernelUnlockMutex(PSPMutex *mutex, u32 &error) {
|
||||
__KernelMutexEraseLock(mutex);
|
||||
|
||||
bool wokeThreads = false;
|
||||
|
@ -459,7 +451,7 @@ static bool __KernelUnlockMutex(Mutex *mutex, u32 &error)
|
|||
void __KernelMutexTimeout(u64 userdata, int cyclesLate)
|
||||
{
|
||||
SceUID threadID = (SceUID)userdata;
|
||||
HLEKernel::WaitExecTimeout<Mutex, WAITTYPE_MUTEX>(threadID);
|
||||
HLEKernel::WaitExecTimeout<PSPMutex, WAITTYPE_MUTEX>(threadID);
|
||||
}
|
||||
|
||||
void __KernelMutexThreadEnd(SceUID threadID)
|
||||
|
@ -470,7 +462,7 @@ void __KernelMutexThreadEnd(SceUID threadID)
|
|||
SceUID waitingMutexID = __KernelGetWaitID(threadID, WAITTYPE_MUTEX, error);
|
||||
if (waitingMutexID)
|
||||
{
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(waitingMutexID, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(waitingMutexID, error);
|
||||
if (mutex)
|
||||
HLEKernel::RemoveWaitingThread(mutex->waitingThreads, threadID);
|
||||
}
|
||||
|
@ -481,7 +473,7 @@ void __KernelMutexThreadEnd(SceUID threadID)
|
|||
{
|
||||
// Need to increment early so erase() doesn't invalidate.
|
||||
SceUID mutexID = (*iter++).second;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(mutexID, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(mutexID, error);
|
||||
|
||||
if (mutex)
|
||||
{
|
||||
|
@ -491,8 +483,7 @@ void __KernelMutexThreadEnd(SceUID threadID)
|
|||
}
|
||||
}
|
||||
|
||||
static void __KernelWaitMutex(Mutex *mutex, u32 timeoutPtr)
|
||||
{
|
||||
static void __KernelWaitMutex(PSPMutex *mutex, u32 timeoutPtr) {
|
||||
if (timeoutPtr == 0 || mutexWaitTimer == -1)
|
||||
return;
|
||||
|
||||
|
@ -511,7 +502,7 @@ static void __KernelWaitMutex(Mutex *mutex, u32 timeoutPtr)
|
|||
int sceKernelCancelMutex(SceUID uid, int count, u32 numWaitThreadsPtr)
|
||||
{
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(uid, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(uid, error);
|
||||
if (mutex)
|
||||
{
|
||||
bool lockable = count <= 0 || __KernelLockMutexCheck(mutex, count, error);
|
||||
|
@ -566,7 +557,7 @@ int sceKernelLockMutex(SceUID id, int count, u32 timeoutPtr)
|
|||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelLockMutex(%i, %i, %08x)", id, count, timeoutPtr);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
|
||||
|
||||
if (__KernelLockMutex(mutex, count, error))
|
||||
return 0;
|
||||
|
@ -591,7 +582,7 @@ int sceKernelLockMutexCB(SceUID id, int count, u32 timeoutPtr)
|
|||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelLockMutexCB(%i, %i, %08x)", id, count, timeoutPtr);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
|
||||
|
||||
if (!__KernelLockMutexCheck(mutex, count, error))
|
||||
{
|
||||
|
@ -630,7 +621,7 @@ int sceKernelTryLockMutex(SceUID id, int count)
|
|||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelTryLockMutex(%i, %i)", id, count);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
|
||||
|
||||
if (__KernelLockMutex(mutex, count, error))
|
||||
return 0;
|
||||
|
@ -645,7 +636,7 @@ int sceKernelUnlockMutex(SceUID id, int count)
|
|||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelUnlockMutex(%i, %i)", id, count);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
|
||||
|
||||
if (error)
|
||||
return error;
|
||||
|
@ -672,7 +663,7 @@ int sceKernelUnlockMutex(SceUID id, int count)
|
|||
int sceKernelReferMutexStatus(SceUID id, u32 infoAddr)
|
||||
{
|
||||
u32 error;
|
||||
Mutex *m = kernelObjects.Get<Mutex>(id, error);
|
||||
PSPMutex *m = kernelObjects.Get<PSPMutex>(id, error);
|
||||
if (!m)
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelReferMutexStatus(%i, %08x): invalid mutex id", id, infoAddr);
|
||||
|
|
|
@ -53,8 +53,7 @@ struct NativeSemaphore
|
|||
};
|
||||
|
||||
|
||||
struct Semaphore : public KernelObject
|
||||
{
|
||||
struct PSPSemaphore : public KernelObject {
|
||||
const char *GetName() override { return ns.name; }
|
||||
const char *GetTypeName() override { return "Semaphore"; }
|
||||
|
||||
|
@ -103,12 +102,11 @@ void __KernelSemaDoState(PointerWrap &p)
|
|||
|
||||
KernelObject *__KernelSemaphoreObject()
|
||||
{
|
||||
return new Semaphore;
|
||||
return new PSPSemaphore;
|
||||
}
|
||||
|
||||
// Returns whether the thread should be removed.
|
||||
static bool __KernelUnlockSemaForThread(Semaphore *s, SceUID threadID, u32 &error, int result, bool &wokeThreads)
|
||||
{
|
||||
static bool __KernelUnlockSemaForThread(PSPSemaphore *s, SceUID threadID, u32 &error, int result, bool &wokeThreads) {
|
||||
if (!HLEKernel::VerifyWait(threadID, WAITTYPE_SEMA, s->GetUID()))
|
||||
return true;
|
||||
|
||||
|
@ -139,7 +137,7 @@ static bool __KernelUnlockSemaForThread(Semaphore *s, SceUID threadID, u32 &erro
|
|||
|
||||
void __KernelSemaBeginCallback(SceUID threadID, SceUID prevCallbackId)
|
||||
{
|
||||
auto result = HLEKernel::WaitBeginCallback<Semaphore, WAITTYPE_SEMA, SceUID>(threadID, prevCallbackId, semaWaitTimer);
|
||||
auto result = HLEKernel::WaitBeginCallback<PSPSemaphore, WAITTYPE_SEMA, SceUID>(threadID, prevCallbackId, semaWaitTimer);
|
||||
if (result == HLEKernel::WAIT_CB_SUCCESS)
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelWaitSemaCB: Suspending sema wait for callback");
|
||||
else
|
||||
|
@ -148,15 +146,14 @@ void __KernelSemaBeginCallback(SceUID threadID, SceUID prevCallbackId)
|
|||
|
||||
void __KernelSemaEndCallback(SceUID threadID, SceUID prevCallbackId)
|
||||
{
|
||||
auto result = HLEKernel::WaitEndCallback<Semaphore, WAITTYPE_SEMA, SceUID>(threadID, prevCallbackId, semaWaitTimer, __KernelUnlockSemaForThread);
|
||||
auto result = HLEKernel::WaitEndCallback<PSPSemaphore, WAITTYPE_SEMA, SceUID>(threadID, prevCallbackId, semaWaitTimer, __KernelUnlockSemaForThread);
|
||||
if (result == HLEKernel::WAIT_CB_RESUMED_WAIT)
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelWaitSemaCB: Resuming sema wait for callback");
|
||||
}
|
||||
|
||||
// Resume all waiting threads (for delete / cancel.)
|
||||
// Returns true if it woke any threads.
|
||||
static bool __KernelClearSemaThreads(Semaphore *s, int reason)
|
||||
{
|
||||
static bool __KernelClearSemaThreads(PSPSemaphore *s, int reason) {
|
||||
u32 error;
|
||||
bool wokeThreads = false;
|
||||
std::vector<SceUID>::iterator iter, end;
|
||||
|
@ -170,7 +167,7 @@ static bool __KernelClearSemaThreads(Semaphore *s, int reason)
|
|||
int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr)
|
||||
{
|
||||
u32 error;
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(id, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
if (newCount > s->ns.maxCount)
|
||||
|
@ -215,7 +212,7 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32
|
|||
return SCE_KERNEL_ERROR_ILLEGAL_ATTR;
|
||||
}
|
||||
|
||||
Semaphore *s = new Semaphore;
|
||||
PSPSemaphore *s = new PSPSemaphore();
|
||||
SceUID id = kernelObjects.Create(s);
|
||||
|
||||
s->ns.size = sizeof(NativeSemaphore);
|
||||
|
@ -244,7 +241,7 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32
|
|||
int sceKernelDeleteSema(SceUID id)
|
||||
{
|
||||
u32 error;
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(id, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelDeleteSema(%i)", id);
|
||||
|
@ -253,7 +250,7 @@ int sceKernelDeleteSema(SceUID id)
|
|||
if (wokeThreads)
|
||||
hleReSchedule("semaphore deleted");
|
||||
|
||||
return kernelObjects.Destroy<Semaphore>(id);
|
||||
return kernelObjects.Destroy<PSPSemaphore>(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -265,7 +262,7 @@ int sceKernelDeleteSema(SceUID id)
|
|||
int sceKernelReferSemaStatus(SceUID id, u32 infoPtr)
|
||||
{
|
||||
u32 error;
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(id, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelReferSemaStatus(%i, %08x)", id, infoPtr);
|
||||
|
@ -290,7 +287,7 @@ int sceKernelReferSemaStatus(SceUID id, u32 infoPtr)
|
|||
int sceKernelSignalSema(SceUID id, int signal)
|
||||
{
|
||||
u32 error;
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(id, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
if (s->ns.currentCount + signal - (int) s->waitingThreads.size() > s->ns.maxCount)
|
||||
|
@ -336,10 +333,10 @@ void __KernelSemaTimeout(u64 userdata, int cycleslate)
|
|||
u32 error;
|
||||
SceUID uid = __KernelGetWaitID(threadID, WAITTYPE_SEMA, error);
|
||||
|
||||
HLEKernel::WaitExecTimeout<Semaphore, WAITTYPE_SEMA>(threadID);
|
||||
HLEKernel::WaitExecTimeout<PSPSemaphore, WAITTYPE_SEMA>(threadID);
|
||||
|
||||
// If in FIFO mode, that may have cleared another thread to wake up.
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(uid, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(uid, error);
|
||||
if (s && (s->ns.attr & PSP_SEMA_ATTR_PRIORITY) == PSP_SEMA_ATTR_FIFO) {
|
||||
bool wokeThreads;
|
||||
std::vector<SceUID>::iterator iter = s->waitingThreads.begin();
|
||||
|
@ -351,8 +348,7 @@ void __KernelSemaTimeout(u64 userdata, int cycleslate)
|
|||
}
|
||||
}
|
||||
|
||||
static void __KernelSetSemaTimeout(Semaphore *s, u32 timeoutPtr)
|
||||
{
|
||||
static void __KernelSetSemaTimeout(PSPSemaphore *s, u32 timeoutPtr) {
|
||||
if (timeoutPtr == 0 || semaWaitTimer == -1)
|
||||
return;
|
||||
|
||||
|
@ -378,7 +374,7 @@ static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool pro
|
|||
hleEatCycles(500);
|
||||
|
||||
u32 error;
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(id, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
if (wantedCount > s->ns.maxCount)
|
||||
|
@ -438,7 +434,7 @@ int sceKernelPollSema(SceUID id, int wantedCount)
|
|||
}
|
||||
|
||||
u32 error;
|
||||
Semaphore *s = kernelObjects.Get<Semaphore>(id, error);
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
if (s->ns.currentCount >= wantedCount && s->waitingThreads.size() == 0)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,7 @@
|
|||
// There's a good description of the thread scheduling rules in:
|
||||
// http://code.google.com/p/jpcsp/source/browse/trunk/src/jpcsp/HLE/modules150/ThreadManForUser.java
|
||||
|
||||
class Thread;
|
||||
class PSPThread;
|
||||
class DebugInterface;
|
||||
|
||||
int sceKernelChangeThreadPriority(SceUID threadID, int priority);
|
||||
|
@ -119,8 +119,7 @@ typedef void (* WaitEndCallbackFunc)(SceUID threadID, SceUID prevCallbackId);
|
|||
|
||||
void __KernelRegisterWaitTypeFuncs(WaitType type, WaitBeginCallbackFunc beginFunc, WaitEndCallbackFunc endFunc);
|
||||
|
||||
struct ThreadContext
|
||||
{
|
||||
struct PSPThreadContext {
|
||||
void reset();
|
||||
|
||||
// r must be followed by f.
|
||||
|
@ -168,8 +167,8 @@ u32 __KernelGetCurThreadStackStart();
|
|||
const char *__KernelGetThreadName(SceUID threadID);
|
||||
bool KernelIsThreadDormant(SceUID threadID);
|
||||
|
||||
void __KernelSaveContext(ThreadContext *ctx, bool vfpuEnabled);
|
||||
void __KernelLoadContext(ThreadContext *ctx, bool vfpuEnabled);
|
||||
void __KernelSaveContext(PSPThreadContext *ctx, bool vfpuEnabled);
|
||||
void __KernelLoadContext(PSPThreadContext *ctx, bool vfpuEnabled);
|
||||
|
||||
u32 __KernelResumeThreadFromWait(SceUID threadID, u32 retval); // can return an error value
|
||||
u32 __KernelResumeThreadFromWait(SceUID threadID, u64 retval);
|
||||
|
@ -216,10 +215,10 @@ int sceKernelGetCallbackCount(SceUID cbId);
|
|||
void sceKernelCheckCallback();
|
||||
int sceKernelReferCallbackStatus(SceUID cbId, u32 statusAddr);
|
||||
|
||||
class Action;
|
||||
class PSPAction;
|
||||
|
||||
// Not an official Callback object, just calls a mips function on the current thread.
|
||||
void __KernelDirectMipsCall(u32 entryPoint, Action *afterAction, u32 args[], int numargs, bool reschedAfter);
|
||||
void __KernelDirectMipsCall(u32 entryPoint, PSPAction *afterAction, u32 args[], int numargs, bool reschedAfter);
|
||||
|
||||
void __KernelReturnFromMipsCall(); // Called as HLE function
|
||||
bool __KernelInCallback();
|
||||
|
@ -228,8 +227,8 @@ bool __KernelInCallback();
|
|||
bool __KernelCheckCallbacks();
|
||||
bool __KernelForceCallbacks();
|
||||
bool __KernelCurHasReadyCallbacks();
|
||||
void __KernelSwitchContext(Thread *target, const char *reason);
|
||||
bool __KernelExecutePendingMipsCalls(Thread *currentThread, bool reschedAfter);
|
||||
void __KernelSwitchContext(PSPThread *target, const char *reason);
|
||||
bool __KernelExecutePendingMipsCalls(PSPThread *currentThread, bool reschedAfter);
|
||||
void __KernelNotifyCallback(SceUID cbId, int notifyArg);
|
||||
|
||||
// Switch to an idle / non-user thread, if not already on one.
|
||||
|
@ -243,8 +242,8 @@ u32 __KernelSetThreadRA(SceUID threadID, u32 nid);
|
|||
|
||||
// A call into game code. These can be pending on a thread.
|
||||
// Similar to Callback-s (NOT CallbackInfos) in JPCSP.
|
||||
typedef Action *(*ActionCreator)();
|
||||
Action *__KernelCreateAction(int actionType);
|
||||
typedef PSPAction *(*ActionCreator)();
|
||||
PSPAction *__KernelCreateAction(int actionType);
|
||||
int __KernelRegisterActionType(ActionCreator creator);
|
||||
void __KernelRestoreActionType(int actionType, ActionCreator creator);
|
||||
|
||||
|
@ -258,7 +257,7 @@ struct MipsCall {
|
|||
u32 cbId;
|
||||
u32 args[6];
|
||||
int numArgs;
|
||||
Action *doAfter;
|
||||
PSPAction *doAfter;
|
||||
u32 savedPc;
|
||||
u32 savedV0;
|
||||
u32 savedV1;
|
||||
|
@ -279,10 +278,10 @@ struct MipsCall {
|
|||
}
|
||||
};
|
||||
|
||||
class Action
|
||||
class PSPAction
|
||||
{
|
||||
public:
|
||||
virtual ~Action() {}
|
||||
virtual ~PSPAction() {}
|
||||
virtual void run(MipsCall &call) = 0;
|
||||
virtual void DoState(PointerWrap &p) = 0;
|
||||
int actionTypeID;
|
||||
|
@ -300,7 +299,7 @@ enum ThreadStatus
|
|||
THREADSTATUS_WAITSUSPEND = THREADSTATUS_WAIT | THREADSTATUS_SUSPEND
|
||||
};
|
||||
|
||||
void __KernelChangeThreadState(Thread *thread, ThreadStatus newStatus);
|
||||
void __KernelChangeThreadState(PSPThread *thread, ThreadStatus newStatus);
|
||||
|
||||
typedef void (*ThreadCallback)(SceUID threadID);
|
||||
void __KernelListenThreadEnd(ThreadCallback callback);
|
||||
|
|
|
@ -355,11 +355,11 @@ static void AnalyzeMpeg(u8 *buffer, u32 validSize, MpegContext *ctx) {
|
|||
INFO_LOG(ME, "First timestamp: %lld, Last timestamp: %lld", ctx->mpegFirstTimestamp, ctx->mpegLastTimestamp);
|
||||
}
|
||||
|
||||
class PostPutAction : public Action {
|
||||
class PostPutAction : public PSPAction {
|
||||
public:
|
||||
PostPutAction() {}
|
||||
void setRingAddr(u32 ringAddr) { ringAddr_ = ringAddr; }
|
||||
static Action *Create() { return new PostPutAction; }
|
||||
static PSPAction *Create() { return new PostPutAction; }
|
||||
void DoState(PointerWrap &p) override {
|
||||
auto s = p.Section("PostPutAction", 1);
|
||||
if (!s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue