#include <rex/kernel/guest_memory.h>
|
|
| GuestMemory (const GuestMemory &)=delete |
|
GuestMemory & | operator= (const GuestMemory &)=delete |
| Result< void > | CopyFrom (u32 address, std::span< std::byte > out) const |
| Result< void > | CopyTo (u32 address, std::span< const std::byte > data) |
| Result< std::span< const std::byte > > | GetReadOnlySpan (u32 address, u32 length) const |
| Result< std::span< std::byte > > | GetWritableSpan (u32 address, u32 length) |
template<typename T>
requires std::is_trivially_copyable_v<T> |
| Result< T > | Load (u32 address) const |
template<typename T>
requires std::is_trivially_copyable_v<T> |
| Result< void > | Store (u32 address, const T &value) |
| Result< std::string > | ReadString (u32 address, u32 max_length=4096) const |
| Result< std::u16string > | ReadString16 (u32 address, u32 max_length=4096) const |
| Result< u32 > | Allocate (u32 size, u32 alignment, GuestProtect protect, GuestHeap heap=GuestHeap::kTitle) |
| Result< void > | Free (u32 address) |
| Result< void > | Protect (u32 address, u32 length, GuestProtect protect) |
| kernel::MemoryView | GetView () const |
| Result< u32 > | HostToGuest (const void *host) const |
|
|
class | TitleRuntime |
|
class | kernel::GuestAllocator |
|
class | kernel::TitleState |
Checked guest virtual memory, used by everything except recompiled code. A call whose range is not mapped with the needed access returns a kMemory error and changes nothing. Spans stay valid until TitleRuntime::Unload.
◆ Allocate()
Allocates guest memory.
- Parameters
-
| size | The size in bytes. |
| alignment | A power of two, at least 4096 for title memory. |
| heap | The heap, title memory by default. Physical is the 64 KiB window at 0xA0000000. |
- Returns
- The address, or a kMemory error.
◆ CopyFrom()
| Result< void > rex::kernel::GuestMemory::CopyFrom |
( |
u32 | address, |
|
|
std::span< std::byte > | out ) const |
|
nodiscard |
Copies guest memory into a buffer.
- Parameters
-
| out | The buffer to fill. Its size is the length. |
- Returns
- Ok, or a kMemory error.
◆ CopyTo()
| Result< void > rex::kernel::GuestMemory::CopyTo |
( |
u32 | address, |
|
|
std::span< const std::byte > | data ) |
|
nodiscard |
Copies bytes into guest memory.
- Parameters
-
- Returns
- Ok, or a kMemory error when any byte is not mapped writable.
◆ Free()
| Result< void > rex::kernel::GuestMemory::Free |
( |
u32 | address | ) |
|
|
nodiscard |
Frees memory from Allocate, from either heap.
- Parameters
-
| address | The address Allocate returned. |
- Returns
- Ok, or a kMemory error.
◆ GetReadOnlySpan()
| Result< std::span< const std::byte > > rex::kernel::GuestMemory::GetReadOnlySpan |
( |
u32 | address, |
|
|
u32 | length ) const |
|
nodiscard |
Returns guest memory to read in place, or a kMemory error.
◆ GetView()
◆ GetWritableSpan()
| Result< std::span< std::byte > > rex::kernel::GuestMemory::GetWritableSpan |
( |
u32 | address, |
|
|
u32 | length ) |
|
nodiscard |
Returns guest memory to write in place, or a kMemory error when any byte is not mapped writable.
◆ HostToGuest()
| Result< u32 > rex::kernel::GuestMemory::HostToGuest |
( |
const void * | host | ) |
const |
|
nodiscard |
Translates a host pointer inside guest memory to its guest address.
- Parameters
-
| host | A pointer, such as the data of a span from GetWritableSpan. |
- Returns
- The guest address, or a kMemory error when the pointer is outside guest memory.
◆ Load()
template<typename T>
requires std::is_trivially_copyable_v<T>
| Result< T > rex::kernel::GuestMemory::Load |
( |
u32 | address | ) |
const |
|
nodiscard |
Reads a guest value.
- Template Parameters
-
| T | A trivially copyable guest type, such as be_u32 or a struct of be_ fields. |
- Returns
- A copy, or a kMemory error.
Reads a guest value.
- Returns
- A copy, or a kMemory error.
◆ Protect()
| Result< void > rex::kernel::GuestMemory::Protect |
( |
u32 | address, |
|
|
u32 | length, |
|
|
GuestProtect | protect ) |
|
nodiscard |
Changes the access of mapped pages. The range covers every page from the one holding the first byte to the one holding the last.
- Returns
- Ok, or a kMemory error when any page is not mapped.
◆ ReadString()
| Result< std::string > rex::kernel::GuestMemory::ReadString |
( |
u32 | address, |
|
|
u32 | max_length = 4096 ) const |
|
nodiscard |
Reads a zero terminated 8 bit string.
- Parameters
-
| max_length | The character limit when no terminator comes first. |
- Returns
- The string, or a kMemory error.
◆ ReadString16()
| Result< std::u16string > rex::kernel::GuestMemory::ReadString16 |
( |
u32 | address, |
|
|
u32 | max_length = 4096 ) const |
|
nodiscard |
Reads a zero terminated big endian UTF-16 string.
- Parameters
-
| max_length | The character limit when no terminator comes first. |
- Returns
- The string in host byte order, or a kMemory error.
◆ Store()
template<typename T>
requires std::is_trivially_copyable_v<T>
| Result< void > rex::kernel::GuestMemory::Store |
( |
u32 | address, |
|
|
const T & | value ) |
|
nodiscard |
Writes a guest value.
- Template Parameters
-
| T | A trivially copyable guest type, such as be_u32 or a struct of be_ fields. |
- Returns
- Ok, or a kMemory error.
Writes a guest value.
- Returns
- Ok, or a kMemory error.
The documentation for this class was generated from the following file: