Skip to content

Commit

Permalink
Merge pull request #170 from igor725/stubz
Browse files Browse the repository at this point in the history
Stub some sceNp apis
  • Loading branch information
SysRay authored May 29, 2024
2 parents dba7044 + 478fefe commit 6533a98
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 15 deletions.
10 changes: 6 additions & 4 deletions core/kernel/pthread_types.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once
#include "utility/utility.h"

// clang-format off

using pthread_entry_func_t = SYSV_ABI void* (*)(void*);
using pthread_key_destructor_func_t = SYSV_ABI void (*)(void*);
using thread_dtors_func_t = SYSV_ABI void (*)();
using thread_clean_func_t = SYSV_ABI void (*)(void*);
using pthread_once_init = SYSV_ABI void (*)();

using thread_dtors_func_t = SYSV_ABI void (*)();
using thread_clean_func_t = SYSV_ABI void (*)(void*);

using pthread_once_init = SYSV_ABI void (*)();
// clang-format on

struct SceSchedParam {
int sched_priority;
Expand Down
6 changes: 3 additions & 3 deletions core/runtime/exports/intern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ void init() {
void initIntercepts() {
/*Usage
// functions has to be of SYSV_ABI!
accessRuntimeExport()->interceptAdd((uintptr_t)int_Malloc, "Y7aJ1uydPMo", "libc", "libc")
accessRuntimeLinker().interceptAdd((uintptr_t)int_Malloc, "Y7aJ1uydPMo", "libc", "libc")
// Calling original
auto const origFunction = accessRuntimeExport()->interceptGetAddr((uintptr_t)int_Malloc);
auto const origFunction = accessRuntimeLinker().interceptGetAddr((uintptr_t)int_Malloc);
typedef SYSV_ABI void* (*fcnPtr)(void*, size_t);
void* ret = ((fcnPtr)origFunction)(ptr, size);
*/
}
} // namespace intern
} // namespace intern
4 changes: 4 additions & 0 deletions core/runtime/formats/elf64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
namespace {
LOG_DEFINE_MODULE(ELF64);

// clang-format off

using module_func_t = SYSV_ABI int (*)(size_t args, const void* argp);
using module_call_func_t = SYSV_ABI void (*)();
using module_ini_fini_func_t = SYSV_ABI int (*)(size_t args, const void* argp, module_func_t func);

// clang-format on

int jmpModule(uint64_t addr, size_t args, const void* argp, module_func_t func) {
return reinterpret_cast<module_ini_fini_func_t>(addr)(args, argp, func);
}
Expand Down
4 changes: 4 additions & 0 deletions core/runtime/runtimeLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
LOG_DEFINE_MODULE(RuntimeLinker);

namespace {
// clang-format off

using atexit_func_t = SYSV_ABI void (*)();
using entry_func_t = SYSV_ABI void (*)(EntryParams const* params, atexit_func_t atexit_func);
using module_func_t = SYSV_ABI int (*)(size_t args, const void* argp, atexit_func_t atexit_func);

// clang-format on

struct FrameS {
FrameS* next;
uintptr_t ret_addr;
Expand Down
4 changes: 4 additions & 0 deletions modules/libSceAvPlayer/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "utility/utility.h"
typedef void* SceAvPlayerHandle;

// clang-format off

using SceAvPlayerLogCallback = SYSV_ABI int (*)(void* userData, const char* format, va_list args);
using SceAvPlayerAllocate = SYSV_ABI void* (*)(void* argP, uint32_t argAlignment, uint32_t argSize);
using SceAvPlayerDeallocate = SYSV_ABI void (*)(void* argP, void* argMemory);
Expand All @@ -14,6 +16,8 @@ using SceAvPlayerReadOffsetFile = SYSV_ABI int (*)(void* argP, uint8_t* argBu
using SceAvPlayerEventCallback = SYSV_ABI void (*)(void* p, int32_t argEventId, int32_t argSourceId, void* argEventData);
using SceAvPlayerSizeFile = SYSV_ABI uint64_t (*)(void* argP);

// clang-format on

enum class SceAvPlayerVideoDecoderType { DEFAULT = 0, RESERVED1, RESERVED2, SOFTWARE2 };

enum class SceAvPlayerAudioDecoderType { DEFAULT = 0, RESERVED1, RESERVED2 };
Expand Down
6 changes: 3 additions & 3 deletions modules/libSceGameLiveStreaming/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ EXPORT SYSV_ABI int32_t sceGameLiveStreamingPermitLiveStreaming() {

EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentStatus(SceGameLiveStreamingStatus* glss) {
LOG_USE_MODULE(libSceGameLiveStreaming);
LOG_ERR(L"todo %S", __FUNCTION__);
LOG_TRACE(L"todo %S", __FUNCTION__);
glss->isOnAir = false;
glss->userId = 1;
return Ok;
}

EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentStatus2(SceGameLiveStreamingStatus2* glss2) {
LOG_USE_MODULE(libSceGameLiveStreaming);
LOG_ERR(L"todo %S", __FUNCTION__);
LOG_TRACE(L"todo %S", __FUNCTION__);
glss2->isOnAir = false;
glss2->userId = 1;
return Ok;
Expand Down Expand Up @@ -69,7 +69,7 @@ EXPORT SYSV_ABI int32_t sceGameLiveStreamingSetCameraFrameSetting(const SceGameL

EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentBroadcastScreenLayout(SceGameLiveStreamingBroadcastScreenLayout* layout) {
LOG_USE_MODULE(libSceGameLiveStreaming);
LOG_ERR(L"todo %S", __FUNCTION__);
LOG_TRACE(L"todo %S", __FUNCTION__);
return Ok;
}

Expand Down
2 changes: 2 additions & 0 deletions modules/libSceNpManager/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
LOG_DEFINE_MODULE(libSceNpManager);

namespace {
// clang-format off
using SceNpStateCallbackA = SYSV_ABI void (*)(int32_t userId, SceNpState state, void* userdata);
using SceNpReachabilityStateCallback = SYSV_ABI void (*)(int32_t userId, SceNpReachabilityState state, void* userdata);
using SceNpGamePresenceCallbackA = SYSV_ABI void (*)(int32_t userId, SceNpGamePresenceStatus status, void* userdata);
using SceNpPlusEventCallback = SYSV_ABI void (*)(int32_t userId, SceNpPlusEventType event, void* userdata);
// clang-format on
} // namespace

extern "C" {
Expand Down
55 changes: 55 additions & 0 deletions modules/libSceNpToolkit2/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,59 @@ EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_11UserProf
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}

/**
* @brief sce::Toolkit::NP::V2::Core::Response<sce::Toolkit::NP::V2::Matching::Room>::~Response()
*
*/

EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_8Matching4RoomEED1Ev)() {
LOG_USE_MODULE(libSceNpToolkit2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}

/**
* @brief sce::Toolkit::NP::V2::Core::RequestBase::getFunctionType() const
*
*/

EXPORT SYSV_ABI int32_t __NID(_ZNK3sce7Toolkit2NP2V24Core11RequestBase15getFunctionTypeEv)() {
LOG_USE_MODULE(libSceNpToolkit2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}

/**
* @brief sce::Toolkit::NP::V2::Core::Response<sce::Toolkit::NP::V2::UserProfile::NpProfiles>::~Response()
*
*/

EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_11UserProfile10NpProfilesEED1Ev)() {
LOG_USE_MODULE(libSceNpToolkit2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}

/**
* @brief sce::Toolkit::NP::V2::Core::Response<sce::Toolkit::NP::V2::TSS::TssData>::Response()
*
*/

EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_3TSS7TssDataEEC1Ev)() {
LOG_USE_MODULE(libSceNpToolkit2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}

/**
* @brief sce::Toolkit::NP::V2::Core::Response<sce::Toolkit::NP::V2::TSS::TssData>::~Response()
*
*/

EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_3TSS7TssDataEED1Ev)() {
LOG_USE_MODULE(libSceNpToolkit2);
LOG_ERR(L"todo %S", __FUNCTION__);
return Ok;
}
}
8 changes: 8 additions & 0 deletions modules/libSceNpWebApi/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ EXPORT SYSV_ABI int32_t sceNpWebApiCreateContextA(int32_t libCtxId, int32_t user
return Ok;
}

EXPORT SYSV_ABI int32_t sceNpWebApiCreatePushEventFilter() {
return Ok;
}

EXPORT SYSV_ABI int32_t sceNpWebApiCreateServicePushEventFilter() {
return Ok;
}

EXPORT SYSV_ABI int32_t sceNpWebApiDeleteContext(int32_t titleUserCtxId) {
return Ok;
}
Expand Down
2 changes: 2 additions & 0 deletions modules/libScePlayGo/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ EXPORT SYSV_ABI int32_t scePlayGoSetToDoList(ScePlayGoHandle handle, const ScePl
EXPORT SYSV_ABI int32_t scePlayGoGetToDoList(ScePlayGoHandle handle, ScePlayGoToDo* outTodoList, uint32_t numberOfEntries, uint32_t* outEntries) {
LOG_USE_MODULE(libScePlayGo);
LOG_ERR(L"TODO: %S", __FUNCTION__);
*outEntries = 0;
return Ok;
}

Expand All @@ -75,6 +76,7 @@ EXPORT SYSV_ABI int32_t scePlayGoPrefetch(ScePlayGoHandle handle, const ScePlayG
EXPORT SYSV_ABI int32_t scePlayGoGetEta(ScePlayGoHandle handle, const ScePlayGoChunkId* chunkIds, uint32_t numberOfEntries, ScePlayGoEta* outEta) {
LOG_USE_MODULE(libScePlayGo);
LOG_ERR(L"TODO: %S", __FUNCTION__);
*outEta = 0;
return Ok;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/libSceRemoteplay/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EXPORT SYSV_ABI int sceRemoteplayProhibitStreaming(SceRemoteplayStreamingProhibi
EXPORT SYSV_ABI int sceRemoteplayGetConnectionStatus(SceUserServiceUserId userid, SceRemoteplayConnectionStatus* pStatus) {
*pStatus = SceRemoteplayConnectionStatus::Disconnect;
LOG_USE_MODULE(libSceRemoteplay);
LOG_ERR(L"todo %S", __FUNCTION__);
LOG_TRACE(L"todo %S", __FUNCTION__);
return Ok;
}
}
}
4 changes: 4 additions & 0 deletions modules/libkernel/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

using SceKernelModule = int32_t;

// clang-format off

using get_thread_atexit_count_func_t = SYSV_ABI int (*)(SceKernelModule);
using thread_atexit_report_func_t = SYSV_ABI void (*)(SceKernelModule);

// clang-format on

typedef int SceKernelAioSubmitId;
typedef void* sigset_t;

Expand Down
13 changes: 10 additions & 3 deletions tools/logging/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
#include <cassert>
#include <chrono>
#include <mutex>
#include <unordered_map>

// clang-format off

#include <p7/GTypes.h>
#include <p7/P7_Telemetry.h>
#include <p7/P7_Trace.h>
#include <unordered_map>
#include <p7/P7_Extensions.h>

// clang-format on

namespace __Log {

Expand Down Expand Up @@ -124,12 +131,12 @@ void __log(eTrace_Level level, void* hmodule, unsigned short i_wLine, const char

if (static_cast<typename std::underlying_type<__Log::eTrace_Level>::type>(level) ==
static_cast<typename std::underlying_type<__Log::eTrace_Level>::type>(eTrace_Level::err)) {
printf("Error:");
printf("%s| Error:", ((sP7Trace_Module*)hmodule)->pName);
vwprintf(i_pFormat, args);
printf("\n");
} else if (static_cast<typename std::underlying_type<__Log::eTrace_Level>::type>(level) ==
static_cast<typename std::underlying_type<__Log::eTrace_Level>::type>(eTrace_Level::crit)) {
printf("Critical Error:");
printf("%s| Critical Error:", ((sP7Trace_Module*)hmodule)->pName);
vwprintf(i_pFormat, args);
printf("\nExiting\n");
}
Expand Down

0 comments on commit 6533a98

Please sign in to comment.