21 using RebuildLogFn = void(*)(uint16_t slot,
const char* message,
void* ctx);
27 bool start()
override;
30 const char*
getName()
const override {
return "tropic_storage"; }
63 bool loadChunk(uint16_t chunkIndex, CacheEntry* entries);
64 bool saveChunk(uint16_t chunkIndex,
const CacheEntry* entries);
65 uint32_t computeMapSignature()
const;
67 bool setEntry(uint16_t slot,
const CacheEntry& entry);
68 bool getEntry(uint16_t slot, CacheEntry* entry);
69 bool isEntryUsed(
const CacheEntry& entry)
const;
70 bool isEntryAllowed(uint16_t slot, uint8_t
moduleId)
const;
74 CacheHeader header_ = {};
75 bool cacheValid_ =
false;
char name[cdc::hal::ISecureElement::RMEM_NAME_LEN]
static constexpr uint16_t CHUNK_SLOTS
bool rebuild()
Rebuilds cache contents from secure-element R-MEM without verbose logging.
void stop() override
Stops cache service.
struct cdc::core::TropicStorage::CacheEntry __attribute__((packed))
bool writeSlot(uint8_t moduleId, uint16_t slot, const char *name, uint8_t flags)
Writes or updates cached metadata entry for one slot.
bool eraseSlot(uint8_t moduleId, uint16_t slot)
Clears cached metadata entry for one slot.
static TropicStorage & instance()
Returns singleton instance of TROPIC metadata cache manager.
bool forEachSlot(uint8_t moduleId, SlotCallback cb, void *ctx)
Iterates all cached slots for one module across its allowed range.
void(*)(uint16_t slot, const CacheEntry &entry, void *ctx) SlotCallback
void setSecureElement(cdc::hal::ISecureElement *se)
bool getSlot(uint8_t moduleId, uint16_t index, SlotCallback cb, void *ctx)
Resolves one module-relative index to slot entry and invokes callback.
const char * getName() const override
ServiceState getState() const override
bool start() override
Starts cache service, initializing first if required.
bool init() override
Initializes cache metadata and validates persisted cache header.
void(*)(uint16_t slot, const char *message, void *ctx) RebuildLogFn
bool isCacheValid() const
static constexpr uint8_t FLAG_USED
bool rebuildVerbose(RebuildLogFn logFn, void *ctx)
Rebuilds cache contents from secure-element R-MEM with optional logging callback.
bool cleanup()
Removes cache entries and chip records that violate slot/module mapping.
static constexpr uint8_t RMEM_NAME_LEN
char name[cdc::hal::ISecureElement::RMEM_NAME_LEN]