summaryrefslogtreecommitdiffstats
path: root/src/core/memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/memory.h')
-rw-r--r--src/core/memory.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/core/memory.h b/src/core/memory.h
index 6d34fcfe2..345fd870d 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -19,7 +19,7 @@ class System;
namespace Kernel {
class PhysicalMemory;
-class Process;
+class KProcess;
} // namespace Kernel
namespace Core::Memory {
@@ -59,11 +59,16 @@ public:
Memory& operator=(Memory&&) = default;
/**
+ * Resets the state of the Memory system.
+ */
+ void Reset();
+
+ /**
* Changes the currently active page table to that of the given process instance.
*
* @param process The process to use the page table of.
*/
- void SetCurrentPageTable(Kernel::Process& process, u32 core_id);
+ void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id);
/**
* Maps an allocated buffer onto a region of the emulated process address space.
@@ -94,7 +99,7 @@ public:
*
* @returns True if the given virtual address is valid, false otherwise.
*/
- bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr) const;
+ bool IsValidVirtualAddress(const Kernel::KProcess& process, VAddr vaddr) const;
/**
* Checks whether or not the supplied address is a valid virtual
@@ -116,6 +121,15 @@ public:
*/
u8* GetPointer(VAddr vaddr);
+ /**
+ * Gets a pointer to the start of a kernel heap allocated memory region. Will allocate one if it
+ * does not already exist.
+ *
+ * @param start_vaddr Start virtual address for the memory region.
+ * @param size Size of the memory region.
+ */
+ u8* GetKernelBuffer(VAddr start_vaddr, size_t size);
+
template <typename T>
T* GetPointer(VAddr vaddr) {
return reinterpret_cast<T*>(GetPointer(vaddr));
@@ -319,7 +333,7 @@ public:
* @post The range [dest_buffer, size) contains the read bytes from the
* process' address space.
*/
- void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer,
+ void ReadBlock(const Kernel::KProcess& process, VAddr src_addr, void* dest_buffer,
std::size_t size);
/**
@@ -340,7 +354,7 @@ public:
* @post The range [dest_buffer, size) contains the read bytes from the
* process' address space.
*/
- void ReadBlockUnsafe(const Kernel::Process& process, VAddr src_addr, void* dest_buffer,
+ void ReadBlockUnsafe(const Kernel::KProcess& process, VAddr src_addr, void* dest_buffer,
std::size_t size);
/**
@@ -400,7 +414,7 @@ public:
* and will mark that region as invalidated to caches that the active
* graphics backend may be maintaining over the course of execution.
*/
- void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer,
+ void WriteBlock(const Kernel::KProcess& process, VAddr dest_addr, const void* src_buffer,
std::size_t size);
/**
@@ -420,7 +434,7 @@ public:
* will be ignored and an error will be logged.
*
*/
- void WriteBlockUnsafe(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer,
+ void WriteBlockUnsafe(const Kernel::KProcess& process, VAddr dest_addr, const void* src_buffer,
std::size_t size);
/**
@@ -472,7 +486,7 @@ public:
* @post The range [dest_addr, size) within the process' address space is
* filled with zeroes.
*/
- void ZeroBlock(const Kernel::Process& process, VAddr dest_addr, std::size_t size);
+ void ZeroBlock(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size);
/**
* Fills the specified address range within the current process' address space with zeroes.
@@ -497,7 +511,7 @@ public:
* @post The range [dest_addr, size) within the process' address space contains the
* same data within the range [src_addr, size).
*/
- void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr,
+ void CopyBlock(const Kernel::KProcess& process, VAddr dest_addr, VAddr src_addr,
std::size_t size);
/**
@@ -524,6 +538,8 @@ public:
void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached);
private:
+ Core::System& system;
+
struct Impl;
std::unique_ptr<Impl> impl;
};