Merge pull request #572 from unknownbrackets/start-module

sceKernelStartModule() basic functionality
This commit is contained in:
Henrik Rydgård committed 2013-02-02 16:30:31 -08:00
commit 174585a627
3 files changed
+32 -14

No files matched your search

+21 -11
View File
@@ -826,25 +826,35 @@ void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValu
RETURN(error);
return;
} else if (module->isFake) {
INFO_LOG(HLE,"sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): faked (undecryptable module)",
INFO_LOG(HLE, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): faked (undecryptable module)",
moduleId,argsize,argAddr,returnValueAddr,optionAddr);
} else {
ERROR_LOG(HLE,"UNIMPL sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x)",
WARN_LOG(HLE, "UNIMPL sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x)",
moduleId,argsize,argAddr,returnValueAddr,optionAddr);
u32 entryAddr = module->nm.entry_addr;
if (entryAddr == -1) {
entryAddr = module->nm.module_start_func;
// attr = module->nm
if (entryAddr == -1 || entryAddr == module->memoryBlockAddr - 1) {
// TODO: Do these always take effect, or do they not override optionAddr?
if (module->nm.module_start_func != 0 && module->nm.module_start_func != -1) {
entryAddr = module->nm.module_start_func;
priority = module->nm.module_start_thread_priority;
attr = module->nm.module_start_thread_attr;
stacksize = module->nm.module_start_thread_stacksize;
} else {
// TODO: Fix, check return value? Or do we call nothing?
RETURN(moduleId);
return;
}
}
SceUID threadID = __KernelCreateThread(module->nm.name, moduleId, entryAddr, priority, stacksize, attr, 0);
sceKernelStartThread(threadID, argsize, argAddr);
// TODO: This will probably return the wrong value?
sceKernelWaitThreadEnd(threadID, 0);
}
//SceUID threadId;
//__KernelCreateThread(threadId, moduleId, module->nm.name, module->nm.entry_addr, priority, stacksize, attr);
// Apparently, we need to call the entry point directly and insert the return value afterwards. This calls
// for a MipsCall and an Action. TODO
RETURN(moduleId); // TODO: Delete
// TODO: Is this the correct return value?
RETURN(moduleId);
}
void sceKernelStopModule(u32 moduleId, u32 argSize, u32 argAddr, u32 returnValueAddr, u32 optionAddr)
+10 -3
View File
@@ -1357,8 +1357,7 @@ void __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int pr
Memory::Write_U8(argp[i], location + i);
}
int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr)
int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr)
{
if (threadName == NULL)
{
@@ -1382,13 +1381,21 @@ int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stack
attr |= PSP_THREAD_ATTR_USER;
SceUID id;
__KernelCreateThread(id, curModule, threadName, entry, prio, stacksize, attr);
__KernelCreateThread(id, moduleID, threadName, entry, prio, stacksize, attr);
INFO_LOG(HLE, "%i = sceKernelCreateThread(name=\"%s\", entry=%08x, prio=%x, stacksize=%i)", id, threadName, entry, prio, stacksize);
if (optionAddr != 0)
WARN_LOG(HLE, "sceKernelCreateThread(name=\"%s\"): unsupported options parameter %08x", threadName, optionAddr);
return id;
}
int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr)
{
SceUID moduleId = curModule;
if (__GetCurrentThread())
moduleId = __GetCurrentThread()->moduleId;
return __KernelCreateThread(threadName, moduleId, entry, prio, stacksize, attr, optionAddr);
}
// int sceKernelStartThread(SceUID threadToStartID, SceSize argSize, void *argBlock)
int sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr)
+1
View File
@@ -26,6 +26,7 @@
void sceKernelChangeThreadPriority();
int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr);
int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr);
void sceKernelDelayThread();
void sceKernelDelayThreadCB();