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