1 /* SPDX-License-Identifier: BSD-3-Clause */
3 * This file is part of the libpayload project.
5 * Copyright (C) 2008 Advanced Micro Devices, Inc.
8 #ifndef _COREBOOT_TABLES_H
9 #define _COREBOOT_TABLES_H
30 #define CB_TAG_UNUSED 0x0000
31 #define CB_TAG_MEMORY 0x0001
33 struct cb_memory_range {
34 struct cbuint64 start;
40 #define CB_MEM_RESERVED 2
43 #define CB_MEM_UNUSABLE 5
44 #define CB_MEM_VENDOR_RSVD 6
45 #define CB_MEM_TABLE 16
50 struct cb_memory_range map[0];
53 #define CB_TAG_HWRPB 0x0002
61 #define CB_TAG_MAINBOARD 0x0003
71 #define CB_TAG_VERSION 0x0004
72 #define CB_TAG_EXTRA_VERSION 0x0005
73 #define CB_TAG_BUILD 0x0006
74 #define CB_TAG_COMPILE_TIME 0x0007
75 #define CB_TAG_COMPILE_BY 0x0008
76 #define CB_TAG_COMPILE_HOST 0x0009
77 #define CB_TAG_COMPILE_DOMAIN 0x000a
78 #define CB_TAG_COMPILER 0x000b
79 #define CB_TAG_LINKER 0x000c
80 #define CB_TAG_ASSEMBLER 0x000d
88 #define CB_TAG_SERIAL 0x000f
93 #define CB_SERIAL_TYPE_IO_MAPPED 1
94 #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
100 #define CB_TAG_CONSOLE 0x0010
108 #define CB_TAG_CONSOLE_SERIAL8250 0
109 #define CB_TAG_CONSOLE_VGA 1 /* OBSOLETE */
110 #define CB_TAG_CONSOLE_BTEXT 2 /* OBSOLETE */
111 #define CB_TAG_CONSOLE_LOGBUF 3
112 #define CB_TAG_CONSOLE_SROM 4 /* OBSOLETE */
113 #define CB_TAG_CONSOLE_EHCI 5
115 #define CB_TAG_FORWARD 0x0011
123 #define CB_TAG_FRAMEBUFFER 0x0012
125 struct cb_framebuffer {
128 u64 physical_address;
139 u8 reserved_mask_pos;
140 u8 reserved_mask_size;
143 #define CB_TAG_GPIO 0x0013
144 #define GPIO_MAX_NAME_LENGTH 16
150 u8 name[GPIO_MAX_NAME_LENGTH];
157 struct cb_gpio gpios[0];
160 #define CB_TAG_FDT 0x0014
164 uint32_t size; /* size of the entire entry */
165 /* the actual FDT gets placed here */
168 #define CB_TAG_VDAT 0x0015
172 uint32_t size; /* size of the entire entry */
177 #define CB_TAG_TIMESTAMPS 0x0016
178 #define CB_TAG_CBMEM_CONSOLE 0x0017
179 #define CB_TAG_MRC_CACHE 0x0018
181 struct cb_cbmem_tab {
187 #define CB_TAG_VBNV 0x0019
196 #define CB_TAG_CMOS_OPTION_TABLE 0x00c8
198 struct cb_cmos_option_table {
204 #define CB_TAG_OPTION 0x00c9
206 #define CMOS_MAX_NAME_LENGTH 32
208 struct cb_cmos_entries {
215 u8 name[CMOS_MAX_NAME_LENGTH];
218 #define CB_TAG_OPTION_ENUM 0x00ca
219 #define CMOS_MAX_TEXT_LENGTH 32
221 struct cb_cmos_enums {
226 u8 text[CMOS_MAX_TEXT_LENGTH];
229 #define CB_TAG_OPTION_DEFAULTS 0x00cb
230 #define CMOS_IMAGE_BUFFER_SIZE 128
232 struct cb_cmos_defaults {
236 u8 name[CMOS_MAX_NAME_LENGTH];
237 u8 default_set[CMOS_IMAGE_BUFFER_SIZE];
240 #define CB_TAG_OPTION_CHECKSUM 0x00cc
241 #define CHECKSUM_NONE 0
242 #define CHECKSUM_PCBIOS 1
244 struct cb_cmos_checksum {
255 #define MEM_RANGE_COUNT(_rec) \
256 (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
258 #define MEM_RANGE_PTR(_rec, _idx) \
259 (((u8 *) (_rec)) + sizeof(*(_rec)) \
260 + (sizeof((_rec)->map[0]) * (_idx)))
262 #define MB_VENDOR_STRING(_mb) \
263 (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx)
265 #define MB_PART_STRING(_mb) \
266 (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx)
268 #define UNPACK_CB64(_in) \
269 ((((u64) _in.hi) << 32) | _in.lo)
271 #define CBMEM_TOC_RESERVED 512
272 #define MAX_CBMEM_ENTRIES 16
273 #define CBMEM_MAGIC 0x434f5245
282 #define CBMEM_ID_FREESPACE 0x46524545
283 #define CBMEM_ID_GDT 0x4c474454
284 #define CBMEM_ID_ACPI 0x41435049
285 #define CBMEM_ID_CBTABLE 0x43425442
286 #define CBMEM_ID_PIRQ 0x49525154
287 #define CBMEM_ID_MPTABLE 0x534d5054
288 #define CBMEM_ID_RESUME 0x5245534d
289 #define CBMEM_ID_RESUME_SCRATCH 0x52455343
290 #define CBMEM_ID_SMBIOS 0x534d4254
291 #define CBMEM_ID_TIMESTAMP 0x54494d45
292 #define CBMEM_ID_MRCDATA 0x4d524344
293 #define CBMEM_ID_CONSOLE 0x434f4e53
294 #define CBMEM_ID_NONE 0x00000000
297 * high_table_reserve() - reserve configuration table in high memory
299 * This reserves configuration table in high memory.
303 int high_table_reserve(void);
306 * high_table_malloc() - allocate configuration table in high memory
308 * This allocates configuration table in high memory.
310 * @bytes: size of configuration table to be allocated
311 * @return: pointer to configuration table in high memory
313 void *high_table_malloc(size_t bytes);
316 * write_coreboot_table() - write coreboot table
318 * This writes coreboot table at a given address.
320 * @addr: start address to write coreboot table
321 * @cfg_tables: pointer to configuration table memory area
323 void write_coreboot_table(u32 addr, struct memory_area *cfg_tables);