diff options
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 102 |
1 files changed, 3 insertions, 99 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index c91eeced9..b5721b740 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -39,11 +39,6 @@ enum : VAddr { | |||
| 39 | 39 | ||
| 40 | /// Application stack | 40 | /// Application stack |
| 41 | DEFAULT_STACK_SIZE = 0x100000, | 41 | DEFAULT_STACK_SIZE = 0x100000, |
| 42 | |||
| 43 | /// Kernel Virtual Address Range | ||
| 44 | KERNEL_REGION_VADDR = 0xFFFFFF8000000000, | ||
| 45 | KERNEL_REGION_SIZE = 0x7FFFE00000, | ||
| 46 | KERNEL_REGION_END = KERNEL_REGION_VADDR + KERNEL_REGION_SIZE, | ||
| 47 | }; | 42 | }; |
| 48 | 43 | ||
| 49 | /// Central class that handles all memory operations and state. | 44 | /// Central class that handles all memory operations and state. |
| @@ -56,7 +51,7 @@ public: | |||
| 56 | Memory& operator=(const Memory&) = delete; | 51 | Memory& operator=(const Memory&) = delete; |
| 57 | 52 | ||
| 58 | Memory(Memory&&) = default; | 53 | Memory(Memory&&) = default; |
| 59 | Memory& operator=(Memory&&) = default; | 54 | Memory& operator=(Memory&&) = delete; |
| 60 | 55 | ||
| 61 | /** | 56 | /** |
| 62 | * Resets the state of the Memory system. | 57 | * Resets the state of the Memory system. |
| @@ -92,24 +87,13 @@ public: | |||
| 92 | 87 | ||
| 93 | /** | 88 | /** |
| 94 | * Checks whether or not the supplied address is a valid virtual | 89 | * Checks whether or not the supplied address is a valid virtual |
| 95 | * address for the given process. | ||
| 96 | * | ||
| 97 | * @param process The emulated process to check the address against. | ||
| 98 | * @param vaddr The virtual address to check the validity of. | ||
| 99 | * | ||
| 100 | * @returns True if the given virtual address is valid, false otherwise. | ||
| 101 | */ | ||
| 102 | bool IsValidVirtualAddress(const Kernel::KProcess& process, VAddr vaddr) const; | ||
| 103 | |||
| 104 | /** | ||
| 105 | * Checks whether or not the supplied address is a valid virtual | ||
| 106 | * address for the current process. | 90 | * address for the current process. |
| 107 | * | 91 | * |
| 108 | * @param vaddr The virtual address to check the validity of. | 92 | * @param vaddr The virtual address to check the validity of. |
| 109 | * | 93 | * |
| 110 | * @returns True if the given virtual address is valid, false otherwise. | 94 | * @returns True if the given virtual address is valid, false otherwise. |
| 111 | */ | 95 | */ |
| 112 | bool IsValidVirtualAddress(VAddr vaddr) const; | 96 | [[nodiscard]] bool IsValidVirtualAddress(VAddr vaddr) const; |
| 113 | 97 | ||
| 114 | /** | 98 | /** |
| 115 | * Gets a pointer to the given address. | 99 | * Gets a pointer to the given address. |
| @@ -134,7 +118,7 @@ public: | |||
| 134 | * @returns The pointer to the given address, if the address is valid. | 118 | * @returns The pointer to the given address, if the address is valid. |
| 135 | * If the address is not valid, nullptr will be returned. | 119 | * If the address is not valid, nullptr will be returned. |
| 136 | */ | 120 | */ |
| 137 | const u8* GetPointer(VAddr vaddr) const; | 121 | [[nodiscard]] const u8* GetPointer(VAddr vaddr) const; |
| 138 | 122 | ||
| 139 | template <typename T> | 123 | template <typename T> |
| 140 | const T* GetPointer(VAddr vaddr) const { | 124 | const T* GetPointer(VAddr vaddr) const { |
| @@ -328,27 +312,6 @@ public: | |||
| 328 | std::size_t size); | 312 | std::size_t size); |
| 329 | 313 | ||
| 330 | /** | 314 | /** |
| 331 | * Reads a contiguous block of bytes from a specified process' address space. | ||
| 332 | * This unsafe version does not trigger GPU flushing. | ||
| 333 | * | ||
| 334 | * @param process The process to read the data from. | ||
| 335 | * @param src_addr The virtual address to begin reading from. | ||
| 336 | * @param dest_buffer The buffer to place the read bytes into. | ||
| 337 | * @param size The amount of data to read, in bytes. | ||
| 338 | * | ||
| 339 | * @note If a size of 0 is specified, then this function reads nothing and | ||
| 340 | * no attempts to access memory are made at all. | ||
| 341 | * | ||
| 342 | * @pre dest_buffer must be at least size bytes in length, otherwise a | ||
| 343 | * buffer overrun will occur. | ||
| 344 | * | ||
| 345 | * @post The range [dest_buffer, size) contains the read bytes from the | ||
| 346 | * process' address space. | ||
| 347 | */ | ||
| 348 | void ReadBlockUnsafe(const Kernel::KProcess& process, VAddr src_addr, void* dest_buffer, | ||
| 349 | std::size_t size); | ||
| 350 | |||
| 351 | /** | ||
| 352 | * Reads a contiguous block of bytes from the current process' address space. | 315 | * Reads a contiguous block of bytes from the current process' address space. |
| 353 | * | 316 | * |
| 354 | * @param src_addr The virtual address to begin reading from. | 317 | * @param src_addr The virtual address to begin reading from. |
| @@ -409,26 +372,6 @@ public: | |||
| 409 | std::size_t size); | 372 | std::size_t size); |
| 410 | 373 | ||
| 411 | /** | 374 | /** |
| 412 | * Writes a range of bytes into a given process' address space at the specified | ||
| 413 | * virtual address. | ||
| 414 | * This unsafe version does not invalidate GPU Memory. | ||
| 415 | * | ||
| 416 | * @param process The process to write data into the address space of. | ||
| 417 | * @param dest_addr The destination virtual address to begin writing the data at. | ||
| 418 | * @param src_buffer The data to write into the process' address space. | ||
| 419 | * @param size The size of the data to write, in bytes. | ||
| 420 | * | ||
| 421 | * @post The address range [dest_addr, size) in the process' address space | ||
| 422 | * contains the data that was within src_buffer. | ||
| 423 | * | ||
| 424 | * @post If an attempt is made to write into an unmapped region of memory, the writes | ||
| 425 | * will be ignored and an error will be logged. | ||
| 426 | * | ||
| 427 | */ | ||
| 428 | void WriteBlockUnsafe(const Kernel::KProcess& process, VAddr dest_addr, const void* src_buffer, | ||
| 429 | std::size_t size); | ||
| 430 | |||
| 431 | /** | ||
| 432 | * Writes a range of bytes into the current process' address space at the specified | 375 | * Writes a range of bytes into the current process' address space at the specified |
| 433 | * virtual address. | 376 | * virtual address. |
| 434 | * | 377 | * |
| @@ -468,29 +411,6 @@ public: | |||
| 468 | void WriteBlockUnsafe(VAddr dest_addr, const void* src_buffer, std::size_t size); | 411 | void WriteBlockUnsafe(VAddr dest_addr, const void* src_buffer, std::size_t size); |
| 469 | 412 | ||
| 470 | /** | 413 | /** |
| 471 | * Fills the specified address range within a process' address space with zeroes. | ||
| 472 | * | ||
| 473 | * @param process The process that will have a portion of its memory zeroed out. | ||
| 474 | * @param dest_addr The starting virtual address of the range to zero out. | ||
| 475 | * @param size The size of the address range to zero out, in bytes. | ||
| 476 | * | ||
| 477 | * @post The range [dest_addr, size) within the process' address space is | ||
| 478 | * filled with zeroes. | ||
| 479 | */ | ||
| 480 | void ZeroBlock(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size); | ||
| 481 | |||
| 482 | /** | ||
| 483 | * Fills the specified address range within the current process' address space with zeroes. | ||
| 484 | * | ||
| 485 | * @param dest_addr The starting virtual address of the range to zero out. | ||
| 486 | * @param size The size of the address range to zero out, in bytes. | ||
| 487 | * | ||
| 488 | * @post The range [dest_addr, size) within the current process' address space is | ||
| 489 | * filled with zeroes. | ||
| 490 | */ | ||
| 491 | void ZeroBlock(VAddr dest_addr, std::size_t size); | ||
| 492 | |||
| 493 | /** | ||
| 494 | * Copies data within a process' address space to another location within the | 414 | * Copies data within a process' address space to another location within the |
| 495 | * same address space. | 415 | * same address space. |
| 496 | * | 416 | * |
| @@ -506,19 +426,6 @@ public: | |||
| 506 | std::size_t size); | 426 | std::size_t size); |
| 507 | 427 | ||
| 508 | /** | 428 | /** |
| 509 | * Copies data within the current process' address space to another location within the | ||
| 510 | * same address space. | ||
| 511 | * | ||
| 512 | * @param dest_addr The destination virtual address to begin copying the data into. | ||
| 513 | * @param src_addr The source virtual address to begin copying the data from. | ||
| 514 | * @param size The size of the data to copy, in bytes. | ||
| 515 | * | ||
| 516 | * @post The range [dest_addr, size) within the current process' address space | ||
| 517 | * contains the same data within the range [src_addr, size). | ||
| 518 | */ | ||
| 519 | void CopyBlock(VAddr dest_addr, VAddr src_addr, std::size_t size); | ||
| 520 | |||
| 521 | /** | ||
| 522 | * Marks each page within the specified address range as cached or uncached. | 429 | * Marks each page within the specified address range as cached or uncached. |
| 523 | * | 430 | * |
| 524 | * @param vaddr The virtual address indicating the start of the address range. | 431 | * @param vaddr The virtual address indicating the start of the address range. |
| @@ -535,7 +442,4 @@ private: | |||
| 535 | std::unique_ptr<Impl> impl; | 442 | std::unique_ptr<Impl> impl; |
| 536 | }; | 443 | }; |
| 537 | 444 | ||
| 538 | /// Determines if the given VAddr is a kernel address | ||
| 539 | bool IsKernelVirtualAddress(VAddr vaddr); | ||
| 540 | |||
| 541 | } // namespace Core::Memory | 445 | } // namespace Core::Memory |