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