1/* 2 * This file is part of the coreboot project. 3 * 4 * Copyright (C) 2002 Linux Networx 5 * (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx) 6 * Copyright (C) 2005-2007 coresystems GmbH 7 * (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH) 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; version 2 of the License. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA 21 */ 22 23#ifndef TABLES_H 24#define TABLES_H 25 26/* 27 * Table management structs and prototypes for coreboot. 28 * 29 * ALL structs and prototypes for tables that coreboot generates should be 30 * defined here. 31 */ 32 33void *write_tables(void); 34 35/* The coreboot table information is for conveying information 36 * from the firmware to the loaded OS image. Primarily this 37 * is expected to be information that cannot be discovered by 38 * other means, such as quering the hardware directly. 39 * 40 * All of the information should be Position Independent Data. 41 * That is it should be safe to relocated any of the information 42 * without it's meaning/correctnes changing. For table that 43 * can reasonably be used on multiple architectures the data 44 * size should be fixed. This should ease the transition between 45 * 32 bit and 64 bit architectures etc. 46 * 47 * The completeness test for the information in this table is: 48 * - Can all of the hardware be detected? 49 * - Are the per motherboard constants available? 50 * - Is there enough to allow a kernel to run that was written before 51 * a particular motherboard is constructed? (Assuming the kernel 52 * has drivers for all of the hardware but it does not have 53 * assumptions on how the hardware is connected together). 54 * 55 * With this test it should be straight forward to determine if a 56 * table entry is required or not. This should remove much of the 57 * long term compatibility burden as table entries which are 58 * irrelevant or have been replaced by better alternatives may be 59 * dropped. Of course it is polite and expidite to include extra 60 * table entries and be backwards compatible, but it is not required. 61 */ 62 63/* Since coreboot is usually compiled 32bit, gcc will align 64bit 64 * types to 32bit boundaries. If the coreboot table is dumped on a 65 * 64bit system, a u64 would be aligned to 64bit boundaries, 66 * breaking the table format. 67 * 68 * lb_uint64 will keep 64bit coreboot table values aligned to 32bit 69 * to ensure compatibility. They can be accessed with the two functions 70 * below: unpack_lb64() and pack_lb64() 71 * 72 * See also: util/lbtdump/lbtdump.c 73 */ 74 75struct lb_uint64 { 76 u32 lo; 77 u32 hi; 78}; 79 80static inline u64 unpack_lb64(struct lb_uint64 value) 81{ 82 u64 result; 83 result = value.hi; 84 result = (result << 32) + value.lo; 85 return result; 86} 87 88static inline struct lb_uint64 pack_lb64(u64 value) 89{ 90 struct lb_uint64 result; 91 result.lo = (value >> 0) & 0xffffffff; 92 result.hi = (value >> 32) & 0xffffffff; 93 return result; 94} 95 96 97 98struct lb_header 99{ 100 u8 signature[4]; /* LBIO */ 101 u32 header_bytes; 102 u32 header_checksum; 103 u32 table_bytes; 104 u32 table_checksum; 105 u32 table_entries; 106}; 107 108/* Every entry in the boot enviroment list will correspond to a boot 109 * info record. Encoding both type and size. The type is obviously 110 * so you can tell what it is. The size allows you to skip that 111 * boot enviroment record if you don't know what it easy. This allows 112 * forward compatibility with records not yet defined. 113 */ 114struct lb_record { 115 u32 tag; /* tag ID */ 116 u32 size; /* size of record (in bytes) */ 117}; 118 119#define LB_TAG_UNUSED 0x0000 120 121#define LB_TAG_MEMORY 0x0001 122 123struct lb_memory_range { 124 struct lb_uint64 start; 125 struct lb_uint64 size; 126 u32 type; 127#define LB_MEM_RAM 1 /* Memory anyone can use */ 128#define LB_MEM_RESERVED 2 /* Don't use this memory region */ 129#define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */ 130}; 131 132struct lb_memory { 133 u32 tag; 134 u32 size; 135 struct lb_memory_range map[0]; 136}; 137 138#define LB_TAG_HWRPB 0x0002 139struct lb_hwrpb { 140 u32 tag; 141 u32 size; 142 u64 hwrpb; 143}; 144 145#define LB_TAG_MAINBOARD 0x0003 146struct lb_mainboard { 147 u32 tag; 148 u32 size; 149 u8 vendor_idx; 150 u8 part_number_idx; 151 u8 strings[0]; 152}; 153 154#define LB_TAG_VERSION 0x0004 155#define LB_TAG_EXTRA_VERSION 0x0005 156#define LB_TAG_BUILD 0x0006 157#define LB_TAG_COMPILE_TIME 0x0007 158#define LB_TAG_COMPILE_BY 0x0008 159#define LB_TAG_COMPILE_HOST 0x0009 160#define LB_TAG_COMPILE_DOMAIN 0x000a 161#define LB_TAG_COMPILER 0x000b 162#define LB_TAG_LINKER 0x000c 163#define LB_TAG_ASSEMBLER 0x000d 164struct lb_string { 165 u32 tag; 166 u32 size; 167 u8 string[0]; 168}; 169 170#define LB_TAG_DEVTREE_PTR 0x000e 171 172struct lb_devtree { 173 u32 tag; 174 u32 size; 175 u32 dev_root_ptr; /* Pointer to the root device */ 176}; 177 178#define LB_TAG_SERIAL 0x000f 179struct lb_serial { 180 u32 tag; 181 u32 size; 182 u16 ioport; 183 u32 baud; 184}; 185 186#define LB_TAG_CONSOLE 0x0010 187struct lb_console { 188 u32 tag; 189 u32 size; 190 u16 type; 191}; 192 193#define LB_TAG_CONSOLE_SERIAL8250 0 194#define LB_TAG_CONSOLE_VGA 1 195#define LB_TAG_CONSOLE_BTEXT 2 196#define LB_TAG_CONSOLE_LOGBUF 3 197#define LB_TAG_CONSOLE_SROM 4 198#define LB_TAG_CONSOLE_EHCI 5 199 200/* The following structures are for the cmos definitions table */ 201#define LB_TAG_CMOS_OPTION_TABLE 200 202/* cmos header record */ 203struct cmos_option_table { 204 u32 tag; /* CMOS definitions table type */ 205 u32 size; /* size of the entire table */ 206 u32 header_length; /* length of header */ 207}; 208 209/* cmos entry record 210 This record is variable length. The name field may be 211 shorter than CMOS_MAX_NAME_LENGTH. The entry may start 212 anywhere in the byte, but can not span bytes unless it 213 starts at the beginning of the byte and the length is 214 fills complete bytes. 215*/ 216#define LB_TAG_OPTION 201 217struct cmos_entries { 218 u32 tag; /* entry type */ 219 u32 size; /* length of this record */ 220 u32 bit; /* starting bit from start of image */ 221 u32 length; /* length of field in bits */ 222 u32 config; /* e=enumeration, h=hex, r=reserved */ 223 u32 config_id; /* a number linking to an enumeration record */ 224#define CMOS_MAX_NAME_LENGTH 32 225 u8 name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii, 226 variable length int aligned */ 227}; 228 229 230/* cmos enumerations record 231 This record is variable length. The text field may be 232 shorter than CMOS_MAX_TEXT_LENGTH. 233*/ 234#define LB_TAG_OPTION_ENUM 202 235struct cmos_enums { 236 u32 tag; /* enumeration type */ 237 u32 size; /* length of this record */ 238 u32 config_id; /* a number identifying the config id */ 239 u32 value; /* the value associated with the text */ 240#define CMOS_MAX_TEXT_LENGTH 32 241 u8 text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii, 242 variable length int aligned */ 243}; 244 245/* cmos defaults record 246 This record contains default settings for the cmos ram. 247*/ 248#define LB_TAG_OPTION_DEFAULTS 203 249struct cmos_defaults { 250 u32 tag; /* default type */ 251 u32 size; /* length of this record */ 252 u32 name_length; /* length of the following name field */ 253 u8 name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */ 254#define CMOS_IMAGE_BUFFER_SIZE 128 255 u8 default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */ 256}; 257 258#define LB_TAG_OPTION_CHECKSUM 204 259struct cmos_checksum { 260 u32 tag; 261 u32 size; 262 /* In practice everything is byte aligned, but things are measured 263 * in bits to be consistent. 264 */ 265 u32 range_start; /* First bit that is checksummed (byte aligned) */ 266 u32 range_end; /* Last bit that is checksummed (byte aligned) */ 267 u32 location; /* First bit of the checksum (byte aligned) */ 268 u32 type; /* Checksum algorithm that is used */ 269#define CHECKSUM_NONE 0 270#define CHECKSUM_PCBIOS 1 271}; 272 273void *arch_write_tables(void); 274unsigned long write_coreboot_table( 275 unsigned long low_table_start, unsigned long low_table_end, 276 unsigned long rom_table_start, unsigned long rom_table_end); 277 278struct lb_header *lb_table_init(unsigned long addr); 279struct lb_record *lb_first_record(struct lb_header *header); 280struct lb_record *lb_last_record(struct lb_header *header); 281struct lb_record *lb_next_record(struct lb_record *rec); 282struct lb_record *lb_new_record(struct lb_header *header); 283struct lb_memory *lb_memory(struct lb_header *header); 284struct lb_mainboard *lb_mainboard(struct lb_header *header); 285unsigned long lb_table_fini(struct lb_header *header); 286 287/* Routines to extract part so the coreboot table or information 288 * from the coreboot table. 289 */ 290struct lb_memory *get_lb_mem(void); 291 292struct cmos_option_table *get_option_table(void); 293 294#ifdef CONFIG_PIRQ_TABLE 295unsigned long write_pirq_routing_table(unsigned long addr); 296#endif 297 298 299#endif /* TABLES_H */ 300

