1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
/** @file
Coreboot PEI module include file.
Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
/*
* This file is part of the libpayload project.
*
* Copyright (C) 2008 Advanced Micro Devices, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _COREBOOT_PEI_H_INCLUDED_
#define _COREBOOT_PEI_H_INCLUDED_
#if defined (_MSC_VER)
#pragma warning( disable : 4200 )
#endif
#define DYN_CBMEM_ALIGN_SIZE (4096)
#define IMD_ENTRY_MAGIC (~0xC0389481)
#define CBMEM_ENTRY_MAGIC (~0xC0389479)
struct cbmem_entry {
UINT32 magic;
UINT32 start;
UINT32 size;
UINT32 id;
};
struct cbmem_root {
UINT32 max_entries;
UINT32 num_entries;
UINT32 locked;
UINT32 size;
struct cbmem_entry entries[0];
};
struct imd_entry {
UINT32 magic;
UINT32 start_offset;
UINT32 size;
UINT32 id;
};
struct imd_root {
UINT32 max_entries;
UINT32 num_entries;
UINT32 flags;
UINT32 entry_align;
UINT32 max_offset;
struct imd_entry entries[0];
};
struct cbuint64 {
UINT32 lo;
UINT32 hi;
};
#define CB_HEADER_SIGNATURE 0x4F49424C
struct cb_header {
UINT32 signature;
UINT32 header_bytes;
UINT32 header_checksum;
UINT32 table_bytes;
UINT32 table_checksum;
UINT32 table_entries;
};
struct cb_record {
UINT32 tag;
UINT32 size;
};
#define CB_TAG_UNUSED 0x0000
#define CB_TAG_MEMORY 0x0001
struct cb_memory_range {
struct cbuint64 start;
struct cbuint64 size;
UINT32 type;
};
#define CB_MEM_RAM 1
#define CB_MEM_RESERVED 2
#define CB_MEM_ACPI 3
#define CB_MEM_NVS 4
#define CB_MEM_UNUSABLE 5
#define CB_MEM_VENDOR_RSVD 6
#define CB_MEM_TABLE 16
struct cb_memory {
UINT32 tag;
UINT32 size;
struct cb_memory_range map[0];
};
#define CB_TAG_MAINBOARD 0x0003
struct cb_mainboard {
UINT32 tag;
UINT32 size;
UINT8 vendor_idx;
UINT8 part_number_idx;
UINT8 strings[0];
};
#define CB_TAG_VERSION 0x0004
#define CB_TAG_EXTRA_VERSION 0x0005
#define CB_TAG_BUILD 0x0006
#define CB_TAG_COMPILE_TIME 0x0007
#define CB_TAG_COMPILE_BY 0x0008
#define CB_TAG_COMPILE_HOST 0x0009
#define CB_TAG_COMPILE_DOMAIN 0x000a
#define CB_TAG_COMPILER 0x000b
#define CB_TAG_LINKER 0x000c
#define CB_TAG_ASSEMBLER 0x000d
struct cb_string {
UINT32 tag;
UINT32 size;
UINT8 string[0];
};
#define CB_TAG_SERIAL 0x000f
struct cb_serial {
UINT32 tag;
UINT32 size;
#define CB_SERIAL_TYPE_IO_MAPPED 1
#define CB_SERIAL_TYPE_MEMORY_MAPPED 2
UINT32 type;
UINT32 baseaddr;
UINT32 baud;
UINT32 regwidth;
// Crystal or input frequency to the chip containing the UART.
// Provide the board specific details to allow the payload to
// initialize the chip containing the UART and make independent
// decisions as to which dividers to select and their values
// to eventually arrive at the desired console baud-rate.
UINT32 input_hertz;
// UART PCI address: bus, device, function
// 1 << 31 - Valid bit, PCI UART in use
// Bus << 20
// Device << 15
// Function << 12
UINT32 uart_pci_addr;
};
#define CB_TAG_CONSOLE 0x00010
struct cb_console {
UINT32 tag;
UINT32 size;
UINT16 type;
};
#define CB_TAG_CONSOLE_SERIAL8250 0
#define CB_TAG_CONSOLE_VGA 1 // OBSOLETE
#define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
#define CB_TAG_CONSOLE_LOGBUF 3
#define CB_TAG_CONSOLE_SROM 4// OBSOLETE
#define CB_TAG_CONSOLE_EHCI 5
#define CB_TAG_FORWARD 0x00011
struct cb_forward {
UINT32 tag;
UINT32 size;
UINT64 forward;
};
struct cb_cbmem_ref {
UINT32 tag;
// Field contains size of this struct == 0x0010
UINT32 size;
UINT64 cbmem_addr;
};
#define CB_TAG_FRAMEBUFFER 0x0012
struct cb_framebuffer {
UINT32 tag;
UINT32 size;
UINT64 physical_address;
UINT32 x_resolution;
UINT32 y_resolution;
UINT32 bytes_per_line;
UINT8 bits_per_pixel;
UINT8 red_mask_pos;
UINT8 red_mask_size;
UINT8 green_mask_pos;
UINT8 green_mask_size;
UINT8 blue_mask_pos;
UINT8 blue_mask_size;
UINT8 reserved_mask_pos;
UINT8 reserved_mask_size;
};
#define CB_TAG_VDAT 0x0015
struct cb_vdat {
UINT32 tag;
UINT32 size; /* size of the entire entry */
UINT64 vdat_addr;
UINT32 vdat_size;
};
#define CB_TAG_TIMESTAMPS 0x0016
#define CB_TAG_CBMEM_CONSOLE 0x0017
struct cbmem_console {
UINT32 size;
UINT32 cursor;
UINT8 body[0];
} __attribute__ ((packed));
#define CB_TAG_MRC_CACHE 0x0018
struct cb_cbmem_tab {
UINT32 tag;
UINT32 size;
UINT64 cbmem_tab;
};
#define CB_TAG_SMMSTOREV2 0x0039
struct cb_smmstorev2 {
UINT32 tag;
UINT32 size;
UINT32 num_blocks; /* Number of writeable blocks in the store */
UINT32 block_size; /* Size of a block in bytes (64 KiB by default) */
UINT32 mmap_addr; /* MMIO address of the store for read-only access */
UINT32 com_buffer; /* Physical address of the communication buffer */
UINT32 com_buffer_size; /* Size of the communication buffer in bytes */
UINT8 apm_cmd; /* The command byte to write to the APM I/O port to
communicate with the store */
UINT8 unused[3]; /* Set to zero */
} __attribute__ ((packed));
/*
* Machine-friendly version of a system firmware component. A component is
* identified by a GUID. coreboot is an obvious main component but there could
* be others (like EC) which should get their own instances of the tag.
*
* The main consumer of this information is UEFI firmware but something else
* could reuse it too.
*
* Larger number in a version field corresponds to a more recent version.
*/
#define CB_TAG_FW_INFO 0x0045
struct lb_efi_fw_info {
UINT32 tag;
UINT32 size;
UINT8 guid[16]; /* Called "firmware class" in UEFI */
UINT32 version; /* Current version */
UINT32 lowest_supported_version; /* Lowest allowed version */
UINT32 fw_size; /* Size of firmware in bytes */
} __attribute__ ((packed));
#define CB_TAG_CAPSULE 0x0046
struct cb_range {
UINT32 tag;
UINT32 size;
UINT64 range_start;
UINT32 range_size;
} __attribute__ ((packed));
/* Helpful macros */
#define MEM_RANGE_COUNT(_rec) \
(((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
#define MEM_RANGE_PTR(_rec, _idx) \
(void *)(((UINT8 *) (_rec)) + sizeof(*(_rec)) \
+ (sizeof((_rec)->map[0]) * (_idx)))
typedef struct cb_memory CB_MEMORY;
#define CB_TAG_BOOT_MODE 0x00cd
enum lb_boot_mode {
/* Regular boot scenarios */
LB_BOOT_MODE_NORMAL,
/* Device is booting in low-batter w/o charger attached */
LB_BOOT_MODE_LOW_BATTERY,
/* Device is booting in low-batter w/ charger attached */
LB_BOOT_MODE_LOW_BATTERY_CHARGING,
/* Device is booting in due to charger insertion */
LB_BOOT_MODE_OFFMODE_CHARGING,
/* Device is booting in due to RTC alarm */
LB_BOOT_MODE_RTC_WAKE,
/* Device is booting in "no-battery" */
LB_BOOT_MODE_NO_BATTERY,
/* Device is booting with flash unlocked. */
LB_BOOT_MODE_FLASH_UPDATE,
};
/*
* Boot Mode: Passed the platform boot mode information to payload.
*/
struct cb_boot_mode {
UINT32 tag;
UINT32 size;
enum lb_boot_mode boot_mode;
} __attribute__ ((packed));
#endif // _COREBOOT_PEI_H_INCLUDED_
|