mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-12 14:48:52 +00:00
Misc implementations and fixes. (#250)
* Implement `sceKernelFtruncate` and `sceKernelUnlink`. * Remove unused variable. * Implement `sceKernelReserveVirtualRange`, misc fixes * Fix `sceKernelReserveVirtualRange`. * Add TODO on reserve * Replace comment with assert. * Add missing copyright header * Add `UNREACHABLE` for `IOFile::Unlink`. * Move NT API initialization out of the header * Fix bug where files were always mapped as read only. * `clang-format`
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "common/error.h"
|
||||
#include "core/address_space.h"
|
||||
#include "core/libraries/kernel/memory_management.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -18,6 +19,18 @@ namespace Core {
|
||||
|
||||
static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE;
|
||||
|
||||
[[nodiscard]] constexpr u64 ToWindowsProt(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;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
struct AddressSpace::Impl {
|
||||
Impl() : process{GetCurrentProcess()} {
|
||||
@@ -325,8 +338,10 @@ void* AddressSpace::Map(VAddr virtual_addr, size_t size, u64 alignment, PAddr ph
|
||||
is_exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void* AddressSpace::MapFile(VAddr virtual_addr, size_t size, size_t offset, uintptr_t fd) {
|
||||
return impl->Map(virtual_addr, offset, size, fd ? PAGE_READONLY : PAGE_READWRITE, fd);
|
||||
void* AddressSpace::MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot,
|
||||
uintptr_t fd) {
|
||||
return impl->Map(virtual_addr, offset, size,
|
||||
ToWindowsProt(std::bit_cast<Core::MemoryProt>(prot)), fd);
|
||||
}
|
||||
|
||||
void AddressSpace::Unmap(VAddr virtual_addr, size_t size, bool has_backing) {
|
||||
|
||||
Reference in New Issue
Block a user