blob: 1417c19ba1dc888f1dc0620fbf45700cc73e1345 [file] [log] [blame]
Stefan Reinauer6540ae52007-07-12 16:35:42 +00001/*****************************************************************************\
Stefan Reinauer7223ab72008-01-18 16:17:44 +00002 * coreboot_tables.h
Stefan Reinauer6540ae52007-07-12 16:35:42 +00003\*****************************************************************************/
4
Stefan Reinauerf527e702008-01-18 15:33:49 +00005#ifndef COREBOOT_TABLES_H
6#define COREBOOT_TABLES_H
Stefan Reinauer6540ae52007-07-12 16:35:42 +00007
8#include <stdint.h>
9
Stefan Reinauerf527e702008-01-18 15:33:49 +000010/* Note: The contents of this file were borrowed from the coreboot source
Elyes HAOUASfcd70082018-08-23 18:19:52 +020011 * code which may be obtained from https://www.coreboot.org/.
12 * Specifically, this code was obtained from LinuxBIOS version 1.1.8.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000013 */
14
Stefan Reinauerf527e702008-01-18 15:33:49 +000015/* The coreboot table information is for conveying information
Elyes HAOUASfcd70082018-08-23 18:19:52 +020016 * from the firmware to the loaded OS image. Primarily this
Stefan Reinauer6540ae52007-07-12 16:35:42 +000017 * is expected to be information that cannot be discovered by
Elyes HAOUASfcd70082018-08-23 18:19:52 +020018 * other means, such as querying the hardware directly.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000019 *
Stefan Reinauer14e22772010-04-27 06:56:47 +000020 * All of the information should be Position Independent Data.
Elyes HAOUASfcd70082018-08-23 18:19:52 +020021 * That is, it should be safe to relocate any of the information
22 * without changing its meaning/correctness. For tables that
Stefan Reinauer6540ae52007-07-12 16:35:42 +000023 * can reasonably be used on multiple architectures the data
Elyes HAOUASfcd70082018-08-23 18:19:52 +020024 * size should be fixed. This should ease the transition between
Stefan Reinauer6540ae52007-07-12 16:35:42 +000025 * 32 bit and 64 bit architectures etc.
26 *
27 * The completeness test for the information in this table is:
28 * - Can all of the hardware be detected?
Elyes HAOUASfcd70082018-08-23 18:19:52 +020029 * - Are the per-motherboard constants available?
Stefan Reinauer6540ae52007-07-12 16:35:42 +000030 * - Is there enough to allow a kernel to run that was written before
31 * a particular motherboard is constructed? (Assuming the kernel
32 * has drivers for all of the hardware but it does not have
33 * assumptions on how the hardware is connected together).
34 *
Elyes HAOUASfcd70082018-08-23 18:19:52 +020035 * With this test it should be straightforward to determine if a
36 * table entry is required or not. This should remove much of the
37 * long-term compatibility burden as table entries which are
Stefan Reinauer6540ae52007-07-12 16:35:42 +000038 * irrelevant or have been replaced by better alternatives may be
Elyes HAOUASfcd70082018-08-23 18:19:52 +020039 * dropped. Of course it is polite and expedite to include extra
Stefan Reinauer6540ae52007-07-12 16:35:42 +000040 * table entries and be backwards compatible, but it is not required.
41 */
42
Stefan Reinauer14e22772010-04-27 06:56:47 +000043/* Since coreboot is usually compiled 32bit, gcc will align 64bit
44 * types to 32bit boundaries. If the coreboot table is dumped on a
45 * 64bit system, a uint64_t would be aligned to 64bit boundaries,
Stefan Reinauer6540ae52007-07-12 16:35:42 +000046 * breaking the table format.
47 *
Stefan Reinauerf527e702008-01-18 15:33:49 +000048 * lb_uint64 will keep 64bit coreboot table values aligned to 32bit
Stefan Reinauer6540ae52007-07-12 16:35:42 +000049 * to ensure compatibility. They can be accessed with the two functions
50 * below: unpack_lb64() and pack_lb64()
51 *
52 * See also: util/lbtdump/lbtdump.c
53 */
54
55struct lb_uint64 {
56 uint32_t lo;
57 uint32_t hi;
58};
59
60static inline uint64_t unpack_lb64(struct lb_uint64 value)
61{
Stefan Reinauer90b96b62010-01-13 21:00:23 +000062 uint64_t result;
63 result = value.hi;
64 result = (result << 32) + value.lo;
65 return result;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000066}
67
68static inline struct lb_uint64 pack_lb64(uint64_t value)
69{
Stefan Reinauer90b96b62010-01-13 21:00:23 +000070 struct lb_uint64 result;
71 result.lo = (value >> 0) & 0xffffffff;
72 result.hi = (value >> 32) & 0xffffffff;
73 return result;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000074}
75
Stefan Reinauer90b96b62010-01-13 21:00:23 +000076struct lb_header {
Patrick Georgi26016972011-01-18 12:12:47 +000077 union {
78 uint8_t signature[4]; /* LBIO */
79 uint32_t signature32;
80 };
Stefan Reinauer90b96b62010-01-13 21:00:23 +000081 uint32_t header_bytes;
82 uint32_t header_checksum;
83 uint32_t table_bytes;
84 uint32_t table_checksum;
85 uint32_t table_entries;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000086};
87
Elyes HAOUASfcd70082018-08-23 18:19:52 +020088/* Every entry in the boot environment list will correspond to a boot
89 * info record, encoding both type and size. The type is obviously
90 * so you can tell what it is. The size allows you to skip that
91 * boot environment record if you don't know what it is. This allows
Stefan Reinauer6540ae52007-07-12 16:35:42 +000092 * forward compatibility with records not yet defined.
93 */
94struct lb_record {
Stefan Reinauer90b96b62010-01-13 21:00:23 +000095 uint32_t tag; /* tag ID */
96 uint32_t size; /* size of record (in bytes) */
Stefan Reinauer6540ae52007-07-12 16:35:42 +000097};
98
Elyes HAOUASfcd70082018-08-23 18:19:52 +020099#define LB_TAG_UNUSED 0x0000
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000100
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200101#define LB_TAG_MEMORY 0x0001
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000102
103struct lb_memory_range {
104 struct lb_uint64 start;
105 struct lb_uint64 size;
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000106 uint32_t type;
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200107#define LB_MEM_RAM 1 /* Memory anyone can use */
108#define LB_MEM_RESERVED 2 /* Don't use this memory region */
109#define LB_MEM_TABLE 16 /* RAM configuration tables are kept in */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000110};
111
112struct lb_memory {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000113 uint32_t tag;
114 uint32_t size;
115 struct lb_memory_range map[0];
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000116};
117
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200118#define LB_TAG_HWRPB 0x0002
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000119struct lb_hwrpb {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000120 uint32_t tag;
121 uint32_t size;
122 uint64_t hwrpb;
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000123};
124
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200125#define LB_TAG_MAINBOARD 0x0003
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000126struct lb_mainboard {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000127 uint32_t tag;
128 uint32_t size;
129 uint8_t vendor_idx;
130 uint8_t part_number_idx;
131 uint8_t strings[0];
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000132};
133
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200134#define LB_TAG_VERSION 0x0004
135#define LB_TAG_EXTRA_VERSION 0x0005
136#define LB_TAG_BUILD 0x0006
137#define LB_TAG_COMPILE_TIME 0x0007
138#define LB_TAG_COMPILE_BY 0x0008
139#define LB_TAG_COMPILE_HOST 0x0009
140#define LB_TAG_COMPILE_DOMAIN 0x000a
141#define LB_TAG_COMPILER 0x000b
142#define LB_TAG_LINKER 0x000c
143#define LB_TAG_ASSEMBLER 0x000d
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000144struct lb_string {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000145 uint32_t tag;
146 uint32_t size;
147 uint8_t string[0];
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000148};
Stefan Reinauer764fe402009-03-17 14:39:36 +0000149#define LB_TAG_SERIAL 0x000f
150#define LB_TAG_CONSOLE 0x0010
151#define LB_TAG_FORWARD 0x0011
152struct lb_forward {
153 uint32_t tag;
154 uint32_t size;
155 uint64_t forward;
156};
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000157
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200158/* The following structures are for the CMOS definitions table */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000159#define LB_TAG_CMOS_OPTION_TABLE 200
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200160/* CMOS header record */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000161struct cmos_option_table {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000162 uint32_t tag; /* CMOS definitions table type */
163 uint32_t size; /* size of the entire table */
164 uint32_t header_length; /* length of header */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000165};
166
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200167/* CMOS entry record
168 * This record has a variable length. The name field may be
169 * shorter than CMOS_MAX_NAME_LENGTH. The entry may start
170 * anywhere in the byte, but can not span bytes unless it
171 * starts at the beginning of the byte and the length
172 * fills complete bytes.
173 */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000174#define LB_TAG_OPTION 201
175struct cmos_entries {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000176 uint32_t tag; /* entry type */
177 uint32_t size; /* length of this record */
178 uint32_t bit; /* starting bit from start of image */
179 uint32_t length; /* length of field in bits */
180 uint32_t config; /* e=enumeration, h=hex, r=reserved */
181 uint32_t config_id; /* a number linking to an enumeration record */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000182#define CMOS_MAX_NAME_LENGTH 32
Stefan Reinauer14e22772010-04-27 06:56:47 +0000183 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000184 variable length int aligned */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000185};
186
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200187/* CMOS enumerations record
188 * This record has a variable length. The text field may be
189 * shorter than CMOS_MAX_TEXT_LENGTH.
190 */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000191#define LB_TAG_OPTION_ENUM 202
192struct cmos_enums {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000193 uint32_t tag; /* enumeration type */
194 uint32_t size; /* length of this record */
195 uint32_t config_id; /* a number identifying the config id */
196 uint32_t value; /* the value associated with the text */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000197#define CMOS_MAX_TEXT_LENGTH 32
Stefan Reinauer14e22772010-04-27 06:56:47 +0000198 uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000199 variable length int aligned */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000200};
201
Elyes HAOUASfcd70082018-08-23 18:19:52 +0200202/* CMOS default record
203 * This record contains default settings for the CMOS RAM.
204 */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000205#define LB_TAG_OPTION_DEFAULTS 203
206struct cmos_defaults {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000207 uint32_t tag; /* default type */
208 uint32_t size; /* length of this record */
209 uint32_t name_length; /* length of the following name field */
210 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000211#define CMOS_IMAGE_BUFFER_SIZE 128
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000212 uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000213};
214
215#define LB_TAG_OPTION_CHECKSUM 204
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000216struct cmos_checksum {
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000217 uint32_t tag;
218 uint32_t size;
219 /* In practice everything is byte aligned, but things are measured
220 * in bits to be consistent.
221 */
222 uint32_t range_start; /* First bit that is checksummed (byte aligned) */
223 uint32_t range_end; /* Last bit that is checksummed (byte aligned) */
224 uint32_t location; /* First bit of the checksum (byte aligned) */
225 uint32_t type; /* Checksum algorithm that is used */
226#define CHECKSUM_NONE 0
227#define CHECKSUM_PCBIOS 1
228};
229
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000230#endif /* COREBOOT_TABLES_H */