123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- /*
- * 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.
- */
- /* Maximum number of memory range definitions. */
- #define SYSINFO_MAX_MEM_RANGES 32
- /* Allow a maximum of 8 GPIOs */
- #define SYSINFO_MAX_GPIOS 8
- struct cbuint64 {
- u32 lo;
- u32 hi;
- };
- struct cb_header {
- u8 signature[4];
- u32 header_bytes;
- u32 header_checksum;
- u32 table_bytes;
- u32 table_checksum;
- u32 table_entries;
- };
- struct cb_record {
- u32 tag;
- u32 size;
- };
- #define CB_TAG_UNUSED 0x0000
- #define CB_TAG_MEMORY 0x0001
- struct cb_memory_range {
- struct cbuint64 start;
- struct cbuint64 size;
- u32 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 {
- u32 tag;
- u32 size;
- struct cb_memory_range map[0];
- };
- #define CB_TAG_HWRPB 0x0002
- struct cb_hwrpb {
- u32 tag;
- u32 size;
- u64 hwrpb;
- };
- #define CB_TAG_MAINBOARD 0x0003
- struct cb_mainboard {
- u32 tag;
- u32 size;
- u8 vendor_idx;
- u8 part_number_idx;
- u8 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 {
- u32 tag;
- u32 size;
- u8 string[0];
- };
- #define CB_TAG_SERIAL 0x000f
- struct cb_serial {
- u32 tag;
- u32 size;
- #define CB_SERIAL_TYPE_IO_MAPPED 1
- #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
- u32 type;
- u32 baseaddr;
- u32 baud;
- };
- #define CB_TAG_CONSOLE 0x00010
- struct cb_console {
- u32 tag;
- u32 size;
- u16 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 // OBSOLETE
- #define CB_TAG_CONSOLE_SROM 4 // OBSOLETE
- #define CB_TAG_CONSOLE_EHCI 5
- #define CB_TAG_FORWARD 0x00011
- struct cb_forward {
- u32 tag;
- u32 size;
- u64 forward;
- };
- #define CB_TAG_FRAMEBUFFER 0x0012
- struct cb_framebuffer {
- u32 tag;
- u32 size;
- u64 physical_address;
- u32 x_resolution;
- u32 y_resolution;
- u32 bytes_per_line;
- u8 bits_per_pixel;
- u8 red_mask_pos;
- u8 red_mask_size;
- u8 green_mask_pos;
- u8 green_mask_size;
- u8 blue_mask_pos;
- u8 blue_mask_size;
- u8 reserved_mask_pos;
- u8 reserved_mask_size;
- };
- #define CB_TAG_GPIO 0x0013
- #define CB_GPIO_ACTIVE_LOW 0
- #define CB_GPIO_ACTIVE_HIGH 1
- #define CB_GPIO_MAX_NAME_LENGTH 16
- struct cb_gpio {
- u32 port;
- u32 polarity;
- u32 value;
- u8 name[CB_GPIO_MAX_NAME_LENGTH];
- };
- struct cb_gpios {
- u32 tag;
- u32 size;
- u32 count;
- struct cb_gpio gpios[0];
- };
- #define CB_TAG_VDAT 0x0015
- #define CB_TAG_VBNV 0x0019
- #define CB_TAG_VBOOT_HANDOFF 0x0020
- #define CB_TAG_DMA 0x0022
- struct cb_range {
- u32 tag;
- u32 size;
- u64 range_start;
- u32 range_size;
- };
- #define CB_TAG_TIMESTAMPS 0x0016
- #define CB_TAG_CBMEM_CONSOLE 0x0017
- #define CB_TAG_MRC_CACHE 0x0018
- #define CB_TAG_ACPI_GNVS 0x0024
- struct cb_cbmem_tab {
- u32 tag;
- u32 size;
- u64 cbmem_tab;
- };
- #define CB_TAG_X86_ROM_MTRR 0x0021
- struct cb_x86_rom_mtrr {
- u32 tag;
- u32 size;
- /* The variable range MTRR index covering the ROM. If one wants to
- * enable caching the ROM, the variable MTRR needs to be set to
- * write-protect. To disable the caching after enabling set the
- * type to uncacheable. */
- u32 index;
- };
- #define CB_TAG_CMOS_OPTION_TABLE 0x00c8
- struct cb_cmos_option_table {
- u32 tag;
- u32 size;
- u32 header_length;
- };
- #define CB_TAG_OPTION 0x00c9
- #define CB_CMOS_MAX_NAME_LENGTH 32
- struct cb_cmos_entries {
- u32 tag;
- u32 size;
- u32 bit;
- u32 length;
- u32 config;
- u32 config_id;
- u8 name[CB_CMOS_MAX_NAME_LENGTH];
- };
- #define CB_TAG_OPTION_ENUM 0x00ca
- #define CB_CMOS_MAX_TEXT_LENGTH 32
- struct cb_cmos_enums {
- u32 tag;
- u32 size;
- u32 config_id;
- u32 value;
- u8 text[CB_CMOS_MAX_TEXT_LENGTH];
- };
- #define CB_TAG_OPTION_DEFAULTS 0x00cb
- #define CB_CMOS_IMAGE_BUFFER_SIZE 128
- struct cb_cmos_defaults {
- u32 tag;
- u32 size;
- u32 name_length;
- u8 name[CB_CMOS_MAX_NAME_LENGTH];
- u8 default_set[CB_CMOS_IMAGE_BUFFER_SIZE];
- };
- #define CB_TAG_OPTION_CHECKSUM 0x00cc
- #define CB_CHECKSUM_NONE 0
- #define CB_CHECKSUM_PCBIOS 1
- struct cb_cmos_checksum {
- u32 tag;
- u32 size;
- u32 range_start;
- u32 range_end;
- u32 location;
- u32 type;
- };
- unsigned short ipchksum(const void *vptr, unsigned long nbytes);
- /* Helpful inlines */
- static inline u64 cb_unpack64(struct cbuint64 val)
- {
- return (((u64) val.hi) << 32) | val.lo;
- }
- static inline u16 cb_checksum(const void *ptr, unsigned len)
- {
- return ipchksum((u8 *)ptr, len);
- }
- static inline const char *cb_mb_vendor_string(const struct cb_mainboard *cbm)
- {
- return (char *)(cbm->strings + cbm->vendor_idx);
- }
- static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
- {
- return (char *)(cbm->strings + cbm->part_number_idx);
- }
- struct sysinfo_t {
- unsigned int cpu_khz;
- struct cb_serial *serial;
- unsigned short ser_ioport;
- unsigned long ser_base; // for mmapped serial
- int n_memranges;
- struct memrange {
- unsigned long long base;
- unsigned long long size;
- unsigned int type;
- } memrange[SYSINFO_MAX_MEM_RANGES];
- struct cb_cmos_option_table *option_table;
- u32 cmos_range_start;
- u32 cmos_range_end;
- u32 cmos_checksum_location;
- u32 vbnv_start;
- u32 vbnv_size;
- char *version;
- char *extra_version;
- char *build;
- char *compile_time;
- char *compile_by;
- char *compile_host;
- char *compile_domain;
- char *compiler;
- char *linker;
- char *assembler;
- char *cb_version;
- struct cb_framebuffer *framebuffer;
- int num_gpios;
- struct cb_gpio gpios[SYSINFO_MAX_GPIOS];
- unsigned long *mbtable; /** Pointer to the multiboot table */
- struct cb_header *header;
- struct cb_mainboard *mainboard;
- /* these are chromeos specific and may or may not be valid. */
- void *vboot_handoff;
- u32 vboot_handoff_size;
- void *vdat_addr;
- u32 vdat_size;
- void *tstamp_table;
- void *cbmem_cons;
- void *mrc_cache;
- void *acpi_gnvs;
- };
- extern struct sysinfo_t lib_sysinfo;
- /* Helpful macros */
- #define MEM_RANGE_COUNT(_rec) \
- (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
- #define MEM_RANGE_PTR(_rec, _idx) \
- (void *)(((u8 *) (_rec)) + sizeof(*(_rec)) \
- + (sizeof((_rec)->map[0]) * (_idx)))
- int get_coreboot_info(struct sysinfo_t *info);
- int cb_parse_header(void *addr, int len, struct sysinfo_t *info);
|