Robin Mueller
042acc1a23
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "SdCardManager.h"
|
|
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <string>
|
|
|
|
namespace xsc {
|
|
|
|
enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
|
|
enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
|
|
|
|
} // namespace xsc
|
|
|
|
|
|
struct RebootFile {
|
|
static constexpr uint8_t DEFAULT_MAX_BOOT_CNT = 10;
|
|
|
|
bool enabled = false;
|
|
size_t maxCount = DEFAULT_MAX_BOOT_CNT;
|
|
uint8_t img00Cnt = 0;
|
|
uint8_t img01Cnt = 0;
|
|
uint8_t img10Cnt = 0;
|
|
uint8_t img11Cnt = 0;
|
|
uint8_t relevantBootCnt = 0;
|
|
bool bootFlag = false;
|
|
xsc::Chip lastChip = xsc::Chip::CHIP_0;
|
|
xsc::Copy lastCopy = xsc::Copy::COPY_0;
|
|
};
|
|
|
|
class SdCardManager;
|
|
|
|
class CoreController {
|
|
public:
|
|
static constexpr char REBOOT_FILE[] = "/conf/reboot.txt";
|
|
static constexpr uint32_t REBOOT_MECHANISM_TRIGGERED = 1;
|
|
static xsc::Chip CURRENT_CHIP;
|
|
static xsc::Copy CURRENT_COPY;
|
|
|
|
CoreController();
|
|
void performRebootFileHandling(bool recreateFile);
|
|
void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc::Chip& tgtChip,
|
|
xsc::Copy& tgtCopy);
|
|
void resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy);
|
|
bool parseRebootFile(std::string path, RebootFile& file);
|
|
void rewriteRebootFile(RebootFile file);
|
|
private:
|
|
struct SdInfo {
|
|
sd::SdCard pref = sd::SdCard::NONE;
|
|
sd::SdState prefState = sd::SdState::OFF;
|
|
sd::SdCard other = sd::SdCard::NONE;
|
|
sd::SdState otherState = sd::SdState::OFF;
|
|
} sdInfo;
|
|
|
|
SdCardManager* sdcMan = nullptr;
|
|
RebootFile rebootFile = {};
|
|
bool doPerformRebootFileHandling = true;
|
|
}; |