Correct sceKernelTlspl func names, etc.

This is mostly pedantic but it's nice to have the right names.
This commit is contained in:
Unknown W. Brackets 2013-12-02 23:29:52 -08:00
parent 7f1a26e5e6
commit e73d43c434
7 changed files with 74 additions and 76 deletions

View File

@ -590,8 +590,8 @@ KernelObject *KernelObjectPool::CreateByIDType(int type)
return __KernelThreadObject();
case SCE_KERNEL_TMID_VTimer:
return __KernelVTimerObject();
case SCE_KERNEL_TMID_Tls:
return __KernelTlsObject();
case SCE_KERNEL_TMID_Tlspl:
return __KernelTlsplObject();
case PPSSPP_KERNEL_TMID_File:
return __KernelFileNodeObject();
case PPSSPP_KERNEL_TMID_DirList:
@ -851,15 +851,14 @@ const HLEFunction ThreadManForUser[] =
{0xd8b299ae,WrapU_IUUU<sceKernelSetVTimerHandler>, "sceKernelSetVTimerHandler"},
{0x53B00E9A,WrapU_IU64UU<sceKernelSetVTimerHandlerWide>, "sceKernelSetVTimerHandlerWide"},
// Names are just guesses, not correct.
{0x8daff657,WrapI_CUUUUU<sceKernelCreateTls>, "sceKernelCreateTls"},
{0x32bf938e,WrapI_I<sceKernelDeleteTls>, "sceKernelDeleteTls"},
{0x721067F3,WrapI_IU<sceKernelReferTlsStatus>, "sceKernelReferTlsStatus"},
{0x8daff657,WrapI_CUUUUU<sceKernelCreateTlspl>, "sceKernelCreateTlspl"},
{0x32bf938e,WrapI_I<sceKernelDeleteTlspl>, "sceKernelDeleteTlspl"},
{0x721067F3,WrapI_IU<sceKernelReferTlsplStatus>, "sceKernelReferTlsplStatus"},
// Not completely certain about args.
{0x4A719FB2,WrapI_I<sceKernelFreeTls>, "sceKernelFreeTls"},
// Probably internal, not sure. Takes (uid, &addr) as parameters... probably.
//{0x65F54FFB,0, "_sceKernelAllocateTls"},
// NOTE: sceKernelAllocateTls is in Kernel_Library, see sceKernelInterrupt.cpp.
{0x4A719FB2,WrapI_I<sceKernelFreeTlspl>, "sceKernelFreeTlspl"},
// Internal. Takes (uid, &addr) as parameters... probably.
//{0x65F54FFB,0, "_sceKernelAllocateTlspl"},
// NOTE: sceKernelGetTlsAddr is in Kernel_Library, see sceKernelInterrupt.cpp.
// Not sure if these should be hooked up. See below.
{0x0E927AED, _sceKernelReturnFromTimerHandler, "_sceKernelReturnFromTimerHandler"},

View File

@ -328,7 +328,7 @@ enum TMIDPurpose
SCE_KERNEL_TMID_SuspendThread = 66,
SCE_KERNEL_TMID_DormantThread = 67,
// No idea what the correct value is here or how to find out.
SCE_KERNEL_TMID_Tls = 0x1001,
SCE_KERNEL_TMID_Tlspl = 0x1001,
// Not official, but need ids for save states.
PPSSPP_KERNEL_TMID_Module = 0x100001,

View File

@ -600,8 +600,7 @@ const HLEFunction Kernel_Library[] =
{0x293b45b8,WrapI_V<sceKernelGetThreadId>, "sceKernelGetThreadId"},
{0xD13BDE95,WrapI_V<sceKernelCheckThreadStack>, "sceKernelCheckThreadStack"},
{0x1839852A,WrapU_UUU<sceKernelMemcpy>, "sceKernelMemcpy"},
// Name is only a guess.
{0xfa835cde,WrapI_I<sceKernelAllocateTls>, "sceKernelAllocateTls"},
{0xfa835cde,WrapI_I<sceKernelGetTlsAddr>, "sceKernelGetTlsAddr"},
};
void Register_Kernel_Library()

View File

@ -32,7 +32,7 @@
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HLE/KernelWaitHelpers.h"
const int TLS_NUM_INDEXES = 16;
const int TLSPL_NUM_INDEXES = 16;
//////////////////////////////////////////////////////////////////////////
// STATE BEGIN
@ -41,7 +41,7 @@ BlockAllocator kernelMemory(256);
static int vplWaitTimer = -1;
static int fplWaitTimer = -1;
static bool tlsUsedIndexes[TLS_NUM_INDEXES];
static bool tlsplUsedIndexes[TLSPL_NUM_INDEXES];
// STATE END
//////////////////////////////////////////////////////////////////////////
@ -218,7 +218,7 @@ void __KernelMemoryInit()
flags_ = 0;
sdkVersion_ = 0;
compilerVersion_ = 0;
memset(tlsUsedIndexes, 0, sizeof(tlsUsedIndexes));
memset(tlsplUsedIndexes, 0, sizeof(tlsplUsedIndexes));
__KernelRegisterWaitTypeFuncs(WAITTYPE_VPL, __KernelVplBeginCallback, __KernelVplEndCallback);
__KernelRegisterWaitTypeFuncs(WAITTYPE_FPL, __KernelFplBeginCallback, __KernelFplEndCallback);
@ -240,7 +240,7 @@ void __KernelMemoryDoState(PointerWrap &p)
p.Do(flags_);
p.Do(sdkVersion_);
p.Do(compilerVersion_);
p.DoArray(tlsUsedIndexes, ARRAY_SIZE(tlsUsedIndexes));
p.DoArray(tlsplUsedIndexes, ARRAY_SIZE(tlsplUsedIndexes));
}
void __KernelMemoryShutdown()
@ -1577,20 +1577,20 @@ u32 SysMemUserForUser_D8DE5C1E(){
enum
{
PSP_ERROR_UNKNOWN_TLS_ID = 0x800201D0,
PSP_ERROR_TOO_MANY_TLS = 0x800201D1,
PSP_ERROR_UNKNOWN_TLSPL_ID = 0x800201D0,
PSP_ERROR_TOO_MANY_TLSPL = 0x800201D1,
};
enum
{
// TODO: Complete untested guesses.
PSP_TLS_ATTR_FIFO = 0,
PSP_TLS_ATTR_PRIORITY = 0x100,
PSP_TLS_ATTR_HIGHMEM = 0x4000,
PSP_TLS_ATTR_KNOWN = PSP_TLS_ATTR_HIGHMEM | PSP_TLS_ATTR_PRIORITY | PSP_TLS_ATTR_FIFO,
PSP_TLSPL_ATTR_FIFO = 0,
PSP_TLSPL_ATTR_PRIORITY = 0x100,
PSP_TLSPL_ATTR_HIGHMEM = 0x4000,
PSP_TLSPL_ATTR_KNOWN = PSP_TLSPL_ATTR_HIGHMEM | PSP_TLSPL_ATTR_PRIORITY | PSP_TLSPL_ATTR_FIFO,
};
struct NativeTls
struct NativeTlspl
{
SceSize_le size;
char name[32];
@ -1602,15 +1602,15 @@ struct NativeTls
u32_le numWaitThreads;
};
struct TLS : public KernelObject
struct TLSPL : public KernelObject
{
const char *GetName() {return ntls.name;}
const char *GetTypeName() {return "TLS";}
static u32 GetMissingErrorCode() { return PSP_ERROR_UNKNOWN_TLS_ID; }
static int GetStaticIDType() { return SCE_KERNEL_TMID_Tls; }
int GetIDType() const { return SCE_KERNEL_TMID_Tls; }
static u32 GetMissingErrorCode() { return PSP_ERROR_UNKNOWN_TLSPL_ID; }
static int GetStaticIDType() { return SCE_KERNEL_TMID_Tlspl; }
int GetIDType() const { return SCE_KERNEL_TMID_Tlspl; }
TLS() : next(0) {}
TLSPL() : next(0) {}
virtual void DoState(PointerWrap &p)
{
@ -1625,39 +1625,39 @@ struct TLS : public KernelObject
p.Do(usage);
}
NativeTls ntls;
NativeTlspl ntls;
u32 address;
std::vector<SceUID> waitingThreads;
int next;
std::vector<SceUID> usage;
};
KernelObject *__KernelTlsObject()
KernelObject *__KernelTlsplObject()
{
return new TLS;
return new TLSPL;
}
SceUID sceKernelCreateTls(const char *name, u32 partition, u32 attr, u32 blockSize, u32 count, u32 optionsPtr)
SceUID sceKernelCreateTlspl(const char *name, u32 partition, u32 attr, u32 blockSize, u32 count, u32 optionsPtr)
{
if (!name)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTls(): invalid name", SCE_KERNEL_ERROR_NO_MEMORY);
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTlspl(): invalid name", SCE_KERNEL_ERROR_NO_MEMORY);
return SCE_KERNEL_ERROR_NO_MEMORY;
}
if ((attr & ~PSP_TLS_ATTR_KNOWN) >= 0x100)
if ((attr & ~PSP_TLSPL_ATTR_KNOWN) >= 0x100)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTls(): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, attr);
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTlspl(): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, attr);
return SCE_KERNEL_ERROR_ILLEGAL_ATTR;
}
if (partition < 1 || partition > 9 || partition == 7)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTls(): invalid partition %d", SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, partition);
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTlspl(): invalid partition %d", SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, partition);
return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT;
}
// We only support user right now.
if (partition != 2 && partition != 6)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTls(): invalid partition %d", SCE_KERNEL_ERROR_ILLEGAL_PERM, partition);
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTlspl(): invalid partition %d", SCE_KERNEL_ERROR_ILLEGAL_PERM, partition);
return SCE_KERNEL_ERROR_ILLEGAL_PERM;
}
@ -1670,13 +1670,13 @@ SceUID sceKernelCreateTls(const char *name, u32 partition, u32 attr, u32 blockSi
illegalMemSize = true;
if (illegalMemSize)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTls(): invalid blockSize/count", SCE_KERNEL_ERROR_ILLEGAL_MEMSIZE);
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTlspl(): invalid blockSize/count", SCE_KERNEL_ERROR_ILLEGAL_MEMSIZE);
return SCE_KERNEL_ERROR_ILLEGAL_MEMSIZE;
}
int index = -1;
for (int i = 0; i < TLS_NUM_INDEXES; ++i)
if (tlsUsedIndexes[i] == false)
for (int i = 0; i < TLSPL_NUM_INDEXES; ++i)
if (tlsplUsedIndexes[i] == false)
{
index = i;
break;
@ -1684,21 +1684,21 @@ SceUID sceKernelCreateTls(const char *name, u32 partition, u32 attr, u32 blockSi
if (index == -1)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTls(): ran out of indexes for TLS objects", PSP_ERROR_TOO_MANY_TLS);
return PSP_ERROR_TOO_MANY_TLS;
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateTlspl(): ran out of indexes for TLS pools", PSP_ERROR_TOO_MANY_TLSPL);
return PSP_ERROR_TOO_MANY_TLSPL;
}
u32 totalSize = blockSize * count;
u32 blockPtr = userMemory.Alloc(totalSize, (attr & PSP_TLS_ATTR_HIGHMEM) != 0, name);
u32 blockPtr = userMemory.Alloc(totalSize, (attr & PSP_TLSPL_ATTR_HIGHMEM) != 0, name);
userMemory.ListBlocks();
if (blockPtr == (u32) -1)
{
ERROR_LOG(SCEKERNEL, "%08x=sceKernelCreateTls(%s, %d, %08x, %d, %d, %08x): failed to allocate memory", SCE_KERNEL_ERROR_NO_MEMORY, name, partition, attr, blockSize, count, optionsPtr);
ERROR_LOG(SCEKERNEL, "%08x=sceKernelCreateTlspl(%s, %d, %08x, %d, %d, %08x): failed to allocate memory", SCE_KERNEL_ERROR_NO_MEMORY, name, partition, attr, blockSize, count, optionsPtr);
return SCE_KERNEL_ERROR_NO_MEMORY;
}
TLS *tls = new TLS();
TLSPL *tls = new TLSPL();
SceUID id = kernelObjects.Create(tls);
tls->ntls.size = sizeof(tls->ntls);
@ -1706,7 +1706,7 @@ SceUID sceKernelCreateTls(const char *name, u32 partition, u32 attr, u32 blockSi
tls->ntls.name[KERNELOBJECT_MAX_NAME_LENGTH] = 0;
tls->ntls.attr = attr;
tls->ntls.index = index;
tlsUsedIndexes[index] = true;
tlsplUsedIndexes[index] = true;
tls->ntls.blockSize = blockSize;
tls->ntls.totalBlocks = count;
tls->ntls.freeBlocks = count;
@ -1714,47 +1714,47 @@ SceUID sceKernelCreateTls(const char *name, u32 partition, u32 attr, u32 blockSi
tls->address = blockPtr;
tls->usage.resize(count, 0);
WARN_LOG(SCEKERNEL, "%08x=sceKernelCreateTls(%s, %d, %08x, %d, %d, %08x)", id, name, partition, attr, blockSize, count, optionsPtr);
WARN_LOG(SCEKERNEL, "%08x=sceKernelCreateTlspl(%s, %d, %08x, %d, %d, %08x)", id, name, partition, attr, blockSize, count, optionsPtr);
// TODO: just alignment?
if (optionsPtr != 0)
{
u32 size = Memory::Read_U32(optionsPtr);
if (size > 4)
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateTls(%s) unsupported options parameter, size = %d", name, size);
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateTlspl(%s) unsupported options parameter, size = %d", name, size);
}
if ((attr & PSP_TLS_ATTR_PRIORITY) != 0)
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateTls(%s) unsupported attr parameter: %08x", name, attr);
if ((attr & PSP_TLSPL_ATTR_PRIORITY) != 0)
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateTlspl(%s) unsupported attr parameter: %08x", name, attr);
return id;
}
// Parameters are an educated guess.
int sceKernelDeleteTls(SceUID uid)
int sceKernelDeleteTlspl(SceUID uid)
{
WARN_LOG(SCEKERNEL, "sceKernelDeleteTls(%08x)", uid);
WARN_LOG(SCEKERNEL, "sceKernelDeleteTlspl(%08x)", uid);
u32 error;
TLS *tls = kernelObjects.Get<TLS>(uid, error);
TLSPL *tls = kernelObjects.Get<TLSPL>(uid, error);
if (tls)
{
// TODO: Wake waiting threads, probably?
userMemory.Free(tls->address);
tlsUsedIndexes[tls->ntls.index] = false;
kernelObjects.Destroy<TLS>(uid);
tlsplUsedIndexes[tls->ntls.index] = false;
kernelObjects.Destroy<TLSPL>(uid);
}
return error;
}
int sceKernelAllocateTls(SceUID uid)
int sceKernelGetTlsAddr(SceUID uid)
{
// TODO: Allocate downward if PSP_TLS_ATTR_HIGHMEM?
DEBUG_LOG(SCEKERNEL, "sceKernelAllocateTls(%08x)", uid);
// TODO: Allocate downward if PSP_TLSPL_ATTR_HIGHMEM?
DEBUG_LOG(SCEKERNEL, "sceKernelGetTlsAddr(%08x)", uid);
if (!__KernelIsDispatchEnabled() || __IsInInterrupt())
return 0;
u32 error;
TLS *tls = kernelObjects.Get<TLS>(uid, error);
TLSPL *tls = kernelObjects.Get<TLSPL>(uid, error);
if (tls)
{
SceUID threadID = __KernelGetCurThread();
@ -1787,7 +1787,7 @@ int sceKernelAllocateTls(SceUID uid)
if (allocBlock == -1)
{
tls->waitingThreads.push_back(threadID);
__KernelWaitCurThread(WAITTYPE_TLS, uid, 1, 0, false, "allocate tls");
__KernelWaitCurThread(WAITTYPE_TLSPL, uid, 1, 0, false, "allocate tls");
return -1;
}
@ -1798,11 +1798,11 @@ int sceKernelAllocateTls(SceUID uid)
}
// Parameters are an educated guess.
int sceKernelFreeTls(SceUID uid)
int sceKernelFreeTlspl(SceUID uid)
{
WARN_LOG(SCEKERNEL, "UNIMPL sceKernelFreeTls(%08x)", uid);
WARN_LOG(SCEKERNEL, "UNIMPL sceKernelFreeTlspl(%08x)", uid);
u32 error;
TLS *tls = kernelObjects.Get<TLS>(uid, error);
TLSPL *tls = kernelObjects.Get<TLSPL>(uid, error);
if (tls)
{
SceUID threadID = __KernelGetCurThread();
@ -1827,7 +1827,7 @@ int sceKernelFreeTls(SceUID uid)
tls->waitingThreads.erase(tls->waitingThreads.begin());
// This thread must've been woken up.
if (!HLEKernel::VerifyWait(waitingThreadID, WAITTYPE_TLS, uid))
if (!HLEKernel::VerifyWait(waitingThreadID, WAITTYPE_TLSPL, uid))
continue;
// Otherwise, if there was a thread waiting, we were full, so this newly freed one is theirs.
@ -1852,11 +1852,11 @@ int sceKernelFreeTls(SceUID uid)
}
// Parameters are an educated guess.
int sceKernelReferTlsStatus(SceUID uid, u32 infoPtr)
int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr)
{
DEBUG_LOG(SCEKERNEL, "sceKernelReferTlsStatus(%08x, %08x)", uid, infoPtr);
DEBUG_LOG(SCEKERNEL, "sceKernelReferTlsplStatus(%08x, %08x)", uid, infoPtr);
u32 error;
TLS *tls = kernelObjects.Get<TLS>(uid, error);
TLSPL *tls = kernelObjects.Get<TLSPL>(uid, error);
if (tls)
{
// TODO: Check size.

View File

@ -35,7 +35,7 @@ void __KernelMemoryShutdown();
KernelObject *__KernelMemoryFPLObject();
KernelObject *__KernelMemoryVPLObject();
KernelObject *__KernelMemoryPMBObject();
KernelObject *__KernelTlsObject();
KernelObject *__KernelTlsplObject();
SceUID sceKernelCreateVpl(const char *name, int partition, u32 attr, u32 vplSize, u32 optPtr);
int sceKernelDeleteVpl(SceUID uid);
@ -57,10 +57,10 @@ int sceKernelReferFplStatus(SceUID uid, u32 statusPtr);
int sceKernelGetCompiledSdkVersion();
SceUID sceKernelCreateTls(const char *name, u32 partitionid, u32 attr, u32 size, u32 count, u32 optionsPtr);
int sceKernelDeleteTls(SceUID uid);
int sceKernelAllocateTls(SceUID uid);
int sceKernelFreeTls(SceUID uid);
int sceKernelReferTlsStatus(SceUID uid, u32 infoPtr);
SceUID sceKernelCreateTlspl(const char *name, u32 partitionid, u32 attr, u32 size, u32 count, u32 optionsPtr);
int sceKernelDeleteTlspl(SceUID uid);
int sceKernelGetTlsAddr(SceUID uid);
int sceKernelFreeTlspl(SceUID uid);
int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr);
void Register_SysMemUserForUser();

View File

@ -68,7 +68,7 @@ const WaitTypeNames waitTypeNames[] = {
{ WAITTYPE_GELISTSYNC, "GeListSync" },
{ WAITTYPE_MODULE, "Module" },
{ WAITTYPE_HLEDELAY, "HleDelay" },
{ WAITTYPE_TLS, "TLS" },
{ WAITTYPE_TLSPL, "TLS" },
{ WAITTYPE_VMEM, "Volatile Mem" },
{ WAITTYPE_ASYNCIO, "AsyncIO" },
};

View File

@ -92,7 +92,7 @@ enum WaitType
WAITTYPE_GELISTSYNC = 18,
WAITTYPE_MODULE = 19,
WAITTYPE_HLEDELAY = 20,
WAITTYPE_TLS = 21,
WAITTYPE_TLSPL = 21,
WAITTYPE_VMEM = 22,
WAITTYPE_ASYNCIO = 23,