class MemoryAllocator

Defined at line 25 of file ../../src/sysmem/server/memory_allocator.h

Public Members

map destroy_callbacks_

Public Methods

void MemoryAllocator (fuchsia_hardware_sysmem::HeapProperties properties)

Defined at line 14 of file ../../src/sysmem/server/memory_allocator.cc

void ~MemoryAllocator ()

Defined at line 20 of file ../../src/sysmem/server/memory_allocator.cc

zx_status_t Allocate (uint64_t size, const fuchsia_sysmem2::SingleBufferSettings & settings, std::optional<std::string> name, uint64_t buffer_collection_id, uint32_t buffer_index, zx::vmo * parent_vmo)

size - the needed size in bytes, rounded up to a page boundaryß

settings - allocators may observe settings if needed, but are discouraged from looking at

settings unless really needed; settings.buffer_settings.size_bytes is the logical size in bytes

not rounded up to a page boundary, so most allocators will only care about `size` (first

parameter).

name - a name that can be useful for debugging

buffer_collection_id + buffer_index - The buffer_collection_id and buffer_index are retrievable

from a sysmem-provided VMO using GetVmoInfo(). Because the sysmem-provided VMO may be a child

(or grandchild) of the allocated VMO, the koid of parent_vmo is not generally retrievable from

a sysmem-provide VMO derived from parent_vmo. Allocators which don't need to correlate a

sysmem-provided VMO to a parent_vmo can ignore buffer_collection_id and buffer_index.

parent_vmo - return the allocated VMO

returns zx_status_t - the error may be useful for debugging, but the error code indicated to

sysmem clients will be sanitized to ZX_ERR_NO_MEMORY.

void Delete (zx::vmo parent_vmo)

This also should clean up any tracking of buffer_collection_id + buffer_index (the specific

combination), as zero sysmem-provided VMOs exist at this point, so it's impossible for any

sysmem-provided VMO to show up with the parent_vmo's buffer_collection_id + buffer_index.

This call takes ownership of parent_vmo, and should close parent_vmo so that the memory used by

parent_vmo can be freed/reclaimed/recycled.

void set_ready ()

These avoid the possibility of trying to use a sysmem-configured secure

heap before the TEE has told the HW to make the physical range

secure/protected. The default SetReady() implementation panics, and the

default is_ready() just returns true.

Defined at line 27 of file ../../src/sysmem/server/memory_allocator.cc

void clear_ready ()

only called on secure allocators

Defined at line 29 of file ../../src/sysmem/server/memory_allocator.cc

bool is_ready ()

Defined at line 31 of file ../../src/sysmem/server/memory_allocator.cc

void AddDestroyCallback (intptr_t key, fit::callback<void ()> callback)

Defined at line 33 of file ../../src/sysmem/server/memory_allocator.cc

void RemoveDestroyCallback (intptr_t key)

Defined at line 38 of file ../../src/sysmem/server/memory_allocator.cc

zx_status_t GetPhysicalMemoryInfo (uint64_t * base, uint64_t * size)

Defined at line 83 of file ../../src/sysmem/server/memory_allocator.h

const fuchsia_hardware_sysmem::HeapProperties & heap_properties ()

Defined at line 87 of file ../../src/sysmem/server/memory_allocator.h

uint64_t id ()

Defined at line 107 of file ../../src/sysmem/server/memory_allocator.h

bool is_already_cleared_on_allocate ()

Defined at line 109 of file ../../src/sysmem/server/memory_allocator.h

bool is_empty ()

Returns true if there are no outstanding allocations, or if the allocator only allocates fully

independent VMOs that fully own their own memory separate from any tracking in sysmem.

Allocators must be empty before they're deleted.

Records