eventlog: Add a log type for Chrome OS diagnostics

Add events for Chrome OS diagnostics in eventlog tool:
* ELOG_TYPE_CROS_DIAGNOSTICS(0xb6): diagnostics-related events
* ELOG_CROS_LAUNCH_DIAGNOSTICS(0x01): sub-type for diagnostics boot

These events are not added anywhere currently. They will be added in
another separate commit.

Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Change-Id: I1b67fdb46f64db33f581cfb5635103c9f5bbb302
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58795
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
diff --git a/src/commonlib/bsd/include/commonlib/bsd/elog.h b/src/commonlib/bsd/include/commonlib/bsd/elog.h
index 7e564fc..29c781b 100644
--- a/src/commonlib/bsd/include/commonlib/bsd/elog.h
+++ b/src/commonlib/bsd/include/commonlib/bsd/elog.h
@@ -305,6 +305,10 @@
 #define ELOG_TYPE_MI_HRPC                 0xb4
 #define ELOG_TYPE_MI_HR                   0xb5
 
+/* Chrome OS diagnostics-related events */
+#define ELOG_TYPE_CROS_DIAGNOSTICS        0xb6
+#define  ELOG_CROS_LAUNCH_DIAGNOSTICS      0x01
+
 struct elog_event_extended_event {
 	uint8_t event_type;
 	uint32_t event_complement;
diff --git a/util/cbfstool/eventlog.c b/util/cbfstool/eventlog.c
index 3ea352e..1fd4113 100644
--- a/util/cbfstool/eventlog.c
+++ b/util/cbfstool/eventlog.c
@@ -157,6 +157,7 @@
 		{ELOG_TYPE_CR50_NEED_RESET, "cr50 Reset Required"},
 		{ELOG_TYPE_EC_DEVICE_EVENT, "EC Device"},
 		{ELOG_TYPE_EXTENDED_EVENT, "Extended Event"},
+		{ELOG_TYPE_CROS_DIAGNOSTICS, "Diagnostics Mode"},
 
 		{ELOG_TYPE_EOL, "End of log"},
 	};
@@ -533,6 +534,11 @@
 		{0, NULL},
 	};
 
+	static const struct valstr cros_diagnostics_types[] = {
+		{ELOG_CROS_LAUNCH_DIAGNOSTICS, "Launch Diagnostics"},
+		{0, NULL},
+	};
+
 	switch (event->type) {
 	case ELOG_TYPE_LOG_CLEAR: {
 		const uint16_t *bytes = event_get_data(event);
@@ -614,6 +620,10 @@
 		eventlog_printf("0x%X", ext_event->event_complement);
 		break;
 	}
+	case ELOG_TYPE_CROS_DIAGNOSTICS: {
+		const uint8_t *type = event_get_data(event);
+		eventlog_printf("%s", val2str(*type, cros_diagnostics_types));
+	}
 	default:
 		break;
 	}