]>
Commit | Line | Data |
---|---|---|
63f559cd GB |
1 | /* |
2 | * This file is part of the libpayload project. | |
3 | * | |
4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. | |
5 | * | |
cb3761ea | 6 | * SPDX-License-Identifier: BSD-3-Clause |
63f559cd GB |
7 | */ |
8 | ||
9 | #ifndef _COREBOOT_TABLES_H | |
10 | #define _COREBOOT_TABLES_H | |
11 | ||
afc366f0 | 12 | #include <linux/compiler.h> |
63f559cd GB |
13 | |
14 | struct cbuint64 { | |
15 | u32 lo; | |
16 | u32 hi; | |
17 | }; | |
18 | ||
19 | struct cb_header { | |
20 | u8 signature[4]; | |
21 | u32 header_bytes; | |
22 | u32 header_checksum; | |
23 | u32 table_bytes; | |
24 | u32 table_checksum; | |
25 | u32 table_entries; | |
26 | }; | |
27 | ||
28 | struct cb_record { | |
29 | u32 tag; | |
30 | u32 size; | |
31 | }; | |
32 | ||
33 | #define CB_TAG_UNUSED 0x0000 | |
34 | #define CB_TAG_MEMORY 0x0001 | |
35 | ||
36 | struct cb_memory_range { | |
37 | struct cbuint64 start; | |
38 | struct cbuint64 size; | |
39 | u32 type; | |
40 | }; | |
41 | ||
42 | #define CB_MEM_RAM 1 | |
43 | #define CB_MEM_RESERVED 2 | |
44 | #define CB_MEM_ACPI 3 | |
45 | #define CB_MEM_NVS 4 | |
46 | #define CB_MEM_UNUSABLE 5 | |
47 | #define CB_MEM_VENDOR_RSVD 6 | |
48 | #define CB_MEM_TABLE 16 | |
49 | ||
50 | struct cb_memory { | |
51 | u32 tag; | |
52 | u32 size; | |
53 | struct cb_memory_range map[0]; | |
54 | }; | |
55 | ||
56 | #define CB_TAG_HWRPB 0x0002 | |
57 | ||
58 | struct cb_hwrpb { | |
59 | u32 tag; | |
60 | u32 size; | |
61 | u64 hwrpb; | |
62 | }; | |
63 | ||
64 | #define CB_TAG_MAINBOARD 0x0003 | |
65 | ||
66 | struct cb_mainboard { | |
67 | u32 tag; | |
68 | u32 size; | |
69 | u8 vendor_idx; | |
70 | u8 part_number_idx; | |
71 | u8 strings[0]; | |
72 | }; | |
73 | ||
74 | #define CB_TAG_VERSION 0x0004 | |
75 | #define CB_TAG_EXTRA_VERSION 0x0005 | |
76 | #define CB_TAG_BUILD 0x0006 | |
77 | #define CB_TAG_COMPILE_TIME 0x0007 | |
78 | #define CB_TAG_COMPILE_BY 0x0008 | |
79 | #define CB_TAG_COMPILE_HOST 0x0009 | |
80 | #define CB_TAG_COMPILE_DOMAIN 0x000a | |
81 | #define CB_TAG_COMPILER 0x000b | |
82 | #define CB_TAG_LINKER 0x000c | |
83 | #define CB_TAG_ASSEMBLER 0x000d | |
84 | ||
85 | struct cb_string { | |
86 | u32 tag; | |
87 | u32 size; | |
88 | u8 string[0]; | |
89 | }; | |
90 | ||
91 | #define CB_TAG_SERIAL 0x000f | |
92 | ||
93 | struct cb_serial { | |
94 | u32 tag; | |
95 | u32 size; | |
96 | #define CB_SERIAL_TYPE_IO_MAPPED 1 | |
97 | #define CB_SERIAL_TYPE_MEMORY_MAPPED 2 | |
98 | u32 type; | |
99 | u32 baseaddr; | |
100 | u32 baud; | |
101 | }; | |
102 | ||
103 | #define CB_TAG_CONSOLE 0x00010 | |
104 | ||
105 | struct cb_console { | |
106 | u32 tag; | |
107 | u32 size; | |
108 | u16 type; | |
109 | }; | |
110 | ||
111 | #define CB_TAG_CONSOLE_SERIAL8250 0 | |
112 | #define CB_TAG_CONSOLE_VGA 1 /* OBSOLETE */ | |
113 | #define CB_TAG_CONSOLE_BTEXT 2 /* OBSOLETE */ | |
114 | #define CB_TAG_CONSOLE_LOGBUF 3 | |
115 | #define CB_TAG_CONSOLE_SROM 4 /* OBSOLETE */ | |
116 | #define CB_TAG_CONSOLE_EHCI 5 | |
117 | ||
118 | #define CB_TAG_FORWARD 0x00011 | |
119 | ||
120 | struct cb_forward { | |
121 | u32 tag; | |
122 | u32 size; | |
123 | u64 forward; | |
124 | }; | |
125 | ||
126 | #define CB_TAG_FRAMEBUFFER 0x0012 | |
127 | struct cb_framebuffer { | |
128 | u32 tag; | |
129 | u32 size; | |
130 | ||
131 | u64 physical_address; | |
132 | u32 x_resolution; | |
133 | u32 y_resolution; | |
134 | u32 bytes_per_line; | |
135 | u8 bits_per_pixel; | |
136 | u8 red_mask_pos; | |
137 | u8 red_mask_size; | |
138 | u8 green_mask_pos; | |
139 | u8 green_mask_size; | |
140 | u8 blue_mask_pos; | |
141 | u8 blue_mask_size; | |
142 | u8 reserved_mask_pos; | |
143 | u8 reserved_mask_size; | |
144 | }; | |
145 | ||
402ed004 SG |
146 | #define CB_TAG_GPIO 0x0013 |
147 | #define GPIO_MAX_NAME_LENGTH 16 | |
148 | struct cb_gpio { | |
149 | u32 port; | |
150 | u32 polarity; | |
151 | u32 value; | |
152 | u8 name[GPIO_MAX_NAME_LENGTH]; | |
153 | }; | |
154 | ||
155 | struct cb_gpios { | |
156 | u32 tag; | |
157 | u32 size; | |
158 | ||
159 | u32 count; | |
160 | struct cb_gpio gpios[0]; | |
161 | }; | |
162 | ||
163 | #define CB_TAG_FDT 0x0014 | |
164 | struct cb_fdt { | |
165 | uint32_t tag; | |
166 | uint32_t size; /* size of the entire entry */ | |
167 | /* the actual FDT gets placed here */ | |
168 | }; | |
169 | ||
170 | #define CB_TAG_VDAT 0x0015 | |
171 | struct cb_vdat { | |
172 | uint32_t tag; | |
173 | uint32_t size; /* size of the entire entry */ | |
174 | void *vdat_addr; | |
175 | uint32_t vdat_size; | |
176 | }; | |
177 | ||
178 | #define CB_TAG_TIMESTAMPS 0x0016 | |
179 | #define CB_TAG_CBMEM_CONSOLE 0x0017 | |
180 | #define CB_TAG_MRC_CACHE 0x0018 | |
181 | struct cb_cbmem_tab { | |
182 | uint32_t tag; | |
183 | uint32_t size; | |
184 | void *cbmem_tab; | |
185 | }; | |
186 | ||
187 | #define CB_TAG_VBNV 0x0019 | |
188 | struct cb_vbnv { | |
189 | uint32_t tag; | |
190 | uint32_t size; | |
191 | uint32_t vbnv_start; | |
192 | uint32_t vbnv_size; | |
193 | }; | |
194 | ||
63f559cd GB |
195 | #define CB_TAG_CMOS_OPTION_TABLE 0x00c8 |
196 | struct cb_cmos_option_table { | |
197 | u32 tag; | |
198 | u32 size; | |
199 | u32 header_length; | |
200 | }; | |
201 | ||
202 | #define CB_TAG_OPTION 0x00c9 | |
203 | #define CMOS_MAX_NAME_LENGTH 32 | |
204 | struct cb_cmos_entries { | |
205 | u32 tag; | |
206 | u32 size; | |
207 | u32 bit; | |
208 | u32 length; | |
209 | u32 config; | |
210 | u32 config_id; | |
211 | u8 name[CMOS_MAX_NAME_LENGTH]; | |
212 | }; | |
213 | ||
214 | ||
215 | #define CB_TAG_OPTION_ENUM 0x00ca | |
216 | #define CMOS_MAX_TEXT_LENGTH 32 | |
217 | struct cb_cmos_enums { | |
218 | u32 tag; | |
219 | u32 size; | |
220 | u32 config_id; | |
221 | u32 value; | |
222 | u8 text[CMOS_MAX_TEXT_LENGTH]; | |
223 | }; | |
224 | ||
225 | #define CB_TAG_OPTION_DEFAULTS 0x00cb | |
226 | #define CMOS_IMAGE_BUFFER_SIZE 128 | |
227 | struct cb_cmos_defaults { | |
228 | u32 tag; | |
229 | u32 size; | |
230 | u32 name_length; | |
231 | u8 name[CMOS_MAX_NAME_LENGTH]; | |
232 | u8 default_set[CMOS_IMAGE_BUFFER_SIZE]; | |
233 | }; | |
234 | ||
235 | #define CB_TAG_OPTION_CHECKSUM 0x00cc | |
236 | #define CHECKSUM_NONE 0 | |
237 | #define CHECKSUM_PCBIOS 1 | |
238 | struct cb_cmos_checksum { | |
239 | u32 tag; | |
240 | u32 size; | |
241 | u32 range_start; | |
242 | u32 range_end; | |
243 | u32 location; | |
244 | u32 type; | |
245 | }; | |
246 | ||
247 | /* Helpful macros */ | |
248 | ||
249 | #define MEM_RANGE_COUNT(_rec) \ | |
250 | (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0])) | |
251 | ||
252 | #define MEM_RANGE_PTR(_rec, _idx) \ | |
253 | (((u8 *) (_rec)) + sizeof(*(_rec)) \ | |
254 | + (sizeof((_rec)->map[0]) * (_idx))) | |
255 | ||
256 | #define MB_VENDOR_STRING(_mb) \ | |
257 | (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx) | |
258 | ||
259 | #define MB_PART_STRING(_mb) \ | |
260 | (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx) | |
261 | ||
262 | #define UNPACK_CB64(_in) \ | |
263 | ((((u64) _in.hi) << 32) | _in.lo) | |
264 | ||
402ed004 SG |
265 | #define CBMEM_TOC_RESERVED 512 |
266 | #define MAX_CBMEM_ENTRIES 16 | |
267 | #define CBMEM_MAGIC 0x434f5245 | |
268 | ||
269 | struct cbmem_entry { | |
270 | u32 magic; | |
271 | u32 id; | |
272 | u64 base; | |
273 | u64 size; | |
274 | } __packed; | |
275 | ||
276 | #define CBMEM_ID_FREESPACE 0x46524545 | |
277 | #define CBMEM_ID_GDT 0x4c474454 | |
278 | #define CBMEM_ID_ACPI 0x41435049 | |
279 | #define CBMEM_ID_CBTABLE 0x43425442 | |
280 | #define CBMEM_ID_PIRQ 0x49525154 | |
281 | #define CBMEM_ID_MPTABLE 0x534d5054 | |
282 | #define CBMEM_ID_RESUME 0x5245534d | |
283 | #define CBMEM_ID_RESUME_SCRATCH 0x52455343 | |
284 | #define CBMEM_ID_SMBIOS 0x534d4254 | |
285 | #define CBMEM_ID_TIMESTAMP 0x54494d45 | |
286 | #define CBMEM_ID_MRCDATA 0x4d524344 | |
287 | #define CBMEM_ID_CONSOLE 0x434f4e53 | |
288 | #define CBMEM_ID_NONE 0x00000000 | |
289 | ||
63f559cd | 290 | #endif |