mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Kernel: Allow volatile for MsgPipe buffers.
This commit is contained in:
parent
56f2d7cdac
commit
251cc73afd
4 changed files with 27 additions and 35 deletions
|
@ -820,7 +820,7 @@ const HLEFunction ThreadManForUser[] =
|
|||
{0X87D4DD36, &WrapI_IU<sceKernelCancelReceiveMbx>, "sceKernelCancelReceiveMbx", 'i', "ix" },
|
||||
{0XA8E8C846, &WrapI_IU<sceKernelReferMbxStatus>, "sceKernelReferMbxStatus", 'i', "ip" },
|
||||
|
||||
{0X7C0DC2A0, &WrapI_CIUUU<sceKernelCreateMsgPipe>, "sceKernelCreateMsgPipe", 'i', "sixxx" },
|
||||
{0X7C0DC2A0, &WrapI_CIUUU<sceKernelCreateMsgPipe>, "sceKernelCreateMsgPipe", 'i', "sixxp" },
|
||||
{0XF0B7DA1C, &WrapI_I<sceKernelDeleteMsgPipe>, "sceKernelDeleteMsgPipe", 'i', "i" },
|
||||
{0X876DBFAD, &WrapI_IUUUUU<sceKernelSendMsgPipe>, "sceKernelSendMsgPipe", 'i', "ixxxxx" },
|
||||
{0X7C41F2C2, &WrapI_IUUUUU<sceKernelSendMsgPipeCB>, "sceKernelSendMsgPipeCB", 'i', "ixxxxx" },
|
||||
|
|
|
@ -504,7 +504,7 @@ void __KernelMemoryShutdown()
|
|||
MemBlockInfoShutdown();
|
||||
}
|
||||
|
||||
static BlockAllocator *BlockAllocatorFromID(int id) {
|
||||
BlockAllocator *BlockAllocatorFromID(int id) {
|
||||
switch (id) {
|
||||
case 1:
|
||||
case 3:
|
||||
|
@ -529,7 +529,7 @@ static BlockAllocator *BlockAllocatorFromID(int id) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static int BlockAllocatorToID(const BlockAllocator *alloc) {
|
||||
int BlockAllocatorToID(const BlockAllocator *alloc) {
|
||||
if (alloc == &kernelMemory)
|
||||
return 1;
|
||||
if (alloc == &userMemory)
|
||||
|
@ -539,7 +539,7 @@ static int BlockAllocatorToID(const BlockAllocator *alloc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static BlockAllocator *BlockAllocatorFromAddr(u32 addr) {
|
||||
BlockAllocator *BlockAllocatorFromAddr(u32 addr) {
|
||||
addr &= 0x3FFFFFFF;
|
||||
if (Memory::IsKernelAndNotVolatileAddress(addr))
|
||||
return &kernelMemory;
|
||||
|
|
|
@ -40,6 +40,10 @@ KernelObject *__KernelMemoryVPLObject();
|
|||
KernelObject *__KernelMemoryPMBObject();
|
||||
KernelObject *__KernelTlsplObject();
|
||||
|
||||
BlockAllocator *BlockAllocatorFromID(int id);
|
||||
int BlockAllocatorToID(const BlockAllocator *alloc);
|
||||
BlockAllocator *BlockAllocatorFromAddr(u32 addr);
|
||||
|
||||
SceUID sceKernelCreateVpl(const char *name, int partition, u32 attr, u32 vplSize, u32 optPtr);
|
||||
int sceKernelDeleteVpl(SceUID uid);
|
||||
int sceKernelAllocateVpl(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr);
|
||||
|
|
|
@ -140,10 +140,13 @@ struct MsgPipe : public KernelObject
|
|||
int GetIDType() const override { return SCE_KERNEL_TMID_Mpipe; }
|
||||
|
||||
MsgPipe() : buffer(0) {}
|
||||
~MsgPipe()
|
||||
{
|
||||
if (buffer != 0)
|
||||
userMemory.Free(buffer);
|
||||
~MsgPipe() {
|
||||
if (buffer != 0) {
|
||||
BlockAllocator *alloc = BlockAllocatorFromAddr(buffer);
|
||||
_assert_msg_(alloc != nullptr, "Should always have a valid allocator/address");
|
||||
if (alloc)
|
||||
alloc->Free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetUsedSize()
|
||||
|
@ -667,41 +670,26 @@ void __KernelMsgPipeDoState(PointerWrap &p)
|
|||
CoreTiming::RestoreRegisterEvent(waitTimer, "MsgPipeTimeout", __KernelMsgPipeTimeout);
|
||||
}
|
||||
|
||||
int sceKernelCreateMsgPipe(const char *name, int partition, u32 attr, u32 size, u32 optionsPtr)
|
||||
{
|
||||
int sceKernelCreateMsgPipe(const char *name, int partition, u32 attr, u32 size, u32 optionsPtr) {
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateMsgPipe(): invalid name", SCE_KERNEL_ERROR_NO_MEMORY);
|
||||
return SCE_KERNEL_ERROR_NO_MEMORY;
|
||||
}
|
||||
return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_NO_MEMORY, "invalid name");
|
||||
if (partition < 1 || partition > 9 || partition == 7)
|
||||
{
|
||||
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateMsgPipe(): 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=sceKernelCreateMsgPipe(): invalid partition %d", SCE_KERNEL_ERROR_ILLEGAL_PERM, partition);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_PERM;
|
||||
}
|
||||
return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, "invalid partition %d", partition);
|
||||
|
||||
BlockAllocator *allocator = BlockAllocatorFromID(partition);
|
||||
if (allocator == nullptr)
|
||||
return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_PERM, "invalid partition %d", partition);
|
||||
|
||||
if ((attr & ~SCE_KERNEL_MPA_KNOWN) >= 0x100)
|
||||
{
|
||||
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateEventFlag(%s): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, name, attr);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ATTR;
|
||||
}
|
||||
return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "invalid attr parameter: %08x", attr);
|
||||
|
||||
u32 memBlockPtr = 0;
|
||||
if (size != 0)
|
||||
{
|
||||
if (size != 0) {
|
||||
// We ignore the upalign to 256.
|
||||
u32 allocSize = size;
|
||||
memBlockPtr = userMemory.Alloc(allocSize, (attr & SCE_KERNEL_MPA_HIGHMEM) != 0, "MsgPipe");
|
||||
memBlockPtr = allocator->Alloc(allocSize, (attr & SCE_KERNEL_MPA_HIGHMEM) != 0, "MsgPipe");
|
||||
if (memBlockPtr == (u32)-1)
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL, "%08x=sceKernelCreateEventFlag(%s): Failed to allocate %i bytes for buffer", SCE_KERNEL_ERROR_NO_MEMORY, name, size);
|
||||
return SCE_KERNEL_ERROR_NO_MEMORY;
|
||||
}
|
||||
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_NO_MEMORY, "failed to allocate %i bytes for buffer", size);
|
||||
}
|
||||
|
||||
MsgPipe *m = new MsgPipe();
|
||||
|
|
Loading…
Add table
Reference in a new issue