1 /* SPDX-License-Identifier: GPL-2.0-only or BSD-3-Clause */
6 #include "coreboot_tables.h"
13 /** These are standard values for the known compression
14 algorithms that coreboot knows about for stages and
15 payloads. Of course, other CBFS users can use whatever
16 values they want, as long as they understand them. */
18 #define CBFS_COMPRESS_NONE 0
19 #define CBFS_COMPRESS_LZMA 1
20 #define CBFS_COMPRESS_LZ4 2
22 /** These are standard component types for well known
23 components (i.e - those that coreboot needs to consume.
24 Users are welcome to use any other value for their
27 #define CBFS_TYPE_STAGE 0x10
28 #define CBFS_TYPE_SELF 0x20
29 #define CBFS_TYPE_FIT_PAYLOAD 0x21
30 #define CBFS_TYPE_OPTIONROM 0x30
31 #define CBFS_TYPE_BOOTSPLASH 0x40
32 #define CBFS_TYPE_RAW 0x50
33 #define CBFS_TYPE_VSA 0x51
34 #define CBFS_TYPE_MBI 0x52
35 #define CBFS_TYPE_MICROCODE 0x53
36 #define CBFS_COMPONENT_CMOS_DEFAULT 0xaa
37 #define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa
40 /** this is the master cbfs header - it need to be
41 located somewhere in the bootblock. Where it
42 actually lives is up to coreboot. A pointer to
43 this header will live at 0xFFFFFFFc, so we can
46 #define CBFS_HEADER_MAGIC 0x4F524243
47 #define CBFS_HEADPTR_ADDR 0xFFFFFFFc
48 #define CBFS_HEADER_VERSION1 0x31313131
58 } __attribute__((packed
));
60 /** This is a component header - every entry in the CBFS
61 will have this header.
63 This is how the component is arranged in the ROM:
67 -------------- <- sizeof(struct component)
69 -------------- <- offset
72 -------------- <- offset + len
75 #define CBFS_FILE_MAGIC "LARCHIVE"
83 } __attribute__((packed
));
85 /*** Component sub-headers ***/
87 /* Following are component sub-headers for the "standard"
90 /** This is the sub-header for stage components. Stages are
91 loaded by coreboot during the normal boot process */
94 u32 compression
; /** Compression type */
95 u64 entry
; /** entry point */
96 u64 load
; /** Where to load in memory */
97 u32 len
; /** length of data to load */
98 u32 memlen
; /** total length of object in memory */
99 } __attribute__((packed
));
101 /** this is the sub-header for payload components. Payloads
102 are loaded by coreboot at the end of the boot process */
104 struct cbfs_payload_segment
{
111 } __attribute__((packed
));
113 struct cbfs_payload
{
114 struct cbfs_payload_segment segments
;
117 #define PAYLOAD_SEGMENT_CODE 0x45444F43
118 #define PAYLOAD_SEGMENT_DATA 0x41544144
119 #define PAYLOAD_SEGMENT_BSS 0x20535342
120 #define PAYLOAD_SEGMENT_PARAMS 0x41524150
121 #define PAYLOAD_SEGMENT_ENTRY 0x52544E45
123 struct cbfs_optionrom
{
126 } __attribute__((packed
));
128 #define CBFS_NAME(_c) (((char *) (_c)) + sizeof(struct cbfs_file))
129 #define CBFS_SUBHEADER(_p) ( (void *) ((((u8 *) (_p)) + ntohl((_p)->offset))) )
131 void * cbfs_get_file(const char *name
);
132 struct cbfs_file
*cbfs_find(const char *name
);
133 void *cbfs_find_file(const char *name
, unsigned int type
, unsigned int *len
);
135 void open_cbfs(const char *filename
);