32 return kBootGuardMagic ^ image ^ ~boots ^ ((crashes << 16) | (crashes >> 16)) ^ 0x5A5A5A5Au;
54 fl::u32 boots, fl::u32 crashes) {
82 fl::u32 h = 0x811C9DC5u;
83 for (fl::u32 i = 0; i < count; i += stride) {
84 h = (h ^ words[i]) * 0x01000193u;
99 fl::u32 escape_boots) {
101 const fl::u32 boots = stored_boots + 1;
102 d.
escape = escape_boots != 0 && boots >= escape_boots;
FL_ALWAYS_INLINE BootGuardDecision bootGuardOnBoot(fl::u32 stored_boots, fl::u32 escape_boots)
Boot-guard policy.
FL_ALWAYS_INLINE void bootGuardStore(volatile BootGuardRecord &r, fl::u32 image, fl::u32 boots, fl::u32 crashes)
Store both counts in r as a valid record of image.
FL_ALWAYS_INLINE bool bootGuardValid(const volatile BootGuardRecord &r, fl::u32 image)
True when r holds a valid record written by firmware image.
FL_ALWAYS_INLINE fl::u32 bootGuardDecodeCrashes(const volatile BootGuardRecord &r, fl::u32 image)
Crash count stored in r, or 0 if r is not a valid record of image.
FL_ALWAYS_INLINE void bootGuardEncode(volatile BootGuardRecord &r, fl::u32 image, fl::u32 boots)
Store boots, keeping the crash count (0 if the record is invalid).
FL_ALWAYS_INLINE fl::u32 bootGuardDecode(const volatile BootGuardRecord &r, fl::u32 image)
Boot count stored in r, or 0 if r is not a valid record of image.
constexpr fl::u32 kBootGuardMagic
FL_ALWAYS_INLINE fl::u32 bootGuardCheck(fl::u32 image, fl::u32 boots, fl::u32 crashes)
FL_ALWAYS_INLINE void bootGuardEncodeCrashes(volatile BootGuardRecord &r, fl::u32 image, fl::u32 crashes)
Store crashes, keeping the boot count (0 if the record is invalid).
FL_ALWAYS_INLINE fl::u32 bootGuardHashWords(const volatile fl::u32 *words, fl::u32 count, fl::u32 stride=1)
FNV-1a over every stride-th of count 32-bit words; platforms hash their firmware image with it to get...
Base definition for an LED controller.
fl::u32 boots
count to store before continuing
fl::u32 image
key of the firmware image that wrote the record
fl::u32 boots
consecutive boots that never called markBootHealthy()
fl::u32 crashes
consecutive watchdog resets (Watchdog::consecutiveCrashCount())
bool escape
reboot into the bootloader now
fl::u32 check
checksum of the fields above, rejects power-on garbage
Reset-persistent boot-guard record.
What the early-boot hook does on this boot.