xref: /aosp_15_r20/external/coreboot/src/lib/cbfs_master_header.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <endian.h>
4 #include <fmap_config.h>
5 #include <commonlib/bsd/cbfs_serialized.h>
6 
7 struct cbfs_header header = {
8 	.magic = cpu_to_be32(CBFS_HEADER_MAGIC),
9 	.version = cpu_to_be32(CBFS_HEADER_VERSION),
10 	/*
11 	 * The offset and romsize fields within the master header are absolute
12 	 * values within the boot media. As such, romsize needs to reflect
13 	 * the end 'offset' for a CBFS. To achieve that the current buffer
14 	 * representing the CBFS region's size is added to the offset of
15 	 * the region within a larger image.
16 	 */
17 	.romsize = cpu_to_be32(FMAP_SECTION_COREBOOT_START + FMAP_SECTION_COREBOOT_SIZE
18 			       - FMAP_SECTION_FLASH_START),
19 	/*
20 	 * The 4 bytes are left out for two reasons:
21 	 * 1. the cbfs master header pointer resides there
22 	 * 2. some cbfs implementations assume that an image that resides
23 	 *    below 4GB has a bootblock and get confused when the end of the
24 	 *    image is at 4GB == 0.
25 	 */
26 	.bootblocksize = cpu_to_be32(4),
27 	.align = cpu_to_be32(CBFS_ALIGNMENT),
28 	.offset = cpu_to_be32(FMAP_SECTION_COREBOOT_START - FMAP_SECTION_FLASH_START),
29 	.architecture = cpu_to_be32(CBFS_ARCHITECTURE_UNKNOWN),
30 };
31