blob: 92518266482c7ff70cafea053f0e3baefbe93cce [file] [log] [blame]
Jordan Crousef6145c32008-03-19 23:56:58 +00001/*
2 * This file is part of the libpayload project.
3 *
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000030#ifndef _COREBOOT_TABLES_H
31#define _COREBOOT_TABLES_H
Jordan Crousef6145c32008-03-19 23:56:58 +000032
33#include <arch/types.h>
Gabe Black54c800a2012-08-28 16:31:09 -070034#include <ipchksum.h>
Jordan Crousef6145c32008-03-19 23:56:58 +000035
36struct cbuint64 {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000037 u32 lo;
38 u32 hi;
Jordan Crousef6145c32008-03-19 23:56:58 +000039};
40
41struct cb_header {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000042 u8 signature[4];
43 u32 header_bytes;
44 u32 header_checksum;
45 u32 table_bytes;
46 u32 table_checksum;
47 u32 table_entries;
Jordan Crousef6145c32008-03-19 23:56:58 +000048};
49
50struct cb_record {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000051 u32 tag;
52 u32 size;
Jordan Crousef6145c32008-03-19 23:56:58 +000053};
54
55#define CB_TAG_UNUSED 0x0000
56#define CB_TAG_MEMORY 0x0001
57
58struct cb_memory_range {
59 struct cbuint64 start;
60 struct cbuint64 size;
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000061 u32 type;
Jordan Crousef6145c32008-03-19 23:56:58 +000062};
63
Stefan Reinauerd1bc3312011-06-22 16:39:19 -070064#define CB_MEM_RAM 1
65#define CB_MEM_RESERVED 2
66#define CB_MEM_ACPI 3
67#define CB_MEM_NVS 4
68#define CB_MEM_UNUSABLE 5
69#define CB_MEM_VENDOR_RSVD 6
70#define CB_MEM_TABLE 16
Jordan Crousef6145c32008-03-19 23:56:58 +000071
72struct cb_memory {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000073 u32 tag;
74 u32 size;
Jordan Crousef6145c32008-03-19 23:56:58 +000075 struct cb_memory_range map[0];
76};
77
78#define CB_TAG_HWRPB 0x0002
79
80struct cb_hwrpb {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000081 u32 tag;
82 u32 size;
83 u64 hwrpb;
Jordan Crousef6145c32008-03-19 23:56:58 +000084};
85
86#define CB_TAG_MAINBOARD 0x0003
87
88struct cb_mainboard {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +000089 u32 tag;
90 u32 size;
91 u8 vendor_idx;
92 u8 part_number_idx;
93 u8 strings[0];
Jordan Crousef6145c32008-03-19 23:56:58 +000094};
95
96#define CB_TAG_VERSION 0x0004
97#define CB_TAG_EXTRA_VERSION 0x0005
98#define CB_TAG_BUILD 0x0006
99#define CB_TAG_COMPILE_TIME 0x0007
100#define CB_TAG_COMPILE_BY 0x0008
101#define CB_TAG_COMPILE_HOST 0x0009
102#define CB_TAG_COMPILE_DOMAIN 0x000a
103#define CB_TAG_COMPILER 0x000b
104#define CB_TAG_LINKER 0x000c
105#define CB_TAG_ASSEMBLER 0x000d
106
107struct cb_string {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000108 u32 tag;
109 u32 size;
110 u8 string[0];
Jordan Crousef6145c32008-03-19 23:56:58 +0000111};
112
113#define CB_TAG_SERIAL 0x000f
114
115struct cb_serial {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000116 u32 tag;
117 u32 size;
Stefan Reinauerd1bc3312011-06-22 16:39:19 -0700118#define CB_SERIAL_TYPE_IO_MAPPED 1
119#define CB_SERIAL_TYPE_MEMORY_MAPPED 2
120 u32 type;
121 u32 baseaddr;
122 u32 baud;
Jordan Crousef6145c32008-03-19 23:56:58 +0000123};
124
125#define CB_TAG_CONSOLE 0x00010
126
127struct cb_console {
Uwe Hermannfad8c2b2008-04-11 18:01:50 +0000128 u32 tag;
129 u32 size;
130 u16 type;
Jordan Crousef6145c32008-03-19 23:56:58 +0000131};
132
133#define CB_TAG_CONSOLE_SERIAL8250 0
Stefan Reinauerabc0c852010-11-22 08:09:50 +0000134#define CB_TAG_CONSOLE_VGA 1 // OBSOLETE
135#define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
Jordan Crousef6145c32008-03-19 23:56:58 +0000136#define CB_TAG_CONSOLE_LOGBUF 3
Stefan Reinauerabc0c852010-11-22 08:09:50 +0000137#define CB_TAG_CONSOLE_SROM 4 // OBSOLETE
Jordan Crousef6145c32008-03-19 23:56:58 +0000138#define CB_TAG_CONSOLE_EHCI 5
139
Stefan Reinauer5f7d5062009-03-17 16:41:01 +0000140#define CB_TAG_FORWARD 0x00011
141
142struct cb_forward {
143 u32 tag;
144 u32 size;
145 u64 forward;
146};
147
Stefan Reinauerb7002542010-03-25 18:56:26 +0000148#define CB_TAG_FRAMEBUFFER 0x0012
149struct cb_framebuffer {
150 u32 tag;
151 u32 size;
152
153 u64 physical_address;
154 u32 x_resolution;
155 u32 y_resolution;
156 u32 bytes_per_line;
157 u8 bits_per_pixel;
158 u8 red_mask_pos;
159 u8 red_mask_size;
160 u8 green_mask_pos;
161 u8 green_mask_size;
162 u8 blue_mask_pos;
163 u8 blue_mask_size;
164 u8 reserved_mask_pos;
165 u8 reserved_mask_size;
166};
167
Gabe Blackd3890cc2012-03-11 01:57:53 -0800168#define CB_TAG_GPIO 0x0013
169#define GPIO_MAX_NAME_LENGTH 16
170struct cb_gpio {
171 u32 port;
172 u32 polarity;
173 u32 value;
174 u8 name[GPIO_MAX_NAME_LENGTH];
175};
176
177struct cb_gpios {
178 u32 tag;
179 u32 size;
180
181 u32 count;
182 struct cb_gpio gpios[0];
183};
184
185#define CB_TAG_VDAT 0x0015
186struct cb_vdat {
187 uint32_t tag;
188 uint32_t size; /* size of the entire entry */
189 void *vdat_addr;
190 uint32_t vdat_size;
191};
192
193#define CB_TAG_TIMESTAMPS 0x0016
194#define CB_TAG_CBMEM_CONSOLE 0x0017
195#define CB_TAG_MRC_CACHE 0x0018
196struct cb_cbmem_tab {
197 uint32_t tag;
198 uint32_t size;
199 void *cbmem_tab;
200};
201
202#define CB_TAG_VBNV 0x0019
203struct cb_vbnv {
204 uint32_t tag;
205 uint32_t size;
206 uint32_t vbnv_start;
207 uint32_t vbnv_size;
208};
209
Stefan Reinauer95a6e1c2008-08-07 10:21:05 +0000210#define CB_TAG_CMOS_OPTION_TABLE 0x00c8
211struct cb_cmos_option_table {
212 u32 tag;
213 u32 size;
214 u32 header_length;
215};
216
217#define CB_TAG_OPTION 0x00c9
218#define CMOS_MAX_NAME_LENGTH 32
219struct cb_cmos_entries {
220 u32 tag;
221 u32 size;
222 u32 bit;
223 u32 length;
224 u32 config;
225 u32 config_id;
226 u8 name[CMOS_MAX_NAME_LENGTH];
227};
228
229
230#define CB_TAG_OPTION_ENUM 0x00ca
231#define CMOS_MAX_TEXT_LENGTH 32
232struct cb_cmos_enums {
233 u32 tag;
234 u32 size;
235 u32 config_id;
236 u32 value;
237 u8 text[CMOS_MAX_TEXT_LENGTH];
238};
239
240#define CB_TAG_OPTION_DEFAULTS 0x00cb
241#define CMOS_IMAGE_BUFFER_SIZE 128
242struct cb_cmos_defaults {
243 u32 tag;
244 u32 size;
245 u32 name_length;
246 u8 name[CMOS_MAX_NAME_LENGTH];
247 u8 default_set[CMOS_IMAGE_BUFFER_SIZE];
248};
249
250#define CB_TAG_OPTION_CHECKSUM 0x00cc
251#define CHECKSUM_NONE 0
252#define CHECKSUM_PCBIOS 1
253struct cb_cmos_checksum {
254 u32 tag;
255 u32 size;
256 u32 range_start;
257 u32 range_end;
258 u32 location;
259 u32 type;
260};
Jordan Crousef6145c32008-03-19 23:56:58 +0000261
Philip Prindeville46404d72011-12-23 17:09:02 -0700262/* Helpful inlines */
263
264static inline u64 cb_unpack64(struct cbuint64 val)
265{
266 return (((u64) val.hi) << 32) | val.lo;
267}
268
Philip Prindevillefe2f6b02011-12-23 17:22:05 -0700269static inline u16 cb_checksum(const void *ptr, unsigned len)
270{
271 return ipchksum(ptr, len);
272}
273
Philip Prindeville9a7c2462011-12-24 22:12:37 -0700274static inline const char *cb_mb_vendor_string(const struct cb_mainboard *cbm)
275{
276 return (char *)(cbm->strings + cbm->vendor_idx);
277}
278
279static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
280{
281 return (char *)(cbm->strings + cbm->part_number_idx);
282}
283
Jordan Crousef6145c32008-03-19 23:56:58 +0000284/* Helpful macros */
285
286#define MEM_RANGE_COUNT(_rec) \
Uwe Hermann6a441bf2008-03-20 19:54:59 +0000287 (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
Jordan Crousef6145c32008-03-19 23:56:58 +0000288
289#define MEM_RANGE_PTR(_rec, _idx) \
Philip Prindeville7d95b3e2011-12-23 17:53:26 -0700290 (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \
291 + (sizeof((_rec)->map[0]) * (_idx)))
Jordan Crousef6145c32008-03-19 23:56:58 +0000292
Jordan Crousef6145c32008-03-19 23:56:58 +0000293#endif