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