blob: 527c44d5fca429e0df38b7df34daf52abef167bb [file] [log] [blame]
Uwe Hermannce1041c2007-02-06 19:53:51 +00001#ifndef LINUXBIOS_TABLES_H
2#define LINUXBIOS_TABLES_H
3
4#include <stdint.h>
5
6/* The linuxbios table information is for conveying information
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
34/* Since LinuxBIOS is usually compiled 32bit, gcc will align 64bit
35 * types to 32bit boundaries. If the LinuxBIOS table is dumped on a
36 * 64bit system, a uint64_t would be aligned to 64bit boundaries,
37 * breaking the table format.
38 *
39 * lb_uint64 will keep 64bit LinuxBIOS table values aligned to 32bit
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
46struct lb_uint64 {
47 uint32_t lo;
48 uint32_t hi;
49};
50
51static inline uint64_t unpack_lb64(struct lb_uint64 value)
52{
53 uint64_t result;
54 result = value.hi;
55 result = (result << 32) + value.lo;
56 return result;
57}
58
59static inline struct lb_uint64 pack_lb64(uint64_t value)
60{
61 struct lb_uint64 result;
62 result.lo = (value >> 0) & 0xffffffff;
63 result.hi = (value >> 32) & 0xffffffff;
64 return result;
65}
66
67
68
69struct lb_header
70{
71 uint8_t signature[4]; /* LBIO */
72 uint32_t header_bytes;
73 uint32_t header_checksum;
74 uint32_t table_bytes;
75 uint32_t table_checksum;
76 uint32_t table_entries;
77};
78
79/* Every entry in the boot enviroment list will correspond to a boot
80 * info record. Encoding both type and size. The type is obviously
81 * so you can tell what it is. The size allows you to skip that
82 * boot enviroment record if you don't know what it easy. This allows
83 * forward compatibility with records not yet defined.
84 */
85struct lb_record {
86 uint32_t tag; /* tag ID */
87 uint32_t size; /* size of record (in bytes) */
88};
89
90#define LB_TAG_UNUSED 0x0000
91
92#define LB_TAG_MEMORY 0x0001
93
94struct lb_memory_range {
95 struct lb_uint64 start;
96 struct lb_uint64 size;
97 uint32_t type;
98#define LB_MEM_RAM 1 /* Memory anyone can use */
99#define LB_MEM_RESERVED 2 /* Don't use this memory region */
100#define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */
101};
102
103struct lb_memory {
104 uint32_t tag;
105 uint32_t size;
106 struct lb_memory_range map[0];
107};
108
109#define LB_TAG_HWRPB 0x0002
110struct lb_hwrpb {
111 uint32_t tag;
112 uint32_t size;
113 uint64_t hwrpb;
114};
115
116#define LB_TAG_MAINBOARD 0x0003
117struct lb_mainboard {
118 uint32_t tag;
119 uint32_t size;
120 uint8_t vendor_idx;
121 uint8_t part_number_idx;
122 uint8_t strings[0];
123};
124
125#define LB_TAG_VERSION 0x0004
126#define LB_TAG_EXTRA_VERSION 0x0005
127#define LB_TAG_BUILD 0x0006
128#define LB_TAG_COMPILE_TIME 0x0007
129#define LB_TAG_COMPILE_BY 0x0008
130#define LB_TAG_COMPILE_HOST 0x0009
131#define LB_TAG_COMPILE_DOMAIN 0x000a
132#define LB_TAG_COMPILER 0x000b
133#define LB_TAG_LINKER 0x000c
134#define LB_TAG_ASSEMBLER 0x000d
135struct lb_string {
136 uint32_t tag;
137 uint32_t size;
138 uint8_t string[0];
139};
140
141/* The following structures are for the cmos definitions table */
142#define LB_TAG_CMOS_OPTION_TABLE 200
143/* cmos header record */
144struct cmos_option_table {
145 uint32_t tag; /* CMOS definitions table type */
146 uint32_t size; /* size of the entire table */
147 uint32_t header_length; /* length of header */
148};
149
150/* cmos entry record
151 This record is variable length. The name field may be
152 shorter than CMOS_MAX_NAME_LENGTH. The entry may start
153 anywhere in the byte, but can not span bytes unless it
154 starts at the beginning of the byte and the length is
155 fills complete bytes.
156*/
157#define LB_TAG_OPTION 201
158struct cmos_entries {
159 uint32_t tag; /* entry type */
160 uint32_t size; /* length of this record */
161 uint32_t bit; /* starting bit from start of image */
162 uint32_t length; /* length of field in bits */
163 uint32_t config; /* e=enumeration, h=hex, r=reserved */
164 uint32_t config_id; /* a number linking to an enumeration record */
165#define CMOS_MAX_NAME_LENGTH 32
166 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
167 variable length int aligned */
168};
169
170
171/* cmos enumerations record
172 This record is variable length. The text field may be
173 shorter than CMOS_MAX_TEXT_LENGTH.
174*/
175#define LB_TAG_OPTION_ENUM 202
176struct cmos_enums {
177 uint32_t tag; /* enumeration type */
178 uint32_t size; /* length of this record */
179 uint32_t config_id; /* a number identifying the config id */
180 uint32_t value; /* the value associated with the text */
181#define CMOS_MAX_TEXT_LENGTH 32
182 uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
183 variable length int aligned */
184};
185
186/* cmos defaults record
187 This record contains default settings for the cmos ram.
188*/
189#define LB_TAG_OPTION_DEFAULTS 203
190struct cmos_defaults {
191 uint32_t tag; /* default type */
192 uint32_t size; /* length of this record */
193 uint32_t name_length; /* length of the following name field */
194 uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
195#define CMOS_IMAGE_BUFFER_SIZE 128
196 uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
197};
198
199#define LB_TAG_OPTION_CHECKSUM 204
200struct cmos_checksum {
201 uint32_t tag;
202 uint32_t size;
203 /* In practice everything is byte aligned, but things are measured
204 * in bits to be consistent.
205 */
206 uint32_t range_start; /* First bit that is checksummed (byte aligned) */
207 uint32_t range_end; /* Last bit that is checksummed (byte aligned) */
208 uint32_t location; /* First bit of the checksum (byte aligned) */
209 uint32_t type; /* Checksum algorithm that is used */
210#define CHECKSUM_NONE 0
211#define CHECKSUM_PCBIOS 1
212};
213
214
215
216#endif /* LINUXBIOS_TABLES_H */