aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarret Kelly <gdk@google.com>2019-08-06 17:23:48 -0400
committerGarret Kelly <gdk@google.com>2019-08-07 13:09:30 -0400
commit5db2a147d247e728f0f838d2573d3a8119323d3e (patch)
tree507de17a294873136f72b2d537dd4a2d231bda8e
parented5dea225cb9805833ceb5d9e0ba8feaee053737 (diff)
downloadgeneric-5db2a147d247e728f0f838d2573d3a8119323d3e.tar.gz
events: Rework events
Flatten event model to more closely match the metric reporting format. Don't nest events under IDs, IDs are now top-level. Bug: 110497903 Test: using event command on red board Change-Id: If25aeefa3c295d7c1e6032ef4ea8e20f7396e949 Signed-off-by: Garret Kelly <gdk@google.com>
-rw-r--r--citadel/updater/updater.cpp4
-rw-r--r--nugget/include/citadel_events.h50
2 files changed, 32 insertions, 22 deletions
diff --git a/citadel/updater/updater.cpp b/citadel/updater/updater.cpp
index ec8fb3f..ed58895 100644
--- a/citadel/updater/updater.cpp
+++ b/citadel/updater/updater.cpp
@@ -1018,8 +1018,8 @@ static uint32_t do_event(AppClient &app, int argc, char *argv[])
uint64_t usecs = evt.uptime_usecs - (secs * 1000000UL);
printf("event record %" PRIu64 "/%" PRIu64 ".%06" PRIu64 ": ",
evt.reset_count, secs, usecs);
- printf("%d 0x%08x 0x%08x 0x%08x\n", evt.id,
- evt.u.raw.w[0], evt.u.raw.w[1], evt.u.raw.w[2]);
+ printf("%d %d 0x%08x 0x%08x 0x%08x\n", evt.id, evt.priority,
+ evt.event.raw.w[0], evt.event.raw.w[1], evt.event.raw.w[2]);
}
return rv;
diff --git a/nugget/include/citadel_events.h b/nugget/include/citadel_events.h
index 336f3c5..c25af55 100644
--- a/nugget/include/citadel_events.h
+++ b/nugget/include/citadel_events.h
@@ -44,47 +44,57 @@ extern "C" {
* instead of changing things.
*/
+/*
+ * Event priority. Stored events of lower priority will be evicted to store
+ * higher-priority events if the queue is full.
+ */
+enum event_priority {
+ EVENT_PRIORITY_LOW = 0,
+ EVENT_PRIORITY_MEDIUM = 1,
+ EVENT_PRIORITY_HIGH = 2,
+};
+
+/*
+ * Event ID values live forever.
+ * Add to the list, but NEVER change or delete existing entries.
+ */
+enum event_id {
+ EVENT_NONE = 0, // Unused ID, used as empty marker.
+ EVENT_ALERT = 1, // Globalsec alert fired.
+ EVENT_REBOOTED = 2, // Device rebooted.
+};
+
/* Please do not change the size of this struct */
#define EVENT_RECORD_SIZE 64
struct event_record {
uint64_t reset_count; /* zeroed by Citadel power cycle */
uint64_t uptime_usecs; /* since last Citadel reset */
uint32_t id;
+ uint32_t priority;
union {
/* id-specific information goes here */
struct {
uint32_t intr_sts[3];
} alert;
struct {
- uint32_t bad_thing;
- } citadel;
- struct {
- uint32_t okay_thing;
- } info;
+ uint32_t rstsrc;
+ uint32_t exitpd;
+ uint32_t which0;
+ uint32_t which1;
+ } rebooted;
/* uninterpreted */
union {
- uint32_t w[11];
- uint16_t h[22];
- uint8_t b[44];
+ uint32_t w[10];
+ uint16_t h[20];
+ uint8_t b[40];
} raw;
- } u;
+ } event;
} __packed;
/* Please do not change the size of this struct */
static_assert(sizeof(struct event_record) == EVENT_RECORD_SIZE,
"Muting the Immutable");
-/*
- * Event ID values live forever.
- * Add to the list, but NEVER change or delete existing entries.
-*/
-enum event_id {
- EVENT_NONE = 0, /* No valid event exists with this ID */
- EVENT_ALERT = 1, /* Security alert reported */
- EVENT_CITADEL = 2, /* Bad: panic, stack overflow, etc. */
- EVENT_INFO = 3, /* FYI: normal reboot, etc. */
-};
-
#ifdef __cplusplus
}
#endif