Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the libpayload project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * 3. The name of the author may not be used to endorse or promote products |
| 15 | * derived from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 30 | #ifndef _COREBOOT_TABLES_H |
| 31 | #define _COREBOOT_TABLES_H |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 32 | |
| 33 | #include <arch/types.h> |
Gabe Black | 54c800a | 2012-08-28 16:31:09 -0700 | [diff] [blame] | 34 | #include <ipchksum.h> |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 35 | |
| 36 | struct cbuint64 { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 37 | u32 lo; |
| 38 | u32 hi; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | struct cb_header { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 42 | u8 signature[4]; |
| 43 | u32 header_bytes; |
| 44 | u32 header_checksum; |
| 45 | u32 table_bytes; |
| 46 | u32 table_checksum; |
| 47 | u32 table_entries; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | struct cb_record { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 51 | u32 tag; |
| 52 | u32 size; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #define CB_TAG_UNUSED 0x0000 |
| 56 | #define CB_TAG_MEMORY 0x0001 |
| 57 | |
| 58 | struct cb_memory_range { |
| 59 | struct cbuint64 start; |
| 60 | struct cbuint64 size; |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 61 | u32 type; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
Stefan Reinauer | d1bc331 | 2011-06-22 16:39:19 -0700 | [diff] [blame] | 64 | #define CB_MEM_RAM 1 |
| 65 | #define CB_MEM_RESERVED 2 |
| 66 | #define CB_MEM_ACPI 3 |
| 67 | #define CB_MEM_NVS 4 |
| 68 | #define CB_MEM_UNUSABLE 5 |
| 69 | #define CB_MEM_VENDOR_RSVD 6 |
| 70 | #define CB_MEM_TABLE 16 |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 71 | |
| 72 | struct cb_memory { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 73 | u32 tag; |
| 74 | u32 size; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 75 | struct cb_memory_range map[0]; |
| 76 | }; |
| 77 | |
| 78 | #define CB_TAG_HWRPB 0x0002 |
| 79 | |
| 80 | struct cb_hwrpb { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 81 | u32 tag; |
| 82 | u32 size; |
| 83 | u64 hwrpb; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | #define CB_TAG_MAINBOARD 0x0003 |
| 87 | |
| 88 | struct cb_mainboard { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 89 | u32 tag; |
| 90 | u32 size; |
| 91 | u8 vendor_idx; |
| 92 | u8 part_number_idx; |
| 93 | u8 strings[0]; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | #define CB_TAG_VERSION 0x0004 |
| 97 | #define CB_TAG_EXTRA_VERSION 0x0005 |
| 98 | #define CB_TAG_BUILD 0x0006 |
| 99 | #define CB_TAG_COMPILE_TIME 0x0007 |
| 100 | #define CB_TAG_COMPILE_BY 0x0008 |
| 101 | #define CB_TAG_COMPILE_HOST 0x0009 |
| 102 | #define CB_TAG_COMPILE_DOMAIN 0x000a |
| 103 | #define CB_TAG_COMPILER 0x000b |
| 104 | #define CB_TAG_LINKER 0x000c |
| 105 | #define CB_TAG_ASSEMBLER 0x000d |
| 106 | |
| 107 | struct cb_string { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 108 | u32 tag; |
| 109 | u32 size; |
| 110 | u8 string[0]; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | #define CB_TAG_SERIAL 0x000f |
| 114 | |
| 115 | struct cb_serial { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 116 | u32 tag; |
| 117 | u32 size; |
Stefan Reinauer | d1bc331 | 2011-06-22 16:39:19 -0700 | [diff] [blame] | 118 | #define CB_SERIAL_TYPE_IO_MAPPED 1 |
| 119 | #define CB_SERIAL_TYPE_MEMORY_MAPPED 2 |
| 120 | u32 type; |
| 121 | u32 baseaddr; |
| 122 | u32 baud; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | #define CB_TAG_CONSOLE 0x00010 |
| 126 | |
| 127 | struct cb_console { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 128 | u32 tag; |
| 129 | u32 size; |
| 130 | u16 type; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | #define CB_TAG_CONSOLE_SERIAL8250 0 |
Stefan Reinauer | abc0c85 | 2010-11-22 08:09:50 +0000 | [diff] [blame] | 134 | #define CB_TAG_CONSOLE_VGA 1 // OBSOLETE |
| 135 | #define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE |
Stefan Reinauer | 5ae3175 | 2013-06-19 13:47:46 -0700 | [diff] [blame] | 136 | #define CB_TAG_CONSOLE_LOGBUF 3 // OBSOLETE |
Stefan Reinauer | abc0c85 | 2010-11-22 08:09:50 +0000 | [diff] [blame] | 137 | #define CB_TAG_CONSOLE_SROM 4 // OBSOLETE |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 138 | #define CB_TAG_CONSOLE_EHCI 5 |
| 139 | |
Stefan Reinauer | 5f7d506 | 2009-03-17 16:41:01 +0000 | [diff] [blame] | 140 | #define CB_TAG_FORWARD 0x00011 |
| 141 | |
| 142 | struct cb_forward { |
| 143 | u32 tag; |
| 144 | u32 size; |
| 145 | u64 forward; |
| 146 | }; |
| 147 | |
Stefan Reinauer | b700254 | 2010-03-25 18:56:26 +0000 | [diff] [blame] | 148 | #define CB_TAG_FRAMEBUFFER 0x0012 |
| 149 | struct cb_framebuffer { |
| 150 | u32 tag; |
| 151 | u32 size; |
| 152 | |
| 153 | u64 physical_address; |
| 154 | u32 x_resolution; |
| 155 | u32 y_resolution; |
| 156 | u32 bytes_per_line; |
| 157 | u8 bits_per_pixel; |
Stefan Tauner | 3509ad3 | 2013-06-25 19:25:46 +0200 | [diff] [blame] | 158 | u8 red_mask_pos; |
Stefan Reinauer | b700254 | 2010-03-25 18:56:26 +0000 | [diff] [blame] | 159 | u8 red_mask_size; |
| 160 | u8 green_mask_pos; |
| 161 | u8 green_mask_size; |
| 162 | u8 blue_mask_pos; |
| 163 | u8 blue_mask_size; |
| 164 | u8 reserved_mask_pos; |
| 165 | u8 reserved_mask_size; |
| 166 | }; |
| 167 | |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 168 | #define CB_TAG_GPIO 0x0013 |
Gabe Black | 025667f | 2012-10-01 17:54:03 -0700 | [diff] [blame] | 169 | #define CB_GPIO_ACTIVE_LOW 0 |
| 170 | #define CB_GPIO_ACTIVE_HIGH 1 |
| 171 | #define CB_GPIO_MAX_NAME_LENGTH 16 |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 172 | struct cb_gpio { |
| 173 | u32 port; |
| 174 | u32 polarity; |
| 175 | u32 value; |
Gabe Black | 025667f | 2012-10-01 17:54:03 -0700 | [diff] [blame] | 176 | u8 name[CB_GPIO_MAX_NAME_LENGTH]; |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | struct cb_gpios { |
| 180 | u32 tag; |
| 181 | u32 size; |
| 182 | |
| 183 | u32 count; |
| 184 | struct cb_gpio gpios[0]; |
| 185 | }; |
| 186 | |
Julius Werner | 1f5487a | 2013-08-27 15:38:54 -0700 | [diff] [blame] | 187 | #define CB_TAG_VDAT 0x0015 |
| 188 | #define CB_TAG_VBNV 0x0019 |
| 189 | #define CB_TAG_VBOOT_HANDOFF 0x0020 |
Julius Werner | b8fad3d | 2013-08-27 15:48:32 -0700 | [diff] [blame] | 190 | #define CB_TAG_DMA 0x0022 |
Julius Werner | 1f5487a | 2013-08-27 15:38:54 -0700 | [diff] [blame] | 191 | struct lb_range { |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 192 | uint32_t tag; |
Julius Werner | 1f5487a | 2013-08-27 15:38:54 -0700 | [diff] [blame] | 193 | uint32_t size; |
| 194 | uint64_t range_start; |
| 195 | uint32_t range_size; |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | #define CB_TAG_TIMESTAMPS 0x0016 |
| 199 | #define CB_TAG_CBMEM_CONSOLE 0x0017 |
| 200 | #define CB_TAG_MRC_CACHE 0x0018 |
Duncan Laurie | f517c44 | 2013-12-12 10:43:58 -0800 | [diff] [blame] | 201 | #define CB_TAG_ACPI_GNVS 0x0024 |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 202 | struct cb_cbmem_tab { |
| 203 | uint32_t tag; |
| 204 | uint32_t size; |
Stefan Reinauer | 642b1db7 | 2013-04-18 18:01:34 -0700 | [diff] [blame] | 205 | uint64_t cbmem_tab; |
Gabe Black | d3890cc | 2012-03-11 01:57:53 -0800 | [diff] [blame] | 206 | }; |
| 207 | |
Vadim Bendebury | 6051e83 | 2014-07-29 17:51:29 -0700 | [diff] [blame^] | 208 | #define CB_TAG_BOARD_ID 0x0025 |
| 209 | struct cb_board_id { |
| 210 | uint32_t tag; |
| 211 | uint32_t size; |
| 212 | /* Board ID as retrieved from the board revision GPIOs. */ |
| 213 | uint32_t board_id; |
| 214 | }; |
| 215 | |
Aaron Durbin | a09760e | 2013-03-26 13:34:37 -0500 | [diff] [blame] | 216 | #define CB_TAG_X86_ROM_MTRR 0x0021 |
| 217 | struct cb_x86_rom_mtrr { |
| 218 | uint32_t tag; |
| 219 | uint32_t size; |
| 220 | /* The variable range MTRR index covering the ROM. If one wants to |
| 221 | * enable caching the ROM, the variable MTRR needs to be set to |
| 222 | * write-protect. To disable the caching after enabling set the |
| 223 | * type to uncacheable. */ |
| 224 | uint32_t index; |
| 225 | }; |
| 226 | |
| 227 | |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 228 | #define CB_TAG_CMOS_OPTION_TABLE 0x00c8 |
| 229 | struct cb_cmos_option_table { |
| 230 | u32 tag; |
| 231 | u32 size; |
| 232 | u32 header_length; |
| 233 | }; |
| 234 | |
| 235 | #define CB_TAG_OPTION 0x00c9 |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 236 | #define CB_CMOS_MAX_NAME_LENGTH 32 |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 237 | struct cb_cmos_entries { |
| 238 | u32 tag; |
| 239 | u32 size; |
| 240 | u32 bit; |
| 241 | u32 length; |
| 242 | u32 config; |
| 243 | u32 config_id; |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 244 | u8 name[CB_CMOS_MAX_NAME_LENGTH]; |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | |
| 248 | #define CB_TAG_OPTION_ENUM 0x00ca |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 249 | #define CB_CMOS_MAX_TEXT_LENGTH 32 |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 250 | struct cb_cmos_enums { |
| 251 | u32 tag; |
| 252 | u32 size; |
| 253 | u32 config_id; |
| 254 | u32 value; |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 255 | u8 text[CB_CMOS_MAX_TEXT_LENGTH]; |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | #define CB_TAG_OPTION_DEFAULTS 0x00cb |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 259 | #define CB_CMOS_IMAGE_BUFFER_SIZE 128 |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 260 | struct cb_cmos_defaults { |
| 261 | u32 tag; |
| 262 | u32 size; |
| 263 | u32 name_length; |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 264 | u8 name[CB_CMOS_MAX_NAME_LENGTH]; |
| 265 | u8 default_set[CB_CMOS_IMAGE_BUFFER_SIZE]; |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 266 | }; |
| 267 | |
| 268 | #define CB_TAG_OPTION_CHECKSUM 0x00cc |
Gabe Black | d94512e | 2012-10-01 18:05:50 -0700 | [diff] [blame] | 269 | #define CB_CHECKSUM_NONE 0 |
| 270 | #define CB_CHECKSUM_PCBIOS 1 |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 271 | struct cb_cmos_checksum { |
| 272 | u32 tag; |
| 273 | u32 size; |
| 274 | u32 range_start; |
| 275 | u32 range_end; |
| 276 | u32 location; |
| 277 | u32 type; |
| 278 | }; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 279 | |
Philip Prindeville | 46404d7 | 2011-12-23 17:09:02 -0700 | [diff] [blame] | 280 | /* Helpful inlines */ |
| 281 | |
| 282 | static inline u64 cb_unpack64(struct cbuint64 val) |
| 283 | { |
| 284 | return (((u64) val.hi) << 32) | val.lo; |
| 285 | } |
| 286 | |
Philip Prindeville | fe2f6b0 | 2011-12-23 17:22:05 -0700 | [diff] [blame] | 287 | static inline u16 cb_checksum(const void *ptr, unsigned len) |
| 288 | { |
| 289 | return ipchksum(ptr, len); |
| 290 | } |
| 291 | |
Philip Prindeville | 9a7c246 | 2011-12-24 22:12:37 -0700 | [diff] [blame] | 292 | static inline const char *cb_mb_vendor_string(const struct cb_mainboard *cbm) |
| 293 | { |
| 294 | return (char *)(cbm->strings + cbm->vendor_idx); |
| 295 | } |
| 296 | |
| 297 | static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm) |
| 298 | { |
| 299 | return (char *)(cbm->strings + cbm->part_number_idx); |
| 300 | } |
| 301 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 302 | /* Helpful macros */ |
| 303 | |
| 304 | #define MEM_RANGE_COUNT(_rec) \ |
Uwe Hermann | 6a441bf | 2008-03-20 19:54:59 +0000 | [diff] [blame] | 305 | (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0])) |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 306 | |
| 307 | #define MEM_RANGE_PTR(_rec, _idx) \ |
Philip Prindeville | 7d95b3e | 2011-12-23 17:53:26 -0700 | [diff] [blame] | 308 | (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \ |
| 309 | + (sizeof((_rec)->map[0]) * (_idx))) |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 310 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 311 | #endif |