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 30#ifndef _COREBOOT_TABLES_H 31#define _COREBOOT_TABLES_H 32 33#include <compiler.h> 34 35struct cbuint64 { 36 u32 lo; 37 u32 hi; 38}; 39 40struct cb_header { 41 u8 signature[4]; 42 u32 header_bytes; 43 u32 header_checksum; 44 u32 table_bytes; 45 u32 table_checksum; 46 u32 table_entries; 47}; 48 49struct cb_record { 50 u32 tag; 51 u32 size; 52}; 53 54#define CB_TAG_UNUSED 0x0000 55#define CB_TAG_MEMORY 0x0001 56 57struct cb_memory_range { 58 struct cbuint64 start; 59 struct cbuint64 size; 60 u32 type; 61}; 62 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 70 71struct cb_memory { 72 u32 tag; 73 u32 size; 74 struct cb_memory_range map[0]; 75}; 76 77#define CB_TAG_HWRPB 0x0002 78 79struct cb_hwrpb { 80 u32 tag; 81 u32 size; 82 u64 hwrpb; 83}; 84 85#define CB_TAG_MAINBOARD 0x0003 86 87struct cb_mainboard { 88 u32 tag; 89 u32 size; 90 u8 vendor_idx; 91 u8 part_number_idx; 92 u8 strings[0]; 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 106struct cb_string { 107 u32 tag; 108 u32 size; 109 u8 string[0]; 110}; 111 112#define CB_TAG_SERIAL 0x000f 113 114struct cb_serial { 115 u32 tag; 116 u32 size; 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; 122}; 123 124#define CB_TAG_CONSOLE 0x00010 125 126struct cb_console { 127 u32 tag; 128 u32 size; 129 u16 type; 130}; 131 132#define CB_TAG_CONSOLE_SERIAL8250 0 133#define CB_TAG_CONSOLE_VGA 1 /* OBSOLETE */ 134#define CB_TAG_CONSOLE_BTEXT 2 /* OBSOLETE */ 135#define CB_TAG_CONSOLE_LOGBUF 3 136#define CB_TAG_CONSOLE_SROM 4 /* OBSOLETE */ 137#define CB_TAG_CONSOLE_EHCI 5 138 139#define CB_TAG_FORWARD 0x00011 140 141struct cb_forward { 142 u32 tag; 143 u32 size; 144 u64 forward; 145}; 146 147#define CB_TAG_FRAMEBUFFER 0x0012 148struct 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 167#define CB_TAG_GPIO 0x0013 168#define GPIO_MAX_NAME_LENGTH 16 169struct cb_gpio { 170 u32 port; 171 u32 polarity; 172 u32 value; 173 u8 name[GPIO_MAX_NAME_LENGTH]; 174}; 175 176struct cb_gpios { 177 u32 tag; 178 u32 size; 179 180 u32 count; 181 struct cb_gpio gpios[0]; 182}; 183 184#define CB_TAG_FDT 0x0014 185struct cb_fdt { 186 uint32_t tag; 187 uint32_t size; /* size of the entire entry */ 188 /* the actual FDT gets placed here */ 189}; 190 191#define CB_TAG_VDAT 0x0015 192struct cb_vdat { 193 uint32_t tag; 194 uint32_t size; /* size of the entire entry */ 195 void *vdat_addr; 196 uint32_t vdat_size; 197}; 198 199#define CB_TAG_TIMESTAMPS 0x0016 200#define CB_TAG_CBMEM_CONSOLE 0x0017 201#define CB_TAG_MRC_CACHE 0x0018 202struct cb_cbmem_tab { 203 uint32_t tag; 204 uint32_t size; 205 void *cbmem_tab; 206}; 207 208#define CB_TAG_VBNV 0x0019 209struct cb_vbnv { 210 uint32_t tag; 211 uint32_t size; 212 uint32_t vbnv_start; 213 uint32_t vbnv_size; 214}; 215 216#define CB_TAG_CMOS_OPTION_TABLE 0x00c8 217struct cb_cmos_option_table { 218 u32 tag; 219 u32 size; 220 u32 header_length; 221}; 222 223#define CB_TAG_OPTION 0x00c9 224#define CMOS_MAX_NAME_LENGTH 32 225struct cb_cmos_entries { 226 u32 tag; 227 u32 size; 228 u32 bit; 229 u32 length; 230 u32 config; 231 u32 config_id; 232 u8 name[CMOS_MAX_NAME_LENGTH]; 233}; 234 235 236#define CB_TAG_OPTION_ENUM 0x00ca 237#define CMOS_MAX_TEXT_LENGTH 32 238struct cb_cmos_enums { 239 u32 tag; 240 u32 size; 241 u32 config_id; 242 u32 value; 243 u8 text[CMOS_MAX_TEXT_LENGTH]; 244}; 245 246#define CB_TAG_OPTION_DEFAULTS 0x00cb 247#define CMOS_IMAGE_BUFFER_SIZE 128 248struct cb_cmos_defaults { 249 u32 tag; 250 u32 size; 251 u32 name_length; 252 u8 name[CMOS_MAX_NAME_LENGTH]; 253 u8 default_set[CMOS_IMAGE_BUFFER_SIZE]; 254}; 255 256#define CB_TAG_OPTION_CHECKSUM 0x00cc 257#define CHECKSUM_NONE 0 258#define CHECKSUM_PCBIOS 1 259struct cb_cmos_checksum { 260 u32 tag; 261 u32 size; 262 u32 range_start; 263 u32 range_end; 264 u32 location; 265 u32 type; 266}; 267 268/* Helpful macros */ 269 270#define MEM_RANGE_COUNT(_rec) \ 271 (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0])) 272 273#define MEM_RANGE_PTR(_rec, _idx) \ 274 (((u8 *) (_rec)) + sizeof(*(_rec)) \ 275 + (sizeof((_rec)->map[0]) * (_idx))) 276 277#define MB_VENDOR_STRING(_mb) \ 278 (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx) 279 280#define MB_PART_STRING(_mb) \ 281 (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx) 282 283#define UNPACK_CB64(_in) \ 284 ((((u64) _in.hi) << 32) | _in.lo) 285 286struct sysinfo_t; 287 288int get_coreboot_info(struct sysinfo_t *info); 289 290#define CBMEM_TOC_RESERVED 512 291#define MAX_CBMEM_ENTRIES 16 292#define CBMEM_MAGIC 0x434f5245 293 294struct cbmem_entry { 295 u32 magic; 296 u32 id; 297 u64 base; 298 u64 size; 299} __packed; 300 301#define CBMEM_ID_FREESPACE 0x46524545 302#define CBMEM_ID_GDT 0x4c474454 303#define CBMEM_ID_ACPI 0x41435049 304#define CBMEM_ID_CBTABLE 0x43425442 305#define CBMEM_ID_PIRQ 0x49525154 306#define CBMEM_ID_MPTABLE 0x534d5054 307#define CBMEM_ID_RESUME 0x5245534d 308#define CBMEM_ID_RESUME_SCRATCH 0x52455343 309#define CBMEM_ID_SMBIOS 0x534d4254 310#define CBMEM_ID_TIMESTAMP 0x54494d45 311#define CBMEM_ID_MRCDATA 0x4d524344 312#define CBMEM_ID_CONSOLE 0x434f4e53 313#define CBMEM_ID_NONE 0x00000000 314 315#endif 316