66 ID id()
const {
return d->id; }
74 return d->isHostAccessible(
alloc);
112 return d->fill(ptr, bytes,
value);
116 const Ops *d =
nullptr;
117 static const Ops *lookup(
ID id);
139 if(
src.ptr ==
nullptr ||
dst.ptr ==
nullptr)
return false;
140 return d->copy(
src,
dst, bytes);
Lightweight error code wrapper for the promeki library.
Definition error.h:39
@ Invalid
Invalid value or argument (EINVAL).
Definition error.h:66
Dynamic array container wrapping std::vector.
Definition list.h:40
Abstraction for memory allocation in different address spaces.
Definition memspace.h:30
MemSpace(ID id=Default)
Constructs a MemSpace for the given memory space ID.
Definition memspace.h:54
ID
Identifies a memory space.
Definition memspace.h:33
@ Default
Alias for System memory.
Definition memspace.h:36
@ SystemSecure
System memory with secure zeroing on free and page locking.
Definition memspace.h:35
bool copy(const MemAllocation &src, const MemAllocation &dst, size_t bytes) const
Copies bytes from a source allocation to a destination allocation.
Definition memspace.h:138
MemAllocation alloc(size_t bytes, size_t align) const
Allocates memory in this memory space.
Definition memspace.h:143
ID id() const
Returns the memory space identifier.
Definition memspace.h:66
Error fill(void *ptr, size_t bytes, char value) const
Fills memory with a byte value.
Definition memspace.h:110
bool isHostAccessible(const MemAllocation &alloc) const
Returns true if the given allocation is directly accessible from the host CPU.
Definition memspace.h:73
const String & name() const
Returns the human-readable name of this memory space.
Definition memspace.h:60
void release(MemAllocation &alloc) const
Releases a previously allocated memory region.
Definition memspace.h:152
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Provides system-level utility functions.
Definition system.h:29
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
const T & value(const Result< T > &r)
Returns the value from a Result.
Definition result.h:56
Describes a memory allocation from a MemSpace.
Definition memspace.h:127
size_t size
Size of the allocation in bytes.
Definition memspace.h:129
size_t align
Alignment of the allocation in bytes.
Definition memspace.h:130
bool isValid() const
Returns true if this allocation is valid.
Definition memspace.h:135
MemSpace ms
The memory space this was allocated from.
Definition memspace.h:131
void * priv
Private data for the allocator implementation.
Definition memspace.h:132
void * ptr
Pointer to the allocated memory.
Definition memspace.h:128
Function table for memory space operations.
Definition memspace.h:40
void(* alloc)(MemAllocation &alloc)
Allocate memory. Size and align are pre-filled.
Definition memspace.h:44
bool(* copy)(const MemAllocation &src, const MemAllocation &dst, size_t bytes)
Copy bytes from this space to another.
Definition memspace.h:46
String name
Human-readable name of the memory space.
Definition memspace.h:42
Error(* fill)(void *ptr, size_t bytes, char value)
Fill memory with a byte value.
Definition memspace.h:47
ID id
The memory space identifier.
Definition memspace.h:41
void(* release)(MemAllocation &alloc)
Release previously allocated memory.
Definition memspace.h:45
bool(* isHostAccessible)(const MemAllocation &alloc)
Returns true if the allocation is directly accessible from the host CPU.
Definition memspace.h:43