mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-12 12:45:56 +00:00
Merge branch 'main' into fontlib
This commit is contained in:
commit
b6b9225b3d
14 changed files with 348 additions and 45 deletions
|
@ -409,6 +409,7 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
|
||||||
src/core/libraries/save_data/save_memory.h
|
src/core/libraries/save_data/save_memory.h
|
||||||
src/core/libraries/save_data/savedata.cpp
|
src/core/libraries/save_data/savedata.cpp
|
||||||
src/core/libraries/save_data/savedata.h
|
src/core/libraries/save_data/savedata.h
|
||||||
|
src/core/libraries/save_data/savedata_error.h
|
||||||
src/core/libraries/save_data/dialog/savedatadialog.cpp
|
src/core/libraries/save_data/dialog/savedatadialog.cpp
|
||||||
src/core/libraries/save_data/dialog/savedatadialog.h
|
src/core/libraries/save_data/dialog/savedatadialog.h
|
||||||
src/core/libraries/save_data/dialog/savedatadialog_ui.cpp
|
src/core/libraries/save_data/dialog/savedatadialog_ui.cpp
|
||||||
|
@ -605,6 +606,10 @@ set(CAMERA_LIBS src/core/libraries/camera/camera.cpp
|
||||||
src/core/libraries/camera/camera_error.h
|
src/core/libraries/camera/camera_error.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(COMPANION_LIBS src/core/libraries/companion/companion_httpd.cpp
|
||||||
|
src/core/libraries/companion/companion_httpd.h
|
||||||
|
src/core/libraries/companion/companion_error.h
|
||||||
|
)
|
||||||
set(DEV_TOOLS src/core/devtools/layer.cpp
|
set(DEV_TOOLS src/core/devtools/layer.cpp
|
||||||
src/core/devtools/layer.h
|
src/core/devtools/layer.h
|
||||||
src/core/devtools/options.cpp
|
src/core/devtools/options.cpp
|
||||||
|
@ -769,6 +774,7 @@ set(CORE src/core/aerolib/stubs.cpp
|
||||||
${VDEC_LIB}
|
${VDEC_LIB}
|
||||||
${VR_LIBS}
|
${VR_LIBS}
|
||||||
${CAMERA_LIBS}
|
${CAMERA_LIBS}
|
||||||
|
${COMPANION_LIBS}
|
||||||
${DEV_TOOLS}
|
${DEV_TOOLS}
|
||||||
src/core/debug_state.cpp
|
src/core/debug_state.cpp
|
||||||
src/core/debug_state.h
|
src/core/debug_state.h
|
||||||
|
|
|
@ -141,6 +141,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
||||||
SUB(Lib, FontFt) \
|
SUB(Lib, FontFt) \
|
||||||
SUB(Lib, SigninDialog) \
|
SUB(Lib, SigninDialog) \
|
||||||
SUB(Lib, Camera) \
|
SUB(Lib, Camera) \
|
||||||
|
SUB(Lib, CompanionHttpd) \
|
||||||
CLS(Frontend) \
|
CLS(Frontend) \
|
||||||
CLS(Render) \
|
CLS(Render) \
|
||||||
SUB(Render, Vulkan) \
|
SUB(Render, Vulkan) \
|
||||||
|
|
|
@ -108,6 +108,7 @@ enum class Class : u8 {
|
||||||
Lib_Font, ///< The libSceFont implementation.
|
Lib_Font, ///< The libSceFont implementation.
|
||||||
Lib_FontFt, ///< The libSceFontFt implementation.
|
Lib_FontFt, ///< The libSceFontFt implementation.
|
||||||
Lib_Camera, ///< The LibCamera implementation.
|
Lib_Camera, ///< The LibCamera implementation.
|
||||||
|
Lib_CompanionHttpd, ///< The LibCompanionHttpd implementation.
|
||||||
Frontend, ///< Emulator UI
|
Frontend, ///< Emulator UI
|
||||||
Render, ///< Video Core
|
Render, ///< Video Core
|
||||||
Render_Vulkan, ///< Vulkan backend
|
Render_Vulkan, ///< Vulkan backend
|
||||||
|
|
20
src/core/libraries/companion/companion_error.h
Normal file
20
src/core/libraries/companion/companion_error.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// companion_httpd error codes
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_UNKNOWN = 0x80E40001;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_FATAL = 0x80E40002;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOMEM = 0x80E40003;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_INVALID_PARAM = 0x80E40004;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_INVALID_OPERATION = 0x80E40005;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_INITIALIZED = 0x80E40006;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_ALREADY_INITIALIZED = 0x80E40007;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NO_EVENT = 0x80E40008;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_GENERATE_RESPONSE = 0x80E40009;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_ALREADY_STARTED = 0x80E4000A;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_STARTED = 0x80E4000B;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_ALREADY_REGISTERED = 0x80E4000;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_NOT_CONNECTED = 0x80E4000D;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_ERROR_USER_NOT_FOUND = 0x80E4000E;
|
142
src/core/libraries/companion/companion_httpd.cpp
Normal file
142
src/core/libraries/companion/companion_httpd.cpp
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "companion_error.h"
|
||||||
|
#include "core/libraries/companion/companion_httpd.h"
|
||||||
|
#include "core/libraries/error_codes.h"
|
||||||
|
#include "core/libraries/libs.h"
|
||||||
|
|
||||||
|
namespace Libraries::CompanionHttpd {
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdAddHeader(const char* key, const char* value,
|
||||||
|
OrbisCompanionHttpdResponse* response) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI
|
||||||
|
sceCompanionHttpdGet2ndScreenStatus(Libraries::UserService::OrbisUserServiceUserId) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdGetEvent(OrbisCompanionHttpdEvent* pEvent) {
|
||||||
|
pEvent->event = ORBIS_COMPANION_HTTPD_EVENT_DISCONNECT; // disconnected
|
||||||
|
LOG_DEBUG(Lib_CompanionHttpd, "device disconnected");
|
||||||
|
return ORBIS_COMPANION_HTTPD_ERROR_NO_EVENT; // No events to obtain
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI
|
||||||
|
sceCompanionHttpdGetUserId(u32 addr, Libraries::UserService::OrbisUserServiceUserId* userId) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdInitialize() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdInitialize2() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdOptParamInitialize() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdRegisterRequestBodyReceptionCallback(
|
||||||
|
OrbisCompanionHttpdRequestBodyReceptionCallback function, void* param) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI
|
||||||
|
sceCompanionHttpdRegisterRequestCallback(OrbisCompanionHttpdRequestCallback function, void* param) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdRegisterRequestCallback2(
|
||||||
|
OrbisCompanionHttpdRequestCallback function, void* param) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdSetBody(const char* body, u64 bodySize,
|
||||||
|
OrbisCompanionHttpdResponse* response) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdSetStatus(s32 status, OrbisCompanionHttpdResponse* response) {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdStart() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdStop() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdTerminate() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestBodyReceptionCallback() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestCallback() {
|
||||||
|
LOG_ERROR(Lib_CompanionHttpd, "(STUBBED) called");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterlibSceCompanionHttpd(Core::Loader::SymbolsResolver* sym) {
|
||||||
|
LIB_FUNCTION("8pWltDG7h6A", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdAddHeader);
|
||||||
|
LIB_FUNCTION("B-QBMeFdNgY", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdGet2ndScreenStatus);
|
||||||
|
LIB_FUNCTION("Vku4big+IYM", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdGetEvent);
|
||||||
|
LIB_FUNCTION("0SySxcuVNG0", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdGetUserId);
|
||||||
|
LIB_FUNCTION("ykNpWs3ktLY", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdInitialize);
|
||||||
|
LIB_FUNCTION("OA6FbORefbo", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdInitialize2);
|
||||||
|
LIB_FUNCTION("r-2-a0c7Kfc", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdOptParamInitialize);
|
||||||
|
LIB_FUNCTION("fHNmij7kAUM", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdRegisterRequestBodyReceptionCallback);
|
||||||
|
LIB_FUNCTION("OaWw+IVEdbI", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdRegisterRequestCallback);
|
||||||
|
LIB_FUNCTION("-0c9TCTwnGs", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdRegisterRequestCallback2);
|
||||||
|
LIB_FUNCTION("h3OvVxzX4qM", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdSetBody);
|
||||||
|
LIB_FUNCTION("w7oz0AWHpT4", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdSetStatus);
|
||||||
|
LIB_FUNCTION("k7F0FcDM-Xc", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdStart);
|
||||||
|
LIB_FUNCTION("0SCgzfVQHpo", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdStop);
|
||||||
|
LIB_FUNCTION("+-du9tWgE9s", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdTerminate);
|
||||||
|
LIB_FUNCTION("ZSHiUfYK+QI", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdUnregisterRequestBodyReceptionCallback);
|
||||||
|
LIB_FUNCTION("xweOi2QT-BE", "libSceCompanionHttpd", 1, "libSceCompanionHttpd", 1, 1,
|
||||||
|
sceCompanionHttpdUnregisterRequestCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Libraries::CompanionHttpd
|
91
src/core/libraries/companion/companion_httpd.h
Normal file
91
src/core/libraries/companion/companion_httpd.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
#include "core/libraries/network/net.h"
|
||||||
|
#include "core/libraries/system/userservice.h"
|
||||||
|
|
||||||
|
namespace Core::Loader {
|
||||||
|
class SymbolsResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Libraries::CompanionHttpd {
|
||||||
|
|
||||||
|
// OrbisCompanionHttpdEvent event codes
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_EVENT_CONNECT = 0x10000001;
|
||||||
|
constexpr int ORBIS_COMPANION_HTTPD_EVENT_DISCONNECT = 0x10000002;
|
||||||
|
|
||||||
|
struct OrbisCompanionHttpdHeader {
|
||||||
|
char* key;
|
||||||
|
char* value;
|
||||||
|
struct OrbisCompanionHttpdHeader* header;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisCompanionHttpdRequest {
|
||||||
|
s32 method;
|
||||||
|
char* url;
|
||||||
|
OrbisCompanionHttpdHeader* header;
|
||||||
|
char* body;
|
||||||
|
u64 bodySize;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisCompanionHttpdResponse {
|
||||||
|
s32 status;
|
||||||
|
OrbisCompanionHttpdHeader* header;
|
||||||
|
char* body;
|
||||||
|
u64 bodySize;
|
||||||
|
};
|
||||||
|
|
||||||
|
using OrbisCompanionHttpdRequestBodyReceptionCallback =
|
||||||
|
PS4_SYSV_ABI s32 (*)(s32 event, Libraries::UserService::OrbisUserServiceUserId userId,
|
||||||
|
const OrbisCompanionHttpdRequest* httpRequest, void* param);
|
||||||
|
|
||||||
|
using OrbisCompanionHttpdRequestCallback =
|
||||||
|
PS4_SYSV_ABI s32 (*)(Libraries::UserService::OrbisUserServiceUserId userId,
|
||||||
|
const OrbisCompanionHttpdRequest* httpRequest,
|
||||||
|
OrbisCompanionHttpdResponse* httpResponse, void* param);
|
||||||
|
|
||||||
|
struct OrbisCompanionUtilDeviceInfo {
|
||||||
|
Libraries::UserService::OrbisUserServiceUserId userId;
|
||||||
|
Libraries::Net::OrbisNetSockaddrIn addr;
|
||||||
|
char reserved[236];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OrbisCompanionHttpdEvent {
|
||||||
|
s32 event;
|
||||||
|
union {
|
||||||
|
OrbisCompanionUtilDeviceInfo deviceInfo;
|
||||||
|
Libraries::UserService::OrbisUserServiceUserId userId;
|
||||||
|
char reserved[256];
|
||||||
|
} data;
|
||||||
|
};
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdAddHeader(const char* key, const char* value,
|
||||||
|
OrbisCompanionHttpdResponse* response);
|
||||||
|
s32 PS4_SYSV_ABI
|
||||||
|
sceCompanionHttpdGet2ndScreenStatus(Libraries::UserService::OrbisUserServiceUserId userId);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdGetEvent(OrbisCompanionHttpdEvent* pEvent);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdGetUserId(u32 addr,
|
||||||
|
Libraries::UserService::OrbisUserServiceUserId* userId);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdInitialize();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdInitialize2();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdOptParamInitialize();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdRegisterRequestBodyReceptionCallback(
|
||||||
|
OrbisCompanionHttpdRequestBodyReceptionCallback function, void* param);
|
||||||
|
s32 PS4_SYSV_ABI
|
||||||
|
sceCompanionHttpdRegisterRequestCallback(OrbisCompanionHttpdRequestCallback function, void* param);
|
||||||
|
s32 PS4_SYSV_ABI
|
||||||
|
sceCompanionHttpdRegisterRequestCallback2(OrbisCompanionHttpdRequestCallback function, void* param);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdSetBody(const char* body, u64 bodySize,
|
||||||
|
OrbisCompanionHttpdResponse* response);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdSetStatus(s32 status, OrbisCompanionHttpdResponse* response);
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdStart();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdStop();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdTerminate();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestBodyReceptionCallback();
|
||||||
|
s32 PS4_SYSV_ABI sceCompanionHttpdUnregisterRequestCallback();
|
||||||
|
|
||||||
|
void RegisterlibSceCompanionHttpd(Core::Loader::SymbolsResolver* sym);
|
||||||
|
} // namespace Libraries::CompanionHttpd
|
|
@ -209,6 +209,19 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
||||||
"anon");
|
"anon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 PS4_SYSV_ABI sceKernelMapDirectMemory2(void** addr, u64 len, s32 type, s32 prot, s32 flags,
|
||||||
|
s64 phys_addr, u64 alignment) {
|
||||||
|
LOG_INFO(Kernel_Vmm, "called, redirected to sceKernelMapNamedDirectMemory");
|
||||||
|
const s32 ret =
|
||||||
|
sceKernelMapNamedDirectMemory(addr, len, prot, flags, phys_addr, alignment, "anon");
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
auto* memory = Core::Memory::Instance();
|
||||||
|
memory->SetDirectMemoryType(phys_addr, type);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, std::size_t len, int prot,
|
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, std::size_t len, int prot,
|
||||||
int flags, const char* name) {
|
int flags, const char* name) {
|
||||||
|
|
||||||
|
@ -645,6 +658,7 @@ void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("yDBwVAolDgg", "libkernel", 1, "libkernel", 1, 1, sceKernelIsStack);
|
LIB_FUNCTION("yDBwVAolDgg", "libkernel", 1, "libkernel", 1, 1, sceKernelIsStack);
|
||||||
LIB_FUNCTION("NcaWUxfMNIQ", "libkernel", 1, "libkernel", 1, 1, sceKernelMapNamedDirectMemory);
|
LIB_FUNCTION("NcaWUxfMNIQ", "libkernel", 1, "libkernel", 1, 1, sceKernelMapNamedDirectMemory);
|
||||||
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, sceKernelMapDirectMemory);
|
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, sceKernelMapDirectMemory);
|
||||||
|
LIB_FUNCTION("BQQniolj9tQ", "libkernel", 1, "libkernel", 1, 1, sceKernelMapDirectMemory2);
|
||||||
LIB_FUNCTION("WFcfL2lzido", "libkernel", 1, "libkernel", 1, 1, sceKernelQueryMemoryProtection);
|
LIB_FUNCTION("WFcfL2lzido", "libkernel", 1, "libkernel", 1, 1, sceKernelQueryMemoryProtection);
|
||||||
LIB_FUNCTION("BHouLQzh0X0", "libkernel", 1, "libkernel", 1, 1, sceKernelDirectMemoryQuery);
|
LIB_FUNCTION("BHouLQzh0X0", "libkernel", 1, "libkernel", 1, 1, sceKernelDirectMemoryQuery);
|
||||||
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
|
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "core/libraries/audio3d/audio3d.h"
|
#include "core/libraries/audio3d/audio3d.h"
|
||||||
#include "core/libraries/avplayer/avplayer.h"
|
#include "core/libraries/avplayer/avplayer.h"
|
||||||
#include "core/libraries/camera/camera.h"
|
#include "core/libraries/camera/camera.h"
|
||||||
|
#include "core/libraries/companion/companion_httpd.h"
|
||||||
#include "core/libraries/disc_map/disc_map.h"
|
#include "core/libraries/disc_map/disc_map.h"
|
||||||
#include "core/libraries/game_live_streaming/gamelivestreaming.h"
|
#include "core/libraries/game_live_streaming/gamelivestreaming.h"
|
||||||
#include "core/libraries/gnmdriver/gnmdriver.h"
|
#include "core/libraries/gnmdriver/gnmdriver.h"
|
||||||
|
@ -124,6 +125,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
|
||||||
Libraries::Ulobjmgr::RegisterlibSceUlobjmgr(sym);
|
Libraries::Ulobjmgr::RegisterlibSceUlobjmgr(sym);
|
||||||
Libraries::SigninDialog::RegisterlibSceSigninDialog(sym);
|
Libraries::SigninDialog::RegisterlibSceSigninDialog(sym);
|
||||||
Libraries::Camera::RegisterlibSceCamera(sym);
|
Libraries::Camera::RegisterlibSceCamera(sym);
|
||||||
|
Libraries::CompanionHttpd::RegisterlibSceCompanionHttpd(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries
|
} // namespace Libraries
|
||||||
|
|
|
@ -10,15 +10,14 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <core/libraries/system/msgdialog_ui.h>
|
#include "boost/icl/concept/interval.hpp"
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/elf_info.h"
|
#include "common/elf_info.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "core/file_sys/fs.h"
|
#include "core/file_sys/fs.h"
|
||||||
|
#include "core/libraries/system/msgdialog_ui.h"
|
||||||
#include "save_instance.h"
|
#include "save_instance.h"
|
||||||
|
|
||||||
using Common::FS::IOFile;
|
using Common::FS::IOFile;
|
||||||
|
@ -35,11 +34,12 @@ namespace Libraries::SaveData::SaveMemory {
|
||||||
static Core::FileSys::MntPoints* g_mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
static Core::FileSys::MntPoints* g_mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||||
|
|
||||||
struct SlotData {
|
struct SlotData {
|
||||||
OrbisUserServiceUserId user_id;
|
OrbisUserServiceUserId user_id{};
|
||||||
std::string game_serial;
|
std::string game_serial;
|
||||||
std::filesystem::path folder_path;
|
std::filesystem::path folder_path;
|
||||||
PSF sfo;
|
PSF sfo;
|
||||||
std::vector<u8> memory_cache;
|
std::vector<u8> memory_cache;
|
||||||
|
size_t memory_cache_size{};
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::mutex g_slot_mtx;
|
static std::mutex g_slot_mtx;
|
||||||
|
@ -97,7 +97,8 @@ std::filesystem::path GetSavePath(OrbisUserServiceUserId user_id, u32 slot_id,
|
||||||
return SaveInstance::MakeDirSavePath(user_id, Common::ElfInfo::Instance().GameSerial(), dir);
|
return SaveInstance::MakeDirSavePath(user_id, Common::ElfInfo::Instance().GameSerial(), dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial) {
|
size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial,
|
||||||
|
size_t memory_size) {
|
||||||
std::lock_guard lck{g_slot_mtx};
|
std::lock_guard lck{g_slot_mtx};
|
||||||
|
|
||||||
const auto save_dir = GetSavePath(user_id, slot_id, game_serial);
|
const auto save_dir = GetSavePath(user_id, slot_id, game_serial);
|
||||||
|
@ -109,6 +110,7 @@ size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_
|
||||||
.folder_path = save_dir,
|
.folder_path = save_dir,
|
||||||
.sfo = {},
|
.sfo = {},
|
||||||
.memory_cache = {},
|
.memory_cache = {},
|
||||||
|
.memory_cache_size = memory_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
SaveInstance::SetupDefaultParamSFO(data.sfo, GetSaveDir(slot_id), std::string{game_serial});
|
SaveInstance::SetupDefaultParamSFO(data.sfo, GetSaveDir(slot_id), std::string{game_serial});
|
||||||
|
@ -196,9 +198,9 @@ void ReadMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset) {
|
||||||
auto& data = g_attached_slots[slot_id];
|
auto& data = g_attached_slots[slot_id];
|
||||||
auto& memory = data.memory_cache;
|
auto& memory = data.memory_cache;
|
||||||
if (memory.empty()) { // Load file
|
if (memory.empty()) { // Load file
|
||||||
|
memory.resize(data.memory_cache_size);
|
||||||
IOFile f{data.folder_path / FilenameSaveDataMemory, Common::FS::FileAccessMode::Read};
|
IOFile f{data.folder_path / FilenameSaveDataMemory, Common::FS::FileAccessMode::Read};
|
||||||
if (f.IsOpen()) {
|
if (f.IsOpen()) {
|
||||||
memory.resize(f.GetSize());
|
|
||||||
f.Seek(0);
|
f.Seek(0);
|
||||||
f.ReadSpan(std::span{memory});
|
f.ReadSpan(std::span{memory});
|
||||||
}
|
}
|
||||||
|
@ -222,5 +224,4 @@ void WriteMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset) {
|
||||||
Backup::NewRequest(data.user_id, data.game_serial, GetSaveDir(slot_id),
|
Backup::NewRequest(data.user_id, data.game_serial, GetSaveDir(slot_id),
|
||||||
Backup::OrbisSaveDataEventType::__DO_NOT_SAVE);
|
Backup::OrbisSaveDataEventType::__DO_NOT_SAVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries::SaveData::SaveMemory
|
} // namespace Libraries::SaveData::SaveMemory
|
|
@ -4,13 +4,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "save_backup.h"
|
#include "core/libraries/save_data/save_backup.h"
|
||||||
|
|
||||||
class PSF;
|
class PSF;
|
||||||
|
|
||||||
namespace Libraries::SaveData {
|
namespace Libraries::SaveData {
|
||||||
using OrbisUserServiceUserId = s32;
|
using OrbisUserServiceUserId = s32;
|
||||||
}
|
} // namespace Libraries::SaveData
|
||||||
|
|
||||||
namespace Libraries::SaveData::SaveMemory {
|
namespace Libraries::SaveData::SaveMemory {
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ void PersistMemory(u32 slot_id, bool lock = true);
|
||||||
std::string_view game_serial);
|
std::string_view game_serial);
|
||||||
|
|
||||||
// returns the size of the save memory if exists
|
// returns the size of the save memory if exists
|
||||||
size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial);
|
size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial,
|
||||||
|
size_t memory_size);
|
||||||
|
|
||||||
// Write the icon. Set buf to null to read the standard icon.
|
// Write the icon. Set buf to null to read the standard icon.
|
||||||
void SetIcon(u32 slot_id, void* buf = nullptr, size_t buf_size = 0);
|
void SetIcon(u32 slot_id, void* buf = nullptr, size_t buf_size = 0);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <core/libraries/system/msgdialog_ui.h>
|
|
||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
@ -20,7 +19,9 @@
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/libraries/save_data/savedata.h"
|
#include "core/libraries/save_data/savedata.h"
|
||||||
|
#include "core/libraries/save_data/savedata_error.h"
|
||||||
#include "core/libraries/system/msgdialog.h"
|
#include "core/libraries/system/msgdialog.h"
|
||||||
|
#include "core/libraries/system/msgdialog_ui.h"
|
||||||
#include "save_backup.h"
|
#include "save_backup.h"
|
||||||
#include "save_instance.h"
|
#include "save_instance.h"
|
||||||
#include "save_memory.h"
|
#include "save_memory.h"
|
||||||
|
@ -33,27 +34,6 @@ using Common::ElfInfo;
|
||||||
|
|
||||||
namespace Libraries::SaveData {
|
namespace Libraries::SaveData {
|
||||||
|
|
||||||
enum class Error : u32 {
|
|
||||||
OK = 0,
|
|
||||||
USER_SERVICE_NOT_INITIALIZED = 0x80960002,
|
|
||||||
PARAMETER = 0x809F0000,
|
|
||||||
NOT_INITIALIZED = 0x809F0001,
|
|
||||||
OUT_OF_MEMORY = 0x809F0002,
|
|
||||||
BUSY = 0x809F0003,
|
|
||||||
NOT_MOUNTED = 0x809F0004,
|
|
||||||
EXISTS = 0x809F0007,
|
|
||||||
NOT_FOUND = 0x809F0008,
|
|
||||||
NO_SPACE_FS = 0x809F000A,
|
|
||||||
INTERNAL = 0x809F000B,
|
|
||||||
MOUNT_FULL = 0x809F000C,
|
|
||||||
BAD_MOUNTED = 0x809F000D,
|
|
||||||
BROKEN = 0x809F000F,
|
|
||||||
INVALID_LOGIN_USER = 0x809F0011,
|
|
||||||
MEMORY_NOT_READY = 0x809F0012,
|
|
||||||
BACKUP_BUSY = 0x809F0013,
|
|
||||||
BUSY_FOR_SAVING = 0x809F0016,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class OrbisSaveDataSaveDataMemoryOption : u32 {
|
enum class OrbisSaveDataSaveDataMemoryOption : u32 {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
SET_PARAM = 1 << 0,
|
SET_PARAM = 1 << 0,
|
||||||
|
@ -1593,8 +1573,8 @@ Error PS4_SYSV_ABI sceSaveDataSetupSaveDataMemory2(const OrbisSaveDataMemorySetu
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
size_t existed_size =
|
size_t existed_size = SaveMemory::SetupSaveMemory(setupParam->userId, slot_id,
|
||||||
SaveMemory::SetupSaveMemory(setupParam->userId, slot_id, g_game_serial);
|
g_game_serial, setupParam->memorySize);
|
||||||
if (existed_size == 0) { // Just created
|
if (existed_size == 0) { // Just created
|
||||||
if (g_fw_ver >= ElfInfo::FW_45 && setupParam->initParam != nullptr) {
|
if (g_fw_ver >= ElfInfo::FW_45 && setupParam->initParam != nullptr) {
|
||||||
auto& sfo = SaveMemory::GetParamSFO(slot_id);
|
auto& sfo = SaveMemory::GetParamSFO(slot_id);
|
||||||
|
|
27
src/core/libraries/save_data/savedata_error.h
Normal file
27
src/core/libraries/save_data/savedata_error.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Libraries::SaveData {
|
||||||
|
enum class Error : u32 {
|
||||||
|
OK = 0,
|
||||||
|
USER_SERVICE_NOT_INITIALIZED = 0x80960002,
|
||||||
|
PARAMETER = 0x809F0000,
|
||||||
|
NOT_INITIALIZED = 0x809F0001,
|
||||||
|
OUT_OF_MEMORY = 0x809F0002,
|
||||||
|
BUSY = 0x809F0003,
|
||||||
|
NOT_MOUNTED = 0x809F0004,
|
||||||
|
EXISTS = 0x809F0007,
|
||||||
|
NOT_FOUND = 0x809F0008,
|
||||||
|
NO_SPACE_FS = 0x809F000A,
|
||||||
|
INTERNAL = 0x809F000B,
|
||||||
|
MOUNT_FULL = 0x809F000C,
|
||||||
|
BAD_MOUNTED = 0x809F000D,
|
||||||
|
BROKEN = 0x809F000F,
|
||||||
|
INVALID_LOGIN_USER = 0x809F0011,
|
||||||
|
MEMORY_NOT_READY = 0x809F0012,
|
||||||
|
BACKUP_BUSY = 0x809F0013,
|
||||||
|
BUSY_FOR_SAVING = 0x809F0016,
|
||||||
|
};
|
||||||
|
} // namespace Libraries::SaveData
|
|
@ -362,11 +362,8 @@ int MemoryManager::MapMemory(void** out_addr, VAddr virtual_addr, size_t size, M
|
||||||
return ORBIS_KERNEL_ERROR_ENOMEM;
|
return ORBIS_KERNEL_ERROR_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When virtual addr is zero, force it to virtual_base. The guest cannot pass Fixed
|
// Limit the minumum address to SystemManagedVirtualBase to prevent hardware-specific issues.
|
||||||
// flag so we will take the branch that searches for free (or reserved) mappings.
|
VAddr mapped_addr = (virtual_addr == 0) ? impl.SystemManagedVirtualBase() : virtual_addr;
|
||||||
virtual_addr = (virtual_addr == 0) ? impl.SystemManagedVirtualBase() : virtual_addr;
|
|
||||||
alignment = alignment > 0 ? alignment : 16_KB;
|
|
||||||
VAddr mapped_addr = alignment > 0 ? Common::AlignUp(virtual_addr, alignment) : virtual_addr;
|
|
||||||
|
|
||||||
// Fixed mapping means the virtual address must exactly match the provided one.
|
// Fixed mapping means the virtual address must exactly match the provided one.
|
||||||
if (True(flags & MemoryMapFlags::Fixed)) {
|
if (True(flags & MemoryMapFlags::Fixed)) {
|
||||||
|
@ -376,24 +373,29 @@ int MemoryManager::MapMemory(void** out_addr, VAddr virtual_addr, size_t size, M
|
||||||
// To account for this, unmap any reserved areas within this mapping range first.
|
// To account for this, unmap any reserved areas within this mapping range first.
|
||||||
auto unmap_addr = mapped_addr;
|
auto unmap_addr = mapped_addr;
|
||||||
auto unmap_size = size;
|
auto unmap_size = size;
|
||||||
while (!vma.IsMapped() && unmap_addr < mapped_addr + size && remaining_size < size) {
|
// If flag NoOverwrite is provided, don't overwrite mapped VMAs.
|
||||||
|
// When it isn't provided, VMAs can be overwritten regardless of if they're mapped.
|
||||||
|
while ((False(flags & MemoryMapFlags::NoOverwrite) || !vma.IsMapped()) &&
|
||||||
|
unmap_addr < mapped_addr + size && remaining_size < size) {
|
||||||
auto unmapped = UnmapBytesFromEntry(unmap_addr, vma, unmap_size);
|
auto unmapped = UnmapBytesFromEntry(unmap_addr, vma, unmap_size);
|
||||||
unmap_addr += unmapped;
|
unmap_addr += unmapped;
|
||||||
unmap_size -= unmapped;
|
unmap_size -= unmapped;
|
||||||
vma = FindVMA(unmap_addr)->second;
|
vma = FindVMA(unmap_addr)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should return SCE_KERNEL_ERROR_ENOMEM but rarely happens.
|
|
||||||
vma = FindVMA(mapped_addr)->second;
|
vma = FindVMA(mapped_addr)->second;
|
||||||
remaining_size = vma.base + vma.size - mapped_addr;
|
remaining_size = vma.base + vma.size - mapped_addr;
|
||||||
ASSERT_MSG(!vma.IsMapped() && remaining_size >= size,
|
if (vma.IsMapped() || remaining_size < size) {
|
||||||
"Memory region {:#x} to {:#x} isn't free enough to map region {:#x} to {:#x}",
|
LOG_ERROR(Kernel_Vmm, "Unable to map {:#x} bytes at address {:#x}", size, mapped_addr);
|
||||||
vma.base, vma.base + vma.size, virtual_addr, virtual_addr + size);
|
return ORBIS_KERNEL_ERROR_ENOMEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the first free area starting with provided virtual address.
|
// Find the first free area starting with provided virtual address.
|
||||||
if (False(flags & MemoryMapFlags::Fixed)) {
|
if (False(flags & MemoryMapFlags::Fixed)) {
|
||||||
mapped_addr = SearchFree(mapped_addr, size, alignment);
|
// Provided address needs to be aligned before we can map.
|
||||||
|
alignment = alignment > 0 ? alignment : 16_KB;
|
||||||
|
mapped_addr = SearchFree(Common::AlignUp(mapped_addr, alignment), size, alignment);
|
||||||
if (mapped_addr == -1) {
|
if (mapped_addr == -1) {
|
||||||
// No suitable memory areas to map to
|
// No suitable memory areas to map to
|
||||||
return ORBIS_KERNEL_ERROR_ENOMEM;
|
return ORBIS_KERNEL_ERROR_ENOMEM;
|
||||||
|
@ -783,6 +785,19 @@ int MemoryManager::DirectQueryAvailable(PAddr search_start, PAddr search_end, si
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 MemoryManager::SetDirectMemoryType(s64 phys_addr, s32 memory_type) {
|
||||||
|
std::scoped_lock lk{mutex};
|
||||||
|
|
||||||
|
auto& dmem_area = FindDmemArea(phys_addr)->second;
|
||||||
|
|
||||||
|
ASSERT_MSG(phys_addr <= dmem_area.GetEnd() && !dmem_area.is_free,
|
||||||
|
"Direct memory area is not mapped");
|
||||||
|
|
||||||
|
dmem_area.memory_type = memory_type;
|
||||||
|
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void MemoryManager::NameVirtualRange(VAddr virtual_addr, size_t size, std::string_view name) {
|
void MemoryManager::NameVirtualRange(VAddr virtual_addr, size_t size, std::string_view name) {
|
||||||
auto it = FindVMA(virtual_addr);
|
auto it = FindVMA(virtual_addr);
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,8 @@ public:
|
||||||
int GetDirectMemoryType(PAddr addr, int* directMemoryTypeOut, void** directMemoryStartOut,
|
int GetDirectMemoryType(PAddr addr, int* directMemoryTypeOut, void** directMemoryStartOut,
|
||||||
void** directMemoryEndOut);
|
void** directMemoryEndOut);
|
||||||
|
|
||||||
|
s32 SetDirectMemoryType(s64 phys_addr, s32 memory_type);
|
||||||
|
|
||||||
void NameVirtualRange(VAddr virtual_addr, size_t size, std::string_view name);
|
void NameVirtualRange(VAddr virtual_addr, size_t size, std::string_view name);
|
||||||
|
|
||||||
void InvalidateMemory(VAddr addr, u64 size) const;
|
void InvalidateMemory(VAddr addr, u64 size) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue