Fill out ChromeOS specific coreboot table extensions
[coreboot.git] / src / include / boot / coreboot_tables.h
1 #ifndef COREBOOT_TABLES_H
2 #define COREBOOT_TABLES_H
3
4 #include <stdint.h>
5
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.
10  *
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.
17  *
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).
25  *
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.
32  */
33
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.
38  *
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()
42  *
43  * See also: util/lbtdump/lbtdump.c
44  */
45
46 struct lb_uint64 {
47         uint32_t lo;
48         uint32_t hi;
49 };
50
51 static inline uint64_t unpack_lb64(struct lb_uint64 value)
52 {
53         uint64_t result;
54         result = value.hi;
55         result = (result << 32) + value.lo;
56         return result;
57 }
58
59 static inline struct lb_uint64 pack_lb64(uint64_t value)
60 {
61         struct lb_uint64 result;
62         result.lo = (value >> 0) & 0xffffffff;
63         result.hi = (value >> 32) & 0xffffffff;
64         return result;
65 }
66
67 struct lb_header
68 {
69         uint8_t  signature[4]; /* LBIO */
70         uint32_t header_bytes;
71         uint32_t header_checksum;
72         uint32_t table_bytes;
73         uint32_t table_checksum;
74         uint32_t table_entries;
75 };
76
77 /* Every entry in the boot environment list will correspond to a boot
78  * info record.  Encoding both type and size.  The type is obviously
79  * so you can tell what it is.  The size allows you to skip that
80  * boot environment record if you don't know what it easy.  This allows
81  * forward compatibility with records not yet defined.
82  */
83 struct lb_record {
84         uint32_t tag;           /* tag ID */
85         uint32_t size;          /* size of record (in bytes) */
86 };
87
88 #define LB_TAG_UNUSED           0x0000
89
90 #define LB_TAG_MEMORY           0x0001
91
92 struct lb_memory_range {
93         struct lb_uint64 start;
94         struct lb_uint64 size;
95         uint32_t type;
96 #define LB_MEM_RAM               1      /* Memory anyone can use */
97 #define LB_MEM_RESERVED          2      /* Don't use this memory region */
98 #define LB_MEM_ACPI              3      /* ACPI Tables */
99 #define LB_MEM_NVS               4      /* ACPI NVS Memory */
100 #define LB_MEM_UNUSABLE          5      /* Unusable address space */
101 #define LB_MEM_VENDOR_RSVD       6      /* Vendor Reserved */
102 #define LB_MEM_TABLE            16      /* Ram configuration tables are kept in */
103 };
104
105 struct lb_memory {
106         uint32_t tag;
107         uint32_t size;
108         struct lb_memory_range map[0];
109 };
110
111 #define LB_TAG_HWRPB            0x0002
112 struct lb_hwrpb {
113         uint32_t tag;
114         uint32_t size;
115         uint64_t hwrpb;
116 };
117
118 #define LB_TAG_MAINBOARD        0x0003
119 struct lb_mainboard {
120         uint32_t tag;
121         uint32_t size;
122         uint8_t  vendor_idx;
123         uint8_t  part_number_idx;
124         uint8_t  strings[0];
125 };
126
127 #define LB_TAG_VERSION          0x0004
128 #define LB_TAG_EXTRA_VERSION    0x0005
129 #define LB_TAG_BUILD            0x0006
130 #define LB_TAG_COMPILE_TIME     0x0007
131 #define LB_TAG_COMPILE_BY       0x0008
132 #define LB_TAG_COMPILE_HOST     0x0009
133 #define LB_TAG_COMPILE_DOMAIN   0x000a
134 #define LB_TAG_COMPILER         0x000b
135 #define LB_TAG_LINKER           0x000c
136 #define LB_TAG_ASSEMBLER        0x000d
137 struct lb_string {
138         uint32_t tag;
139         uint32_t size;
140         uint8_t  string[0];
141 };
142
143 /* 0xe is taken by v3 */
144
145 #define LB_TAG_SERIAL           0x000f
146 struct lb_serial {
147         uint32_t tag;
148         uint32_t size;
149 #define LB_SERIAL_TYPE_IO_MAPPED     1
150 #define LB_SERIAL_TYPE_MEMORY_MAPPED 2
151         uint32_t type;
152         uint32_t baseaddr;
153         uint32_t baud;
154 };
155
156 #define LB_TAG_CONSOLE          0x0010
157 struct lb_console {
158         uint32_t tag;
159         uint32_t size;
160         uint16_t type;
161 };
162
163 #define LB_TAG_CONSOLE_SERIAL8250       0
164 #define LB_TAG_CONSOLE_VGA              1 // OBSOLETE
165 #define LB_TAG_CONSOLE_BTEXT            2 // OBSOLETE
166 #define LB_TAG_CONSOLE_LOGBUF           3
167 #define LB_TAG_CONSOLE_SROM             4 // OBSOLETE
168 #define LB_TAG_CONSOLE_EHCI             5
169 #define LB_TAG_CONSOLE_SERIAL8250MEM    6
170
171 #define LB_TAG_FORWARD          0x0011
172 struct lb_forward {
173         uint32_t tag;
174         uint32_t size;
175         uint64_t forward;
176 };
177
178 #define LB_TAG_FRAMEBUFFER      0x0012
179 struct lb_framebuffer {
180         uint32_t tag;
181         uint32_t size;
182
183         uint64_t physical_address;
184         uint32_t x_resolution;
185         uint32_t y_resolution;
186         uint32_t bytes_per_line;
187         uint8_t bits_per_pixel;
188         uint8_t red_mask_pos;
189         uint8_t red_mask_size;
190         uint8_t green_mask_pos;
191         uint8_t green_mask_size;
192         uint8_t blue_mask_pos;
193         uint8_t blue_mask_size;
194         uint8_t reserved_mask_pos;
195         uint8_t reserved_mask_size;
196 };
197
198 #define LB_TAG_GPIO     0x0013
199
200 struct lb_gpio {
201         uint32_t port;
202         uint32_t polarity;
203         uint32_t value;
204 #define GPIO_MAX_NAME_LENGTH 16
205         uint8_t name[GPIO_MAX_NAME_LENGTH];
206 };
207
208 struct lb_gpios {
209         uint32_t tag;
210         uint32_t size;
211
212         uint32_t count;
213         struct lb_gpio gpios[0];
214 };
215
216 #define LB_TAG_VDAT     0x0015
217 struct lb_vdat {
218         uint32_t tag;
219         uint32_t size;
220
221         void    *vdat_addr;
222         uint32_t vdat_size;
223 };
224
225 #define LB_TAG_TIMESTAMPS       0x0016
226 #define LB_TAG_CBMEM_CONSOLE    0x0017
227 #define LB_TAG_MRC_CACHE        0x0018
228 struct lb_cbmem_ref {
229         uint32_t tag;
230         uint32_t size;
231
232         void    *cbmem_addr;
233 };
234
235 #define LB_TAG_VBNV             0x0019
236 struct lb_vbnv {
237         uint32_t tag;
238         uint32_t size;
239
240         uint32_t vbnv_start;
241         uint32_t vbnv_size;
242 };
243
244 /* The following structures are for the cmos definitions table */
245 #define LB_TAG_CMOS_OPTION_TABLE 200
246 /* cmos header record */
247 struct cmos_option_table {
248         uint32_t tag;               /* CMOS definitions table type */
249         uint32_t size;               /* size of the entire table */
250         uint32_t header_length;      /* length of header */
251 };
252
253 /* cmos entry record
254         This record is variable length.  The name field may be
255         shorter than CMOS_MAX_NAME_LENGTH. The entry may start
256         anywhere in the byte, but can not span bytes unless it
257         starts at the beginning of the byte and the length is
258         fills complete bytes.
259 */
260 #define LB_TAG_OPTION 201
261 struct cmos_entries {
262         uint32_t tag;                /* entry type */
263         uint32_t size;               /* length of this record */
264         uint32_t bit;                /* starting bit from start of image */
265         uint32_t length;             /* length of field in bits */
266         uint32_t config;             /* e=enumeration, h=hex, r=reserved */
267         uint32_t config_id;          /* a number linking to an enumeration record */
268 #define CMOS_MAX_NAME_LENGTH 32
269         uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
270                                                variable length int aligned */
271 };
272
273
274 /* cmos enumerations record
275         This record is variable length.  The text field may be
276         shorter than CMOS_MAX_TEXT_LENGTH.
277 */
278 #define LB_TAG_OPTION_ENUM 202
279 struct cmos_enums {
280         uint32_t tag;                /* enumeration type */
281         uint32_t size;               /* length of this record */
282         uint32_t config_id;          /* a number identifying the config id */
283         uint32_t value;              /* the value associated with the text */
284 #define CMOS_MAX_TEXT_LENGTH 32
285         uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
286                                                 variable length int aligned */
287 };
288
289 /* cmos defaults record
290         This record contains default settings for the cmos ram.
291 */
292 #define LB_TAG_OPTION_DEFAULTS 203
293 struct cmos_defaults {
294         uint32_t tag;                /* default type */
295         uint32_t size;               /* length of this record */
296         uint32_t name_length;        /* length of the following name field */
297         uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
298 #define CMOS_IMAGE_BUFFER_SIZE 256
299         uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
300 };
301
302 #define LB_TAG_OPTION_CHECKSUM 204
303 struct  cmos_checksum {
304         uint32_t tag;
305         uint32_t size;
306         /* In practice everything is byte aligned, but things are measured
307          * in bits to be consistent.
308          */
309         uint32_t range_start;   /* First bit that is checksummed (byte aligned) */
310         uint32_t range_end;     /* Last bit that is checksummed (byte aligned) */
311         uint32_t location;      /* First bit of the checksum (byte aligned) */
312         uint32_t type;          /* Checksum algorithm that is used */
313 #define CHECKSUM_NONE   0
314 #define CHECKSUM_PCBIOS 1
315 };
316
317 #endif /* COREBOOT_TABLES_H */