Merge pull request #284 from polybiusproxy/linux-fix

Fix Linux builds
This commit is contained in:
georgemoralis 2024-07-11 16:40:21 +03:00 committed by GitHub
commit f3baad7fc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#ifdef _WIN32
#include "ntapi.h" #include "ntapi.h"
NtDelayExecution_t NtDelayExecution = nullptr; NtDelayExecution_t NtDelayExecution = nullptr;
@ -18,3 +20,5 @@ void Initialize() {
} }
} // namespace Common::NtApi } // namespace Common::NtApi
#endif

View File

@ -19,6 +19,8 @@ namespace Core {
static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE; static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE;
#ifdef _WIN32
[[nodiscard]] constexpr u64 ToWindowsProt(Core::MemoryProt prot) { [[nodiscard]] constexpr u64 ToWindowsProt(Core::MemoryProt prot) {
switch (prot) { switch (prot) {
case Core::MemoryProt::NoAccess: case Core::MemoryProt::NoAccess:
@ -31,7 +33,6 @@ static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE;
} }
} }
#ifdef _WIN32
struct AddressSpace::Impl { struct AddressSpace::Impl {
Impl() : process{GetCurrentProcess()} { Impl() : process{GetCurrentProcess()} {
// Allocate virtual address placeholder for our address space. // Allocate virtual address placeholder for our address space.
@ -228,6 +229,18 @@ enum PosixPageProtection {
PAGE_EXECUTE_READWRITE = PROT_EXEC | PROT_READ | PROT_WRITE PAGE_EXECUTE_READWRITE = PROT_EXEC | PROT_READ | PROT_WRITE
}; };
[[nodiscard]] constexpr PosixPageProtection ToPosixProt(Core::MemoryProt prot) {
switch (prot) {
case Core::MemoryProt::NoAccess:
default:
return PAGE_NOACCESS;
case Core::MemoryProt::CpuRead:
return PAGE_READONLY;
case Core::MemoryProt::CpuReadWrite:
return PAGE_READWRITE;
}
}
struct AddressSpace::Impl { struct AddressSpace::Impl {
Impl() { Impl() {
// Allocate virtual address placeholder for our address space. // Allocate virtual address placeholder for our address space.
@ -340,8 +353,13 @@ void* AddressSpace::Map(VAddr virtual_addr, size_t size, u64 alignment, PAddr ph
void* AddressSpace::MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot, void* AddressSpace::MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot,
uintptr_t fd) { uintptr_t fd) {
#ifdef _WIN32
return impl->Map(virtual_addr, offset, size, return impl->Map(virtual_addr, offset, size,
ToWindowsProt(std::bit_cast<Core::MemoryProt>(prot)), fd); ToWindowsProt(std::bit_cast<Core::MemoryProt>(prot)), fd);
#else
return impl->Map(virtual_addr, offset, size, ToPosixProt(std::bit_cast<Core::MemoryProt>(prot)),
fd);
#endif
} }
void AddressSpace::Unmap(VAddr virtual_addr, size_t size, bool has_backing) { void AddressSpace::Unmap(VAddr virtual_addr, size_t size, bool has_backing) {

View File

@ -40,7 +40,9 @@ Emulator::Emulator()
Config::load(config_dir / "config.toml"); Config::load(config_dir / "config.toml");
// Initialize NT API functions // Initialize NT API functions
#ifdef _WIN32
Common::NtApi::Initialize(); Common::NtApi::Initialize();
#endif
// Start logger. // Start logger.
Common::Log::Initialize(); Common::Log::Initialize();