summaryrefslogtreecommitdiff
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;
19 19
20namespace Kernel { 20namespace Kernel {
21class PhysicalMemory; 21class PhysicalMemory;
22class Process; 22class KProcess;
23} // namespace Kernel 23} // namespace Kernel
24 24
25namespace Core::Memory { 25namespace Core::Memory {
@@ -59,11 +59,16 @@ public:
59 Memory& operator=(Memory&&) = default; 59 Memory& operator=(Memory&&) = default;
60 60
61 /** 61 /**
62 * Resets the state of the Memory system.
63 */
64 void Reset();
65
66 /**
62 * Changes the currently active page table to that of the given process instance. 67 * Changes the currently active page table to that of the given process instance.
63 * 68 *
64 * @param process The process to use the page table of. 69 * @param process The process to use the page table of.
65 */ 70 */
66 void SetCurrentPageTable(Kernel::Process& process, u32 core_id); 71 void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id);
67 72
68 /** 73 /**
69 * Maps an allocated buffer onto a region of the emulated process address space. 74 * Maps an allocated buffer onto a region of the emulated process address space.
@@ -94,7 +99,7 @@ public:
94 * 99 *
95 * @returns True if the given virtual address is valid, false otherwise. 100 * @returns True if the given virtual address is valid, false otherwise.
96 */ 101 */
97 bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr) const; 102 bool IsValidVirtualAddress(const Kernel::KProcess& process, VAddr vaddr) const;
98 103
99 /** 104 /**
100 * Checks whether or not the supplied address is a valid virtual 105 * Checks whether or not the supplied address is a valid virtual
@@ -116,6 +121,15 @@ public:
116 */ 121 */
117 u8* GetPointer(VAddr vaddr); 122 u8* GetPointer(VAddr vaddr);
118 123
124 /**
125 * Gets a pointer to the start of a kernel heap allocated memory region. Will allocate one if it
126 * does not already exist.
127 *
128 * @param start_vaddr Start virtual address for the memory region.
129 * @param size Size of the memory region.
130 */
131 u8* GetKernelBuffer(VAddr start_vaddr, size_t size);
132
119 template <typename T> 133 template <typename T>
120 T* GetPointer(VAddr vaddr) { 134 T* GetPointer(VAddr vaddr) {
121 return reinterpret_cast<T*>(GetPointer(vaddr)); 135 return reinterpret_cast<T*>(GetPointer(vaddr));
@@ -319,7 +333,7 @@ public:
319 * @post The range [dest_buffer, size) contains the read bytes from the 333 * @post The range [dest_buffer, size) contains the read bytes from the
320 * process' address space. 334 * process' address space.
321 */ 335 */
322 void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, 336 void ReadBlock(const Kernel::KProcess& process, VAddr src_addr, void* dest_buffer,
323 std::size_t size); 337 std::size_t size);
324 338
325 /** 339 /**
@@ -340,7 +354,7 @@ public:
340 * @post The range [dest_buffer, size) contains the read bytes from the 354 * @post The range [dest_buffer, size) contains the read bytes from the
341 * process' address space. 355 * process' address space.
342 */ 356 */
343 void ReadBlockUnsafe(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, 357 void ReadBlockUnsafe(const Kernel::KProcess& process, VAddr src_addr, void* dest_buffer,
344 std::size_t size); 358 std::size_t size);
345 359
346 /** 360 /**
@@ -400,7 +414,7 @@ public:
400 * and will mark that region as invalidated to caches that the active 414 * and will mark that region as invalidated to caches that the active
401 * graphics backend may be maintaining over the course of execution. 415 * graphics backend may be maintaining over the course of execution.
402 */ 416 */
403 void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, 417 void WriteBlock(const Kernel::KProcess& process, VAddr dest_addr, const void* src_buffer,
404 std::size_t size); 418 std::size_t size);
405 419
406 /** 420 /**
@@ -420,7 +434,7 @@ public:
420 * will be ignored and an error will be logged. 434 * will be ignored and an error will be logged.
421 * 435 *
422 */ 436 */
423 void WriteBlockUnsafe(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, 437 void WriteBlockUnsafe(const Kernel::KProcess& process, VAddr dest_addr, const void* src_buffer,
424 std::size_t size); 438 std::size_t size);
425 439
426 /** 440 /**
@@ -472,7 +486,7 @@ public:
472 * @post The range [dest_addr, size) within the process' address space is 486 * @post The range [dest_addr, size) within the process' address space is
473 * filled with zeroes. 487 * filled with zeroes.
474 */ 488 */
475 void ZeroBlock(const Kernel::Process& process, VAddr dest_addr, std::size_t size); 489 void ZeroBlock(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size);
476 490
477 /** 491 /**
478 * Fills the specified address range within the current process' address space with zeroes. 492 * Fills the specified address range within the current process' address space with zeroes.
@@ -497,7 +511,7 @@ public:
497 * @post The range [dest_addr, size) within the process' address space contains the 511 * @post The range [dest_addr, size) within the process' address space contains the
498 * same data within the range [src_addr, size). 512 * same data within the range [src_addr, size).
499 */ 513 */
500 void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, 514 void CopyBlock(const Kernel::KProcess& process, VAddr dest_addr, VAddr src_addr,
501 std::size_t size); 515 std::size_t size);
502 516
503 /** 517 /**
@@ -524,6 +538,8 @@ public:
524 void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached); 538 void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached);
525 539
526private: 540private:
541 Core::System& system;
542
527 struct Impl; 543 struct Impl;
528 std::unique_ptr<Impl> impl; 544 std::unique_ptr<Impl> impl;
529}; 545};