00001 #ifndef COREBOOT_TABLES_H 00002 #define COREBOOT_TABLES_H 00003 00004 #include <stdint.h> 00005 00006 /* The coreboot table information is for conveying information 00007 * from the firmware to the loaded OS image. Primarily this 00008 * is expected to be information that cannot be discovered by 00009 * other means, such as quering the hardware directly. 00010 * 00011 * All of the information should be Position Independent Data. 00012 * That is it should be safe to relocated any of the information 00013 * without it's meaning/correctnes changing. For table that 00014 * can reasonably be used on multiple architectures the data 00015 * size should be fixed. This should ease the transition between 00016 * 32 bit and 64 bit architectures etc. 00017 * 00018 * The completeness test for the information in this table is: 00019 * - Can all of the hardware be detected? 00020 * - Are the per motherboard constants available? 00021 * - Is there enough to allow a kernel to run that was written before 00022 * a particular motherboard is constructed? (Assuming the kernel 00023 * has drivers for all of the hardware but it does not have 00024 * assumptions on how the hardware is connected together). 00025 * 00026 * With this test it should be straight forward to determine if a 00027 * table entry is required or not. This should remove much of the 00028 * long term compatibility burden as table entries which are 00029 * irrelevant or have been replaced by better alternatives may be 00030 * dropped. Of course it is polite and expidite to include extra 00031 * table entries and be backwards compatible, but it is not required. 00032 */ 00033 00034 /* Since coreboot is usually compiled 32bit, gcc will align 64bit 00035 * types to 32bit boundaries. If the coreboot table is dumped on a 00036 * 64bit system, a uint64_t would be aligned to 64bit boundaries, 00037 * breaking the table format. 00038 * 00039 * lb_uint64 will keep 64bit coreboot table values aligned to 32bit 00040 * to ensure compatibility. They can be accessed with the two functions 00041 * below: unpack_lb64() and pack_lb64() 00042 * 00043 * See also: util/lbtdump/lbtdump.c 00044 */ 00045 00046 struct lb_uint64 { 00047 uint32_t lo; 00048 uint32_t hi; 00049 }; 00050 00051 static inline uint64_t unpack_lb64(struct lb_uint64 value) 00052 { 00053 uint64_t result; 00054 result = value.hi; 00055 result = (result << 32) + value.lo; 00056 return result; 00057 } 00058 00059 static inline struct lb_uint64 pack_lb64(uint64_t value) 00060 { 00061 struct lb_uint64 result; 00062 result.lo = (value >> 0) & 0xffffffff; 00063 result.hi = (value >> 32) & 0xffffffff; 00064 return result; 00065 } 00066 00067 00068 00069 struct lb_header 00070 { 00071 uint8_t signature[4]; /* LBIO */ 00072 uint32_t header_bytes; 00073 uint32_t header_checksum; 00074 uint32_t table_bytes; 00075 uint32_t table_checksum; 00076 uint32_t table_entries; 00077 }; 00078 00079 /* Every entry in the boot enviroment list will correspond to a boot 00080 * info record. Encoding both type and size. The type is obviously 00081 * so you can tell what it is. The size allows you to skip that 00082 * boot enviroment record if you don't know what it easy. This allows 00083 * forward compatibility with records not yet defined. 00084 */ 00085 struct lb_record { 00086 uint32_t tag; /* tag ID */ 00087 uint32_t size; /* size of record (in bytes) */ 00088 }; 00089 00090 #define LB_TAG_UNUSED 0x0000 00091 00092 #define LB_TAG_MEMORY 0x0001 00093 00094 struct lb_memory_range { 00095 struct lb_uint64 start; 00096 struct lb_uint64 size; 00097 uint32_t type; 00098 #define LB_MEM_RAM 1 /* Memory anyone can use */ 00099 #define LB_MEM_RESERVED 2 /* Don't use this memory region */ 00100 #define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */ 00101 }; 00102 00103 struct lb_memory { 00104 uint32_t tag; 00105 uint32_t size; 00106 struct lb_memory_range map[0]; 00107 }; 00108 00109 #define LB_TAG_HWRPB 0x0002 00110 struct lb_hwrpb { 00111 uint32_t tag; 00112 uint32_t size; 00113 uint64_t hwrpb; 00114 }; 00115 00116 #define LB_TAG_MAINBOARD 0x0003 00117 struct lb_mainboard { 00118 uint32_t tag; 00119 uint32_t size; 00120 uint8_t vendor_idx; 00121 uint8_t part_number_idx; 00122 uint8_t strings[0]; 00123 }; 00124 00125 #define LB_TAG_VERSION 0x0004 00126 #define LB_TAG_EXTRA_VERSION 0x0005 00127 #define LB_TAG_BUILD 0x0006 00128 #define LB_TAG_COMPILE_TIME 0x0007 00129 #define LB_TAG_COMPILE_BY 0x0008 00130 #define LB_TAG_COMPILE_HOST 0x0009 00131 #define LB_TAG_COMPILE_DOMAIN 0x000a 00132 #define LB_TAG_COMPILER 0x000b 00133 #define LB_TAG_LINKER 0x000c 00134 #define LB_TAG_ASSEMBLER 0x000d 00135 struct lb_string { 00136 uint32_t tag; 00137 uint32_t size; 00138 uint8_t string[0]; 00139 }; 00140 00141 /* 0xe is taken by v3 */ 00142 00143 #define LB_TAG_SERIAL 0x000f 00144 struct lb_serial { 00145 uint32_t tag; 00146 uint32_t size; 00147 uint16_t ioport; 00148 uint32_t baud; 00149 }; 00150 00151 #define LB_TAG_CONSOLE 0x0010 00152 struct lb_console { 00153 uint32_t tag; 00154 uint32_t size; 00155 uint16_t type; 00156 }; 00157 00158 #define LB_TAG_CONSOLE_SERIAL8250 0 00159 #define LB_TAG_CONSOLE_VGA 1 00160 #define LB_TAG_CONSOLE_BTEXT 2 00161 #define LB_TAG_CONSOLE_LOGBUF 3 00162 #define LB_TAG_CONSOLE_SROM 4 00163 #define LB_TAG_CONSOLE_EHCI 5 00164 00165 /* The following structures are for the cmos definitions table */ 00166 #define LB_TAG_CMOS_OPTION_TABLE 200 00167 /* cmos header record */ 00168 struct cmos_option_table { 00169 uint32_t tag; /* CMOS definitions table type */ 00170 uint32_t size; /* size of the entire table */ 00171 uint32_t header_length; /* length of header */ 00172 }; 00173 00174 /* cmos entry record 00175 This record is variable length. The name field may be 00176 shorter than CMOS_MAX_NAME_LENGTH. The entry may start 00177 anywhere in the byte, but can not span bytes unless it 00178 starts at the beginning of the byte and the length is 00179 fills complete bytes. 00180 */ 00181 #define LB_TAG_OPTION 201 00182 struct cmos_entries { 00183 uint32_t tag; /* entry type */ 00184 uint32_t size; /* length of this record */ 00185 uint32_t bit; /* starting bit from start of image */ 00186 uint32_t length; /* length of field in bits */ 00187 uint32_t config; /* e=enumeration, h=hex, r=reserved */ 00188 uint32_t config_id; /* a number linking to an enumeration record */ 00189 #define CMOS_MAX_NAME_LENGTH 32 00190 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii, 00191 variable length int aligned */ 00192 }; 00193 00194 00195 /* cmos enumerations record 00196 This record is variable length. The text field may be 00197 shorter than CMOS_MAX_TEXT_LENGTH. 00198 */ 00199 #define LB_TAG_OPTION_ENUM 202 00200 struct cmos_enums { 00201 uint32_t tag; /* enumeration type */ 00202 uint32_t size; /* length of this record */ 00203 uint32_t config_id; /* a number identifying the config id */ 00204 uint32_t value; /* the value associated with the text */ 00205 #define CMOS_MAX_TEXT_LENGTH 32 00206 uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii, 00207 variable length int aligned */ 00208 }; 00209 00210 /* cmos defaults record 00211 This record contains default settings for the cmos ram. 00212 */ 00213 #define LB_TAG_OPTION_DEFAULTS 203 00214 struct cmos_defaults { 00215 uint32_t tag; /* default type */ 00216 uint32_t size; /* length of this record */ 00217 uint32_t name_length; /* length of the following name field */ 00218 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */ 00219 #define CMOS_IMAGE_BUFFER_SIZE 128 00220 uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */ 00221 }; 00222 00223 #define LB_TAG_OPTION_CHECKSUM 204 00224 struct cmos_checksum { 00225 uint32_t tag; 00226 uint32_t size; 00227 /* In practice everything is byte aligned, but things are measured 00228 * in bits to be consistent. 00229 */ 00230 uint32_t range_start; /* First bit that is checksummed (byte aligned) */ 00231 uint32_t range_end; /* Last bit that is checksummed (byte aligned) */ 00232 uint32_t location; /* First bit of the checksum (byte aligned) */ 00233 uint32_t type; /* Checksum algorithm that is used */ 00234 #define CHECKSUM_NONE 0 00235 #define CHECKSUM_PCBIOS 1 00236 }; 00237 00238 00239 00240 #endif /* COREBOOT_TABLES_H */
1.5.5