| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#ifndef _COREBOOT_TABLES_H |
| 30 |
#define _COREBOOT_TABLES_H |
| 31 |
|
| 32 |
#include <arch/types.h> |
| 33 |
#include <commonlib/bsd/ipchksum.h> |
| 34 |
#include <stdint.h> |
| 35 |
|
| 36 |
enum { |
| 37 |
CB_TAG_UNUSED = 0x0000, |
| 38 |
CB_TAG_MEMORY = 0x0001, |
| 39 |
CB_TAG_HWRPB = 0x0002, |
| 40 |
CB_TAG_MAINBOARD = 0x0003, |
| 41 |
CB_TAG_VERSION = 0x0004, |
| 42 |
CB_TAG_EXTRA_VERSION = 0x0005, |
| 43 |
CB_TAG_BUILD = 0x0006, |
| 44 |
CB_TAG_COMPILE_TIME = 0x0007, |
| 45 |
CB_TAG_COMPILE_BY = 0x0008, |
| 46 |
CB_TAG_COMPILE_HOST = 0x0009, |
| 47 |
CB_TAG_COMPILE_DOMAIN = 0x000a, |
| 48 |
CB_TAG_COMPILER = 0x000b, |
| 49 |
CB_TAG_LINKER = 0x000c, |
| 50 |
CB_TAG_ASSEMBLER = 0x000d, |
| 51 |
CB_TAG_SERIAL = 0x000f, |
| 52 |
CB_TAG_CONSOLE = 0x0010, |
| 53 |
CB_TAG_FORWARD = 0x0011, |
| 54 |
CB_TAG_FRAMEBUFFER = 0x0012, |
| 55 |
CB_TAG_GPIO = 0x0013, |
| 56 |
CB_TAG_TIMESTAMPS = 0x0016, |
| 57 |
CB_TAG_CBMEM_CONSOLE = 0x0017, |
| 58 |
CB_TAG_MRC_CACHE = 0x0018, |
| 59 |
CB_TAG_VBNV = 0x0019, |
| 60 |
CB_TAG_VBOOT_HANDOFF = 0x0020, |
| 61 |
CB_TAG_X86_ROM_MTRR = 0x0021, |
| 62 |
CB_TAG_DMA = 0x0022, |
| 63 |
CB_TAG_RAM_OOPS = 0x0023, |
| 64 |
CB_TAG_ACPI_GNVS = 0x0024, |
| 65 |
CB_TAG_BOARD_ID = 0x0025, |
| 66 |
CB_TAG_VERSION_TIMESTAMP = 0x0026, |
| 67 |
CB_TAG_WIFI_CALIBRATION = 0x0027, |
| 68 |
CB_TAG_RAM_CODE = 0x0028, |
| 69 |
CB_TAG_SPI_FLASH = 0x0029, |
| 70 |
CB_TAG_SERIALNO = 0x002a, |
| 71 |
CB_TAG_MTC = 0x002b, |
| 72 |
CB_TAG_VPD = 0x002c, |
| 73 |
CB_TAG_SKU_ID = 0x002d, |
| 74 |
CB_TAG_BOOT_MEDIA_PARAMS = 0x0030, |
| 75 |
CB_TAG_CBMEM_ENTRY = 0x0031, |
| 76 |
CB_TAG_TSC_INFO = 0x0032, |
| 77 |
CB_TAG_MAC_ADDRS = 0x0033, |
| 78 |
CB_TAG_VBOOT_WORKBUF = 0x0034, |
| 79 |
CB_TAG_MMC_INFO = 0x0035, |
| 80 |
CB_TAG_TCPA_LOG = 0x0036, |
| 81 |
CB_TAG_FMAP = 0x0037, |
| 82 |
CB_TAG_SMMSTOREV2 = 0x0039, |
| 83 |
CB_TAG_BOARD_CONFIG = 0x0040, |
| 84 |
CB_TAG_ACPI_CNVS = 0x0041, |
| 85 |
CB_TAG_TYPE_C_INFO = 0x0042, |
| 86 |
CB_TAG_ACPI_RSDP = 0x0043, |
| 87 |
CB_TAG_PCIE = 0x0044, |
| 88 |
CB_TAG_CMOS_OPTION_TABLE = 0x00c8, |
| 89 |
CB_TAG_OPTION = 0x00c9, |
| 90 |
CB_TAG_OPTION_ENUM = 0x00ca, |
| 91 |
CB_TAG_OPTION_DEFAULTS = 0x00cb, |
| 92 |
CB_TAG_OPTION_CHECKSUM = 0x00cc, |
| 93 |
CB_TAG_BOOT_MODE = 0x00cd, |
| 94 |
}; |
| 95 |
|
| 96 |
typedef __aligned(4) uint64_t cb_uint64_t; |
| 97 |
|
| 98 |
struct cb_header { |
| 99 |
u8 signature[4]; |
| 100 |
u32 header_bytes; |
| 101 |
u32 header_checksum; |
| 102 |
u32 table_bytes; |
| 103 |
u32 table_checksum; |
| 104 |
u32 table_entries; |
| 105 |
}; |
| 106 |
|
| 107 |
struct cb_record { |
| 108 |
u32 tag; |
| 109 |
u32 size; |
| 110 |
}; |
| 111 |
|
| 112 |
struct cb_memory_range { |
| 113 |
cb_uint64_t start; |
| 114 |
cb_uint64_t size; |
| 115 |
u32 type; |
| 116 |
}; |
| 117 |
|
| 118 |
#define CB_MEM_RAM 1 |
| 119 |
#define CB_MEM_RESERVED 2 |
| 120 |
#define CB_MEM_ACPI 3 |
| 121 |
#define CB_MEM_NVS 4 |
| 122 |
#define CB_MEM_UNUSABLE 5 |
| 123 |
#define CB_MEM_VENDOR_RSVD 6 |
| 124 |
#define CB_MEM_TABLE 16 |
| 125 |
|
| 126 |
struct cb_memory { |
| 127 |
u32 tag; |
| 128 |
u32 size; |
| 129 |
struct cb_memory_range map[]; |
| 130 |
}; |
| 131 |
|
| 132 |
struct cb_hwrpb { |
| 133 |
u32 tag; |
| 134 |
u32 size; |
| 135 |
u64 hwrpb; |
| 136 |
}; |
| 137 |
|
| 138 |
struct cb_mainboard { |
| 139 |
u32 tag; |
| 140 |
u32 size; |
| 141 |
u8 vendor_idx; |
| 142 |
u8 part_number_idx; |
| 143 |
u8 strings[]; |
| 144 |
}; |
| 145 |
|
| 146 |
enum type_c_orientation { |
| 147 |
TYPEC_ORIENTATION_NONE, |
| 148 |
TYPEC_ORIENTATION_NORMAL, |
| 149 |
TYPEC_ORIENTATION_REVERSE, |
| 150 |
}; |
| 151 |
|
| 152 |
struct type_c_port_info { |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
uint8_t usb2_port_number; |
| 158 |
uint8_t usb3_port_number; |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
uint8_t sbu_orientation; |
| 165 |
uint8_t data_orientation; |
| 166 |
}; |
| 167 |
|
| 168 |
struct type_c_info { |
| 169 |
u32 port_count; |
| 170 |
struct type_c_port_info port_info[]; |
| 171 |
}; |
| 172 |
|
| 173 |
struct cb_string { |
| 174 |
u32 tag; |
| 175 |
u32 size; |
| 176 |
u8 string[]; |
| 177 |
}; |
| 178 |
|
| 179 |
struct cb_serial { |
| 180 |
u32 tag; |
| 181 |
u32 size; |
| 182 |
#define CB_SERIAL_TYPE_IO_MAPPED 1 |
| 183 |
#define CB_SERIAL_TYPE_MEMORY_MAPPED 2 |
| 184 |
u32 type; |
| 185 |
u32 baseaddr; |
| 186 |
u32 baud; |
| 187 |
u32 regwidth; |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
u32 input_hertz; |
| 195 |
}; |
| 196 |
|
| 197 |
struct cb_console { |
| 198 |
u32 tag; |
| 199 |
u32 size; |
| 200 |
u16 type; |
| 201 |
}; |
| 202 |
|
| 203 |
#define CB_TAG_CONSOLE_SERIAL8250 0 |
| 204 |
#define CB_TAG_CONSOLE_VGA 1 // OBSOLETE |
| 205 |
#define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE |
| 206 |
#define CB_TAG_CONSOLE_LOGBUF 3 // OBSOLETE |
| 207 |
#define CB_TAG_CONSOLE_SROM 4 // OBSOLETE |
| 208 |
#define CB_TAG_CONSOLE_EHCI 5 |
| 209 |
|
| 210 |
struct cb_forward { |
| 211 |
u32 tag; |
| 212 |
u32 size; |
| 213 |
u64 forward; |
| 214 |
}; |
| 215 |
|
| 216 |
|
| 217 |
enum cb_fb_orientation { |
| 218 |
CB_FB_ORIENTATION_NORMAL = 0, |
| 219 |
CB_FB_ORIENTATION_BOTTOM_UP = 1, |
| 220 |
CB_FB_ORIENTATION_LEFT_UP = 2, |
| 221 |
CB_FB_ORIENTATION_RIGHT_UP = 3, |
| 222 |
}; |
| 223 |
|
| 224 |
struct cb_framebuffer_flags { |
| 225 |
u8 has_external_display : 1; |
| 226 |
u8 reserved : 7; |
| 227 |
}; |
| 228 |
|
| 229 |
struct cb_framebuffer { |
| 230 |
u32 tag; |
| 231 |
u32 size; |
| 232 |
|
| 233 |
u64 physical_address; |
| 234 |
u32 x_resolution; |
| 235 |
u32 y_resolution; |
| 236 |
u32 bytes_per_line; |
| 237 |
u8 bits_per_pixel; |
| 238 |
u8 red_mask_pos; |
| 239 |
u8 red_mask_size; |
| 240 |
u8 green_mask_pos; |
| 241 |
u8 green_mask_size; |
| 242 |
u8 blue_mask_pos; |
| 243 |
u8 blue_mask_size; |
| 244 |
u8 reserved_mask_pos; |
| 245 |
u8 reserved_mask_size; |
| 246 |
u8 orientation; |
| 247 |
struct cb_framebuffer_flags flags; |
| 248 |
u8 pad; |
| 249 |
}; |
| 250 |
|
| 251 |
#define CB_GPIO_ACTIVE_LOW 0 |
| 252 |
#define CB_GPIO_ACTIVE_HIGH 1 |
| 253 |
#define CB_GPIO_MAX_NAME_LENGTH 16 |
| 254 |
struct cb_gpio { |
| 255 |
u32 port; |
| 256 |
u32 polarity; |
| 257 |
u32 value; |
| 258 |
u8 name[CB_GPIO_MAX_NAME_LENGTH]; |
| 259 |
}; |
| 260 |
|
| 261 |
struct cb_gpios { |
| 262 |
u32 tag; |
| 263 |
u32 size; |
| 264 |
|
| 265 |
u32 count; |
| 266 |
struct cb_gpio gpios[]; |
| 267 |
}; |
| 268 |
|
| 269 |
struct cb_pcie { |
| 270 |
uint32_t tag; |
| 271 |
uint32_t size; |
| 272 |
cb_uint64_t ctrl_base; |
| 273 |
}; |
| 274 |
|
| 275 |
struct lb_range { |
| 276 |
uint32_t tag; |
| 277 |
uint32_t size; |
| 278 |
cb_uint64_t range_start; |
| 279 |
uint32_t range_size; |
| 280 |
}; |
| 281 |
|
| 282 |
struct cb_cbmem_tab { |
| 283 |
uint32_t tag; |
| 284 |
uint32_t size; |
| 285 |
cb_uint64_t cbmem_tab; |
| 286 |
}; |
| 287 |
|
| 288 |
struct cb_x86_rom_mtrr { |
| 289 |
uint32_t tag; |
| 290 |
uint32_t size; |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
uint32_t index; |
| 296 |
}; |
| 297 |
|
| 298 |
|
| 299 |
struct flash_mmap_window { |
| 300 |
uint32_t flash_base; |
| 301 |
uint32_t host_base; |
| 302 |
uint32_t size; |
| 303 |
}; |
| 304 |
|
| 305 |
struct cb_spi_flash { |
| 306 |
uint32_t tag; |
| 307 |
uint32_t size; |
| 308 |
uint32_t flash_size; |
| 309 |
uint32_t sector_size; |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
uint8_t erase_cmd; |
| 316 |
#define CB_SPI_FLASH_FLAG_IN_4BYTE_ADDR_MODE (1 << 0) |
| 317 |
uint8_t flags; |
| 318 |
uint16_t reserved; |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
uint32_t mmap_count; |
| 324 |
struct flash_mmap_window mmap_table[]; |
| 325 |
}; |
| 326 |
|
| 327 |
struct cb_boot_media_params { |
| 328 |
uint32_t tag; |
| 329 |
uint32_t size; |
| 330 |
|
| 331 |
cb_uint64_t fmap_offset; |
| 332 |
cb_uint64_t cbfs_offset; |
| 333 |
cb_uint64_t cbfs_size; |
| 334 |
cb_uint64_t boot_media_size; |
| 335 |
}; |
| 336 |
|
| 337 |
|
| 338 |
struct cb_cbmem_entry { |
| 339 |
uint32_t tag; |
| 340 |
uint32_t size; |
| 341 |
|
| 342 |
cb_uint64_t address; |
| 343 |
uint32_t entry_size; |
| 344 |
uint32_t id; |
| 345 |
}; |
| 346 |
|
| 347 |
struct cb_tsc_info { |
| 348 |
uint32_t tag; |
| 349 |
uint32_t size; |
| 350 |
|
| 351 |
uint32_t freq_khz; |
| 352 |
}; |
| 353 |
|
| 354 |
struct mac_address { |
| 355 |
uint8_t mac_addr[6]; |
| 356 |
uint8_t pad[2]; |
| 357 |
}; |
| 358 |
|
| 359 |
struct cb_macs { |
| 360 |
uint32_t tag; |
| 361 |
uint32_t size; |
| 362 |
uint32_t count; |
| 363 |
struct mac_address mac_addrs[]; |
| 364 |
}; |
| 365 |
|
| 366 |
struct cb_mmc_info { |
| 367 |
uint32_t tag; |
| 368 |
uint32_t size; |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
int32_t early_cmd1_status; |
| 378 |
}; |
| 379 |
|
| 380 |
struct cb_board_config { |
| 381 |
uint32_t tag; |
| 382 |
uint32_t size; |
| 383 |
|
| 384 |
cb_uint64_t fw_config; |
| 385 |
uint32_t board_id; |
| 386 |
uint32_t ram_code; |
| 387 |
uint32_t sku_id; |
| 388 |
}; |
| 389 |
|
| 390 |
#define CB_MAX_SERIALNO_LENGTH 32 |
| 391 |
|
| 392 |
struct cb_cmos_option_table { |
| 393 |
u32 tag; |
| 394 |
u32 size; |
| 395 |
u32 header_length; |
| 396 |
}; |
| 397 |
|
| 398 |
#define CB_CMOS_MAX_NAME_LENGTH 32 |
| 399 |
struct cb_cmos_entries { |
| 400 |
u32 tag; |
| 401 |
u32 size; |
| 402 |
u32 bit; |
| 403 |
u32 length; |
| 404 |
u32 config; |
| 405 |
u32 config_id; |
| 406 |
u8 name[CB_CMOS_MAX_NAME_LENGTH]; |
| 407 |
}; |
| 408 |
|
| 409 |
#define CB_CMOS_MAX_TEXT_LENGTH 32 |
| 410 |
struct cb_cmos_enums { |
| 411 |
u32 tag; |
| 412 |
u32 size; |
| 413 |
u32 config_id; |
| 414 |
u32 value; |
| 415 |
u8 text[CB_CMOS_MAX_TEXT_LENGTH]; |
| 416 |
}; |
| 417 |
|
| 418 |
#define CB_CMOS_IMAGE_BUFFER_SIZE 128 |
| 419 |
struct cb_cmos_defaults { |
| 420 |
u32 tag; |
| 421 |
u32 size; |
| 422 |
u32 name_length; |
| 423 |
u8 name[CB_CMOS_MAX_NAME_LENGTH]; |
| 424 |
u8 default_set[CB_CMOS_IMAGE_BUFFER_SIZE]; |
| 425 |
}; |
| 426 |
|
| 427 |
#define CB_CHECKSUM_NONE 0 |
| 428 |
#define CB_CHECKSUM_PCBIOS 1 |
| 429 |
struct cb_cmos_checksum { |
| 430 |
u32 tag; |
| 431 |
u32 size; |
| 432 |
u32 range_start; |
| 433 |
u32 range_end; |
| 434 |
u32 location; |
| 435 |
u32 type; |
| 436 |
}; |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
struct cb_acpi_rsdp { |
| 442 |
uint32_t tag; |
| 443 |
uint32_t size; |
| 444 |
cb_uint64_t rsdp_pointer; |
| 445 |
}; |
| 446 |
|
| 447 |
enum boot_mode_t { |
| 448 |
CB_BOOT_MODE_NORMAL, |
| 449 |
CB_BOOT_MODE_LOW_BATTERY, |
| 450 |
CB_BOOT_MODE_OFFMODE_CHARGING, |
| 451 |
}; |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
struct cb_boot_mode { |
| 459 |
uint32_t tag; |
| 460 |
uint32_t size; |
| 461 |
|
| 462 |
enum boot_mode_t boot_mode; |
| 463 |
}; |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
static inline u16 cb_checksum(const void *ptr, unsigned len) |
| 468 |
{ |
| 469 |
return ipchksum(ptr, len); |
| 470 |
} |
| 471 |
|
| 472 |
static inline const char *cb_mb_vendor_string(const struct cb_mainboard *cbm) |
| 473 |
{ |
| 474 |
return (char *)(cbm->strings + cbm->vendor_idx); |
| 475 |
} |
| 476 |
|
| 477 |
static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm) |
| 478 |
{ |
| 479 |
return (char *)(cbm->strings + cbm->part_number_idx); |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
#define MEM_RANGE_COUNT(_rec) \ |
| 485 |
(((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0])) |
| 486 |
|
| 487 |
#define MEM_RANGE_PTR(_rec, _idx) \ |
| 488 |
(void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \ |
| 489 |
+ (sizeof((_rec)->map[0]) * (_idx))) |
| 490 |
|
| 491 |
#endif |