Files
ZephCore/zephcore/helpers/boot_info.h
T

45 lines
1.4 KiB
C

/*
* SPDX-License-Identifier: MIT
*
* The MCU's reset cause, captured and cleared once at POST_KERNEL on every
* role. hwinfo's flags accumulate between resets on some platforms, so
* clearing after reading is what isolates the most recent one.
*/
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The cause hwinfo reported at boot. out must be non-NULL. False means hwinfo
* could not report one, which differs from a cause of 0. Call from main() or
* later; an initialiser at or before POST_KERNEL may get false.
*/
bool zephcore_boot_reset_cause(uint32_t *out);
/*
* Render as space-prefixed labels, e.g. " PIN SOFTWARE", or with hints set,
* " PIN(reset button) SOFTWARE". Returns characters written, excluding the
* NUL; 0 means nothing to render. Writes nothing when buf is NULL or cap is 0,
* otherwise always NUL-terminates, truncating at the first label that does not
* fit. 127 bytes hold every label without hints, 239 with.
*/
int zephcore_boot_reset_cause_str(char *buf, size_t cap, bool hints);
/*
* The part of the cause the renderer would name. Use this rather than the raw
* cause when deciding whether a cause is worth reporting, so an unlabelled bit
* cannot trigger a report that then names unrelated labels.
*/
uint32_t zephcore_boot_reset_cause_labelled(void);
#ifdef __cplusplus
}
#endif