coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
coreboot_tables.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef COMMONLIB_COREBOOT_TABLES_H
4 #define COMMONLIB_COREBOOT_TABLES_H
5 
6 #include <stdint.h>
7 
8 /* The coreboot table information is for conveying information
9  * from the firmware to the loaded OS image. Primarily this
10  * is expected to be information that cannot be discovered by
11  * other means, such as querying the hardware directly.
12  *
13  * All of the information should be Position Independent Data.
14  * That is it should be safe to relocated any of the information
15  * without it's meaning/correctness changing. For table that
16  * can reasonably be used on multiple architectures the data
17  * size should be fixed. This should ease the transition between
18  * 32 bit and 64 bit architectures etc.
19  *
20  * The completeness test for the information in this table is:
21  * - Can all of the hardware be detected?
22  * - Are the per motherboard constants available?
23  * - Is there enough to allow a kernel to run that was written before
24  * a particular motherboard is constructed? (Assuming the kernel
25  * has drivers for all of the hardware but it does not have
26  * assumptions on how the hardware is connected together).
27  *
28  * With this test it should be straight forward to determine if a
29  * table entry is required or not. This should remove much of the
30  * long term compatibility burden as table entries which are
31  * irrelevant or have been replaced by better alternatives may be
32  * dropped. Of course it is polite and expedite to include extra
33  * table entries and be backwards compatible, but it is not required.
34  */
35 
36 enum {
37  LB_TAG_UNUSED = 0x0000,
38  LB_TAG_MEMORY = 0x0001,
39  LB_TAG_HWRPB = 0x0002,
40  LB_TAG_MAINBOARD = 0x0003,
41  LB_TAG_VERSION = 0x0004,
43  LB_TAG_BUILD = 0x0006,
48  LB_TAG_COMPILER = 0x000b,
49  LB_TAG_LINKER = 0x000c,
50  LB_TAG_ASSEMBLER = 0x000d,
51  LB_TAG_SERIAL = 0x000f,
52  LB_TAG_CONSOLE = 0x0010,
53  LB_TAG_FORWARD = 0x0011,
55  LB_TAG_GPIO = 0x0013,
58  LB_TAG_MRC_CACHE = 0x0018,
59  LB_TAG_VBNV = 0x0019,
60  LB_TAG_VBOOT_HANDOFF = 0x0020, /* deprecated */
62  LB_TAG_DMA = 0x0022,
63  LB_TAG_RAM_OOPS = 0x0023,
64  LB_TAG_ACPI_GNVS = 0x0024,
65  LB_TAG_BOARD_ID = 0x0025, /* deprecated */
68  LB_TAG_RAM_CODE = 0x0028, /* deprecated */
69  LB_TAG_SPI_FLASH = 0x0029,
70  LB_TAG_SERIALNO = 0x002a,
71  LB_TAG_MTC = 0x002b,
72  LB_TAG_VPD = 0x002c,
73  LB_TAG_SKU_ID = 0x002d, /* deprecated */
76  LB_TAG_TSC_INFO = 0x0032,
77  LB_TAG_MAC_ADDRS = 0x0033,
79  LB_TAG_MMC_INFO = 0x0035,
80  LB_TAG_TCPA_LOG = 0x0036,
81  LB_TAG_FMAP = 0x0037,
86  LB_TAG_ACPI_CNVS = 0x0041,
88  LB_TAG_ACPI_RSDP = 0x0043,
89  /* The following options are CMOS-related */
91  LB_TAG_OPTION = 0x00c9,
95 };
96 
97 /* Since coreboot is usually compiled 32bit, gcc will align 64bit
98  * types to 32bit boundaries. If the coreboot table is dumped on a
99  * 64bit system, a uint64_t would be aligned to 64bit boundaries,
100  * breaking the table format.
101  *
102  * lb_uint64_t will keep 64bit coreboot table values aligned to 32bit
103  * to ensure compatibility.
104  */
105 
106 typedef __aligned(4) uint64_t lb_uint64_t;
107 
108 struct lb_header {
109  uint8_t signature[4]; /* LBIO */
115 };
116 
117 /* Every entry in the boot environment list will correspond to a boot
118  * info record. Encoding both type and size. The type is obviously
119  * so you can tell what it is. The size allows you to skip that
120  * boot environment record if you don't know what it is. This allows
121  * forward compatibility with records not yet defined.
122  */
123 struct lb_record {
124  uint32_t tag; /* tag ID */
125  uint32_t size; /* size of record (in bytes) */
126 };
127 
129  lb_uint64_t start;
130  lb_uint64_t size;
132 #define LB_MEM_RAM 1 /* Memory anyone can use */
133 #define LB_MEM_RESERVED 2 /* Don't use this memory region */
134 #define LB_MEM_ACPI 3 /* ACPI Tables */
135 #define LB_MEM_NVS 4 /* ACPI NVS Memory */
136 #define LB_MEM_UNUSABLE 5 /* Unusable address space */
137 #define LB_MEM_VENDOR_RSVD 6 /* Vendor Reserved */
138 #define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */
139 };
140 
141 struct lb_memory {
144  struct lb_memory_range map[0];
145 };
146 
147 struct lb_hwrpb {
150  lb_uint64_t hwrpb;
151 };
152 
153 struct lb_mainboard {
159 };
160 
161 struct lb_string {
164  uint8_t string[0];
165 };
166 
167 struct lb_timestamp {
171 };
172 
173 /* 0xe is taken by v3 */
174 
175 struct lb_serial {
178 #define LB_SERIAL_TYPE_IO_MAPPED 1
179 #define LB_SERIAL_TYPE_MEMORY_MAPPED 2
184 
185  /* Crystal or input frequency to the chip containing the UART.
186  * Provide the board specific details to allow the payload to
187  * initialize the chip containing the UART and make independent
188  * decisions as to which dividers to select and their values
189  * to eventually arrive at the desired console baud-rate. */
191 
192  /* UART PCI address: bus, device, function
193  * 1 << 31 - Valid bit, PCI UART in use
194  * Bus << 20
195  * Device << 15
196  * Function << 12
197  */
199 };
200 
201 struct lb_console {
205 };
206 
207 #define LB_TAG_CONSOLE_SERIAL8250 0
208 #define LB_TAG_CONSOLE_VGA 1 // OBSOLETE
209 #define LB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
210 #define LB_TAG_CONSOLE_LOGBUF 3 // OBSOLETE
211 #define LB_TAG_CONSOLE_SROM 4 // OBSOLETE
212 #define LB_TAG_CONSOLE_EHCI 5
213 #define LB_TAG_CONSOLE_SERIAL8250MEM 6
214 
215 struct lb_forward {
218  lb_uint64_t forward;
219 };
220 
221 /**
222  * coreboot framebuffer
223  *
224  * The coreboot framebuffer uses a very common format usually referred
225  * to as "linear framebuffer":
226  *
227  * The first pixel of the framebuffer is the upper left corner, its
228  * address is given by `physical_address`.
229  *
230  * Each pixel is represented by exactly `bits_per_pixel` bits. If a
231  * pixel (or a color component therein) doesn't fill a whole byte or
232  * doesn't start on a byte boundary, it starts at the least signifi-
233  * cant bit not occupied by the previous pixel (or color component).
234  * Pixels (or color components) that span multiple bytes always start
235  * in the byte with the lowest address.
236  *
237  * The framebuffer provides a visible rectangle of `x_resolution` *
238  * `y_resolution` pixels. However, the lines always start at a byte
239  * boundary given by `bytes_per_line`, which may leave a gap after
240  * each line of pixels. Thus, the data for a pixel with the coordi-
241  * nates (x, y) from the upper left corner always starts at
242  *
243  * physical_address + y * bytes_per_line + x * bits_per_pixel / 8
244  *
245  * `bytes_per_line` is always big enough to hold `x_resolution`
246  * pixels. It can, however, be arbitrarily higher (e.g. to fulfill
247  * hardware constraints or for optimization purposes). The size of
248  * the framebuffer is always `y_resolution * bytes_per_line`.
249  *
250  * The coreboot framebuffer only supports RGB color formats. The
251  * position and size of each color component are specified indivi-
252  * dually by <color>_mask_pos and <color>_mask_size. To allow byte
253  * or word aligned pixels, a fourth (padding) component may be
254  * specified by `reserved_mask_pos` and `reserved_mask_size`.
255  *
256  * Software utilizing the coreboot framebuffer shall consider all
257  * fields described above. It may, however, only implement a subset
258  * of the possible color formats.
259  */
260 
261 /*
262  * Framebuffer orientation, matches drm_connector.h drm_panel_orientation in the
263  * Linux kernel.
264  */
270 };
271 
275 
276  lb_uint64_t physical_address;
290 };
291 
292 struct lb_gpio {
295 #define ACTIVE_LOW 0
296 #define ACTIVE_HIGH 1
298 #define GPIO_MAX_NAME_LENGTH 16
300 };
301 
302 struct lb_gpios {
305 
307  struct lb_gpio gpios[0];
308 };
309 
310 struct lb_range {
313 
314  lb_uint64_t range_start;
316 };
317 
319 
320 struct lb_cbmem_ref {
323 
324  lb_uint64_t cbmem_addr;
325 };
326 
330  /* The variable range MTRR index covering the ROM. */
332 };
333 
334 /* Memory map windows to translate addresses between SPI flash space and host address space. */
339 };
340 
341 struct lb_spi_flash {
347  /*
348  * Number of mmap windows used by the platform to decode addresses between SPI flash
349  * space and host address space. This determines the number of entries in mmap_table.
350  */
351 
353  struct flash_mmap_window mmap_table[0];
354 };
355 
359  /* offsets are relative to start of boot media */
360  lb_uint64_t fmap_offset;
361  lb_uint64_t cbfs_offset;
362  lb_uint64_t cbfs_size;
363  lb_uint64_t boot_media_size;
364 };
365 
366 /*
367  * There can be more than one of these records as there is one per cbmem entry.
368  */
372 
373  lb_uint64_t address;
376 };
377 
378 struct lb_tsc_info {
381 
383 };
384 
385 struct mac_address {
387  uint8_t pad[2]; /* Pad it to 8 bytes to keep it simple. */
388 };
389 
390 struct lb_mmc_info {
393  /*
394  * Passes the early mmc status to payload to indicate if firmware
395  * successfully sent CMD0, CMD1 to the card or not. In case of
396  * success, the payload can skip the first step of the initialization
397  * sequence which is to send CMD0, and instead start by sending CMD1
398  * as described in Jedec Standard JESD83-B1 section 6.4.3.
399  * passes 1 on success
400  */
402 };
403 
404 /*
405  * USB Type-C Port Information
406  * This record contains board-specific type-c port information.
407  * There will be one record per type-C port.
408  * Orientation fields should be of type enum type_c_orientation.
409  */
411  /* The orientation of the signal follows the orientation of the CC lines. */
413  /* The orientation of the signal is fixed to follow CC1 */
415  /* The orientation of the signal is fixed to follow CC2 */
417 };
418 
424 };
425 
426 struct type_c_info {
428  struct type_c_port_info port_info[0];
429 };
430 
431 struct lb_macs {
435  struct mac_address mac_addrs[0];
436 };
437 
441 
442  lb_uint64_t fw_config;
446 };
447 
448 #define MAX_SERIALNO_LENGTH 32
449 
450 /* The following structures are for the CMOS definitions table */
451 /* CMOS header record */
453  uint32_t tag; /* CMOS definitions table type */
454  uint32_t size; /* size of the entire table */
455  uint32_t header_length; /* length of header */
456 };
457 
458 /* CMOS entry record
459  * This record is variable length. The name field may be
460  * shorter than CMOS_MAX_NAME_LENGTH. The entry may start
461  * anywhere in the byte, but can not span bytes unless it
462  * starts at the beginning of the byte and the length is
463  * fills complete bytes.
464  */
465 struct cmos_entries {
466  uint32_t tag; /* entry type */
467  uint32_t size; /* length of this record */
468  uint32_t bit; /* starting bit from start of image */
469  uint32_t length; /* length of field in bits */
470  uint32_t config; /* e=enumeration, h=hex, r=reserved */
471  uint32_t config_id; /* a number linking to an enumeration record */
472 #define CMOS_MAX_NAME_LENGTH 32
473  uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
474  variable length int aligned */
475 };
476 
477 /* CMOS enumerations record
478  * This record is variable length. The text field may be
479  * shorter than CMOS_MAX_TEXT_LENGTH.
480  */
481 struct cmos_enums {
482  uint32_t tag; /* enumeration type */
483  uint32_t size; /* length of this record */
484  uint32_t config_id; /* a number identifying the config id */
485  uint32_t value; /* the value associated with the text */
486 #define CMOS_MAX_TEXT_LENGTH 32
487  uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
488  variable length int aligned */
489 };
490 
491 /* CMOS defaults record
492  * This record contains default settings for the CMOS ram.
493  */
495  uint32_t tag; /* default type */
496  uint32_t size; /* length of this record */
497  uint32_t name_length; /* length of the following name field */
498  uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
499 #define CMOS_IMAGE_BUFFER_SIZE 256
500  uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
501 };
502 
506  /* In practice everything is byte aligned, but things are measured
507  * in bits to be consistent.
508  */
509  uint32_t range_start; /* First bit that is checksummed (byte aligned) */
510  uint32_t range_end; /* Last bit that is checksummed (byte aligned) */
511  uint32_t location; /* First bit of the checksum (byte aligned) */
512  uint32_t type; /* Checksum algorithm that is used */
513 #define CHECKSUM_NONE 0
514 #define CHECKSUM_PCBIOS 1
515 };
516 
517 /* SMMSTOREv2 record
518  * This record contains information to use SMMSTOREv2.
519  */
520 
524  uint32_t num_blocks; /* Number of writeable blocks in SMM */
525  uint32_t block_size; /* Size of a block in byte. Default: 64 KiB */
526  uint32_t mmap_addr; /* MMIO address of the store for read only access */
527  uint32_t com_buffer; /* Physical address of the communication buffer */
528  uint32_t com_buffer_size; /* Size of the communication buffer in bytes */
529  uint8_t apm_cmd; /* The command byte to write to the APM I/O port */
530  uint8_t unused[3]; /* Set to zero */
531 };
532 
537 };
538 
539 /*
540  * Handoff buffer for TPM Physical Presence Interface.
541  * * ppi_address Pointer to PPI buffer shared with ACPI
542  * The layout of the buffer matches the QEMU virtual memory device
543  * that is generated by QEMU.
544  * See files 'hw/i386/acpi-build.c' and 'include/hw/acpi/tpm.h'
545  * for details.
546  * * tpm_version TPM version: 1 for TPM1.2, 2 for TPM2.0
547  * * ppi_version BCD encoded version of TPM PPI interface
548  */
552  uint32_t ppi_address; /* Address of ACPI PPI communication buffer */
553  uint8_t tpm_version; /* 1: TPM1.2, 2: TPM2.0 */
554  uint8_t ppi_version; /* BCD encoded */
555 };
556 
557 
558 /*
559  * Handoff the ACPI RSDP
560  */
561 struct lb_acpi_rsdp {
564  lb_uint64_t rsdp_pointer; /* Address of the ACPI RSDP */
565 };
566 
567 #endif
struct arm64_kernel_header header
Definition: fit_payload.c:30
#define CMOS_MAX_TEXT_LENGTH
@ LB_TAG_ASSEMBLER
@ LB_TAG_BUILD
@ LB_TAG_VBOOT_WORKBUF
@ LB_TAG_COMPILE_TIME
@ LB_TAG_TCPA_LOG
@ LB_TAG_COMPILE_DOMAIN
@ LB_TAG_RAM_OOPS
@ LB_TAG_SERIAL
@ LB_TAG_VBNV
@ LB_TAG_SMMSTOREV2
@ LB_TAG_VERSION_TIMESTAMP
@ LB_TAG_CONSOLE
@ LB_TAG_BOARD_ID
@ LB_TAG_EXTRA_VERSION
@ LB_TAG_FRAMEBUFFER
@ LB_TAG_OPTION_DEFAULTS
@ LB_TAG_FMAP
@ LB_TAG_DMA
@ LB_TAG_OPTION_ENUM
@ LB_TAG_MMC_INFO
@ LB_TAG_SPI_FLASH
@ LB_TAG_COMPILE_HOST
@ LB_TAG_ACPI_CNVS
@ LB_TAG_X86_ROM_MTRR
@ LB_TAG_TSC_INFO
@ LB_TAG_TIMESTAMPS
@ LB_TAG_OPTION_CHECKSUM
@ LB_TAG_ACPI_RSDP
@ LB_TAG_ACPI_GNVS
@ LB_TAG_TPM_PPI_HANDOFF
@ LB_TAG_BOOT_MEDIA_PARAMS
@ LB_TAG_CBMEM_CONSOLE
@ LB_TAG_VBOOT_HANDOFF
@ LB_TAG_TYPE_C_INFO
@ LB_TAG_VPD
@ LB_TAG_CBMEM_ENTRY
@ LB_TAG_HWRPB
@ LB_TAG_CMOS_OPTION_TABLE
@ LB_TAG_UNUSED
@ LB_TAG_RAM_CODE
@ LB_TAG_COMPILE_BY
@ LB_TAG_FORWARD
@ LB_TAG_PLATFORM_BLOB_VERSION
@ LB_TAG_SKU_ID
@ LB_TAG_MTC
@ LB_TAG_MEMORY
@ LB_TAG_COMPILER
@ LB_TAG_LINKER
@ LB_TAG_SERIALNO
@ LB_TAG_MAC_ADDRS
@ LB_TAG_BOARD_CONFIG
@ LB_TAG_GPIO
@ LB_TAG_VERSION
@ LB_TAG_MAINBOARD
@ LB_TAG_OPTION
@ LB_TAG_MRC_CACHE
@ LB_TAG_WIFI_CALIBRATION
#define GPIO_MAX_NAME_LENGTH
#define CMOS_IMAGE_BUFFER_SIZE
lb_tmp_ppi_tpm_version
@ LB_TPM_VERSION_TPM_VERSION_1_2
@ LB_TPM_VERSION_TPM_VERSION_2
@ LB_TPM_VERSION_UNSPEC
lb_fb_orientation
coreboot framebuffer
@ LB_FB_ORIENTATION_BOTTOM_UP
@ LB_FB_ORIENTATION_NORMAL
@ LB_FB_ORIENTATION_LEFT_UP
@ LB_FB_ORIENTATION_RIGHT_UP
typedef __aligned(4) uint64_t lb_uint64_t
void lb_ramoops(struct lb_header *header)
type_c_orientation
@ TYPEC_ORIENTATION_NORMAL
@ TYPEC_ORIENTATION_REVERSE
@ TYPEC_ORIENTATION_NONE
#define CMOS_MAX_NAME_LENGTH
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
signed int int32_t
Definition: stdint.h:13
unsigned char uint8_t
Definition: stdint.h:8
uint32_t range_end
uint32_t range_start
uint8_t name[CMOS_MAX_NAME_LENGTH]
uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]
uint32_t name_length
uint8_t name[CMOS_MAX_NAME_LENGTH]
uint32_t config_id
uint8_t text[CMOS_MAX_TEXT_LENGTH]
uint32_t size
uint32_t tag
uint32_t value
uint32_t config_id
lb_uint64_t rsdp_pointer
lb_uint64_t fw_config
lb_uint64_t boot_media_size
uint32_t size
uint32_t id
uint32_t tag
lb_uint64_t address
uint32_t entry_size
lb_uint64_t cbmem_addr
uint16_t type
uint32_t tag
uint32_t size
lb_uint64_t forward
uint32_t tag
uint32_t size
uint8_t blue_mask_size
uint8_t reserved_mask_size
uint8_t green_mask_size
uint8_t bits_per_pixel
lb_uint64_t physical_address
uint32_t bytes_per_line
uint8_t reserved_mask_pos
uint32_t x_resolution
uint8_t green_mask_pos
uint32_t y_resolution
uint32_t polarity
uint8_t name[GPIO_MAX_NAME_LENGTH]
uint32_t port
uint32_t value
struct lb_gpio gpios[0]
uint32_t size
uint32_t count
uint32_t tag
uint32_t header_checksum
uint32_t table_checksum
uint32_t table_bytes
uint32_t table_entries
uint32_t header_bytes
lb_uint64_t hwrpb
uint32_t size
uint32_t tag
uint32_t count
uint32_t size
uint32_t tag
struct mac_address mac_addrs[0]
uint8_t part_number_idx
uint8_t strings[0]
uint8_t vendor_idx
lb_uint64_t start
lb_uint64_t size
uint32_t size
uint32_t tag
struct lb_memory_range map[0]
int32_t early_cmd1_status
uint32_t range_size
lb_uint64_t range_start
uint32_t tag
uint32_t size
uint32_t tag
uint32_t size
uint32_t uart_pci_addr
uint32_t input_hertz
uint32_t tag
uint32_t size
uint32_t regwidth
uint32_t type
uint32_t baud
uint32_t baseaddr
uint32_t num_blocks
uint32_t mmap_addr
uint32_t com_buffer_size
uint8_t unused[3]
uint32_t com_buffer
uint32_t block_size
uint32_t flash_size
uint32_t mmap_count
uint32_t sector_size
uint32_t erase_cmd
struct flash_mmap_window mmap_table[0]
uint32_t size
uint32_t tag
uint32_t timestamp
uint32_t freq_khz
uint8_t mac_addr[6]
uint8_t pad[2]
struct type_c_port_info port_info[0]
uint32_t port_count