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> |
| 34 | |
| 35 | struct cbuint64 { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 36 | u32 lo; |
| 37 | u32 hi; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct cb_header { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 41 | u8 signature[4]; |
| 42 | u32 header_bytes; |
| 43 | u32 header_checksum; |
| 44 | u32 table_bytes; |
| 45 | u32 table_checksum; |
| 46 | u32 table_entries; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct cb_record { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 50 | u32 tag; |
| 51 | u32 size; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | #define CB_TAG_UNUSED 0x0000 |
| 55 | #define CB_TAG_MEMORY 0x0001 |
| 56 | |
| 57 | struct cb_memory_range { |
| 58 | struct cbuint64 start; |
| 59 | struct cbuint64 size; |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 60 | u32 type; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
Stefan Reinauer | d1bc331 | 2011-06-22 16:39:19 -0700 | [diff] [blame] | 63 | #define CB_MEM_RAM 1 |
| 64 | #define CB_MEM_RESERVED 2 |
| 65 | #define CB_MEM_ACPI 3 |
| 66 | #define CB_MEM_NVS 4 |
| 67 | #define CB_MEM_UNUSABLE 5 |
| 68 | #define CB_MEM_VENDOR_RSVD 6 |
| 69 | #define CB_MEM_TABLE 16 |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 70 | |
| 71 | struct cb_memory { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 72 | u32 tag; |
| 73 | u32 size; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 74 | struct cb_memory_range map[0]; |
| 75 | }; |
| 76 | |
| 77 | #define CB_TAG_HWRPB 0x0002 |
| 78 | |
| 79 | struct cb_hwrpb { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 80 | u32 tag; |
| 81 | u32 size; |
| 82 | u64 hwrpb; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | #define CB_TAG_MAINBOARD 0x0003 |
| 86 | |
| 87 | struct cb_mainboard { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 88 | u32 tag; |
| 89 | u32 size; |
| 90 | u8 vendor_idx; |
| 91 | u8 part_number_idx; |
| 92 | u8 strings[0]; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | #define CB_TAG_VERSION 0x0004 |
| 96 | #define CB_TAG_EXTRA_VERSION 0x0005 |
| 97 | #define CB_TAG_BUILD 0x0006 |
| 98 | #define CB_TAG_COMPILE_TIME 0x0007 |
| 99 | #define CB_TAG_COMPILE_BY 0x0008 |
| 100 | #define CB_TAG_COMPILE_HOST 0x0009 |
| 101 | #define CB_TAG_COMPILE_DOMAIN 0x000a |
| 102 | #define CB_TAG_COMPILER 0x000b |
| 103 | #define CB_TAG_LINKER 0x000c |
| 104 | #define CB_TAG_ASSEMBLER 0x000d |
| 105 | |
| 106 | struct cb_string { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 107 | u32 tag; |
| 108 | u32 size; |
| 109 | u8 string[0]; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | #define CB_TAG_SERIAL 0x000f |
| 113 | |
| 114 | struct cb_serial { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 115 | u32 tag; |
| 116 | u32 size; |
Stefan Reinauer | d1bc331 | 2011-06-22 16:39:19 -0700 | [diff] [blame] | 117 | #define CB_SERIAL_TYPE_IO_MAPPED 1 |
| 118 | #define CB_SERIAL_TYPE_MEMORY_MAPPED 2 |
| 119 | u32 type; |
| 120 | u32 baseaddr; |
| 121 | u32 baud; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | #define CB_TAG_CONSOLE 0x00010 |
| 125 | |
| 126 | struct cb_console { |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 127 | u32 tag; |
| 128 | u32 size; |
| 129 | u16 type; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | #define CB_TAG_CONSOLE_SERIAL8250 0 |
Stefan Reinauer | abc0c85 | 2010-11-22 08:09:50 +0000 | [diff] [blame] | 133 | #define CB_TAG_CONSOLE_VGA 1 // OBSOLETE |
| 134 | #define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 135 | #define CB_TAG_CONSOLE_LOGBUF 3 |
Stefan Reinauer | abc0c85 | 2010-11-22 08:09:50 +0000 | [diff] [blame] | 136 | #define CB_TAG_CONSOLE_SROM 4 // OBSOLETE |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 137 | #define CB_TAG_CONSOLE_EHCI 5 |
| 138 | |
Stefan Reinauer | 5f7d506 | 2009-03-17 16:41:01 +0000 | [diff] [blame] | 139 | #define CB_TAG_FORWARD 0x00011 |
| 140 | |
| 141 | struct cb_forward { |
| 142 | u32 tag; |
| 143 | u32 size; |
| 144 | u64 forward; |
| 145 | }; |
| 146 | |
Stefan Reinauer | b700254 | 2010-03-25 18:56:26 +0000 | [diff] [blame] | 147 | #define CB_TAG_FRAMEBUFFER 0x0012 |
| 148 | struct cb_framebuffer { |
| 149 | u32 tag; |
| 150 | u32 size; |
| 151 | |
| 152 | u64 physical_address; |
| 153 | u32 x_resolution; |
| 154 | u32 y_resolution; |
| 155 | u32 bytes_per_line; |
| 156 | u8 bits_per_pixel; |
| 157 | u8 red_mask_pos; |
| 158 | u8 red_mask_size; |
| 159 | u8 green_mask_pos; |
| 160 | u8 green_mask_size; |
| 161 | u8 blue_mask_pos; |
| 162 | u8 blue_mask_size; |
| 163 | u8 reserved_mask_pos; |
| 164 | u8 reserved_mask_size; |
| 165 | }; |
| 166 | |
Stefan Reinauer | 95a6e1c | 2008-08-07 10:21:05 +0000 | [diff] [blame] | 167 | #define CB_TAG_CMOS_OPTION_TABLE 0x00c8 |
| 168 | struct cb_cmos_option_table { |
| 169 | u32 tag; |
| 170 | u32 size; |
| 171 | u32 header_length; |
| 172 | }; |
| 173 | |
| 174 | #define CB_TAG_OPTION 0x00c9 |
| 175 | #define CMOS_MAX_NAME_LENGTH 32 |
| 176 | struct cb_cmos_entries { |
| 177 | u32 tag; |
| 178 | u32 size; |
| 179 | u32 bit; |
| 180 | u32 length; |
| 181 | u32 config; |
| 182 | u32 config_id; |
| 183 | u8 name[CMOS_MAX_NAME_LENGTH]; |
| 184 | }; |
| 185 | |
| 186 | |
| 187 | #define CB_TAG_OPTION_ENUM 0x00ca |
| 188 | #define CMOS_MAX_TEXT_LENGTH 32 |
| 189 | struct cb_cmos_enums { |
| 190 | u32 tag; |
| 191 | u32 size; |
| 192 | u32 config_id; |
| 193 | u32 value; |
| 194 | u8 text[CMOS_MAX_TEXT_LENGTH]; |
| 195 | }; |
| 196 | |
| 197 | #define CB_TAG_OPTION_DEFAULTS 0x00cb |
| 198 | #define CMOS_IMAGE_BUFFER_SIZE 128 |
| 199 | struct cb_cmos_defaults { |
| 200 | u32 tag; |
| 201 | u32 size; |
| 202 | u32 name_length; |
| 203 | u8 name[CMOS_MAX_NAME_LENGTH]; |
| 204 | u8 default_set[CMOS_IMAGE_BUFFER_SIZE]; |
| 205 | }; |
| 206 | |
| 207 | #define CB_TAG_OPTION_CHECKSUM 0x00cc |
| 208 | #define CHECKSUM_NONE 0 |
| 209 | #define CHECKSUM_PCBIOS 1 |
| 210 | struct cb_cmos_checksum { |
| 211 | u32 tag; |
| 212 | u32 size; |
| 213 | u32 range_start; |
| 214 | u32 range_end; |
| 215 | u32 location; |
| 216 | u32 type; |
| 217 | }; |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 218 | |
Philip Prindeville | 46404d7 | 2011-12-23 17:09:02 -0700 | [diff] [blame] | 219 | /* Helpful inlines */ |
| 220 | |
| 221 | static inline u64 cb_unpack64(struct cbuint64 val) |
| 222 | { |
| 223 | return (((u64) val.hi) << 32) | val.lo; |
| 224 | } |
| 225 | |
Philip Prindeville | fe2f6b0 | 2011-12-23 17:22:05 -0700 | [diff] [blame^] | 226 | static inline u16 cb_checksum(const void *ptr, unsigned len) |
| 227 | { |
| 228 | return ipchksum(ptr, len); |
| 229 | } |
| 230 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 231 | /* Helpful macros */ |
| 232 | |
| 233 | #define MEM_RANGE_COUNT(_rec) \ |
Uwe Hermann | 6a441bf | 2008-03-20 19:54:59 +0000 | [diff] [blame] | 234 | (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0])) |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 235 | |
| 236 | #define MEM_RANGE_PTR(_rec, _idx) \ |
Uwe Hermann | fad8c2b | 2008-04-11 18:01:50 +0000 | [diff] [blame] | 237 | (((u8 *) (_rec)) + sizeof(*(_rec)) \ |
Uwe Hermann | 6a441bf | 2008-03-20 19:54:59 +0000 | [diff] [blame] | 238 | + (sizeof((_rec)->map[0]) * (_idx))) |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 239 | |
| 240 | #define MB_VENDOR_STRING(_mb) \ |
| 241 | (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx) |
| 242 | |
| 243 | #define MB_PART_STRING(_mb) \ |
| 244 | (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx) |
| 245 | |
Jordan Crouse | f6145c3 | 2008-03-19 23:56:58 +0000 | [diff] [blame] | 246 | #endif |