xref: /aosp_15_r20/external/vboot_reference/futility/file_type_bios.h (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1 /* Copyright 2013 The ChromiumOS Authors
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef VBOOT_REFERENCE_FILE_TYPE_BIOS_H_
7 #define VBOOT_REFERENCE_FILE_TYPE_BIOS_H_
8 
9 #include <stdint.h>
10 
11 #include "futility.h"
12 
13 /*
14  * The Chrome OS BIOS must contain specific FMAP areas, which we want to look
15  * at in a certain order.
16  */
17 enum bios_component {
18 	BIOS_FMAP_GBB,
19 	BIOS_FMAP_FW_MAIN_A,
20 	BIOS_FMAP_FW_MAIN_B,
21 	BIOS_FMAP_VBLOCK_A,
22 	BIOS_FMAP_VBLOCK_B,
23 
24 	NUM_BIOS_COMPONENTS
25 };
26 
27 static const char *const fmap_name[] = {
28 	"GBB",	     /* BIOS_FMAP_GBB */
29 	"FW_MAIN_A", /* BIOS_FMAP_FW_MAIN_A */
30 	"FW_MAIN_B", /* BIOS_FMAP_FW_MAIN_B */
31 	"VBLOCK_A",  /* BIOS_FMAP_VBLOCK_A */
32 	"VBLOCK_B",  /* BIOS_FMAP_VBLOCK_B */
33 };
34 _Static_assert(ARRAY_SIZE(fmap_name) == NUM_BIOS_COMPONENTS,
35 	       "Size of fmap_name[] should match NUM_BIOS_COMPONENTS");
36 
37 /* Location information for each component */
38 struct bios_area_s {
39 	uint32_t offset; /* to avoid pointer math */
40 	uint8_t *buf;
41 	uint32_t len;
42 	uint32_t is_valid;
43 
44 	/* VBLOCK only */
45 	uint32_t flags;
46 	uint32_t version;
47 
48 	/* FW_MAIN only */
49 	size_t fw_size; /* effective size from cbfstool (if available) */
50 	struct vb2_hash metadata_hash;
51 };
52 
53 /* State to track as we visit all components */
54 struct bios_state_s {
55 	/* Current component */
56 	enum bios_component c;
57 	/* Other activites, possibly before or after the current one */
58 	struct bios_area_s area[NUM_BIOS_COMPONENTS];
59 	struct bios_area_s recovery_key;
60 	struct bios_area_s rootkey;
61 };
62 
63 int show_fw_preamble_buf(const char *fname, uint8_t *buf, uint32_t len,
64 			 struct bios_state_s *state);
65 
66 #endif /* VBOOT_REFERENCE_FILE_TYPE_BIOS_H_ */
67