Skip to content
Permalink
Browse files

Merge pull request #12328 from unknownbrackets/io-async

Use PSP threads for async IO
  • Loading branch information...
hrydgard committed Oct 7, 2019
2 parents 83c349a + c53acfc commit eb2109a0f117e767ff53ca8ddd119423935d2784
Showing with 335 additions and 148 deletions.
  1. +15 −3 Core/HLE/HLEHelperThread.cpp
  2. +5 −1 Core/HLE/HLEHelperThread.h
  3. +283 −138 Core/HLE/sceIo.cpp
  4. +19 −3 Core/HLE/sceKernelThread.cpp
  5. +2 −0 Core/HLE/sceKernelThread.h
  6. +11 −3 Core/HLE/scePsmf.cpp
@@ -49,17 +49,20 @@ HLEHelperThread::HLEHelperThread(const char *threadName, const char *module, con
}

HLEHelperThread::~HLEHelperThread() {
__KernelDeleteThread(id_, SCE_KERNEL_ERROR_THREAD_TERMINATED, "helper deleted");
kernelMemory.Free(entry_);
if (id_)
__KernelDeleteThread(id_, SCE_KERNEL_ERROR_THREAD_TERMINATED, "helper deleted");
if (entry_)
kernelMemory.Free(entry_);
}

void HLEHelperThread::AllocEntry(u32 size) {
entry_ = kernelMemory.Alloc(size);
Memory::Memset(entry_, 0, size);
currentMIPS->InvalidateICache(entry_, size);
}

void HLEHelperThread::Create(const char *threadName, u32 prio, int stacksize) {
id_ = __KernelCreateThreadInternal(threadName, __KernelGetCurThreadModuleId(), entry_, prio, stacksize, 0);
id_ = __KernelCreateThreadInternal(threadName, __KernelGetCurThreadModuleId(), entry_, prio, stacksize, 0x00001000);
}

void HLEHelperThread::DoState(PointerWrap &p) {
@@ -79,3 +82,12 @@ void HLEHelperThread::Start(u32 a0, u32 a1) {
void HLEHelperThread::Terminate() {
__KernelStopThread(id_, SCE_KERNEL_ERROR_THREAD_TERMINATED, "helper terminated");
}

bool HLEHelperThread::Stopped() {
return KernelIsThreadDormant(id_);
}

void HLEHelperThread::Forget() {
id_ = 0;
entry_ = 0;
}
@@ -31,11 +31,15 @@ class HLEHelperThread {

void Start(u32 a0, u32 a1);
void Terminate();
bool Stopped();

// For savestates.
void Forget();

private:
void AllocEntry(u32 size);
void Create(const char *threadName, u32 prio, int stacksize);

SceUID id_;
u32 entry_;
};
};

0 comments on commit eb2109a

Please sign in to comment.
You can’t perform that action at this time.