Merge branch 'main' into main

This commit is contained in:
georgemoralis 2024-10-13 11:52:18 +03:00 committed by GitHub
commit 0258f1e93f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 160 additions and 42 deletions

View File

@ -22,6 +22,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
- A processor with at least 4 cores and 6 threads - A processor with at least 4 cores and 6 threads
- Above 2.5 GHz frequency - Above 2.5 GHz frequency
- required support AVX2 extension or Rosetta 2 on ARM
### GPU ### GPU

View File

@ -538,12 +538,12 @@ void load(const std::filesystem::path& path) {
// TODO Migration code, after a major release this should be removed. // TODO Migration code, after a major release this should be removed.
auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {}); auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {});
if (!old_game_install_dir.empty()) { if (!old_game_install_dir.empty()) {
settings_install_dirs.emplace_back(std::filesystem::path{old_game_install_dir}); addGameInstallDir(std::filesystem::path{old_game_install_dir});
} else { } else {
const auto install_dir_array = const auto install_dir_array =
toml::find_or<std::vector<std::string>>(gui, "installDirs", {}); toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
for (const auto& dir : install_dir_array) { for (const auto& dir : install_dir_array) {
settings_install_dirs.emplace_back(std::filesystem::path{dir}); addGameInstallDir(std::filesystem::path{dir});
} }
} }

View File

@ -231,7 +231,7 @@ void IOFile::Unlink() {
// Mark the file for deletion // Mark the file for deletion
// TODO: Also remove the file path? // TODO: Also remove the file path?
#if _WIN64 #ifdef _WIN64
FILE_DISPOSITION_INFORMATION disposition; FILE_DISPOSITION_INFORMATION disposition;
IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK iosb;
@ -242,7 +242,11 @@ void IOFile::Unlink() {
NtSetInformationFile(hfile, &iosb, &disposition, sizeof(disposition), NtSetInformationFile(hfile, &iosb, &disposition, sizeof(disposition),
FileDispositionInformation); FileDispositionInformation);
#else #else
UNREACHABLE_MSG("Missing Linux implementation"); if (unlink(file_path.c_str()) != 0) {
const auto ec = std::error_code{errno, std::generic_category()};
LOG_ERROR(Common_Filesystem, "Failed to unlink the file at path={}, ec_message={}",
PathToUTF8String(file_path), ec.message());
}
#endif #endif
} }

View File

@ -30,14 +30,13 @@ static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE_PRO;
#ifdef _WIN32 #ifdef _WIN32
[[nodiscard]] constexpr u64 ToWindowsProt(Core::MemoryProt prot) { [[nodiscard]] constexpr u64 ToWindowsProt(Core::MemoryProt prot) {
switch (prot) { if (True(prot & Core::MemoryProt::CpuReadWrite) ||
case Core::MemoryProt::NoAccess: True(prot & Core::MemoryProt::GpuReadWrite)) {
default:
return PAGE_NOACCESS;
case Core::MemoryProt::CpuRead:
return PAGE_READONLY;
case Core::MemoryProt::CpuReadWrite:
return PAGE_READWRITE; return PAGE_READWRITE;
} else if (True(prot & Core::MemoryProt::CpuRead) || True(prot & Core::MemoryProt::GpuRead)) {
return PAGE_READONLY;
} else {
return PAGE_NOACCESS;
} }
} }
@ -290,14 +289,13 @@ enum PosixPageProtection {
}; };
[[nodiscard]] constexpr PosixPageProtection ToPosixProt(Core::MemoryProt prot) { [[nodiscard]] constexpr PosixPageProtection ToPosixProt(Core::MemoryProt prot) {
switch (prot) { if (True(prot & Core::MemoryProt::CpuReadWrite) ||
case Core::MemoryProt::NoAccess: True(prot & Core::MemoryProt::GpuReadWrite)) {
default:
return PAGE_NOACCESS;
case Core::MemoryProt::CpuRead:
return PAGE_READONLY;
case Core::MemoryProt::CpuReadWrite:
return PAGE_READWRITE; return PAGE_READWRITE;
} else if (True(prot & Core::MemoryProt::CpuRead) || True(prot & Core::MemoryProt::GpuRead)) {
return PAGE_READONLY;
} else {
return PAGE_NOACCESS;
} }
} }

View File

@ -6,8 +6,10 @@
#include "avplayer_impl.h" #include "avplayer_impl.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/singleton.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
#include "core/libraries/kernel/libkernel.h" #include "core/libraries/kernel/libkernel.h"
#include "core/linker.h"
using namespace Libraries::Kernel; using namespace Libraries::Kernel;
@ -17,28 +19,32 @@ void* PS4_SYSV_ABI AvPlayer::Allocate(void* handle, u32 alignment, u32 size) {
const auto* const self = reinterpret_cast<AvPlayer*>(handle); const auto* const self = reinterpret_cast<AvPlayer*>(handle);
const auto allocate = self->m_init_data_original.memory_replacement.allocate; const auto allocate = self->m_init_data_original.memory_replacement.allocate;
const auto ptr = self->m_init_data_original.memory_replacement.object_ptr; const auto ptr = self->m_init_data_original.memory_replacement.object_ptr;
return allocate(ptr, alignment, size); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(allocate, ptr, alignment, size);
} }
void PS4_SYSV_ABI AvPlayer::Deallocate(void* handle, void* memory) { void PS4_SYSV_ABI AvPlayer::Deallocate(void* handle, void* memory) {
const auto* const self = reinterpret_cast<AvPlayer*>(handle); const auto* const self = reinterpret_cast<AvPlayer*>(handle);
const auto deallocate = self->m_init_data_original.memory_replacement.deallocate; const auto deallocate = self->m_init_data_original.memory_replacement.deallocate;
const auto ptr = self->m_init_data_original.memory_replacement.object_ptr; const auto ptr = self->m_init_data_original.memory_replacement.object_ptr;
return deallocate(ptr, memory); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(deallocate, ptr, memory);
} }
void* PS4_SYSV_ABI AvPlayer::AllocateTexture(void* handle, u32 alignment, u32 size) { void* PS4_SYSV_ABI AvPlayer::AllocateTexture(void* handle, u32 alignment, u32 size) {
const auto* const self = reinterpret_cast<AvPlayer*>(handle); const auto* const self = reinterpret_cast<AvPlayer*>(handle);
const auto allocate = self->m_init_data_original.memory_replacement.allocate_texture; const auto allocate = self->m_init_data_original.memory_replacement.allocate_texture;
const auto ptr = self->m_init_data_original.memory_replacement.object_ptr; const auto ptr = self->m_init_data_original.memory_replacement.object_ptr;
return allocate(ptr, alignment, size); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(allocate, ptr, alignment, size);
} }
void PS4_SYSV_ABI AvPlayer::DeallocateTexture(void* handle, void* memory) { void PS4_SYSV_ABI AvPlayer::DeallocateTexture(void* handle, void* memory) {
const auto* const self = reinterpret_cast<AvPlayer*>(handle); const auto* const self = reinterpret_cast<AvPlayer*>(handle);
const auto deallocate = self->m_init_data_original.memory_replacement.deallocate_texture; const auto deallocate = self->m_init_data_original.memory_replacement.deallocate_texture;
const auto ptr = self->m_init_data_original.memory_replacement.object_ptr; const auto ptr = self->m_init_data_original.memory_replacement.object_ptr;
return deallocate(ptr, memory); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(deallocate, ptr, memory);
} }
int PS4_SYSV_ABI AvPlayer::OpenFile(void* handle, const char* filename) { int PS4_SYSV_ABI AvPlayer::OpenFile(void* handle, const char* filename) {
@ -47,7 +53,8 @@ int PS4_SYSV_ABI AvPlayer::OpenFile(void* handle, const char* filename) {
const auto open = self->m_init_data_original.file_replacement.open; const auto open = self->m_init_data_original.file_replacement.open;
const auto ptr = self->m_init_data_original.file_replacement.object_ptr; const auto ptr = self->m_init_data_original.file_replacement.object_ptr;
return open(ptr, filename); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(open, ptr, filename);
} }
int PS4_SYSV_ABI AvPlayer::CloseFile(void* handle) { int PS4_SYSV_ABI AvPlayer::CloseFile(void* handle) {
@ -56,7 +63,8 @@ int PS4_SYSV_ABI AvPlayer::CloseFile(void* handle) {
const auto close = self->m_init_data_original.file_replacement.close; const auto close = self->m_init_data_original.file_replacement.close;
const auto ptr = self->m_init_data_original.file_replacement.object_ptr; const auto ptr = self->m_init_data_original.file_replacement.object_ptr;
return close(ptr); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(close, ptr);
} }
int PS4_SYSV_ABI AvPlayer::ReadOffsetFile(void* handle, u8* buffer, u64 position, u32 length) { int PS4_SYSV_ABI AvPlayer::ReadOffsetFile(void* handle, u8* buffer, u64 position, u32 length) {
@ -65,7 +73,8 @@ int PS4_SYSV_ABI AvPlayer::ReadOffsetFile(void* handle, u8* buffer, u64 position
const auto read_offset = self->m_init_data_original.file_replacement.readOffset; const auto read_offset = self->m_init_data_original.file_replacement.readOffset;
const auto ptr = self->m_init_data_original.file_replacement.object_ptr; const auto ptr = self->m_init_data_original.file_replacement.object_ptr;
return read_offset(ptr, buffer, position, length); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(read_offset, ptr, buffer, position, length);
} }
u64 PS4_SYSV_ABI AvPlayer::SizeFile(void* handle) { u64 PS4_SYSV_ABI AvPlayer::SizeFile(void* handle) {
@ -74,7 +83,8 @@ u64 PS4_SYSV_ABI AvPlayer::SizeFile(void* handle) {
const auto size = self->m_init_data_original.file_replacement.size; const auto size = self->m_init_data_original.file_replacement.size;
const auto ptr = self->m_init_data_original.file_replacement.object_ptr; const auto ptr = self->m_init_data_original.file_replacement.object_ptr;
return size(ptr); const auto* linker = Common::Singleton<Core::Linker>::Instance();
return linker->ExecuteGuest(size, ptr);
} }
SceAvPlayerInitData AvPlayer::StubInitData(const SceAvPlayerInitData& data) { SceAvPlayerInitData AvPlayer::StubInitData(const SceAvPlayerInitData& data) {

View File

@ -87,7 +87,12 @@ void PS4_SYSV_ABI AvPlayerState::AutoPlayEventCallback(void* opaque, SceAvPlayer
return; return;
} }
// Pass other events to the game DefaultEventCallback(opaque, event_id, 0, event_data);
}
void AvPlayerState::DefaultEventCallback(void* opaque, SceAvPlayerEvents event_id, s32 source_id,
void* event_data) {
auto const self = reinterpret_cast<AvPlayerState*>(opaque);
const auto callback = self->m_event_replacement.event_callback; const auto callback = self->m_event_replacement.event_callback;
const auto ptr = self->m_event_replacement.object_ptr; const auto ptr = self->m_event_replacement.object_ptr;
if (callback != nullptr) { if (callback != nullptr) {
@ -102,8 +107,10 @@ AvPlayerState::AvPlayerState(const SceAvPlayerInitData& init_data)
if (m_event_replacement.event_callback == nullptr || init_data.auto_start) { if (m_event_replacement.event_callback == nullptr || init_data.auto_start) {
m_auto_start = true; m_auto_start = true;
m_init_data.event_replacement.event_callback = &AvPlayerState::AutoPlayEventCallback; m_init_data.event_replacement.event_callback = &AvPlayerState::AutoPlayEventCallback;
m_init_data.event_replacement.object_ptr = this; } else {
m_init_data.event_replacement.event_callback = &AvPlayerState::DefaultEventCallback;
} }
m_init_data.event_replacement.object_ptr = this;
if (init_data.default_language != nullptr) { if (init_data.default_language != nullptr) {
std::memcpy(m_default_language, init_data.default_language, sizeof(m_default_language)); std::memcpy(m_default_language, init_data.default_language, sizeof(m_default_language));
} }
@ -367,8 +374,7 @@ void AvPlayerState::EmitEvent(SceAvPlayerEvents event_id, void* event_data) {
const auto callback = m_init_data.event_replacement.event_callback; const auto callback = m_init_data.event_replacement.event_callback;
if (callback) { if (callback) {
const auto ptr = m_init_data.event_replacement.object_ptr; const auto ptr = m_init_data.event_replacement.object_ptr;
const auto* linker = Common::Singleton<Core::Linker>::Instance(); callback(ptr, event_id, 0, event_data);
linker->ExecuteGuest(callback, ptr, event_id, 0, event_data);
} }
} }

View File

@ -42,6 +42,9 @@ private:
static void PS4_SYSV_ABI AutoPlayEventCallback(void* handle, SceAvPlayerEvents event_id, static void PS4_SYSV_ABI AutoPlayEventCallback(void* handle, SceAvPlayerEvents event_id,
s32 source_id, void* event_data); s32 source_id, void* event_data);
static void PS4_SYSV_ABI DefaultEventCallback(void* handle, SceAvPlayerEvents event_id,
s32 source_id, void* event_data);
void OnWarning(u32 id) override; void OnWarning(u32 id) override;
void OnError() override; void OnError() override;
void OnEOF() override; void OnEOF() override;

View File

@ -175,7 +175,7 @@ Error PS4_SYSV_ABI sceImeDialogInit(OrbisImeDialogParam* param, OrbisImeParamExt
} }
if (extended) { if (extended) {
if (magic_enum::enum_contains(extended->priority)) { if (!magic_enum::enum_contains(extended->priority)) {
LOG_INFO(Lib_ImeDialog, "Invalid extended->priority"); LOG_INFO(Lib_ImeDialog, "Invalid extended->priority");
return Error::INVALID_EXTENDED; return Error::INVALID_EXTENDED;
} }

View File

@ -321,26 +321,26 @@ int PS4_SYSV_ABI sceKernelRmdir(const char* path) {
const std::filesystem::path dir_name = mnt->GetHostPath(path, &ro); const std::filesystem::path dir_name = mnt->GetHostPath(path, &ro);
if (dir_name.empty()) { if (dir_name.empty()) {
LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, permission denied", LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, permission denied",
fmt::UTF(dir_name.u8string())); fmt::UTF(dir_name.u8string()));
return SCE_KERNEL_ERROR_EACCES; return SCE_KERNEL_ERROR_EACCES;
} }
if (ro) { if (ro) {
LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, directory is read only", LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, directory is read only",
fmt::UTF(dir_name.u8string())); fmt::UTF(dir_name.u8string()));
return SCE_KERNEL_ERROR_EROFS; return SCE_KERNEL_ERROR_EROFS;
} }
if (!std::filesystem::is_directory(dir_name)) { if (!std::filesystem::is_directory(dir_name)) {
LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, path is not a directory", LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, path is not a directory",
fmt::UTF(dir_name.u8string())); fmt::UTF(dir_name.u8string()));
return ORBIS_KERNEL_ERROR_ENOTDIR; return ORBIS_KERNEL_ERROR_ENOTDIR;
} }
if (!std::filesystem::exists(dir_name)) { if (!std::filesystem::exists(dir_name)) {
LOG_INFO(Kernel_Fs, "Failed to remove directory: {}, no such file or directory", LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, no such file or directory",
fmt::UTF(dir_name.u8string())); fmt::UTF(dir_name.u8string()));
return ORBIS_KERNEL_ERROR_ENOENT; return ORBIS_KERNEL_ERROR_ENOENT;
} }
@ -348,7 +348,7 @@ int PS4_SYSV_ABI sceKernelRmdir(const char* path) {
int result = std::filesystem::remove_all(dir_name, ec); int result = std::filesystem::remove_all(dir_name, ec);
if (!ec) { if (!ec) {
LOG_DEBUG(Kernel_Fs, "Removed directory: {}", fmt::UTF(dir_name.u8string())); LOG_INFO(Kernel_Fs, "Removed directory: {}", fmt::UTF(dir_name.u8string()));
return ORBIS_OK; return ORBIS_OK;
} }
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, error_code={}", LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, error_code={}",

View File

@ -157,6 +157,7 @@ void SetPosixErrno(int e) {
g_posix_errno = e; g_posix_errno = e;
} }
} }
int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd, size_t offset, int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd, size_t offset,
void** res) { void** res) {
LOG_INFO(Kernel_Vmm, "called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, offset = {}", LOG_INFO(Kernel_Vmm, "called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, offset = {}",

View File

@ -28,7 +28,7 @@ enum class MemoryProt : u32 {
CpuReadWrite = 2, CpuReadWrite = 2,
GpuRead = 16, GpuRead = 16,
GpuWrite = 32, GpuWrite = 32,
GpuReadWrite = 38, GpuReadWrite = 48,
}; };
DECLARE_ENUM_FLAG_OPERATORS(MemoryProt) DECLARE_ENUM_FLAG_OPERATORS(MemoryProt)

View File

@ -469,6 +469,41 @@
<source>Back Button Behavior</source> <source>Back Button Behavior</source>
<translation>Sjellja e butonit kthimit</translation> <translation>Sjellja e butonit kthimit</translation>
</message> </message>
<message>
<location filename="../settings_dialog.ui" line="595"/>
<source>Input</source>
<translation>Hyrja</translation>
</message>
<message>
<location filename="../settings_dialog.ui" line="611"/>
<source>Cursor</source>
<translation>Kursori</translation>
</message>
<message>
<location filename="../settings_dialog.ui" line="635"/>
<source>Hide Cursor</source>
<translation>Fshih kursorin</translation>
</message>
<message>
<location filename="../settings_dialog.ui" line="668"/>
<source>Hide Cursor Idle Timeout</source>
<translation>Koha për fshehjen e kursorit joaktiv</translation>
</message>
<message>
<location filename="../settings_dialog.ui" line="595"/>
<source>Input</source>
<translation>Hyrja</translation>
</message>
<message>
<location filename="../settings_dialog.ui" line="767"/>
<source>Controller</source>
<translation>Dorezë</translation>
</message>
<message>
<location filename="../settings_dialog.ui" line="797"/>
<source>Back Button Behavior</source>
<translation>Sjellja e butonit mbrapa</translation>
</message>
<message> <message>
<location filename="../settings_dialog.ui" line="272"/> <location filename="../settings_dialog.ui" line="272"/>
<source>Graphics</source> <source>Graphics</source>
@ -1133,6 +1168,66 @@
<source>None</source> <source>None</source>
<translation>Asnjë</translation> <translation>Asnjë</translation>
</message> </message>
<message>
<location filename="../settings_dialog.cpp" line="392"/>
<source>cursorGroupBox</source>
<translation>Kursori:\nNdrysho cilësimet lidhje me kursorin.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="394"/>
<source>hideCursorGroupBox</source>
<translation>Fshih kursorin:\nCakto sjelljen e fshehjes kursorit.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="396"/>
<source>idleTimeoutGroupBox</source>
<translation>Koha për fshehjen e kursorit joaktiv:\Kohëzgjatja ( sekonda) pas cilës kursori ka nuk ka qënë veprim fshihet.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="70"/>
<source>Never</source>
<translation>Kurrë</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="71"/>
<source>Idle</source>
<translation>Pa vepruar</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="72"/>
<source>Always</source>
<translation>Gjithmonë</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="330"/>
<source>backButtonBehaviorGroupBox</source>
<translation>Back Button Behavior:\nAllows setting which part of the touchpad the back button will emulate a touch on.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="330"/>
<source>backButtonBehaviorGroupBox</source>
<translation>Sjellja e butonit mbrapa:\nLejon përcaktohet se cilën pjesë tastierës prekëse do imitojë një prekje butoni prapa.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="101"/>
<source>Touchpad Left</source>
<translation>Tastiera prekëse majtas</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="102"/>
<source>Touchpad Right</source>
<translation>Tastiera prekëse djathtas</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="103"/>
<source>Touchpad Center</source>
<translation>Tastiera prekëse qendër</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="104"/>
<source>None</source>
<translation>Asnjë</translation>
</message>
<message> <message>
<location filename="../settings_dialog.cpp" line="312"/> <location filename="../settings_dialog.cpp" line="312"/>
<source>graphicsAdapterGroupBox</source> <source>graphicsAdapterGroupBox</source>
@ -1239,7 +1334,7 @@
<message> <message>
<location filename="../game_list_frame.cpp" line="38"/> <location filename="../game_list_frame.cpp" line="38"/>
<source>Play Time</source> <source>Play Time</source>
<translation>Kohë Lojë</translation> <translation>Koha e luajtjes</translation>
</message> </message>
</context> </context>
<context> <context>