util/cbfstool/elogtool: Support logging FW vboot info in elog

List of changes:
1. Add support for new elog event type to log vboot info (type 0xB7).
2. Add support string for fw_slot name, boot status and boot mode.
3. Print fw slot information like FW try count, FW current slot,
    previous FW slot, previous FW boot result and boot mode.

BUG=b:215615970
TEST=Able to build and boot google/kano to OS.
localhost # elogtool list
0 | 2022-07-01 11:10:27 | Log area cleared | 4088
1 | 2022-07-01 11:10:27 | Memory Cache Update | Normal | Success
2 | 2022-07-01 11:10:42 | System boot | 360
3 | 2022-07-01 11:10:42 | Power Fail
4 | 2022-07-01 11:10:42 | SUS Power Fail
5 | 2022-07-01 11:10:42 | ACPI Wake | S5
6 | 2022-07-01 11:10:42 | Wake Source | Power Button | 0
7 | 2022-07-01 11:10:42 | Chrome OS Developer Mode
8 | 2022-07-01 11:10:42 | Firmware vboot info |
                          boot_mode=Developer |
                          fw_tried=B | fw_try_count=0 |
                          fw_prev_tried=B | fw_prev_result=Unknown
9 | 2022-07-01 11:11:42 | System boot | 361
10 | 2022-07-01 11:11:42 | System Reset
11 | 2022-07-01 11:11:42 | Firmware vboot info |
			  boot_mode=Developer |
			  fw_tried=B | fw_try_count=0 |
			  fw_prev_tried=B | fw_prev_result=Success

localhost # crossystem recovery_request=1
localhost # elogtool list
41 | 2022-07-13 12:13:48 | Firmware vboot info |
			  boot_mode=Manual recovery boot |
		          recovery_reason: 0x1/0 (Recovery requested
			  from legacy utility) | fw_tried=A |
			  fw_try_count=0 | fw_prev_tried=A |
			  fw_prev_result=Unknown

Signed-off-by: Subrata Banik <subratabanik@google.com>
Change-Id: I48b5d54723683cef51e416fc6f58da000507fbcc
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65562
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/util/cbfstool/eventlog.c b/util/cbfstool/eventlog.c
index 120bb40..e9a4e8e 100644
--- a/util/cbfstool/eventlog.c
+++ b/util/cbfstool/eventlog.c
@@ -158,6 +158,7 @@
 		{ELOG_TYPE_EC_DEVICE_EVENT, "EC Device"},
 		{ELOG_TYPE_EXTENDED_EVENT, "Extended Event"},
 		{ELOG_TYPE_CROS_DIAGNOSTICS, "Diagnostics Mode"},
+		{ELOG_TYPE_FW_VBOOT_INFO, "Firmware vboot info"},
 
 		{ELOG_TYPE_EOL, "End of log"},
 	};
@@ -623,6 +624,24 @@
 	case ELOG_TYPE_CROS_DIAGNOSTICS: {
 		const uint8_t *type = event_get_data(event);
 		eventlog_printf("%s", val2str(*type, cros_diagnostics_types));
+		break;
+	}
+	case ELOG_TYPE_FW_VBOOT_INFO: {
+		const union vb2_fw_boot_info *info = event_get_data(event);
+
+		eventlog_printf("boot_mode=%s", vb2_boot_mode_string(info->boot_mode));
+
+		if (info->boot_mode == VB2_BOOT_MODE_BROKEN_SCREEN ||
+		    info->boot_mode == VB2_BOOT_MODE_MANUAL_RECOVERY)
+			eventlog_printf("recovery_reason=%#x/%#x (%s)",
+				  info->recovery_reason, info->recovery_subcode,
+				  vb2_get_recovery_reason_string(info->recovery_reason));
+
+		eventlog_printf("fw_tried=%s", vb2_slot_string(info->slot));
+		eventlog_printf("fw_try_count=%d", info->tries);
+		eventlog_printf("fw_prev_tried=%s", vb2_slot_string(info->prev_slot));
+		eventlog_printf("fw_prev_result=%s", vb2_result_string(info->prev_result));
+		break;
 	}
 	default:
 		break;