2 * This file is part of the libpayload project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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
32 #include <arch/types.h>
34 /* Maximum number of memory range definitions. */
35 #define SYSINFO_MAX_MEM_RANGES 32
36 /* Allow a maximum of 8 GPIOs */
37 #define SYSINFO_MAX_GPIOS 8
43 struct cb_serial *serial;
44 unsigned short ser_ioport;
45 unsigned long ser_base; // for mmapped serial
50 unsigned long long base;
51 unsigned long long size;
53 } memrange[SYSINFO_MAX_MEM_RANGES];
55 struct cb_cmos_option_table *option_table;
56 uint32_t cmos_range_start;
57 uint32_t cmos_range_end;
58 uint32_t cmos_checksum_location;
59 #ifdef CONFIG_CHROMEOS
77 struct cb_framebuffer *framebuffer;
79 #ifdef CONFIG_CHROMEOS
81 struct cb_gpio gpios[SYSINFO_MAX_GPIOS];
84 unsigned long *mbtable; /** Pointer to the multiboot table */
86 struct cb_header *header;
87 struct cb_mainboard *mainboard;
89 /* these are chromeos specific and may or may not be valid. */
91 uint32_t vboot_handoff_size;
96 int x86_rom_var_mtrr_index;
105 extern struct sysinfo_t lib_sysinfo;
113 uint8_t signature[4];
114 uint32_t header_bytes;
115 uint32_t header_checksum;
116 uint32_t table_bytes;
117 uint32_t table_checksum;
118 uint32_t table_entries;
126 #define CB_TAG_UNUSED 0x0000
127 #define CB_TAG_MEMORY 0x0001
129 struct cb_memory_range {
130 struct cbuint64 start;
131 struct cbuint64 size;
136 #define CB_MEM_RESERVED 2
137 #define CB_MEM_ACPI 3
139 #define CB_MEM_UNUSABLE 5
140 #define CB_MEM_VENDOR_RSVD 6
141 #define CB_MEM_TABLE 16
146 struct cb_memory_range map[0];
149 #define CB_TAG_HWRPB 0x0002
157 #define CB_TAG_MAINBOARD 0x0003
159 struct cb_mainboard {
163 uint8_t part_number_idx;
167 #define CB_TAG_VERSION 0x0004
168 #define CB_TAG_EXTRA_VERSION 0x0005
169 #define CB_TAG_BUILD 0x0006
170 #define CB_TAG_COMPILE_TIME 0x0007
171 #define CB_TAG_COMPILE_BY 0x0008
172 #define CB_TAG_COMPILE_HOST 0x0009
173 #define CB_TAG_COMPILE_DOMAIN 0x000a
174 #define CB_TAG_COMPILER 0x000b
175 #define CB_TAG_LINKER 0x000c
176 #define CB_TAG_ASSEMBLER 0x000d
184 #define CB_TAG_SERIAL 0x000f
189 #define CB_SERIAL_TYPE_IO_MAPPED 1
190 #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
196 #define CB_TAG_CONSOLE 0x00010
204 #define CB_TAG_CONSOLE_SERIAL8250 0
205 #define CB_TAG_CONSOLE_VGA 1 // OBSOLETE
206 #define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
207 #define CB_TAG_CONSOLE_LOGBUF 3 // OBSOLETE
208 #define CB_TAG_CONSOLE_SROM 4 // OBSOLETE
209 #define CB_TAG_CONSOLE_EHCI 5
211 #define CB_TAG_FORWARD 0x00011
219 #define CB_TAG_FRAMEBUFFER 0x0012
220 struct cb_framebuffer {
224 uint64_t physical_address;
225 uint32_t x_resolution;
226 uint32_t y_resolution;
227 uint32_t bytes_per_line;
228 uint8_t bits_per_pixel;
229 uint8_t red_mask_pos;
230 uint8_t red_mask_size;
231 uint8_t green_mask_pos;
232 uint8_t green_mask_size;
233 uint8_t blue_mask_pos;
234 uint8_t blue_mask_size;
235 uint8_t reserved_mask_pos;
236 uint8_t reserved_mask_size;
239 #define CB_TAG_GPIO 0x0013
240 #define CB_GPIO_ACTIVE_LOW 0
241 #define CB_GPIO_ACTIVE_HIGH 1
242 #define CB_GPIO_MAX_NAME_LENGTH 16
247 uint8_t name[CB_GPIO_MAX_NAME_LENGTH];
255 struct cb_gpio gpios[0];
258 #define CB_TAG_VDAT 0x0015
259 #define CB_TAG_VBNV 0x0019
260 #define CB_TAG_VBOOT_HANDOFF 0x0020
261 #define CB_TAG_DMA 0x0022
265 uint64_t range_start;
269 #define CB_TAG_TIMESTAMPS 0x0016
270 #define CB_TAG_CBMEM_CONSOLE 0x0017
271 #define CB_TAG_MRC_CACHE 0x0018
272 #define CB_TAG_ACPI_GNVS 0x0024
273 struct cb_cbmem_tab {
279 #define CB_TAG_X86_ROM_MTRR 0x0021
280 struct cb_x86_rom_mtrr {
283 /* The variable range MTRR index covering the ROM. If one wants to
284 * enable caching the ROM, the variable MTRR needs to be set to
285 * write-protect. To disable the caching after enabling set the
286 * type to uncacheable. */
291 #define CB_TAG_CMOS_OPTION_TABLE 0x00c8
292 struct cb_cmos_option_table {
295 uint32_t header_length;
298 #define CB_TAG_OPTION 0x00c9
299 #define CB_CMOS_MAX_NAME_LENGTH 32
300 struct cb_cmos_entries {
307 uint8_t name[CB_CMOS_MAX_NAME_LENGTH];
311 #define CB_TAG_OPTION_ENUM 0x00ca
312 #define CB_CMOS_MAX_TEXT_LENGTH 32
313 struct cb_cmos_enums {
318 uint8_t text[CB_CMOS_MAX_TEXT_LENGTH];
321 #define CB_TAG_OPTION_DEFAULTS 0x00cb
322 #define CB_CMOS_IMAGE_BUFFER_SIZE 128
323 struct cb_cmos_defaults {
326 uint32_t name_length;
327 uint8_t name[CB_CMOS_MAX_NAME_LENGTH];
328 uint8_t default_set[CB_CMOS_IMAGE_BUFFER_SIZE];
331 #define CB_TAG_OPTION_CHECKSUM 0x00cc
332 #define CB_CHECKSUM_NONE 0
333 #define CB_CHECKSUM_PCBIOS 1
334 struct cb_cmos_checksum {
337 uint32_t range_start;
343 /* Helpful inlines */
345 static inline uint64_t cb_unpack64(struct cbuint64 val)
347 return (((uint64_t) val.hi) << 32) | val.lo;
350 static inline uint16_t cb_checksum(const void *ptr, unsigned len)
352 return ipchecksum((uint8_t *)ptr, len);
355 static inline const char *cb_mb_vendor_string(const struct cb_mainboard *cbm)
357 return (char *)(cbm->strings + cbm->vendor_idx);
360 static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
362 return (char *)(cbm->strings + cbm->part_number_idx);
367 #define MEM_RANGE_COUNT(_rec) \
368 (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
370 #define MEM_RANGE_PTR(_rec, _idx) \
371 (void *)(((uint8_t *) (_rec)) + sizeof(*(_rec)) \
372 + (sizeof((_rec)->map[0]) * (_idx)))
374 int get_coreboot_info(struct sysinfo_t *info);