CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::core::SlotManager Class Reference

Manages logical-to-physical RMEM slot mapping for module storage layers. More...

#include <SlotManager.h>

Public Member Functions

void setSlotRange (uint16_t start, uint16_t end, uint8_t moduleId)
 Configures logical-to-physical slot mapping using raw values.
void setSlotRange (const IModule::SlotRange &range)
 Configures logical-to-physical slot mapping from a SlotRange struct.
uint16_t capacity () const
 Returns available entry capacity from configured slot range.
bool toPhysicalSlot (uint16_t logicalIndex, uint16_t *slotOut) const
 Converts logical index to physical RMEM slot.
bool toLogicalSlot (uint16_t slot, uint16_t *logicalIndexOut) const
 Converts physical RMEM slot to logical index.
bool findFreeSlot (uint16_t *slotOut) const
 Finds first free physical slot in configured range.
bool hasSlotRange () const
 Returns whether a valid slot range is configured.
uint16_t rmemStart () const
 Returns configured RMEM start slot.
uint16_t rmemEnd () const
 Returns configured RMEM end slot.
uint8_t moduleId () const
 Returns configured owning module identifier.

Protected Attributes

bool hasSlotRange_ = false
uint16_t rmemStart_ = 0
uint16_t rmemEnd_ = 0
uint8_t moduleId_ = 0

Detailed Description

Manages logical-to-physical RMEM slot mapping for module storage layers.

Encapsulates slot range bookkeeping and free-slot discovery shared by OathStore, PasswordStore, and other storage layers backed by the Tropic secure element.

Definition at line 19 of file SlotManager.h.

Member Function Documentation

◆ capacity()

uint16_t cdc::core::SlotManager::capacity ( ) const
inline

Returns available entry capacity from configured slot range.

Returns
Number of addressable logical entries, or 0 when no range is set.

Definition at line 57 of file SlotManager.h.

References hasSlotRange_, rmemEnd_, and rmemStart_.

Referenced by findFreeSlot().

◆ findFreeSlot()

bool cdc::core::SlotManager::findFreeSlot ( uint16_t * slotOut) const
inline

Finds first free physical slot in configured range.

Parameters
slotOutOutput physical slot.
Returns
true if a free slot was found.

Definition at line 96 of file SlotManager.h.

References capacity(), cdc::core::TropicStorage::forEachSlot(), hasSlotRange_, cdc::core::TropicStorage::instance(), moduleId_, rmemEnd_, and rmemStart_.

◆ hasSlotRange()

bool cdc::core::SlotManager::hasSlotRange ( ) const
inline

Returns whether a valid slot range is configured.

Returns
true when slot range was set successfully.

Definition at line 142 of file SlotManager.h.

References hasSlotRange_.

◆ moduleId()

uint8_t cdc::core::SlotManager::moduleId ( ) const
inline

Returns configured owning module identifier.

Returns
Module identifier used for slot ownership filtering.

Definition at line 160 of file SlotManager.h.

References moduleId_.

Referenced by setSlotRange().

◆ rmemEnd()

uint16_t cdc::core::SlotManager::rmemEnd ( ) const
inline

Returns configured RMEM end slot.

Returns
Last RMEM slot in the configured range.

Definition at line 154 of file SlotManager.h.

References rmemEnd_.

◆ rmemStart()

uint16_t cdc::core::SlotManager::rmemStart ( ) const
inline

Returns configured RMEM start slot.

Returns
First RMEM slot in the configured range.

Definition at line 148 of file SlotManager.h.

References rmemStart_.

◆ setSlotRange() [1/2]

void cdc::core::SlotManager::setSlotRange ( const IModule::SlotRange & range)
inline

Configures logical-to-physical slot mapping from a SlotRange struct.

Parameters
rangeSlot range descriptor (only RMEM fields are consumed).

Definition at line 45 of file SlotManager.h.

References cdc::core::IModule::SlotRange::hasRmem, cdc::core::IModule::SlotRange::moduleId, cdc::core::IModule::SlotRange::rmemEnd, cdc::core::IModule::SlotRange::rmemStart, and setSlotRange().

◆ setSlotRange() [2/2]

void cdc::core::SlotManager::setSlotRange ( uint16_t start,
uint16_t end,
uint8_t moduleId )
inline

Configures logical-to-physical slot mapping using raw values.

Parameters
startFirst RMEM slot.
endLast RMEM slot.
moduleIdOwning module identifier.

Definition at line 27 of file SlotManager.h.

References hasSlotRange_, moduleId(), moduleId_, rmemEnd_, and rmemStart_.

Referenced by setSlotRange().

◆ toLogicalSlot()

bool cdc::core::SlotManager::toLogicalSlot ( uint16_t slot,
uint16_t * logicalIndexOut ) const
inline

Converts physical RMEM slot to logical index.

Parameters
slotPhysical slot.
logicalIndexOutOutput logical index.
Returns
true on valid mapping.

Definition at line 83 of file SlotManager.h.

References hasSlotRange_, rmemEnd_, and rmemStart_.

◆ toPhysicalSlot()

bool cdc::core::SlotManager::toPhysicalSlot ( uint16_t logicalIndex,
uint16_t * slotOut ) const
inline

Converts logical index to physical RMEM slot.

Parameters
logicalIndexLogical index.
slotOutOutput physical slot.
Returns
true on valid mapping.

Definition at line 68 of file SlotManager.h.

References hasSlotRange_, rmemEnd_, and rmemStart_.

Member Data Documentation

◆ hasSlotRange_

bool cdc::core::SlotManager::hasSlotRange_ = false
protected

◆ moduleId_

uint8_t cdc::core::SlotManager::moduleId_ = 0
protected

Definition at line 166 of file SlotManager.h.

Referenced by findFreeSlot(), moduleId(), and setSlotRange().

◆ rmemEnd_

uint16_t cdc::core::SlotManager::rmemEnd_ = 0
protected

◆ rmemStart_

uint16_t cdc::core::SlotManager::rmemStart_ = 0
protected

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