ReXGlue SDK
Loading...
Searching...
No Matches
rex::kernel::WorkspaceHeap Class Reference

#include <rex/kernel/guest_allocator.h>

Inheritance diagram for rex::kernel::WorkspaceHeap:
[legend]

Public Member Functions

 WorkspaceHeap (Key, GuestAddressSpace &memory, u32 base, u32 size)
u32 GetSize () const
u32 GetAllocated () const
Result< u32 > Allocate (u32 size, bool zero) override
void Free (u32 address) override

Static Public Member Functions

static Result< std::unique_ptr< WorkspaceHeap > > Create (GuestAddressSpace &memory, u32 size)
static u32 ResolveSize (u32 header_size)

Additional Inherited Members

Protected Member Functions inherited from rex::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete

Detailed Description

The title workspace, title memory the system uses on the title's behalf. Blocks are sized to the request and rounded to 16 bytes, so a freed block can be taken again by a request of its size.

Constructor & Destructor Documentation

◆ WorkspaceHeap()

rex::kernel::WorkspaceHeap::WorkspaceHeap ( Key ,
GuestAddressSpace & memory,
u32 base,
u32 size )

Wraps a committed range. Only Create can make the key.

Member Function Documentation

◆ Allocate()

Result< u32 > rex::kernel::WorkspaceHeap::Allocate ( u32 size,
bool zero )
nodiscardoverridevirtual

Allocates bytes from the workspace.

Parameters
zeroTrue to zero the bytes.
Returns
The guest address, or an error when the workspace is exhausted.

Implements rex::kernel::ITitleWorkspace.

◆ Create()

Result< std::unique_ptr< WorkspaceHeap > > rex::kernel::WorkspaceHeap::Create ( GuestAddressSpace & memory,
u32 size )
staticnodiscard

Reserves and commits the workspace range.

Returns
An error when the memory cannot be committed.

◆ Free()

void rex::kernel::WorkspaceHeap::Free ( u32 address)
overridevirtual

Frees an address from Allocate. An address outside the workspace, or one that is not a live block, is logged and ignored.

Parameters
addressThe guest address, 0 for none.

Implements rex::kernel::ITitleWorkspace.

◆ GetAllocated()

u32 rex::kernel::WorkspaceHeap::GetAllocated ( ) const
nodiscard

Returns the bytes held by live blocks.

◆ ResolveSize()

u32 rex::kernel::WorkspaceHeap::ResolveSize ( u32 header_size)
staticnodiscard

Resolves the workspace size of a title.

Parameters
header_sizeThe XEX workspace size, 0 when the header is missing.

The documentation for this class was generated from the following file: