sceKernelCreateEqueue implemented

This commit is contained in:
georgemoralis 2023-08-17 10:10:13 +03:00
parent e58601bc2d
commit bba76cdf49
9 changed files with 72 additions and 14 deletions

View file

@ -52,7 +52,7 @@ add_executable(shadps4
src/Core/PS4/HLE/Kernel/event_queues.h src/Core/PS4/HLE/Kernel/event_queues.h
src/Core/PS4/HLE/Kernel/cpu_management.cpp src/Core/PS4/HLE/Kernel/cpu_management.cpp
src/Core/PS4/HLE/Kernel/cpu_management.h src/Core/PS4/HLE/Kernel/cpu_management.h
"src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" ) "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp")
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY}) target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY})

View file

@ -1,6 +1,8 @@
#pragma once #pragma once
constexpr int SCE_OK = 0; constexpr int SCE_OK = 0;
constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000c;//Insufficient memory constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000c; // Insufficient memory
constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016;//null or invalid states constexpr int SCE_KERNEL_ERROR_EFAULT = 0x8002000e; // Invalid address pointer
constexpr int SCE_KERNEL_ERROR_EAGAIN = 0x80020023;//Memory cannot be allocated constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016; // null or invalid states
constexpr int SCE_KERNEL_ERROR_EAGAIN = 0x80020023; // Memory cannot be allocated
constexpr int SCE_KERNEL_ERROR_ENAMETOOLONG = 0x8002003f; // character strings exceeds valid size

View file

@ -0,0 +1,5 @@
#include "event_queue.h"
namespace HLE::Kernel::Objects {
EqueueInternal::~EqueueInternal() {}
}; // namespace HLE::Kernel::Objects

View file

@ -0,0 +1,14 @@
#pragma once
#include <string>
namespace HLE::Kernel::Objects {
class EqueueInternal {
public:
EqueueInternal() = default;
virtual ~EqueueInternal();
void setName(const std::string& m_name) { this->m_name = m_name; }
private:
std::string m_name;
};
}; // namespace HLE::Kernel::Objects

View file

@ -0,0 +1,37 @@
#include "event_queues.h"
#include <Core/PS4/HLE/Libs.h>
#include <Util/log.h>
#include <Core/PS4/HLE/ErrorCodes.h>
namespace HLE::Libs::LibKernel::EventQueues {
constexpr bool log_file_equeues = true; // disable it to disable logging
int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name) {
PRINT_FUNCTION_NAME();
if (eq == nullptr) {
LOG_TRACE_IF(log_file_equeues, "sceKernelCreateEqueue returned SCE_KERNEL_ERROR_EINVAL eq invalid\n");
return SCE_KERNEL_ERROR_EINVAL;
}
if (name == nullptr) {
LOG_TRACE_IF(log_file_equeues, "sceKernelCreateEqueue returned SCE_KERNEL_ERROR_EFAULT name invalid\n");
return SCE_KERNEL_ERROR_EFAULT;
}
if (name == NULL) {
LOG_TRACE_IF(log_file_equeues, "sceKernelCreateEqueue returned SCE_KERNEL_ERROR_EINVAL name is null\n");
return SCE_KERNEL_ERROR_EINVAL;
}
int s = sizeof(char);
if (strlen(name) > 31) { // max is 32 including null terminator
LOG_TRACE_IF(log_file_equeues, "sceKernelCreateEqueue returned SCE_KERNEL_ERROR_ENAMETOOLONG name size exceeds 32 bytes\n");
return SCE_KERNEL_ERROR_ENAMETOOLONG;
}
*eq = new Kernel::Objects::EqueueInternal;
(*eq)->setName(std::string(name));
LOG_INFO_IF(log_file_equeues, "sceKernelCreateEqueue created with name \"{}\"\n", name);
return SCE_OK;
}
}; // namespace HLE::Libs::LibKernel::EventQueues

View file

@ -1,5 +1,10 @@
#pragma once #pragma once
#include <types.h> #include <types.h>
#include "Objects/event_queue.h"
namespace HLE::Libs::LibKernel::EventQueues {}; namespace HLE::Libs::LibKernel::EventQueues {
using SceKernelEqueue = Kernel::Objects::EqueueInternal*;
int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name);
}; // namespace HLE::Libs::LibKernel::EventQueues

View file

@ -7,6 +7,7 @@
#include "../../../Util/Singleton.h" #include "../../../Util/Singleton.h"
#include "Kernel/Objects/physical_memory.h" #include "Kernel/Objects/physical_memory.h"
#include "Kernel/cpu_management.h" #include "Kernel/cpu_management.h"
#include "Kernel/event_queues.h"
namespace HLE::Libs::LibKernel { namespace HLE::Libs::LibKernel {
@ -17,12 +18,6 @@ namespace HLE::Libs::LibKernel {
return 0; return 0;
} }
int PS4_SYSV_ABI sceKernelCreateEqueue(/* SceKernelEqueue* eq*/ int eq, const char* name)
{
//BREAKPOINT();
PRINT_DUMMY_FUNCTION_NAME();
return 0;
}
int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/) int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/)
{ {
BREAKPOINT(); BREAKPOINT();
@ -40,7 +35,7 @@ namespace HLE::Libs::LibKernel {
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelMapDirectMemory); LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelMapDirectMemory);
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory); LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
//equeue //equeue
LIB_FUNCTION("D0OdFMjp46I", "libkernel", 1, "libkernel", 1, 1, sceKernelCreateEqueue); LIB_FUNCTION("D0OdFMjp46I", "libkernel", 1, "libkernel", 1, 1, EventQueues::sceKernelCreateEqueue);
LIB_FUNCTION("fzyMKs9kim0", "libkernel", 1, "libkernel", 1, 1, sceKernelWaitEqueue); LIB_FUNCTION("fzyMKs9kim0", "libkernel", 1, "libkernel", 1, 1, sceKernelWaitEqueue);
//misc //misc
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, CPUManagement::sceKernelIsNeoMode); LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, CPUManagement::sceKernelIsNeoMode);

View file

@ -5,7 +5,7 @@ namespace HLE::Libs::LibKernel {
void LibKernel_Register(SymbolsResolver* sym); void LibKernel_Register(SymbolsResolver* sym);
// functions // functions
int PS4_SYSV_ABI sceKernelCreateEqueue(/* SceKernelEqueue* eq*/ int eq, const char* name);
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len); int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len);

View file

@ -36,7 +36,7 @@
} }
#define PRINT_DUMMY_FUNCTION_NAME() \ #define PRINT_DUMMY_FUNCTION_NAME() \
{ LOG_INFO_IF(true, "dummy {}()\n", __func__); } { LOG_WARN_IF(true, "dummy {}()\n", __func__); }
namespace HLE::Libs { namespace HLE::Libs {
void Init_HLE_Libs(SymbolsResolver* sym); void Init_HLE_Libs(SymbolsResolver* sym);