|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <PluginStorage.h>
Static Public Member Functions | |
| static bool | mount () |
| Mount the plugins partition. Auto-formats if empty. | |
| static void | unmount () |
| Unmount the plugins partition (rarely used; mostly tests). | |
| static const char * | basePath () |
| Returns the VFS path prefix, e.g. "/vfat". | |
| static std::vector< std::string > | listPluginIds () |
| Discover all installed plugin ids. A plugin is recognised by the presence of both <id>.wasm and <id>.meta files. | |
| static std::string | binaryPath (const std::string &id) |
| Returns the path that should be loaded for <id>: <id>.aot if it exists on disk, otherwise <id>.wasm. | |
| static std::string | wasmPath (const std::string &id) |
| Returns the full VFS path of <id>.wasm. | |
| static std::string | aotPath (const std::string &id) |
| Returns the full VFS path of <id>.aot. | |
| static std::string | metaPath (const std::string &id) |
| Returns the full VFS path of <id>.meta. | |
| static std::string | langPath (const std::string &id) |
| Returns the full VFS path of <id>.lang (translation overlay). | |
| static std::string | disabledPath (const std::string &id) |
| Returns the full VFS path of <id>.disabled. | |
| static bool | isDisabled (const std::string &id) |
| True when the plugin has a persistent disabled marker. | |
| static bool | setDisabled (const std::string &id, bool disabled) |
| Create or remove the persistent disabled marker for a plugin. | |
| static bool | stats (uint64_t &free_bytes, uint64_t &total_bytes) |
| Returns the free and total bytes on the plugins partition. | |
| static uint16_t | blockSize () |
| Logical sector size of the vfat volume in bytes (MSC block size). | |
| static uint64_t | blockTotalBytes () |
| Total accessible size of the vfat volume in bytes. | |
| static bool | blockRead (uint32_t lba, uint32_t offset, void *buf, uint32_t len) |
| Reads raw bytes from the wear-levelling logical space. | |
| static bool | blockWrite (uint32_t lba, uint32_t offset, const void *buf, uint32_t len) |
| Erases and writes raw bytes to the wear-levelling logical space. | |
| static void | setHostActive (bool active) |
| Marks whether a USB host currently holds the volume over MSC. | |
| static bool | hostActive () |
| Reports whether a USB host currently holds the volume over MSC. | |
| static void | remountIfPending () |
| Performs a deferred remount scheduled by setHostActive(false). | |
| static void | protectSystemDir () |
| Applies advisory read-only + hidden + system FAT attributes to the system folder so standard host file managers hide and protect it. | |
Definition at line 19 of file PluginStorage.h.
|
static |
Returns the full VFS path of <id>.aot.
Definition at line 170 of file PluginStorage.cpp.
References cdc::plugin_manager::SYSTEM_DIR.
Referenced by binaryPath(), and cdc::plugin_manager::PluginManager::uninstallPlugin().
|
static |
Returns the VFS path prefix, e.g. "/vfat".
Definition at line 109 of file PluginStorage.cpp.
References cdc::plugin_manager::MOUNT_POINT.
|
static |
Returns the path that should be loaded for <id>: <id>.aot if it exists on disk, otherwise <id>.wasm.
Definition at line 153 of file PluginStorage.cpp.
References aotPath(), and wasmPath().
Referenced by cdc::plugin_manager::Plugin::load().
|
static |
Reads raw bytes from the wear-levelling logical space.
| lba | Logical block address (in blockSize() units). |
| offset | Byte offset added inside the block. |
| buf | Destination buffer. |
| len | Number of bytes to read. |
Definition at line 229 of file PluginStorage.cpp.
References cdc::plugin_manager::s_mounted, cdc::plugin_manager::s_wl_handle, and usb_msc_range_ok().
|
static |
Logical sector size of the vfat volume in bytes (MSC block size).
Definition at line 217 of file PluginStorage.cpp.
References cdc::plugin_manager::s_mounted, and cdc::plugin_manager::s_wl_handle.
|
static |
Total accessible size of the vfat volume in bytes.
Definition at line 223 of file PluginStorage.cpp.
References cdc::plugin_manager::s_mounted, and cdc::plugin_manager::s_wl_handle.
|
static |
Erases and writes raw bytes to the wear-levelling logical space.
offset must be 0 and len a multiple of blockSize(); the addressed range is erased then written, matching the FATFS-over-WL sector semantics.
| lba | Logical block address (in blockSize() units). |
| offset | Byte offset inside the block (must be 0). |
| buf | Source buffer. |
| len | Number of bytes to write. |
Definition at line 238 of file PluginStorage.cpp.
References cdc::plugin_manager::s_mounted, cdc::plugin_manager::s_wl_handle, and usb_msc_range_ok().
|
static |
Returns the full VFS path of <id>.disabled.
Definition at line 185 of file PluginStorage.cpp.
References cdc::plugin_manager::SYSTEM_DIR.
Referenced by isDisabled(), setDisabled(), and cdc::plugin_manager::PluginManager::uninstallPlugin().
|
static |
Reports whether a USB host currently holds the volume over MSC.
Definition at line 263 of file PluginStorage.cpp.
References cdc::plugin_manager::s_host_active.
|
static |
True when the plugin has a persistent disabled marker.
Definition at line 190 of file PluginStorage.cpp.
References disabledPath().
Referenced by cdc::plugin_manager::PluginManager::isPluginDisabled().
|
static |
Returns the full VFS path of <id>.lang (translation overlay).
Definition at line 180 of file PluginStorage.cpp.
References cdc::plugin_manager::SYSTEM_DIR.
Referenced by cdc::plugin_manager::Plugin::loadLangOverlay(), and cdc::plugin_manager::PluginManager::uninstallPlugin().
|
static |
Discover all installed plugin ids. A plugin is recognised by the presence of both <id>.wasm and <id>.meta files.
Definition at line 119 of file PluginStorage.cpp.
References cdc::plugin_manager::ends_with(), metaPath(), name, cdc::plugin_manager::s_mounted, and cdc::plugin_manager::SYSTEM_DIR.
Referenced by cdc::plugin_manager::PluginManager::init(), and cdc::plugin_manager::PluginManager::listInstalledIds().
|
static |
Returns the full VFS path of <id>.meta.
Definition at line 175 of file PluginStorage.cpp.
References cdc::plugin_manager::SYSTEM_DIR.
Referenced by cdc::plugin_manager::PluginManager::getManifest(), listPluginIds(), and cdc::plugin_manager::PluginManager::uninstallPlugin().
|
static |
Mount the plugins partition. Auto-formats if empty.
Definition at line 72 of file PluginStorage.cpp.
References cdc::plugin_manager::ensure_volume_label(), LOG_E, LOG_I, cdc::plugin_manager::MOUNT_POINT, cdc::plugin_manager::PARTITION_LABEL, protectSystemDir(), cdc::plugin_manager::s_mounted, cdc::plugin_manager::s_wl_handle, cdc::plugin_manager::SYSTEM_DIR, and cdc::plugin_manager::TAG.
Referenced by cdc::plugin_manager::PluginManager::init(), and remountIfPending().
|
static |
Applies advisory read-only + hidden + system FAT attributes to the system folder so standard host file managers hide and protect it.
Best-effort: skipped while hostActive(); failures are logged and ignored.
Definition at line 277 of file PluginStorage.cpp.
References LOG_I, LOG_W, cdc::plugin_manager::s_host_active, cdc::plugin_manager::s_mounted, cdc::plugin_manager::SYSTEM_DIR, cdc::plugin_manager::TAG, and cdc::plugin_manager::vfat_drive().
Referenced by mount().
|
static |
Performs a deferred remount scheduled by setHostActive(false).
Call from a non-USB task (e.g. a module tick) so the FATFS cache is refreshed and host-written files appear in the file browser. No-op when nothing is pending or a host is still attached.
Definition at line 268 of file PluginStorage.cpp.
References LOG_I, mount(), cdc::plugin_manager::MOUNT_POINT, cdc::plugin_manager::s_host_active, cdc::plugin_manager::s_mounted, cdc::plugin_manager::s_remount_pending, cdc::plugin_manager::TAG, and unmount().
|
static |
Create or remove the persistent disabled marker for a plugin.
Definition at line 197 of file PluginStorage.cpp.
References disabledPath(), and cdc::core::openFile().
Referenced by cdc::plugin_manager::PluginManager::setPluginDisabled().
|
static |
Marks whether a USB host currently holds the volume over MSC.
While active, badge-side writers MUST refuse to write (the host is the sole writer). The active->inactive edge schedules a remount (performed by remountIfPending() on a safe task) so host-written files become visible. Safe to call from the USB task.
| active | true when a host has mounted the MSC LUN. |
Definition at line 250 of file PluginStorage.cpp.
References LOG_I, cdc::plugin_manager::s_host_active, cdc::plugin_manager::s_remount_pending, cdc::plugin_manager::TAG, and usb_msc_should_remount().
|
static |
Returns the free and total bytes on the plugins partition.
Definition at line 211 of file PluginStorage.cpp.
References cdc::plugin_manager::MOUNT_POINT, and cdc::plugin_manager::s_mounted.
|
static |
Unmount the plugins partition (rarely used; mostly tests).
Definition at line 101 of file PluginStorage.cpp.
References cdc::plugin_manager::MOUNT_POINT, cdc::plugin_manager::s_mounted, and cdc::plugin_manager::s_wl_handle.
Referenced by cdc::plugin_manager::PluginManager::deinit(), and remountIfPending().
|
static |
Returns the full VFS path of <id>.wasm.
Definition at line 165 of file PluginStorage.cpp.
References cdc::plugin_manager::SYSTEM_DIR.
Referenced by binaryPath(), cdc::plugin_manager::PluginInfoView::loadForPluginId(), and cdc::plugin_manager::PluginManager::uninstallPlugin().