13#if EFI_CONFIGURATION_STORAGE
18#if EFI_CONFIGURATION_STORAGE || defined(EFI_UNIT_TEST)
21#if (EFI_STORAGE_INT_FLASH == TRUE) || defined(EFI_UNIT_TEST)
32#if EFI_SHAFT_POSITION_INPUT
51#if EFI_CONFIGURATION_STORAGE
53#if EFI_STORAGE_INT_FLASH == TRUE
57#if EFI_STORAGE_MFS == TRUE
61#if EFI_STORAGE_SD == TRUE
65#define STORAGE_MANAGER_POLL_INTERVAL_MS 100
73#define MSG_CMD_WRITE (0)
75#define MSG_CMD_WRITE_NOW (1)
76#define MSG_CMD_READ (2)
77#define MSG_CMD_PING (3)
78#define MSG_CMD_REG (4)
79#define MSG_CMD_UNREG (5)
81#define MSG_ID_MASK 0x1f
91 efiPrintf(
"Requested to write unknown record id %ld",
id);
105 efiPrintf(
"Requested to read unknown record id %ld",
id);
116 return "MFS_INT_FLASH";
118 return "MFS_EXT_FLASH";
128#define for_all_storages SettingStorageBase* storage = nullptr; \
129 for (size_t i = 0; i < storagesCount; i++) \
130 if ((storage = storages[i]) != nullptr)
134 if ((storage->isReady()) && (storage->isIdSupported(
id))) {
143 bool success =
false;
147 if ((!storage->isReady()) || (!storage->isIdSupported(
id))) {
151 status = storage->store(
id, ptr,
size);
161 bool success =
false;
165 if ((!storage->isReady()) || (!storage->isIdSupported(
id))) {
169 status = storage->read(
id, ptr,
size);
180 msg_t msg = ((cmd & 0xff) << 24) | (arg & 0x00ffffff);
182 chibios_rt::CriticalSectionLocker csl;
201 efiPrintf(
"Trying to register already exist storage %s",
storageTypeToName(type));
251#if (EFI_STORAGE_MFS == TRUE) || (EFI_STORAGE_SD == TRUE)
259 chRegSetThreadName(
"storage manger");
266 ret =
storageManagerMb.fetch(&msg, TIME_MS2I(STORAGE_MANAGER_POLL_INTERVAL_MS));
268 uint8_t cmd = (msg >> 24) & 0xff;
269 uint32_t
id = msg & MSG_ID_MASK;
278 case MSG_CMD_WRITE_NOW:
289#if EFI_STORAGE_INT_FLASH == TRUE
294#if EFI_STORAGE_MFS == TRUE
299#if EFI_STORAGE_SD == TRUE
358 bool settingsStorageReady =
false;
360 (void)settingsStorageReady;
362#if EFI_STORAGE_INT_FLASH == TRUE
366#if EFI_STORAGE_MFS == TRUE
367 if (settingsStorageReady) {
383 chThdCreateStatic(storageManagerThreadStack,
sizeof(storageManagerThreadStack), PRIO_STORAGE_MANAGER,
storageManagerThread,
nullptr);
bool mcuCanFlashWhileRunning()
TriggerCentral triggerCentral
RpmCalculator rpmCalculator
constexpr auto & module()
bool isStopped() const override
bool directSelfStimulation
static EngineAccessor engine
bool writeToFlashNowImpl()
static const char * storageTypeToName(StorageType type)
bool storageIsStorageRegistered(StorageType type)
static THD_WORKING_AREA(storageManagerThreadStack, 3 *UTILITY_THREAD_STACK_SIZE)
static uint32_t pendingReads
bool storageReqestReadID(StorageItemId id)
bool storageUnregisterStorage(StorageType type)
static bool storageWriteID(uint32_t id)
static bool storageReadID(uint32_t id)
bool storagRequestUnregisterStorage(StorageType id)
bool storageRegisterStorage(StorageType type, SettingStorageBase *storage)
chibios_rt::Mailbox< msg_t, 16 > storageManagerMb
static SettingStorageBase * storages[storagesCount]
StorageStatus storageRead(StorageItemId id, uint8_t *ptr, size_t size)
static uint32_t pendingWrites
bool storageRequestWriteID(StorageItemId id, bool forced)
bool storageAllowWriteID(StorageItemId id)
static constexpr size_t storagesCount
static void storageManagerThread(void *)
StorageStatus storageWrite(StorageItemId id, const uint8_t *ptr, size_t size)
bool getNeedToWriteConfiguration()
static bool storageManagerSendCmd(uint32_t cmd, uint32_t arg)
static bool storageIsIdAvailableForId(StorageItemId id)
bool storagRequestRegisterStorage(StorageType id)
@ EFI_SETTINGS_BACKUP_RECORD_ID
@ EFI_STORAGE_TOTAL_ITEMS
Storage interface to internal MCU flash header.
Storage interface to FatFS header.