Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame^] | 1 | #ifndef COREBOOT_TABLES_H |
| 2 | #define COREBOOT_TABLES_H |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame^] | 6 | /* The coreboot table information is for conveying information |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 7 | * from the firmware to the loaded OS image. Primarily this |
| 8 | * is expected to be information that cannot be discovered by |
| 9 | * other means, such as quering the hardware directly. |
| 10 | * |
| 11 | * All of the information should be Position Independent Data. |
| 12 | * That is it should be safe to relocated any of the information |
| 13 | * without it's meaning/correctnes changing. For table that |
| 14 | * can reasonably be used on multiple architectures the data |
| 15 | * size should be fixed. This should ease the transition between |
| 16 | * 32 bit and 64 bit architectures etc. |
| 17 | * |
| 18 | * The completeness test for the information in this table is: |
| 19 | * - Can all of the hardware be detected? |
| 20 | * - Are the per motherboard constants available? |
| 21 | * - Is there enough to allow a kernel to run that was written before |
| 22 | * a particular motherboard is constructed? (Assuming the kernel |
| 23 | * has drivers for all of the hardware but it does not have |
| 24 | * assumptions on how the hardware is connected together). |
| 25 | * |
| 26 | * With this test it should be straight forward to determine if a |
| 27 | * table entry is required or not. This should remove much of the |
| 28 | * long term compatibility burden as table entries which are |
| 29 | * irrelevant or have been replaced by better alternatives may be |
| 30 | * dropped. Of course it is polite and expidite to include extra |
| 31 | * table entries and be backwards compatible, but it is not required. |
| 32 | */ |
| 33 | |
Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame^] | 34 | /* Since coreboot is usually compiled 32bit, gcc will align 64bit |
| 35 | * types to 32bit boundaries. If the coreboot table is dumped on a |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 36 | * 64bit system, a uint64_t would be aligned to 64bit boundaries, |
| 37 | * breaking the table format. |
| 38 | * |
Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame^] | 39 | * lb_uint64 will keep 64bit coreboot table values aligned to 32bit |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 40 | * to ensure compatibility. They can be accessed with the two functions |
| 41 | * below: unpack_lb64() and pack_lb64() |
| 42 | * |
| 43 | * See also: util/lbtdump/lbtdump.c |
| 44 | */ |
| 45 | |
| 46 | struct lb_uint64 { |
| 47 | uint32_t lo; |
| 48 | uint32_t hi; |
| 49 | }; |
| 50 | |
| 51 | static inline uint64_t unpack_lb64(struct lb_uint64 value) |
| 52 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 53 | uint64_t result; |
| 54 | result = value.hi; |
| 55 | result = (result << 32) + value.lo; |
| 56 | return result; |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static inline struct lb_uint64 pack_lb64(uint64_t value) |
| 60 | { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 61 | struct lb_uint64 result; |
| 62 | result.lo = (value >> 0) & 0xffffffff; |
| 63 | result.hi = (value >> 32) & 0xffffffff; |
| 64 | return result; |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 67 | struct lb_header { |
| 68 | uint8_t signature[4]; /* LBIO */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 69 | uint32_t header_bytes; |
| 70 | uint32_t header_checksum; |
| 71 | uint32_t table_bytes; |
| 72 | uint32_t table_checksum; |
| 73 | uint32_t table_entries; |
| 74 | }; |
| 75 | |
| 76 | /* Every entry in the boot enviroment list will correspond to a boot |
| 77 | * info record. Encoding both type and size. The type is obviously |
| 78 | * so you can tell what it is. The size allows you to skip that |
| 79 | * boot enviroment record if you don't know what it easy. This allows |
| 80 | * forward compatibility with records not yet defined. |
| 81 | */ |
| 82 | struct lb_record { |
| 83 | uint32_t tag; /* tag ID */ |
| 84 | uint32_t size; /* size of record (in bytes) */ |
| 85 | }; |
| 86 | |
| 87 | #define LB_TAG_UNUSED 0x0000 |
| 88 | |
| 89 | #define LB_TAG_MEMORY 0x0001 |
| 90 | |
| 91 | struct lb_memory_range { |
| 92 | struct lb_uint64 start; |
| 93 | struct lb_uint64 size; |
| 94 | uint32_t type; |
| 95 | #define LB_MEM_RAM 1 /* Memory anyone can use */ |
| 96 | #define LB_MEM_RESERVED 2 /* Don't use this memory region */ |
| 97 | #define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */ |
| 98 | }; |
| 99 | |
| 100 | struct lb_memory { |
| 101 | uint32_t tag; |
| 102 | uint32_t size; |
| 103 | struct lb_memory_range map[0]; |
| 104 | }; |
| 105 | |
| 106 | #define LB_TAG_HWRPB 0x0002 |
| 107 | struct lb_hwrpb { |
| 108 | uint32_t tag; |
| 109 | uint32_t size; |
| 110 | uint64_t hwrpb; |
| 111 | }; |
| 112 | |
| 113 | #define LB_TAG_MAINBOARD 0x0003 |
| 114 | struct lb_mainboard { |
| 115 | uint32_t tag; |
| 116 | uint32_t size; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 117 | uint8_t vendor_idx; |
| 118 | uint8_t part_number_idx; |
| 119 | uint8_t strings[0]; |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | #define LB_TAG_VERSION 0x0004 |
| 123 | #define LB_TAG_EXTRA_VERSION 0x0005 |
| 124 | #define LB_TAG_BUILD 0x0006 |
| 125 | #define LB_TAG_COMPILE_TIME 0x0007 |
| 126 | #define LB_TAG_COMPILE_BY 0x0008 |
| 127 | #define LB_TAG_COMPILE_HOST 0x0009 |
| 128 | #define LB_TAG_COMPILE_DOMAIN 0x000a |
| 129 | #define LB_TAG_COMPILER 0x000b |
| 130 | #define LB_TAG_LINKER 0x000c |
| 131 | #define LB_TAG_ASSEMBLER 0x000d |
| 132 | struct lb_string { |
| 133 | uint32_t tag; |
| 134 | uint32_t size; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 135 | uint8_t string[0]; |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | /* The following structures are for the cmos definitions table */ |
| 139 | #define LB_TAG_CMOS_OPTION_TABLE 200 |
| 140 | /* cmos header record */ |
| 141 | struct cmos_option_table { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 142 | uint32_t tag; /* CMOS definitions table type */ |
| 143 | uint32_t size; /* size of the entire table */ |
| 144 | uint32_t header_length; /* length of header */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | /* cmos entry record |
| 148 | This record is variable length. The name field may be |
| 149 | shorter than CMOS_MAX_NAME_LENGTH. The entry may start |
| 150 | anywhere in the byte, but can not span bytes unless it |
| 151 | starts at the beginning of the byte and the length is |
| 152 | fills complete bytes. |
| 153 | */ |
| 154 | #define LB_TAG_OPTION 201 |
| 155 | struct cmos_entries { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 156 | uint32_t tag; /* entry type */ |
| 157 | uint32_t size; /* length of this record */ |
| 158 | uint32_t bit; /* starting bit from start of image */ |
| 159 | uint32_t length; /* length of field in bits */ |
| 160 | uint32_t config; /* e=enumeration, h=hex, r=reserved */ |
| 161 | uint32_t config_id; /* a number linking to an enumeration record */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 162 | #define CMOS_MAX_NAME_LENGTH 32 |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 163 | uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii, |
| 164 | variable length int aligned */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 165 | }; |
| 166 | |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 167 | /* cmos enumerations record |
| 168 | This record is variable length. The text field may be |
| 169 | shorter than CMOS_MAX_TEXT_LENGTH. |
| 170 | */ |
| 171 | #define LB_TAG_OPTION_ENUM 202 |
| 172 | struct cmos_enums { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 173 | uint32_t tag; /* enumeration type */ |
| 174 | uint32_t size; /* length of this record */ |
| 175 | uint32_t config_id; /* a number identifying the config id */ |
| 176 | uint32_t value; /* the value associated with the text */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 177 | #define CMOS_MAX_TEXT_LENGTH 32 |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 178 | uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii, |
| 179 | variable length int aligned */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | /* cmos defaults record |
| 183 | This record contains default settings for the cmos ram. |
| 184 | */ |
| 185 | #define LB_TAG_OPTION_DEFAULTS 203 |
| 186 | struct cmos_defaults { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 187 | uint32_t tag; /* default type */ |
| 188 | uint32_t size; /* length of this record */ |
| 189 | uint32_t name_length; /* length of the following name field */ |
| 190 | uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 191 | #define CMOS_IMAGE_BUFFER_SIZE 128 |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 192 | uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */ |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | #define LB_TAG_OPTION_CHECKSUM 204 |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 196 | struct cmos_checksum { |
Uwe Hermann | ce1041c | 2007-02-06 19:53:51 +0000 | [diff] [blame] | 197 | uint32_t tag; |
| 198 | uint32_t size; |
| 199 | /* In practice everything is byte aligned, but things are measured |
| 200 | * in bits to be consistent. |
| 201 | */ |
| 202 | uint32_t range_start; /* First bit that is checksummed (byte aligned) */ |
| 203 | uint32_t range_end; /* Last bit that is checksummed (byte aligned) */ |
| 204 | uint32_t location; /* First bit of the checksum (byte aligned) */ |
| 205 | uint32_t type; /* Checksum algorithm that is used */ |
| 206 | #define CHECKSUM_NONE 0 |
| 207 | #define CHECKSUM_PCBIOS 1 |
| 208 | }; |
| 209 | |
Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame^] | 210 | #endif /* COREBOOT_TABLES_H */ |