From d3890cc16de538c44ed1419a1df54bde560d1787 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 11 Mar 2012 01:57:53 -0800 Subject: Update libpayloads understanding of the coreboot tables. Give it somewhere to put the new info in sysinfo, and tell it how to parse the new tables which it doesn't yet understand. Change-Id: I01d3318138696e6407553c27c1814f79e3fbc4f8 Signed-off-by: Gabe Black Reviewed-on: http://review.coreboot.org/1718 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- payloads/libpayload/Config.in | 6 ++ payloads/libpayload/arch/i386/coreboot.c | 96 +++++++++++++++++++++++++++ payloads/libpayload/include/coreboot_tables.h | 42 ++++++++++++ payloads/libpayload/include/sysinfo.h | 32 +++++++++ 4 files changed, 176 insertions(+) (limited to 'payloads') diff --git a/payloads/libpayload/Config.in b/payloads/libpayload/Config.in index 821475b8c4..701988dff4 100644 --- a/payloads/libpayload/Config.in +++ b/payloads/libpayload/Config.in @@ -53,6 +53,12 @@ config DEVELOPER Prompt for developer options. These options are only interesting for libpayload developers. +config CHROMEOS + bool "ChromeOS specific features" + default n + help + Enable ChromeOS specific features. + endmenu menu "Architecture Options" diff --git a/payloads/libpayload/arch/i386/coreboot.c b/payloads/libpayload/arch/i386/coreboot.c index 8500d41f51..81d121a96a 100644 --- a/payloads/libpayload/arch/i386/coreboot.c +++ b/payloads/libpayload/arch/i386/coreboot.c @@ -84,6 +84,51 @@ static void cb_parse_version(void *ptr, struct sysinfo_t *info) info->cb_version = (char *)ver->string; } +#if CONFIG_CHROMEOS +static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info) +{ + struct cb_vbnv *vbnv = (struct cb_vbnv *)ptr; + + info->vbnv_start = vbnv->vbnv_start; + info->vbnv_size = vbnv->vbnv_size; +} + +static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info) +{ + int i; + struct cb_gpios *gpios = (struct cb_gpios *)ptr; + + info->num_gpios = (gpios->count < SYSINFO_MAX_GPIOS) ? + (gpios->count) : SYSINFO_MAX_GPIOS; + + for (i = 0; i < info->num_gpios; i++) + info->gpios[i] = gpios->gpios[i]; +} + +static void cb_parse_vdat(unsigned char *ptr, struct sysinfo_t *info) +{ + struct cb_vdat *vdat = (struct cb_vdat *) ptr; + + info->vdat_addr = vdat->vdat_addr; + info->vdat_size = vdat->vdat_size; +} +#endif + +static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info) +{ + info->tstamp_table = ((struct cb_cbmem_tab *)ptr)->cbmem_tab; +} + +static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info) +{ + info->cbmem_cons = ((struct cb_cbmem_tab *)ptr)->cbmem_tab; +} + +static void cb_parse_mrc_cache(unsigned char *ptr, struct sysinfo_t *info) +{ + info->mrc_cache = ((struct cb_cbmem_tab *)ptr)->cbmem_tab; +} + #ifdef CONFIG_NVRAM static void cb_parse_optiontable(void *ptr, struct sysinfo_t *info) { @@ -106,6 +151,11 @@ static void cb_parse_framebuffer(void *ptr, struct sysinfo_t *info) } #endif +static void cb_parse_string(unsigned char *ptr, char **info) +{ + *info = (char *)((struct cb_string *)ptr)->string; +} + static int cb_parse_header(void *addr, int len, struct sysinfo_t *info) { struct cb_header *header; @@ -157,6 +207,33 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info) case CB_TAG_VERSION: cb_parse_version(ptr, info); break; + case CB_TAG_EXTRA_VERSION: + cb_parse_string(ptr, &info->extra_version); + break; + case CB_TAG_BUILD: + cb_parse_string(ptr, &info->build); + break; + case CB_TAG_COMPILE_TIME: + cb_parse_string(ptr, &info->compile_time); + break; + case CB_TAG_COMPILE_BY: + cb_parse_string(ptr, &info->compile_by); + break; + case CB_TAG_COMPILE_HOST: + cb_parse_string(ptr, &info->compile_host); + break; + case CB_TAG_COMPILE_DOMAIN: + cb_parse_string(ptr, &info->compile_domain); + break; + case CB_TAG_COMPILER: + cb_parse_string(ptr, &info->compiler); + break; + case CB_TAG_LINKER: + cb_parse_string(ptr, &info->linker); + break; + case CB_TAG_ASSEMBLER: + cb_parse_string(ptr, &info->assembler); + break; #ifdef CONFIG_NVRAM case CB_TAG_CMOS_OPTION_TABLE: cb_parse_optiontable(ptr, info); @@ -174,6 +251,25 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info) #endif case CB_TAG_MAINBOARD: info->mainboard = (struct cb_mainboard *)ptr; +#if CONFIG_CHROMEOS + case CB_TAG_GPIO: + cb_parse_gpios(ptr, info); + break; + case CB_TAG_VDAT: + cb_parse_vdat(ptr, info); + break; + case CB_TAG_VBNV: + cb_parse_vbnv(ptr, info); + break; +#endif + case CB_TAG_TIMESTAMPS: + cb_parse_tstamp(ptr, info); + break; + case CB_TAG_CBMEM_CONSOLE: + cb_parse_cbmem_cons(ptr, info); + break; + case CB_TAG_MRC_CACHE: + cb_parse_mrc_cache(ptr, info); break; } diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 20bcc4e4c9..9251826648 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -165,6 +165,48 @@ struct cb_framebuffer { u8 reserved_mask_size; }; +#define CB_TAG_GPIO 0x0013 +#define GPIO_MAX_NAME_LENGTH 16 +struct cb_gpio { + u32 port; + u32 polarity; + u32 value; + u8 name[GPIO_MAX_NAME_LENGTH]; +}; + +struct cb_gpios { + u32 tag; + u32 size; + + u32 count; + struct cb_gpio gpios[0]; +}; + +#define CB_TAG_VDAT 0x0015 +struct cb_vdat { + uint32_t tag; + uint32_t size; /* size of the entire entry */ + void *vdat_addr; + uint32_t vdat_size; +}; + +#define CB_TAG_TIMESTAMPS 0x0016 +#define CB_TAG_CBMEM_CONSOLE 0x0017 +#define CB_TAG_MRC_CACHE 0x0018 +struct cb_cbmem_tab { + uint32_t tag; + uint32_t size; + void *cbmem_tab; +}; + +#define CB_TAG_VBNV 0x0019 +struct cb_vbnv { + uint32_t tag; + uint32_t size; + uint32_t vbnv_start; + uint32_t vbnv_size; +}; + #define CB_TAG_CMOS_OPTION_TABLE 0x00c8 struct cb_cmos_option_table { u32 tag; diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index cce934f42f..bb5b2eea68 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -32,6 +32,10 @@ /* Allow a maximum of 16 memory range definitions. */ #define SYSINFO_MAX_MEM_RANGES 16 +/* Allow a maximum of 8 GPIOs */ +#define SYSINFO_MAX_GPIOS 8 + +#include struct cb_serial; @@ -53,15 +57,43 @@ struct sysinfo_t { u32 cmos_range_start; u32 cmos_range_end; u32 cmos_checksum_location; +#if CONFIG_CHROMEOS + u32 vbnv_start; + u32 vbnv_size; +#endif + + 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; +#if CONFIG_CHROMEOS + int num_gpios; + struct cb_gpio gpios[SYSINFO_MAX_GPIOS]; +#endif + unsigned long *mbtable; /** Pointer to the multiboot table */ struct cb_header *header; struct cb_mainboard *mainboard; + +#if CONFIG_CHROMEOS + void *vdat_addr; + u32 vdat_size; +#endif + void *tstamp_table; + void *cbmem_cons; + void *mrc_cache; }; extern struct sysinfo_t lib_sysinfo; -- cgit v1.2.3