1 #ifndef COREBOOT_TABLES_H
2 #define COREBOOT_TABLES_H
6 /* The coreboot table information is for conveying information
7 * from the firmware to the loaded OS image. Primarily this
8 * is expected to be information that cannot be discovered by
9 * other means, such as quering the hardware directly.
11 * All of the information should be Position Independent Data.
12 * That is it should be safe to relocated any of the information
13 * without it's meaning/correctnes changing. For table that
14 * can reasonably be used on multiple architectures the data
15 * size should be fixed. This should ease the transition between
16 * 32 bit and 64 bit architectures etc.
18 * The completeness test for the information in this table is:
19 * - Can all of the hardware be detected?
20 * - Are the per motherboard constants available?
21 * - Is there enough to allow a kernel to run that was written before
22 * a particular motherboard is constructed? (Assuming the kernel
23 * has drivers for all of the hardware but it does not have
24 * assumptions on how the hardware is connected together).
26 * With this test it should be straight forward to determine if a
27 * table entry is required or not. This should remove much of the
28 * long term compatibility burden as table entries which are
29 * irrelevant or have been replaced by better alternatives may be
30 * dropped. Of course it is polite and expidite to include extra
31 * table entries and be backwards compatible, but it is not required.
34 /* Since coreboot is usually compiled 32bit, gcc will align 64bit
35 * types to 32bit boundaries. If the coreboot table is dumped on a
36 * 64bit system, a uint64_t would be aligned to 64bit boundaries,
37 * breaking the table format.
39 * lb_uint64 will keep 64bit coreboot table values aligned to 32bit
40 * to ensure compatibility. They can be accessed with the two functions
41 * below: unpack_lb64() and pack_lb64()
43 * See also: util/lbtdump/lbtdump.c
51 static inline uint64_t unpack_lb64(struct lb_uint64 value)
55 result = (result << 32) + value.lo;
59 static inline struct lb_uint64 pack_lb64(uint64_t value)
61 struct lb_uint64 result;
62 result.lo = (value >> 0) & 0xffffffff;
63 result.hi = (value >> 32) & 0xffffffff;
71 uint8_t signature[4]; /* LBIO */
72 uint32_t header_bytes;
73 uint32_t header_checksum;
75 uint32_t table_checksum;
76 uint32_t table_entries;
79 /* Every entry in the boot enviroment list will correspond to a boot
80 * info record. Encoding both type and size. The type is obviously
81 * so you can tell what it is. The size allows you to skip that
82 * boot enviroment record if you don't know what it easy. This allows
83 * forward compatibility with records not yet defined.
86 uint32_t tag; /* tag ID */
87 uint32_t size; /* size of record (in bytes) */
90 #define LB_TAG_UNUSED 0x0000
92 #define LB_TAG_MEMORY 0x0001
94 struct lb_memory_range {
95 struct lb_uint64 start;
96 struct lb_uint64 size;
98 #define LB_MEM_RAM 1 /* Memory anyone can use */
99 #define LB_MEM_RESERVED 2 /* Don't use this memory region */
100 #define LB_MEM_ACPI 3 /* ACPI Tables */
101 #define LB_MEM_NVS 4 /* ACPI NVS Memory */
102 #define LB_MEM_UNUSABLE 5 /* Unusable address space */
103 #define LB_MEM_VENDOR_RSVD 6 /* Vendor Reserved */
104 #define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */
110 struct lb_memory_range map[0];
113 #define LB_TAG_HWRPB 0x0002
120 #define LB_TAG_MAINBOARD 0x0003
121 struct lb_mainboard {
125 uint8_t part_number_idx;
129 #define LB_TAG_VERSION 0x0004
130 #define LB_TAG_EXTRA_VERSION 0x0005
131 #define LB_TAG_BUILD 0x0006
132 #define LB_TAG_COMPILE_TIME 0x0007
133 #define LB_TAG_COMPILE_BY 0x0008
134 #define LB_TAG_COMPILE_HOST 0x0009
135 #define LB_TAG_COMPILE_DOMAIN 0x000a
136 #define LB_TAG_COMPILER 0x000b
137 #define LB_TAG_LINKER 0x000c
138 #define LB_TAG_ASSEMBLER 0x000d
145 /* 0xe is taken by v3 */
147 #define LB_TAG_SERIAL 0x000f
155 #define LB_TAG_CONSOLE 0x0010
162 #define LB_TAG_FORWARD 0x0011
169 #define LB_TAG_CONSOLE_SERIAL8250 0
170 #define LB_TAG_CONSOLE_VGA 1
171 #define LB_TAG_CONSOLE_BTEXT 2
172 #define LB_TAG_CONSOLE_LOGBUF 3
173 #define LB_TAG_CONSOLE_SROM 4
174 #define LB_TAG_CONSOLE_EHCI 5
176 /* The following structures are for the cmos definitions table */
177 #define LB_TAG_CMOS_OPTION_TABLE 200
178 /* cmos header record */
179 struct cmos_option_table {
180 uint32_t tag; /* CMOS definitions table type */
181 uint32_t size; /* size of the entire table */
182 uint32_t header_length; /* length of header */
186 This record is variable length. The name field may be
187 shorter than CMOS_MAX_NAME_LENGTH. The entry may start
188 anywhere in the byte, but can not span bytes unless it
189 starts at the beginning of the byte and the length is
190 fills complete bytes.
192 #define LB_TAG_OPTION 201
193 struct cmos_entries {
194 uint32_t tag; /* entry type */
195 uint32_t size; /* length of this record */
196 uint32_t bit; /* starting bit from start of image */
197 uint32_t length; /* length of field in bits */
198 uint32_t config; /* e=enumeration, h=hex, r=reserved */
199 uint32_t config_id; /* a number linking to an enumeration record */
200 #define CMOS_MAX_NAME_LENGTH 32
201 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
202 variable length int aligned */
206 /* cmos enumerations record
207 This record is variable length. The text field may be
208 shorter than CMOS_MAX_TEXT_LENGTH.
210 #define LB_TAG_OPTION_ENUM 202
212 uint32_t tag; /* enumeration type */
213 uint32_t size; /* length of this record */
214 uint32_t config_id; /* a number identifying the config id */
215 uint32_t value; /* the value associated with the text */
216 #define CMOS_MAX_TEXT_LENGTH 32
217 uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
218 variable length int aligned */
221 /* cmos defaults record
222 This record contains default settings for the cmos ram.
224 #define LB_TAG_OPTION_DEFAULTS 203
225 struct cmos_defaults {
226 uint32_t tag; /* default type */
227 uint32_t size; /* length of this record */
228 uint32_t name_length; /* length of the following name field */
229 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
230 #define CMOS_IMAGE_BUFFER_SIZE 256
231 uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
234 #define LB_TAG_OPTION_CHECKSUM 204
235 struct cmos_checksum {
238 /* In practice everything is byte aligned, but things are measured
239 * in bits to be consistent.
241 uint32_t range_start; /* First bit that is checksummed (byte aligned) */
242 uint32_t range_end; /* Last bit that is checksummed (byte aligned) */
243 uint32_t location; /* First bit of the checksum (byte aligned) */
244 uint32_t type; /* Checksum algorithm that is used */
245 #define CHECKSUM_NONE 0
246 #define CHECKSUM_PCBIOS 1
251 #endif /* COREBOOT_TABLES_H */