2 * This file is part of the libpayload project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
6 * SPDX-License-Identifier: BSD-3-Clause
9 #ifndef _COREBOOT_TABLES_H
10 #define _COREBOOT_TABLES_H
31 #define CB_TAG_UNUSED 0x0000
32 #define CB_TAG_MEMORY 0x0001
34 struct cb_memory_range {
35 struct cbuint64 start;
41 #define CB_MEM_RESERVED 2
44 #define CB_MEM_UNUSABLE 5
45 #define CB_MEM_VENDOR_RSVD 6
46 #define CB_MEM_TABLE 16
51 struct cb_memory_range map[0];
54 #define CB_TAG_HWRPB 0x0002
62 #define CB_TAG_MAINBOARD 0x0003
72 #define CB_TAG_VERSION 0x0004
73 #define CB_TAG_EXTRA_VERSION 0x0005
74 #define CB_TAG_BUILD 0x0006
75 #define CB_TAG_COMPILE_TIME 0x0007
76 #define CB_TAG_COMPILE_BY 0x0008
77 #define CB_TAG_COMPILE_HOST 0x0009
78 #define CB_TAG_COMPILE_DOMAIN 0x000a
79 #define CB_TAG_COMPILER 0x000b
80 #define CB_TAG_LINKER 0x000c
81 #define CB_TAG_ASSEMBLER 0x000d
89 #define CB_TAG_SERIAL 0x000f
94 #define CB_SERIAL_TYPE_IO_MAPPED 1
95 #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
101 #define CB_TAG_CONSOLE 0x0010
109 #define CB_TAG_CONSOLE_SERIAL8250 0
110 #define CB_TAG_CONSOLE_VGA 1 /* OBSOLETE */
111 #define CB_TAG_CONSOLE_BTEXT 2 /* OBSOLETE */
112 #define CB_TAG_CONSOLE_LOGBUF 3
113 #define CB_TAG_CONSOLE_SROM 4 /* OBSOLETE */
114 #define CB_TAG_CONSOLE_EHCI 5
116 #define CB_TAG_FORWARD 0x0011
124 #define CB_TAG_FRAMEBUFFER 0x0012
126 struct cb_framebuffer {
129 u64 physical_address;
140 u8 reserved_mask_pos;
141 u8 reserved_mask_size;
144 #define CB_TAG_GPIO 0x0013
145 #define GPIO_MAX_NAME_LENGTH 16
151 u8 name[GPIO_MAX_NAME_LENGTH];
158 struct cb_gpio gpios[0];
161 #define CB_TAG_FDT 0x0014
165 uint32_t size; /* size of the entire entry */
166 /* the actual FDT gets placed here */
169 #define CB_TAG_VDAT 0x0015
173 uint32_t size; /* size of the entire entry */
178 #define CB_TAG_TIMESTAMPS 0x0016
179 #define CB_TAG_CBMEM_CONSOLE 0x0017
180 #define CB_TAG_MRC_CACHE 0x0018
182 struct cb_cbmem_tab {
188 #define CB_TAG_VBNV 0x0019
197 #define CB_TAG_CMOS_OPTION_TABLE 0x00c8
199 struct cb_cmos_option_table {
205 #define CB_TAG_OPTION 0x00c9
207 #define CMOS_MAX_NAME_LENGTH 32
209 struct cb_cmos_entries {
216 u8 name[CMOS_MAX_NAME_LENGTH];
219 #define CB_TAG_OPTION_ENUM 0x00ca
220 #define CMOS_MAX_TEXT_LENGTH 32
222 struct cb_cmos_enums {
227 u8 text[CMOS_MAX_TEXT_LENGTH];
230 #define CB_TAG_OPTION_DEFAULTS 0x00cb
231 #define CMOS_IMAGE_BUFFER_SIZE 128
233 struct cb_cmos_defaults {
237 u8 name[CMOS_MAX_NAME_LENGTH];
238 u8 default_set[CMOS_IMAGE_BUFFER_SIZE];
241 #define CB_TAG_OPTION_CHECKSUM 0x00cc
242 #define CHECKSUM_NONE 0
243 #define CHECKSUM_PCBIOS 1
245 struct cb_cmos_checksum {
256 #define MEM_RANGE_COUNT(_rec) \
257 (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
259 #define MEM_RANGE_PTR(_rec, _idx) \
260 (((u8 *) (_rec)) + sizeof(*(_rec)) \
261 + (sizeof((_rec)->map[0]) * (_idx)))
263 #define MB_VENDOR_STRING(_mb) \
264 (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx)
266 #define MB_PART_STRING(_mb) \
267 (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx)
269 #define UNPACK_CB64(_in) \
270 ((((u64) _in.hi) << 32) | _in.lo)
272 #define CBMEM_TOC_RESERVED 512
273 #define MAX_CBMEM_ENTRIES 16
274 #define CBMEM_MAGIC 0x434f5245
283 #define CBMEM_ID_FREESPACE 0x46524545
284 #define CBMEM_ID_GDT 0x4c474454
285 #define CBMEM_ID_ACPI 0x41435049
286 #define CBMEM_ID_CBTABLE 0x43425442
287 #define CBMEM_ID_PIRQ 0x49525154
288 #define CBMEM_ID_MPTABLE 0x534d5054
289 #define CBMEM_ID_RESUME 0x5245534d
290 #define CBMEM_ID_RESUME_SCRATCH 0x52455343
291 #define CBMEM_ID_SMBIOS 0x534d4254
292 #define CBMEM_ID_TIMESTAMP 0x54494d45
293 #define CBMEM_ID_MRCDATA 0x4d524344
294 #define CBMEM_ID_CONSOLE 0x434f4e53
295 #define CBMEM_ID_NONE 0x00000000
298 * high_table_reserve() - reserve configuration table in high memory
300 * This reserves configuration table in high memory.
304 int high_table_reserve(void);
307 * high_table_malloc() - allocate configuration table in high memory
309 * This allocates configuration table in high memory.
311 * @bytes: size of configuration table to be allocated
312 * @return: pointer to configuration table in high memory
314 void *high_table_malloc(size_t bytes);
317 * write_coreboot_table() - write coreboot table
319 * This writes coreboot table at a given address.
321 * @addr: start address to write coreboot table
322 * @cfg_tables: pointer to configuration table memory area
324 void write_coreboot_table(u32 addr, struct memory_area *cfg_tables);