coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cbfs_serialized.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only */
2 
3 #ifndef _CBFS_SERIALIZED_H_
4 #define _CBFS_SERIALIZED_H_
5 
6 #include <stdint.h>
7 #include <vb2_sha.h>
8 
13 };
14 
15 enum cbfs_type {
16  /* QUERY is an alias for DELETED that can be passed to CBFS APIs to
17  inquire about the type of a file, rather than constrain it. */
19  CBFS_TYPE_DELETED = 0x00000000,
20  CBFS_TYPE_NULL = 0xffffffff,
26  CBFS_TYPE_FIT = 0x21,
29  CBFS_TYPE_RAW = 0x50,
30  CBFS_TYPE_VSA = 0x51,
31  CBFS_TYPE_MBI = 0x52,
33  CBFS_TYPE_FSP = 0x60,
34  CBFS_TYPE_MRC = 0x61,
35  CBFS_TYPE_MMA = 0x62,
36  CBFS_TYPE_EFI = 0x63,
39  CBFS_TYPE_SPD = 0xab,
42 };
43 
44 #define CBFS_HEADER_MAGIC 0x4F524243 /* BE: 'ORBC' */
45 #define CBFS_HEADER_VERSION1 0x31313131 /* BE: '1111' */
46 #define CBFS_HEADER_VERSION2 0x31313132 /* BE: '1112' */
47 #define CBFS_HEADER_VERSION CBFS_HEADER_VERSION2
48 
49 /* this is the master cbfs header - it must be located somewhere available
50  * to bootblock (to load romstage). The last 4 bytes in the image contain its
51  * relative offset from the end of the image (as a 32-bit signed integer). */
52 
53 struct cbfs_header {
58  uint32_t align; /* fixed to 64 bytes */
63 
64 /* this used to be flexible, but wasn't ever set to something different. */
65 #define CBFS_ALIGNMENT 64
66 
67 /* "Unknown" refers to CBFS headers version 1,
68  * before the architecture was defined (i.e., x86 only).
69  */
72  CBFS_ARCHITECTURE_X86 = 0x00000001,
73  CBFS_ARCHITECTURE_ARM = 0x00000010,
75  CBFS_ARCHITECTURE_MIPS = 0x00000100, /* deprecated */
78 };
79 
80 /** This is a component header - every entry in the CBFS
81  will have this header.
82 
83  This is how the component is arranged in the ROM:
84 
85  -------------- <- 0
86  component header
87  -------------- <- sizeof(struct component)
88  component name
89  -------------- <- offset
90  data
91  ...
92  -------------- <- offset + len
93 */
94 
95 #define CBFS_FILE_MAGIC "LARCHIVE"
96 #define CBFS_METADATA_MAX_SIZE 256
97 
98 struct cbfs_file {
99  char magic[8];
104  char filename[0];
105 } __packed;
106 
107 #if defined __GNUC__ && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
108 _Static_assert(sizeof(struct cbfs_file) == 24, "cbfs_file size mismatch");
109 #endif
110 
111 /* The common fields of extended cbfs file attributes.
112  Attributes are expected to start with tag/len, then append their
113  specific fields. */
116  /* len covers the whole structure, incl. tag and len */
119 } __packed;
120 
121 /* All attribute sizes must be divisible by this! */
122 #define CBFS_ATTRIBUTE_ALIGN 4
123 
124 /* Depending on how the header was initialized, it may be backed with 0x00 or
125  * 0xff. Support both. */
129  CBFS_FILE_ATTR_TAG_COMPRESSION = 0x42435a4c, /* BE: 'BCZL' */
130  CBFS_FILE_ATTR_TAG_HASH = 0x68736148, /* BE: 'hsaH' */
131  CBFS_FILE_ATTR_TAG_POSITION = 0x42435350, /* BE: 'BCSP' */
132  CBFS_FILE_ATTR_TAG_ALIGNMENT = 0x42434c41, /* BE: 'BCLA' */
133  CBFS_FILE_ATTR_TAG_IBB = 0x32494242, /* BE: '2IBB' */
134  CBFS_FILE_ATTR_TAG_PADDING = 0x47444150, /* BE: 'GNDP' */
135  CBFS_FILE_ATTR_TAG_STAGEHEADER = 0x53746748, /* BE: 'StgH' */
136 };
137 
141  /* whole file compression format. 0 if no compression. */
144 } __packed;
145 
146 /* Actual size in CBFS may be larger/smaller than struct size! */
150  struct vb2_hash hash;
151 } __packed;
152 
157 } __packed;
158 
163 } __packed;
164 
168  uint64_t loadaddr; /* Memory address to load the code to. */
169  uint32_t entry_offset; /* Offset of entry point from loadaddr. */
170  uint32_t memlen; /* Total length (including BSS) in memory. */
171 } __packed;
172 
173 
174 /*** Component sub-headers ***/
175 
176 /* Following are component sub-headers for the "standard"
177  component types */
178 
179 /** this is the sub-header for payload components. Payloads
180  are loaded by coreboot at the end of the boot process */
181 
189 } __packed;
190 
191 struct cbfs_payload {
193 };
194 
196  PAYLOAD_SEGMENT_CODE = 0x434F4445, /* BE: 'CODE' */
197  PAYLOAD_SEGMENT_DATA = 0x44415441, /* BE: 'DATA' */
198  PAYLOAD_SEGMENT_BSS = 0x42535320, /* BE: 'BSS ' */
199  PAYLOAD_SEGMENT_PARAMS = 0x50415241, /* BE: 'PARA' */
200  PAYLOAD_SEGMENT_ENTRY = 0x454E5452, /* BE: 'ENTR' */
201 };
202 
206 } __packed;
207 
208 #endif /* _CBFS_SERIALIZED_H_ */
struct cbfs_header __packed
cbfs_compression
@ CBFS_COMPRESS_LZMA
@ CBFS_COMPRESS_NONE
@ CBFS_COMPRESS_LZ4
cbfs_architecture
@ CBFS_ARCHITECTURE_ARM
@ CBFS_ARCHITECTURE_RISCV
@ CBFS_ARCHITECTURE_PPC64
@ CBFS_ARCHITECTURE_MIPS
@ CBFS_ARCHITECTURE_X86
@ CBFS_ARCHITECTURE_AARCH64
@ CBFS_ARCHITECTURE_UNKNOWN
cbfs_payload_segment_type
@ PAYLOAD_SEGMENT_ENTRY
@ PAYLOAD_SEGMENT_DATA
@ PAYLOAD_SEGMENT_CODE
@ PAYLOAD_SEGMENT_BSS
@ PAYLOAD_SEGMENT_PARAMS
cbfs_type
@ CBFS_TYPE_MRC
@ CBFS_TYPE_VSA
@ CBFS_TYPE_SELF
@ CBFS_TYPE_MBI
@ CBFS_TYPE_STAGE
@ CBFS_TYPE_QUERY
@ CBFS_TYPE_LEGACY_STAGE
@ CBFS_TYPE_RAW
@ CBFS_TYPE_OPTIONROM
@ CBFS_TYPE_SPD
@ CBFS_TYPE_FIT
@ CBFS_TYPE_DELETED
@ CBFS_TYPE_CMOS_DEFAULT
@ CBFS_TYPE_MICROCODE
@ CBFS_TYPE_MMA
@ CBFS_TYPE_FSP
@ CBFS_TYPE_NULL
@ CBFS_TYPE_MRC_CACHE
@ CBFS_TYPE_EFI
@ CBFS_TYPE_CBFSHEADER
@ CBFS_TYPE_STRUCT
@ CBFS_TYPE_BOOTBLOCK
@ CBFS_TYPE_CMOS_LAYOUT
@ CBFS_TYPE_BOOTSPLASH
cbfs_file_attr_tag
@ CBFS_FILE_ATTR_TAG_UNUSED2
@ CBFS_FILE_ATTR_TAG_PADDING
@ CBFS_FILE_ATTR_TAG_ALIGNMENT
@ CBFS_FILE_ATTR_TAG_POSITION
@ CBFS_FILE_ATTR_TAG_HASH
@ CBFS_FILE_ATTR_TAG_UNUSED
@ CBFS_FILE_ATTR_TAG_COMPRESSION
@ CBFS_FILE_ATTR_TAG_IBB
@ CBFS_FILE_ATTR_TAG_STAGEHEADER
_Static_assert(sizeof(hls_t)==HLS_SIZE, "HLS_SIZE must equal to sizeof(hls_t)")
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
unsigned char uint8_t
Definition: stdint.h:8
struct vb2_hash hash
char magic[8]
uint32_t len
uint32_t offset
uint32_t type
char filename[0]
uint32_t attributes_offset
uint32_t offset
uint32_t romsize
uint32_t bootblocksize
uint32_t pad[1]
uint32_t architecture
uint32_t version
uint32_t align
uint32_t magic
uint32_t compression
this is the sub-header for payload components.
struct cbfs_payload_segment segments