blob: d6e1b769425da9a54f64871891934b67792b28e7 [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
11 * code which may be obtained from http://www.coreboot.org/.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000012 * Specifically, this code was obtained from LinuxBIOS version 1.1.8.
13 */
14
Stefan Reinauerf527e702008-01-18 15:33:49 +000015/* The coreboot table information is for conveying information
Stefan Reinauer6540ae52007-07-12 16:35:42 +000016 * from the firmware to the loaded OS image. Primarily this
17 * is expected to be information that cannot be discovered by
18 * other means, such as quering the hardware directly.
19 *
20 * All of the information should be Position Independent Data.
21 * That is it should be safe to relocated any of the information
22 * without it's meaning/correctnes changing. For table that
23 * can reasonably be used on multiple architectures the data
24 * size should be fixed. This should ease the transition between
25 * 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?
29 * - Are the per motherboard constants available?
30 * - 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 *
35 * With this test it should be straight forward 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
38 * irrelevant or have been replaced by better alternatives may be
39 * dropped. Of course it is polite and expidite to include extra
40 * table entries and be backwards compatible, but it is not required.
41 */
42
Stefan Reinauerf527e702008-01-18 15:33:49 +000043/* Since coreboot is usually compiled 32bit, gcc will align 64bit
44 * types to 32bit boundaries. If the coreboot table is dumped on a
Stefan Reinauer6540ae52007-07-12 16:35:42 +000045 * 64bit system, a uint64_t would be aligned to 64bit boundaries,
46 * 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 {
77 uint8_t signature[4]; /* LBIO */
78 uint32_t header_bytes;
79 uint32_t header_checksum;
80 uint32_t table_bytes;
81 uint32_t table_checksum;
82 uint32_t table_entries;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000083};
84
85/* Every entry in the boot enviroment list will correspond to a boot
86 * info record. Encoding both type and size. The type is obviously
87 * so you can tell what it is. The size allows you to skip that
88 * boot enviroment record if you don't know what it easy. This allows
89 * forward compatibility with records not yet defined.
90 */
91struct lb_record {
Stefan Reinauer90b96b62010-01-13 21:00:23 +000092 uint32_t tag; /* tag ID */
93 uint32_t size; /* size of record (in bytes) */
Stefan Reinauer6540ae52007-07-12 16:35:42 +000094};
95
96#define LB_TAG_UNUSED 0x0000
97
98#define LB_TAG_MEMORY 0x0001
99
100struct lb_memory_range {
101 struct lb_uint64 start;
102 struct lb_uint64 size;
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000103 uint32_t type;
104#define LB_MEM_RAM 1 /* Memory anyone can use */
105#define LB_MEM_RESERVED 2 /* Don't use this memory region */
106#define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000107};
108
109struct lb_memory {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000110 uint32_t tag;
111 uint32_t size;
112 struct lb_memory_range map[0];
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000113};
114
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000115#define LB_TAG_HWRPB 0x0002
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000116struct lb_hwrpb {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000117 uint32_t tag;
118 uint32_t size;
119 uint64_t hwrpb;
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000120};
121
122#define LB_TAG_MAINBOARD 0x0003
123struct lb_mainboard {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000124 uint32_t tag;
125 uint32_t size;
126 uint8_t vendor_idx;
127 uint8_t part_number_idx;
128 uint8_t strings[0];
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000129};
130
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000131#define LB_TAG_VERSION 0x0004
132#define LB_TAG_EXTRA_VERSION 0x0005
133#define LB_TAG_BUILD 0x0006
134#define LB_TAG_COMPILE_TIME 0x0007
135#define LB_TAG_COMPILE_BY 0x0008
136#define LB_TAG_COMPILE_HOST 0x0009
137#define LB_TAG_COMPILE_DOMAIN 0x000a
138#define LB_TAG_COMPILER 0x000b
139#define LB_TAG_LINKER 0x000c
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000140#define LB_TAG_ASSEMBLER 0x000d
141struct lb_string {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000142 uint32_t tag;
143 uint32_t size;
144 uint8_t string[0];
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000145};
Stefan Reinauer764fe402009-03-17 14:39:36 +0000146#define LB_TAG_SERIAL 0x000f
147#define LB_TAG_CONSOLE 0x0010
148#define LB_TAG_FORWARD 0x0011
149struct lb_forward {
150 uint32_t tag;
151 uint32_t size;
152 uint64_t forward;
153};
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000154
155/* The following structures are for the cmos definitions table */
156#define LB_TAG_CMOS_OPTION_TABLE 200
157/* cmos header record */
158struct cmos_option_table {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000159 uint32_t tag; /* CMOS definitions table type */
160 uint32_t size; /* size of the entire table */
161 uint32_t header_length; /* length of header */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000162};
163
164/* cmos entry record
165 This record is variable length. The name field may be
166 shorter than CMOS_MAX_NAME_LENGTH. The entry may start
167 anywhere in the byte, but can not span bytes unless it
168 starts at the beginning of the byte and the length is
169 fills complete bytes.
170*/
171#define LB_TAG_OPTION 201
172struct cmos_entries {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000173 uint32_t tag; /* entry type */
174 uint32_t size; /* length of this record */
175 uint32_t bit; /* starting bit from start of image */
176 uint32_t length; /* length of field in bits */
177 uint32_t config; /* e=enumeration, h=hex, r=reserved */
178 uint32_t config_id; /* a number linking to an enumeration record */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000179#define CMOS_MAX_NAME_LENGTH 32
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000180 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
181 variable length int aligned */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000182};
183
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000184/* cmos enumerations record
185 This record is variable length. The text field may be
186 shorter than CMOS_MAX_TEXT_LENGTH.
187*/
188#define LB_TAG_OPTION_ENUM 202
189struct cmos_enums {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000190 uint32_t tag; /* enumeration type */
191 uint32_t size; /* length of this record */
192 uint32_t config_id; /* a number identifying the config id */
193 uint32_t value; /* the value associated with the text */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000194#define CMOS_MAX_TEXT_LENGTH 32
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000195 uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
196 variable length int aligned */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000197};
198
199/* cmos defaults record
200 This record contains default settings for the cmos ram.
201*/
202#define LB_TAG_OPTION_DEFAULTS 203
203struct cmos_defaults {
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000204 uint32_t tag; /* default type */
205 uint32_t size; /* length of this record */
206 uint32_t name_length; /* length of the following name field */
207 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000208#define CMOS_IMAGE_BUFFER_SIZE 128
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000209 uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000210};
211
212#define LB_TAG_OPTION_CHECKSUM 204
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000213struct cmos_checksum {
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000214 uint32_t tag;
215 uint32_t size;
216 /* In practice everything is byte aligned, but things are measured
217 * in bits to be consistent.
218 */
219 uint32_t range_start; /* First bit that is checksummed (byte aligned) */
220 uint32_t range_end; /* Last bit that is checksummed (byte aligned) */
221 uint32_t location; /* First bit of the checksum (byte aligned) */
222 uint32_t type; /* Checksum algorithm that is used */
223#define CHECKSUM_NONE 0
224#define CHECKSUM_PCBIOS 1
225};
226
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000227#endif /* COREBOOT_TABLES_H */