forked from ShuriZma/suyu
1
0
Fork 0

core: memory: Move to Core::Memory namespace.

- helpful to disambiguate Kernel::Memory namespace.
This commit is contained in:
bunnei 2020-03-31 15:10:44 -04:00
parent b838e58d63
commit 4caff51710
37 changed files with 100 additions and 98 deletions

View File

@ -36,9 +36,9 @@ public:
} }
void SetWaveIndex(std::size_t index); void SetWaveIndex(std::size_t index);
std::vector<s16> DequeueSamples(std::size_t sample_count, Memory::Memory& memory); std::vector<s16> DequeueSamples(std::size_t sample_count, Core::Memory::Memory& memory);
void UpdateState(); void UpdateState();
void RefreshBuffer(Memory::Memory& memory); void RefreshBuffer(Core::Memory::Memory& memory);
private: private:
bool is_in_use{}; bool is_in_use{};
@ -66,13 +66,14 @@ public:
return info; return info;
} }
void UpdateState(Memory::Memory& memory); void UpdateState(Core::Memory::Memory& memory);
private: private:
EffectOutStatus out_status{}; EffectOutStatus out_status{};
EffectInStatus info{}; EffectInStatus info{};
}; };
AudioRenderer::AudioRenderer(Core::Timing::CoreTiming& core_timing, Memory::Memory& memory_,
AudioRenderer::AudioRenderer(Core::Timing::CoreTiming& core_timing, Core::Memory::Memory& memory_,
AudioRendererParameter params, AudioRendererParameter params,
std::shared_ptr<Kernel::WritableEvent> buffer_event, std::shared_ptr<Kernel::WritableEvent> buffer_event,
std::size_t instance_number) std::size_t instance_number)
@ -208,7 +209,7 @@ void AudioRenderer::VoiceState::SetWaveIndex(std::size_t index) {
} }
std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(std::size_t sample_count, std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(std::size_t sample_count,
Memory::Memory& memory) { Core::Memory::Memory& memory) {
if (!IsPlaying()) { if (!IsPlaying()) {
return {}; return {};
} }
@ -258,7 +259,7 @@ void AudioRenderer::VoiceState::UpdateState() {
is_in_use = info.is_in_use; is_in_use = info.is_in_use;
} }
void AudioRenderer::VoiceState::RefreshBuffer(Memory::Memory& memory) { void AudioRenderer::VoiceState::RefreshBuffer(Core::Memory::Memory& memory) {
const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr; const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr;
const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz; const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz;
std::vector<s16> new_samples(wave_buffer_size / sizeof(s16)); std::vector<s16> new_samples(wave_buffer_size / sizeof(s16));
@ -310,7 +311,7 @@ void AudioRenderer::VoiceState::RefreshBuffer(Memory::Memory& memory) {
is_refresh_pending = false; is_refresh_pending = false;
} }
void AudioRenderer::EffectState::UpdateState(Memory::Memory& memory) { void AudioRenderer::EffectState::UpdateState(Core::Memory::Memory& memory) {
if (info.is_new) { if (info.is_new) {
out_status.state = EffectStatus::New; out_status.state = EffectStatus::New;
} else { } else {

View File

@ -22,7 +22,7 @@ namespace Kernel {
class WritableEvent; class WritableEvent;
} }
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -221,7 +221,7 @@ static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has wrong size
class AudioRenderer { class AudioRenderer {
public: public:
AudioRenderer(Core::Timing::CoreTiming& core_timing, Memory::Memory& memory_, AudioRenderer(Core::Timing::CoreTiming& core_timing, Core::Memory::Memory& memory_,
AudioRendererParameter params, AudioRendererParameter params,
std::shared_ptr<Kernel::WritableEvent> buffer_event, std::size_t instance_number); std::shared_ptr<Kernel::WritableEvent> buffer_event, std::size_t instance_number);
~AudioRenderer(); ~AudioRenderer();
@ -244,7 +244,7 @@ private:
std::vector<EffectState> effects; std::vector<EffectState> effects;
std::unique_ptr<AudioOut> audio_out; std::unique_ptr<AudioOut> audio_out;
StreamPtr stream; StreamPtr stream;
Memory::Memory& memory; Core::Memory::Memory& memory;
}; };
} // namespace AudioCore } // namespace AudioCore

View File

@ -60,7 +60,7 @@ static_assert(sizeof(ELFSymbol) == 0x18, "ELFSymbol has incorrect size.");
using Symbols = std::vector<std::pair<ELFSymbol, std::string>>; using Symbols = std::vector<std::pair<ELFSymbol, std::string>>;
Symbols GetSymbols(VAddr text_offset, Memory::Memory& memory) { Symbols GetSymbols(VAddr text_offset, Core::Memory::Memory& memory) {
const auto mod_offset = text_offset + memory.Read32(text_offset + 4); const auto mod_offset = text_offset + memory.Read32(text_offset + 4);
if (mod_offset < text_offset || (mod_offset & 0b11) != 0 || if (mod_offset < text_offset || (mod_offset & 0b11) != 0 ||

View File

@ -15,7 +15,7 @@
#include "core/arm/arm_interface.h" #include "core/arm/arm_interface.h"
#include "core/arm/exclusive_monitor.h" #include "core/arm/exclusive_monitor.h"
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }

View File

@ -15,7 +15,7 @@
#include "core/arm/exclusive_monitor.h" #include "core/arm/exclusive_monitor.h"
#include "core/arm/unicorn/arm_unicorn.h" #include "core/arm/unicorn/arm_unicorn.h"
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -92,7 +92,7 @@ public:
private: private:
friend class ARM_Dynarmic_64; friend class ARM_Dynarmic_64;
Dynarmic::A64::ExclusiveMonitor monitor; Dynarmic::A64::ExclusiveMonitor monitor;
Memory::Memory& memory; Core::Memory::Memory& memory;
}; };
} // namespace Core } // namespace Core

View File

@ -8,7 +8,7 @@
#include "common/common_types.h" #include "common/common_types.h"
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }

View File

@ -346,7 +346,7 @@ struct System::Impl {
std::unique_ptr<Loader::AppLoader> app_loader; std::unique_ptr<Loader::AppLoader> app_loader;
std::unique_ptr<Tegra::GPU> gpu_core; std::unique_ptr<Tegra::GPU> gpu_core;
std::unique_ptr<Hardware::InterruptManager> interrupt_manager; std::unique_ptr<Hardware::InterruptManager> interrupt_manager;
Memory::Memory memory; Core::Memory::Memory memory;
CpuManager cpu_manager; CpuManager cpu_manager;
bool is_powered_on = false; bool is_powered_on = false;
bool exit_lock = false; bool exit_lock = false;
@ -505,7 +505,7 @@ Memory::Memory& System::Memory() {
return impl->memory; return impl->memory;
} }
const Memory::Memory& System::Memory() const { const Core::Memory::Memory& System::Memory() const {
return impl->memory; return impl->memory;
} }

View File

@ -36,9 +36,10 @@ class AppLoader;
enum class ResultStatus : u16; enum class ResultStatus : u16;
} // namespace Loader } // namespace Loader
namespace Memory { namespace Core::Memory {
struct CheatEntry; struct CheatEntry;
} // namespace Memory class Memory;
} // namespace Core::Memory
namespace Service { namespace Service {
@ -86,10 +87,6 @@ namespace Core::Hardware {
class InterruptManager; class InterruptManager;
} }
namespace Memory {
class Memory;
}
namespace Core { namespace Core {
class ARM_Interface; class ARM_Interface;
@ -230,10 +227,10 @@ public:
const ExclusiveMonitor& Monitor() const; const ExclusiveMonitor& Monitor() const;
/// Gets a mutable reference to the system memory instance. /// Gets a mutable reference to the system memory instance.
Memory::Memory& Memory(); Core::Memory::Memory& Memory();
/// Gets a constant reference to the system memory instance. /// Gets a constant reference to the system memory instance.
const Memory::Memory& Memory() const; const Core::Memory::Memory& Memory() const;
/// Gets a mutable reference to the GPU interface /// Gets a mutable reference to the GPU interface
Tegra::GPU& GPU(); Tegra::GPU& GPU();

View File

@ -22,7 +22,7 @@ namespace Core::Timing {
class CoreTiming; class CoreTiming;
} }
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }

View File

@ -249,7 +249,7 @@ bool PatchManager::HasNSOPatch(const std::array<u8, 32>& build_id_) const {
} }
namespace { namespace {
std::optional<std::vector<Memory::CheatEntry>> ReadCheatFileFromFolder( std::optional<std::vector<Core::Memory::CheatEntry>> ReadCheatFileFromFolder(
const Core::System& system, u64 title_id, const std::array<u8, 0x20>& build_id_, const Core::System& system, u64 title_id, const std::array<u8, 0x20>& build_id_,
const VirtualDir& base_path, bool upper) { const VirtualDir& base_path, bool upper) {
const auto build_id_raw = Common::HexToString(build_id_, upper); const auto build_id_raw = Common::HexToString(build_id_, upper);
@ -269,14 +269,14 @@ std::optional<std::vector<Memory::CheatEntry>> ReadCheatFileFromFolder(
return std::nullopt; return std::nullopt;
} }
Memory::TextCheatParser parser; Core::Memory::TextCheatParser parser;
return parser.Parse( return parser.Parse(
system, std::string_view(reinterpret_cast<const char* const>(data.data()), data.size())); system, std::string_view(reinterpret_cast<const char* const>(data.data()), data.size()));
} }
} // Anonymous namespace } // Anonymous namespace
std::vector<Memory::CheatEntry> PatchManager::CreateCheatList( std::vector<Core::Memory::CheatEntry> PatchManager::CreateCheatList(
const Core::System& system, const std::array<u8, 32>& build_id_) const { const Core::System& system, const std::array<u8, 32>& build_id_) const {
const auto load_dir = system.GetFileSystemController().GetModificationLoadRoot(title_id); const auto load_dir = system.GetFileSystemController().GetModificationLoadRoot(title_id);
if (load_dir == nullptr) { if (load_dir == nullptr) {
@ -289,7 +289,7 @@ std::vector<Memory::CheatEntry> PatchManager::CreateCheatList(
std::sort(patch_dirs.begin(), patch_dirs.end(), std::sort(patch_dirs.begin(), patch_dirs.end(),
[](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
std::vector<Memory::CheatEntry> out; std::vector<Core::Memory::CheatEntry> out;
for (const auto& subdir : patch_dirs) { for (const auto& subdir : patch_dirs) {
if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) { if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) {
continue; continue;

View File

@ -51,8 +51,8 @@ public:
bool HasNSOPatch(const std::array<u8, 0x20>& build_id) const; bool HasNSOPatch(const std::array<u8, 0x20>& build_id) const;
// Creates a CheatList object with all // Creates a CheatList object with all
std::vector<Memory::CheatEntry> CreateCheatList(const Core::System& system, std::vector<Core::Memory::CheatEntry> CreateCheatList(
const std::array<u8, 0x20>& build_id) const; const Core::System& system, const std::array<u8, 0x20>& build_id) const;
// Currently tracked RomFS patches: // Currently tracked RomFS patches:
// - Game Updates // - Game Updates

View File

@ -47,7 +47,8 @@ ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kern
return MakeResult(std::move(client_session)); return MakeResult(std::move(client_session));
} }
ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory) { ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread,
Core::Memory::Memory& memory) {
// Keep ServerSession alive until we're done working with it. // Keep ServerSession alive until we're done working with it.
if (!parent->Server()) { if (!parent->Server()) {
return ERR_SESSION_CLOSED_BY_REMOTE; return ERR_SESSION_CLOSED_BY_REMOTE;

View File

@ -12,7 +12,7 @@
union ResultCode; union ResultCode;
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -42,7 +42,7 @@ public:
return HANDLE_TYPE; return HANDLE_TYPE;
} }
ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory);
bool ShouldWait(const Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;

View File

@ -59,7 +59,8 @@ void SetupMainThread(Process& owner_process, KernelCore& kernel, u32 priority) {
// (whichever page happens to have an available slot). // (whichever page happens to have an available slot).
class TLSPage { class TLSPage {
public: public:
static constexpr std::size_t num_slot_entries = Memory::PAGE_SIZE / Memory::TLS_ENTRY_SIZE; static constexpr std::size_t num_slot_entries =
Core::Memory::PAGE_SIZE / Core::Memory::TLS_ENTRY_SIZE;
explicit TLSPage(VAddr address) : base_address{address} {} explicit TLSPage(VAddr address) : base_address{address} {}
@ -78,7 +79,7 @@ public:
} }
is_slot_used[i] = true; is_slot_used[i] = true;
return base_address + (i * Memory::TLS_ENTRY_SIZE); return base_address + (i * Core::Memory::TLS_ENTRY_SIZE);
} }
return std::nullopt; return std::nullopt;
@ -88,15 +89,15 @@ public:
// Ensure that all given addresses are consistent with how TLS pages // Ensure that all given addresses are consistent with how TLS pages
// are intended to be used when releasing slots. // are intended to be used when releasing slots.
ASSERT(IsWithinPage(address)); ASSERT(IsWithinPage(address));
ASSERT((address % Memory::TLS_ENTRY_SIZE) == 0); ASSERT((address % Core::Memory::TLS_ENTRY_SIZE) == 0);
const std::size_t index = (address - base_address) / Memory::TLS_ENTRY_SIZE; const std::size_t index = (address - base_address) / Core::Memory::TLS_ENTRY_SIZE;
is_slot_used[index] = false; is_slot_used[index] = false;
} }
private: private:
bool IsWithinPage(VAddr address) const { bool IsWithinPage(VAddr address) const {
return base_address <= address && address < base_address + Memory::PAGE_SIZE; return base_address <= address && address < base_address + Core::Memory::PAGE_SIZE;
} }
VAddr base_address; VAddr base_address;
@ -306,7 +307,7 @@ VAddr Process::CreateTLSRegion() {
} }
void Process::FreeTLSRegion(VAddr tls_address) { void Process::FreeTLSRegion(VAddr tls_address) {
const VAddr aligned_address = Common::AlignDown(tls_address, Memory::PAGE_SIZE); const VAddr aligned_address = Common::AlignDown(tls_address, Core::Memory::PAGE_SIZE);
auto iter = auto iter =
std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) { std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) {
return page.GetBaseAddress() == aligned_address; return page.GetBaseAddress() == aligned_address;

View File

@ -134,7 +134,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory) { ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread,
Core::Memory::Memory& memory) {
u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))};
std::shared_ptr<Kernel::HLERequestContext> context{ std::shared_ptr<Kernel::HLERequestContext> context{
std::make_shared<Kernel::HLERequestContext>(SharedFrom(this), std::move(thread))}; std::make_shared<Kernel::HLERequestContext>(SharedFrom(this), std::move(thread))};
@ -178,7 +179,7 @@ ResultCode ServerSession::CompleteSyncRequest() {
} }
ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread, ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread,
Memory::Memory& memory) { Core::Memory::Memory& memory) {
Core::System::GetInstance().CoreTiming().ScheduleEvent(20000, request_event, {}); Core::System::GetInstance().CoreTiming().ScheduleEvent(20000, request_event, {});
return QueueSyncRequest(std::move(thread), memory); return QueueSyncRequest(std::move(thread), memory);
} }

View File

@ -13,7 +13,7 @@
#include "core/hle/kernel/synchronization_object.h" #include "core/hle/kernel/synchronization_object.h"
#include "core/hle/result.h" #include "core/hle/result.h"
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -92,7 +92,7 @@ public:
* *
* @returns ResultCode from the operation. * @returns ResultCode from the operation.
*/ */
ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory);
bool ShouldWait(const Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;
@ -126,7 +126,7 @@ public:
private: private:
/// Queues a sync request from the emulated application. /// Queues a sync request from the emulated application.
ResultCode QueueSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); ResultCode QueueSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory);
/// Completes a sync request from the emulated application. /// Completes a sync request from the emulated application.
ResultCode CompleteSyncRequest(); ResultCode CompleteSyncRequest();

View File

@ -539,7 +539,7 @@ static ResultCode ArbitrateLock(Core::System& system, Handle holding_thread_hand
"requesting_current_thread_handle=0x{:08X}", "requesting_current_thread_handle=0x{:08X}",
holding_thread_handle, mutex_addr, requesting_thread_handle); holding_thread_handle, mutex_addr, requesting_thread_handle);
if (Memory::IsKernelVirtualAddress(mutex_addr)) { if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) {
LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}", LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}",
mutex_addr); mutex_addr);
return ERR_INVALID_ADDRESS_STATE; return ERR_INVALID_ADDRESS_STATE;
@ -559,7 +559,7 @@ static ResultCode ArbitrateLock(Core::System& system, Handle holding_thread_hand
static ResultCode ArbitrateUnlock(Core::System& system, VAddr mutex_addr) { static ResultCode ArbitrateUnlock(Core::System& system, VAddr mutex_addr) {
LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr); LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr);
if (Memory::IsKernelVirtualAddress(mutex_addr)) { if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) {
LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}", LOG_ERROR(Kernel_SVC, "Mutex Address is a kernel virtual address, mutex_addr={:016X}",
mutex_addr); mutex_addr);
return ERR_INVALID_ADDRESS_STATE; return ERR_INVALID_ADDRESS_STATE;
@ -1611,7 +1611,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add
"called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}",
mutex_addr, condition_variable_addr, thread_handle, nano_seconds); mutex_addr, condition_variable_addr, thread_handle, nano_seconds);
if (Memory::IsKernelVirtualAddress(mutex_addr)) { if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) {
LOG_ERROR( LOG_ERROR(
Kernel_SVC, Kernel_SVC,
"Given mutex address must not be within the kernel address space. address=0x{:016X}", "Given mutex address must not be within the kernel address space. address=0x{:016X}",
@ -1742,7 +1742,7 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type,
type, value, timeout); type, value, timeout);
// If the passed address is a kernel virtual address, return invalid memory state. // If the passed address is a kernel virtual address, return invalid memory state.
if (Memory::IsKernelVirtualAddress(address)) { if (Core::Memory::IsKernelVirtualAddress(address)) {
LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address);
return ERR_INVALID_ADDRESS_STATE; return ERR_INVALID_ADDRESS_STATE;
} }
@ -1770,7 +1770,7 @@ static ResultCode SignalToAddress(Core::System& system, VAddr address, u32 type,
address, type, value, num_to_wake); address, type, value, num_to_wake);
// If the passed address is a kernel virtual address, return invalid memory state. // If the passed address is a kernel virtual address, return invalid memory state.
if (Memory::IsKernelVirtualAddress(address)) { if (Core::Memory::IsKernelVirtualAddress(address)) {
LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address);
return ERR_INVALID_ADDRESS_STATE; return ERR_INVALID_ADDRESS_STATE;
} }

View File

@ -12,7 +12,7 @@
namespace Kernel { namespace Kernel {
TransferMemory::TransferMemory(KernelCore& kernel, Memory::Memory& memory) TransferMemory::TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory)
: Object{kernel}, memory{memory} {} : Object{kernel}, memory{memory} {}
TransferMemory::~TransferMemory() { TransferMemory::~TransferMemory() {
@ -20,7 +20,8 @@ TransferMemory::~TransferMemory() {
Reset(); Reset();
} }
std::shared_ptr<TransferMemory> TransferMemory::Create(KernelCore& kernel, Memory::Memory& memory, std::shared_ptr<TransferMemory> TransferMemory::Create(KernelCore& kernel,
Core::Memory::Memory& memory,
VAddr base_address, u64 size, VAddr base_address, u64 size,
MemoryPermission permissions) { MemoryPermission permissions) {
std::shared_ptr<TransferMemory> transfer_memory{ std::shared_ptr<TransferMemory> transfer_memory{

View File

@ -11,7 +11,7 @@
union ResultCode; union ResultCode;
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -30,12 +30,12 @@ enum class MemoryPermission : u32;
/// ///
class TransferMemory final : public Object { class TransferMemory final : public Object {
public: public:
explicit TransferMemory(KernelCore& kernel, Memory::Memory& memory); explicit TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory);
~TransferMemory() override; ~TransferMemory() override;
static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory; static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory;
static std::shared_ptr<TransferMemory> Create(KernelCore& kernel, Memory::Memory& memory, static std::shared_ptr<TransferMemory> Create(KernelCore& kernel, Core::Memory::Memory& memory,
VAddr base_address, u64 size, VAddr base_address, u64 size,
MemoryPermission permissions); MemoryPermission permissions);
@ -112,7 +112,7 @@ private:
/// Whether or not this transfer memory instance has mapped memory. /// Whether or not this transfer memory instance has mapped memory.
bool is_mapped = false; bool is_mapped = false;
Memory::Memory& memory; Core::Memory::Memory& memory;
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -210,7 +210,7 @@ private:
/// This is the event handle used to check if the audio buffer was released /// This is the event handle used to check if the audio buffer was released
Kernel::EventPair buffer_event; Kernel::EventPair buffer_event;
Memory::Memory& main_memory; Core::Memory::Memory& main_memory;
}; };
AudOutU::AudOutU(Core::System& system_) : ServiceFramework("audout:u"), system{system_} { AudOutU::AudOutU(Core::System& system_) : ServiceFramework("audout:u"), system{system_} {

View File

@ -17,7 +17,7 @@ namespace Service::LM {
class ILogger final : public ServiceFramework<ILogger> { class ILogger final : public ServiceFramework<ILogger> {
public: public:
explicit ILogger(Manager& manager_, Memory::Memory& memory_) explicit ILogger(Manager& manager_, Core::Memory::Memory& memory_)
: ServiceFramework("ILogger"), manager{manager_}, memory{memory_} { : ServiceFramework("ILogger"), manager{manager_}, memory{memory_} {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &ILogger::Log, "Log"}, {0, &ILogger::Log, "Log"},
@ -75,12 +75,12 @@ private:
} }
Manager& manager; Manager& manager;
Memory::Memory& memory; Core::Memory::Memory& memory;
}; };
class LM final : public ServiceFramework<LM> { class LM final : public ServiceFramework<LM> {
public: public:
explicit LM(Manager& manager_, Memory::Memory& memory_) explicit LM(Manager& manager_, Core::Memory::Memory& memory_)
: ServiceFramework{"lm"}, manager{manager_}, memory{memory_} { : ServiceFramework{"lm"}, manager{manager_}, memory{memory_} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -101,7 +101,7 @@ private:
} }
Manager& manager; Manager& manager;
Memory::Memory& memory; Core::Memory::Memory& memory;
}; };
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {

View File

@ -401,7 +401,7 @@ AppLoader_ELF::LoadResult AppLoader_ELF::Load(Kernel::Process& process) {
process.LoadModule(std::move(codeset), entry_point); process.LoadModule(std::move(codeset), entry_point);
is_loaded = true; is_loaded = true;
return {ResultStatus::Success, LoadParameters{48, Memory::DEFAULT_STACK_SIZE}}; return {ResultStatus::Success, LoadParameters{48, Core::Memory::DEFAULT_STACK_SIZE}};
} }
} // namespace Loader } // namespace Loader

View File

@ -14,7 +14,7 @@ namespace Loader {
namespace { namespace {
constexpr u32 PageAlignSize(u32 size) { constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; return (size + Core::Memory::PAGE_MASK) & ~Core::Memory::PAGE_MASK;
} }
} // Anonymous namespace } // Anonymous namespace

View File

@ -127,7 +127,7 @@ FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) {
} }
static constexpr u32 PageAlignSize(u32 size) { static constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; return (size + Core::Memory::PAGE_MASK) & ~Core::Memory::PAGE_MASK;
} }
static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data,
@ -221,7 +221,7 @@ AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process) {
is_loaded = true; is_loaded = true;
return {ResultStatus::Success, return {ResultStatus::Success,
LoadParameters{Kernel::THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE}}; LoadParameters{Kernel::THREADPRIO_DEFAULT, Core::Memory::DEFAULT_STACK_SIZE}};
} }
ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) { ResultStatus AppLoader_NRO::ReadIcon(std::vector<u8>& buffer) {

View File

@ -47,7 +47,7 @@ std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data,
} }
constexpr u32 PageAlignSize(u32 size) { constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; return (size + Core::Memory::PAGE_MASK) & ~Core::Memory::PAGE_MASK;
} }
} // Anonymous namespace } // Anonymous namespace
@ -182,7 +182,7 @@ AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process) {
is_loaded = true; is_loaded = true;
return {ResultStatus::Success, return {ResultStatus::Success,
LoadParameters{Kernel::THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE}}; LoadParameters{Kernel::THREADPRIO_DEFAULT, Core::Memory::DEFAULT_STACK_SIZE}};
} }
ResultStatus AppLoader_NSO::ReadNSOModules(Modules& modules) { ResultStatus AppLoader_NSO::ReadNSOModules(Modules& modules) {

View File

@ -20,7 +20,7 @@
#include "core/memory.h" #include "core/memory.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"
namespace Memory { namespace Core::Memory {
// Implementation class used to keep the specifics of the memory subsystem hidden // Implementation class used to keep the specifics of the memory subsystem hidden
// from outside classes. This also allows modification to the internals of the memory // from outside classes. This also allows modification to the internals of the memory
@ -845,4 +845,4 @@ bool IsKernelVirtualAddress(const VAddr vaddr) {
return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END; return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
} }
} // namespace Memory } // namespace Core::Memory

View File

@ -23,7 +23,7 @@ class PhysicalMemory;
class Process; class Process;
} // namespace Kernel } // namespace Kernel
namespace Memory { namespace Core::Memory {
/** /**
* Page size used by the ARM architecture. This is the smallest granularity with which memory can * Page size used by the ARM architecture. This is the smallest granularity with which memory can
@ -503,4 +503,4 @@ private:
/// Determines if the given VAddr is a kernel address /// Determines if the given VAddr is a kernel address
bool IsKernelVirtualAddress(VAddr vaddr); bool IsKernelVirtualAddress(VAddr vaddr);
} // namespace Memory } // namespace Core::Memory

View File

@ -16,7 +16,7 @@
#include "core/hle/service/sm/sm.h" #include "core/hle/service/sm/sm.h"
#include "core/memory/cheat_engine.h" #include "core/memory/cheat_engine.h"
namespace Memory { namespace Core::Memory {
constexpr s64 CHEAT_ENGINE_TICKS = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 12); constexpr s64 CHEAT_ENGINE_TICKS = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 12);
constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF; constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF;
@ -230,4 +230,4 @@ void CheatEngine::FrameCallback(u64 userdata, s64 cycles_late) {
core_timing.ScheduleEvent(CHEAT_ENGINE_TICKS - cycles_late, event); core_timing.ScheduleEvent(CHEAT_ENGINE_TICKS - cycles_late, event);
} }
} // namespace Memory } // namespace Core::Memory

View File

@ -20,7 +20,7 @@ class CoreTiming;
struct EventType; struct EventType;
} // namespace Core::Timing } // namespace Core::Timing
namespace Memory { namespace Core::Memory {
class StandardVmCallbacks : public DmntCheatVm::Callbacks { class StandardVmCallbacks : public DmntCheatVm::Callbacks {
public: public:
@ -84,4 +84,4 @@ private:
Core::System& system; Core::System& system;
}; };
} // namespace Memory } // namespace Core::Memory

View File

@ -26,7 +26,7 @@
#include "common/common_types.h" #include "common/common_types.h"
namespace Memory { namespace Core::Memory {
struct MemoryRegionExtents { struct MemoryRegionExtents {
u64 base{}; u64 base{};
@ -55,4 +55,4 @@ struct CheatEntry {
CheatDefinition definition{}; CheatDefinition definition{};
}; };
} // namespace Memory } // namespace Core::Memory

View File

@ -27,7 +27,7 @@
#include "core/memory/dmnt_cheat_types.h" #include "core/memory/dmnt_cheat_types.h"
#include "core/memory/dmnt_cheat_vm.h" #include "core/memory/dmnt_cheat_vm.h"
namespace Memory { namespace Core::Memory {
DmntCheatVm::DmntCheatVm(std::unique_ptr<Callbacks> callbacks) : callbacks(std::move(callbacks)) {} DmntCheatVm::DmntCheatVm(std::unique_ptr<Callbacks> callbacks) : callbacks(std::move(callbacks)) {}
@ -1210,4 +1210,4 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
} }
} }
} // namespace Memory } // namespace Core::Memory

View File

@ -30,7 +30,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/memory/dmnt_cheat_types.h" #include "core/memory/dmnt_cheat_types.h"
namespace Memory { namespace Core::Memory {
enum class CheatVmOpcodeType : u32 { enum class CheatVmOpcodeType : u32 {
StoreStatic = 0, StoreStatic = 0,
@ -318,4 +318,4 @@ private:
MemoryAccessType mem_type, u64 rel_address); MemoryAccessType mem_type, u64 rel_address);
}; };
}; // namespace Memory }; // namespace Core::Memory

View File

@ -147,7 +147,7 @@ json GetFullDataAuto(const std::string& timestamp, u64 title_id, Core::System& s
} }
template <bool read_value, typename DescriptorType> template <bool read_value, typename DescriptorType>
json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer, Memory::Memory& memory) { json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer, Core::Memory::Memory& memory) {
auto buffer_out = json::array(); auto buffer_out = json::array();
for (const auto& desc : buffer) { for (const auto& desc : buffer) {
auto entry = json{ auto entry = json{
@ -167,7 +167,7 @@ json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer, Memor
return buffer_out; return buffer_out;
} }
json GetHLERequestContextData(Kernel::HLERequestContext& ctx, Memory::Memory& memory) { json GetHLERequestContextData(Kernel::HLERequestContext& ctx, Core::Memory::Memory& memory) {
json out; json out;
auto cmd_buf = json::array(); auto cmd_buf = json::array();

View File

@ -16,7 +16,7 @@ namespace {
constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 60); constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Hardware::BASE_CLOCK_RATE / 60);
u64 MemoryReadWidth(Memory::Memory& memory, u32 width, VAddr addr) { u64 MemoryReadWidth(Core::Memory::Memory& memory, u32 width, VAddr addr) {
switch (width) { switch (width) {
case 1: case 1:
return memory.Read8(addr); return memory.Read8(addr);
@ -32,7 +32,7 @@ u64 MemoryReadWidth(Memory::Memory& memory, u32 width, VAddr addr) {
} }
} }
void MemoryWriteWidth(Memory::Memory& memory, u32 width, VAddr addr, u64 value) { void MemoryWriteWidth(Core::Memory::Memory& memory, u32 width, VAddr addr, u64 value) {
switch (width) { switch (width) {
case 1: case 1:
memory.Write8(addr, static_cast<u8>(value)); memory.Write8(addr, static_cast<u8>(value));
@ -53,7 +53,7 @@ void MemoryWriteWidth(Memory::Memory& memory, u32 width, VAddr addr, u64 value)
} // Anonymous namespace } // Anonymous namespace
Freezer::Freezer(Core::Timing::CoreTiming& core_timing_, Memory::Memory& memory_) Freezer::Freezer(Core::Timing::CoreTiming& core_timing_, Core::Memory::Memory& memory_)
: core_timing{core_timing_}, memory{memory_} { : core_timing{core_timing_}, memory{memory_} {
event = Core::Timing::CreateEvent( event = Core::Timing::CreateEvent(
"MemoryFreezer::FrameCallback", "MemoryFreezer::FrameCallback",

View File

@ -16,7 +16,7 @@ class CoreTiming;
struct EventType; struct EventType;
} // namespace Core::Timing } // namespace Core::Timing
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -38,7 +38,7 @@ public:
u64 value; u64 value;
}; };
explicit Freezer(Core::Timing::CoreTiming& core_timing_, Memory::Memory& memory_); explicit Freezer(Core::Timing::CoreTiming& core_timing_, Core::Memory::Memory& memory_);
~Freezer(); ~Freezer();
// Enables or disables the entire memory freezer. // Enables or disables the entire memory freezer.
@ -82,7 +82,7 @@ private:
std::shared_ptr<Core::Timing::EventType> event; std::shared_ptr<Core::Timing::EventType> event;
Core::Timing::CoreTiming& core_timing; Core::Timing::CoreTiming& core_timing;
Memory::Memory& memory; Core::Memory::Memory& memory;
}; };
} // namespace Tools } // namespace Tools

View File

@ -23,15 +23,15 @@ constexpr auto RangeFromInterval(Map& map, const Interval& interval) {
} // Anonymous namespace } // Anonymous namespace
RasterizerAccelerated::RasterizerAccelerated(Memory::Memory& cpu_memory_) RasterizerAccelerated::RasterizerAccelerated(Core::Memory::Memory& cpu_memory_)
: cpu_memory{cpu_memory_} {} : cpu_memory{cpu_memory_} {}
RasterizerAccelerated::~RasterizerAccelerated() = default; RasterizerAccelerated::~RasterizerAccelerated() = default;
void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {
std::lock_guard lock{pages_mutex}; std::lock_guard lock{pages_mutex};
const u64 page_start{addr >> Memory::PAGE_BITS}; const u64 page_start{addr >> Core::Memory::PAGE_BITS};
const u64 page_end{(addr + size + Memory::PAGE_SIZE - 1) >> Memory::PAGE_BITS}; const u64 page_end{(addr + size + Core::Memory::PAGE_SIZE - 1) >> Core::Memory::PAGE_BITS};
// Interval maps will erase segments if count reaches 0, so if delta is negative we have to // Interval maps will erase segments if count reaches 0, so if delta is negative we have to
// subtract after iterating // subtract after iterating
@ -44,8 +44,8 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del
const auto interval = pair.first & pages_interval; const auto interval = pair.first & pages_interval;
const int count = pair.second; const int count = pair.second;
const VAddr interval_start_addr = boost::icl::first(interval) << Memory::PAGE_BITS; const VAddr interval_start_addr = boost::icl::first(interval) << Core::Memory::PAGE_BITS;
const VAddr interval_end_addr = boost::icl::last_next(interval) << Memory::PAGE_BITS; const VAddr interval_end_addr = boost::icl::last_next(interval) << Core::Memory::PAGE_BITS;
const u64 interval_size = interval_end_addr - interval_start_addr; const u64 interval_size = interval_end_addr - interval_start_addr;
if (delta > 0 && count == delta) { if (delta > 0 && count == delta) {

View File

@ -11,7 +11,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "video_core/rasterizer_interface.h" #include "video_core/rasterizer_interface.h"
namespace Memory { namespace Core::Memory {
class Memory; class Memory;
} }
@ -20,7 +20,7 @@ namespace VideoCore {
/// Implements the shared part in GPU accelerated rasterizers in RasterizerInterface. /// Implements the shared part in GPU accelerated rasterizers in RasterizerInterface.
class RasterizerAccelerated : public RasterizerInterface { class RasterizerAccelerated : public RasterizerInterface {
public: public:
explicit RasterizerAccelerated(Memory::Memory& cpu_memory_); explicit RasterizerAccelerated(Core::Memory::Memory& cpu_memory_);
~RasterizerAccelerated() override; ~RasterizerAccelerated() override;
void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) override; void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) override;
@ -30,7 +30,7 @@ private:
CachedPageMap cached_pages; CachedPageMap cached_pages;
std::mutex pages_mutex; std::mutex pages_mutex;
Memory::Memory& cpu_memory; Core::Memory::Memory& cpu_memory;
}; };
} // namespace VideoCore } // namespace VideoCore