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

@ -47,7 +47,8 @@ ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kern
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.
if (!parent->Server()) {
return ERR_SESSION_CLOSED_BY_REMOTE;

View file

@ -12,7 +12,7 @@
union ResultCode;
namespace Memory {
namespace Core::Memory {
class Memory;
}
@ -42,7 +42,7 @@ public:
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;

View file

@ -59,7 +59,8 @@ void SetupMainThread(Process& owner_process, KernelCore& kernel, u32 priority) {
// (whichever page happens to have an available slot).
class TLSPage {
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} {}
@ -78,7 +79,7 @@ public:
}
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;
@ -88,15 +89,15 @@ public:
// Ensure that all given addresses are consistent with how TLS pages
// are intended to be used when releasing slots.
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;
}
private:
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;
@ -306,7 +307,7 @@ VAddr Process::CreateTLSRegion() {
}
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 =
std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) {
return page.GetBaseAddress() == aligned_address;

View file

@ -134,7 +134,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con
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()))};
std::shared_ptr<Kernel::HLERequestContext> context{
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,
Memory::Memory& memory) {
Core::Memory::Memory& memory) {
Core::System::GetInstance().CoreTiming().ScheduleEvent(20000, request_event, {});
return QueueSyncRequest(std::move(thread), memory);
}

View file

@ -13,7 +13,7 @@
#include "core/hle/kernel/synchronization_object.h"
#include "core/hle/result.h"
namespace Memory {
namespace Core::Memory {
class Memory;
}
@ -92,7 +92,7 @@ public:
*
* @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;
@ -126,7 +126,7 @@ public:
private:
/// 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.
ResultCode CompleteSyncRequest();

View file

@ -539,7 +539,7 @@ static ResultCode ArbitrateLock(Core::System& system, Handle holding_thread_hand
"requesting_current_thread_handle=0x{:08X}",
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}",
mutex_addr);
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) {
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}",
mutex_addr);
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={}",
mutex_addr, condition_variable_addr, thread_handle, nano_seconds);
if (Memory::IsKernelVirtualAddress(mutex_addr)) {
if (Core::Memory::IsKernelVirtualAddress(mutex_addr)) {
LOG_ERROR(
Kernel_SVC,
"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);
// 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);
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);
// 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);
return ERR_INVALID_ADDRESS_STATE;
}

View file

@ -12,7 +12,7 @@
namespace Kernel {
TransferMemory::TransferMemory(KernelCore& kernel, Memory::Memory& memory)
TransferMemory::TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory)
: Object{kernel}, memory{memory} {}
TransferMemory::~TransferMemory() {
@ -20,7 +20,8 @@ TransferMemory::~TransferMemory() {
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,
MemoryPermission permissions) {
std::shared_ptr<TransferMemory> transfer_memory{

View file

@ -11,7 +11,7 @@
union ResultCode;
namespace Memory {
namespace Core::Memory {
class Memory;
}
@ -30,12 +30,12 @@ enum class MemoryPermission : u32;
///
class TransferMemory final : public Object {
public:
explicit TransferMemory(KernelCore& kernel, Memory::Memory& memory);
explicit TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory);
~TransferMemory() override;
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,
MemoryPermission permissions);
@ -112,7 +112,7 @@ private:
/// Whether or not this transfer memory instance has mapped memory.
bool is_mapped = false;
Memory::Memory& memory;
Core::Memory::Memory& memory;
};
} // namespace Kernel

View file

@ -210,7 +210,7 @@ private:
/// This is the event handle used to check if the audio buffer was released
Kernel::EventPair buffer_event;
Memory::Memory& main_memory;
Core::Memory::Memory& main_memory;
};
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> {
public:
explicit ILogger(Manager& manager_, Memory::Memory& memory_)
explicit ILogger(Manager& manager_, Core::Memory::Memory& memory_)
: ServiceFramework("ILogger"), manager{manager_}, memory{memory_} {
static const FunctionInfo functions[] = {
{0, &ILogger::Log, "Log"},
@ -75,12 +75,12 @@ private:
}
Manager& manager;
Memory::Memory& memory;
Core::Memory::Memory& memory;
};
class LM final : public ServiceFramework<LM> {
public:
explicit LM(Manager& manager_, Memory::Memory& memory_)
explicit LM(Manager& manager_, Core::Memory::Memory& memory_)
: ServiceFramework{"lm"}, manager{manager_}, memory{memory_} {
// clang-format off
static const FunctionInfo functions[] = {
@ -101,7 +101,7 @@ private:
}
Manager& manager;
Memory::Memory& memory;
Core::Memory::Memory& memory;
};
void InstallInterfaces(Core::System& system) {