13extern uint32_t permaramadr;
15struct consts *constants() {
16 return (
struct consts *)&permaramadr;
19static void set_checksum() {
20 uint32_t c = calc_crc32((
void *)constants(), CRC_SIZE, 4);
22 constants()->crc32 = c;
27 CRC_SIZE = offsetof(
struct consts, end_of_checksum);
28 void *v = (
void *)constants();
30 if (constants()->magic == CONSTANTS_MAGIC) {
31 uint32_t c = calc_crc32(v, CRC_SIZE, 4);
32 if (c == constants()->crc32) {
36 memset(v, 0,
sizeof(
struct consts));
37 constants()->magic = CONSTANTS_MAGIC;
43void constants_validate() {
44 if (constants()->magic != CONSTANTS_MAGIC) {
52void constants_print() {
53 struct consts *c = constants();
55 printf(
"Constants (checksum size: %i:\r\n", CRC_SIZE);
56 if (constants()->magic != CONSTANTS_MAGIC) {
57 printf(
"invalid constants magic\r\n");
60 printf(
"last_return_address: %p\r\n", c->last_return_address);
61 printf(
"failing_address : %p\r\n", c->failing_address);
62 printf(
"CFSR : %p\r\n", c->CFSR);
63 printf(
"SHCSR : %p\r\n", c->SHCSR);
64 printf(
"MMFAR : %p\r\n", c->MMFAR);
65 printf(
"HFSR : %p\r\n", c->HFSR);
66 printf(
"BFAR : %p\r\n", c->BFAR);
67 printf(
"reset_counter : %i\r\n", c->reset_counter);
68 printf(
"in_user_app : %i\r\n", c->in_user_app);
69 uint32_t ch = calc_crc32((uint8_t *)c, CRC_SIZE, 4);
72 printf(
"Checksum : OK\r\n");
74 printf(
"Checksum : FAIL\r\n");