35#ifndef PROTOCORE_SECURE_H
36#define PROTOCORE_SECURE_H
59static inline void pc_secure_wipe(
void *ptr,
size_t len)
65 volatile uint8_t *b = (
volatile uint8_t *)ptr;
66 while (len != 0 && (((uintptr_t)b & (
sizeof(uintptr_t) - 1)) != 0))
71 volatile uintptr_t *w = (
volatile uintptr_t *)b;
72 while (len >=
sizeof(uintptr_t))
75 len -=
sizeof(uintptr_t);
77 b = (
volatile uint8_t *)w;
A secure borrow whose acquire and release are one call each.
SecureBorrow(const SecureBorrow &)=delete
SecureBorrow & operator=(const SecureBorrow &)=delete
const pc_span & span() const
The borrowed region; empty if the pool could not satisfy it.
RAII scope guard for secure borrows - marks on entry, wipes and reclaims on every exit.
SecureScope(const SecureScope &)=delete
SecureScope & operator=(const SecureScope &)=delete
User-facing configuration for ProtoCore.
size_t pc_secure_used(void)
Bytes currently handed out.
int pc_secure_slot_of(const void *p)
Which secure slot owns p, or -1 if p is not in the secure pool.
void pc_secure_reset(void)
Wipe and reclaim the whole slot.
size_t pc_secure_mark(void)
Capture the current position, to be handed to pc_secure_release().
bool pc_secure_owns(const void *p)
True if p points inside the secure pool.
pc_span pc_secure_span(size_t n, size_t align)
Borrow n secure bytes as a span whose capacity is bound to the allocation.
void pc_secure_release(size_t mark)
Wipe and reclaim everything borrowed since mark.
void * pc_secure_alloc(size_t n, size_t align)
Borrow n bytes of secure storage, aligned to align.
size_t pc_secure_high_water(void)
Peak bytes ever handed out, for sizing PC_SECURE_ARENA_SIZE.
size_t pc_secure_capacity(void)
Total per-slot capacity in bytes (PC_SECURE_ARENA_SIZE).
A byte region whose run length is bound in both directions.
A writable byte region: the storage, the capacity that belongs to it, and what has been produced into...