Use utils::c_page_size

This commit is contained in:
kd-11 2022-07-02 21:25:55 +03:00 committed by kd-11
parent 278ae7763a
commit fddb6a31a7
2 changed files with 8 additions and 15 deletions

View File

@ -1,33 +1,26 @@
#pragma once #pragma once
#include "util/types.hpp" #include "util/types.hpp"
#include "util/vm.hpp"
#include "StrFmt.h" #include "StrFmt.h"
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#if defined(ARCH_X64)
#define HOST_PAGE_SIZE 4096u
#else
#define HOST_PAGE_SIZE get_page_size()
#endif
namespace utils namespace utils
{ {
class address_range_vector; class address_range_vector;
long get_page_size();
/** /**
* Helpers * Helpers
*/ */
static inline u32 page_start(u32 addr) static inline u32 page_start(u32 addr)
{ {
return addr & ~(HOST_PAGE_SIZE - 1); return addr & ~(c_page_size - 1);
} }
static inline u32 next_page(u32 addr) static inline u32 next_page(u32 addr)
{ {
return page_start(addr) + HOST_PAGE_SIZE; return page_start(addr) + c_page_size;
} }
static inline u32 page_end(u32 addr) static inline u32 page_end(u32 addr)
@ -37,7 +30,7 @@ namespace utils
static inline u32 is_page_aligned(u32 val) static inline u32 is_page_aligned(u32 val)
{ {
return (val & (HOST_PAGE_SIZE - 1)) == 0; return (val & (c_page_size - 1)) == 0;
} }

View File

@ -23,7 +23,7 @@ namespace rsx
{ {
if (p.second.prot != utils::protection::rw) if (p.second.prot != utils::protection::rw)
{ {
utils::memory_protect(vm::base(p.first), utils::get_page_size(), utils::protection::rw); utils::memory_protect(vm::base(p.first), utils::c_page_size, utils::protection::rw);
} }
} }
@ -796,7 +796,7 @@ namespace rsx
if (page.prot == utils::protection::rw) if (page.prot == utils::protection::rw)
{ {
utils::memory_protect(vm::base(page_address), utils::get_page_size(), utils::protection::no); utils::memory_protect(vm::base(page_address), utils::c_page_size, utils::protection::no);
page.prot = utils::protection::no; page.prot = utils::protection::no;
} }
} }
@ -844,7 +844,7 @@ namespace rsx
if (page.prot != utils::protection::rw) if (page.prot != utils::protection::rw)
{ {
utils::memory_protect(vm::base(this_address), utils::get_page_size(), utils::protection::rw); utils::memory_protect(vm::base(this_address), utils::c_page_size, utils::protection::rw);
page.prot = utils::protection::rw; page.prot = utils::protection::rw;
} }
@ -890,7 +890,7 @@ namespace rsx
else else
{ {
// R/W to stale block, unload it and move on // R/W to stale block, unload it and move on
utils::memory_protect(vm::base(page_address), utils::get_page_size(), utils::protection::rw); utils::memory_protect(vm::base(page_address), utils::c_page_size, utils::protection::rw);
m_locked_pages[location].erase(page_address); m_locked_pages[location].erase(page_address);
return true; return true;