coreboot_tables: Minor refactoring to reduce redundant data structures

There are three Coreboot table tags that all define some kind of memory
region, and each has their own homologous struct. I'm about to add a
fourth so I'll just clean this up and turn it into a generic struct
lb_range instead.

BUG=chrome-os-partner:21969
TEST=None

Change-Id: Id148b2737d442e0636d2c05e74efa1fdf844a0d3
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167154
This commit is contained in:
Julius Werner 2013-08-27 15:38:54 -07:00 committed by Caroline Tice
commit 22d82ffa3f
5 changed files with 39 additions and 69 deletions

View file

@ -81,10 +81,10 @@ static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
#ifdef CONFIG_LP_CHROMEOS
static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
{
struct cb_vbnv *vbnv = (struct cb_vbnv *)ptr;
struct cb_range *vbnv = (struct cb_range *)ptr;
info->vbnv_start = vbnv->vbnv_start;
info->vbnv_size = vbnv->vbnv_size;
info->vbnv_start = vbnv->range_start;
info->vbnv_size = vbnv->range_size;
}
static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info)
@ -101,10 +101,10 @@ static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info)
static void cb_parse_vdat(unsigned char *ptr, struct sysinfo_t *info)
{
struct cb_vdat *vdat = (struct cb_vdat *) ptr;
struct cb_range *vdat = (struct cb_range *)ptr;
info->vdat_addr = phys_to_virt(vdat->vdat_addr);
info->vdat_size = vdat->vdat_size;
info->vdat_addr = phys_to_virt(vdat->range_start);
info->vdat_size = vdat->range_size;
}
#endif

View file

@ -82,18 +82,18 @@ static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
#ifdef CONFIG_LP_CHROMEOS
static void cb_parse_vboot_handoff(unsigned char *ptr, struct sysinfo_t *info)
{
struct cb_vboot_handoff *vbho = (struct cb_vboot_handoff *)ptr;
struct cb_range *vbho = (struct cb_range *)ptr;
info->vboot_handoff = (void *)(uintptr_t)vbho->vboot_handoff_addr;
info->vboot_handoff_size = vbho->vboot_handoff_size;
info->vboot_handoff = (void *)(uintptr_t)vbho->range_start;
info->vboot_handoff_size = vbho->range_size;
}
static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
{
struct cb_vbnv *vbnv = (struct cb_vbnv *)ptr;
struct cb_range *vbnv = (struct cb_range *)ptr;
info->vbnv_start = vbnv->vbnv_start;
info->vbnv_size = vbnv->vbnv_size;
info->vbnv_start = vbnv->range_start;
info->vbnv_size = vbnv->range_size;
}
static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info)
@ -110,10 +110,10 @@ static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info)
static void cb_parse_vdat(unsigned char *ptr, struct sysinfo_t *info)
{
struct cb_vdat *vdat = (struct cb_vdat *) ptr;
struct cb_range *vdat = (struct cb_range *) ptr;
info->vdat_addr = phys_to_virt(vdat->vdat_addr);
info->vdat_size = vdat->vdat_size;
info->vdat_addr = phys_to_virt(vdat->range_start);
info->vdat_size = vdat->range_size;
}
#endif

View file

@ -184,12 +184,14 @@ struct cb_gpios {
struct cb_gpio gpios[0];
};
#define CB_TAG_VDAT 0x0015
struct cb_vdat {
#define CB_TAG_VDAT 0x0015
#define CB_TAG_VBNV 0x0019
#define CB_TAG_VBOOT_HANDOFF 0x0020
struct cb_range {
uint32_t tag;
uint32_t size; /* size of the entire entry */
uint64_t vdat_addr;
uint32_t vdat_size;
uint32_t size;
uint64_t range_start;
uint32_t range_size;
};
#define CB_TAG_TIMESTAMPS 0x0016
@ -201,22 +203,6 @@ struct cb_cbmem_tab {
uint64_t 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_VBOOT_HANDOFF 0x0020
struct cb_vboot_handoff {
uint32_t tag;
uint32_t size;
uint64_t vboot_handoff_addr;
uint32_t vboot_handoff_size;
};
#define CB_TAG_X86_ROM_MTRR 0x0021
struct cb_x86_rom_mtrr {
uint32_t tag;

View file

@ -213,13 +213,15 @@ struct lb_gpios {
struct lb_gpio gpios[0];
};
#define LB_TAG_VDAT 0x0015
struct lb_vdat {
#define LB_TAG_VDAT 0x0015
#define LB_TAG_VBNV 0x0019
#define LB_TAB_VBOOT_HANDOFF 0x0020
struct lb_range {
uint32_t tag;
uint32_t size;
uint64_t vdat_addr;
uint32_t vdat_size;
uint64_t range_start;
uint32_t range_size;
};
#define LB_TAG_TIMESTAMPS 0x0016
@ -232,24 +234,6 @@ struct lb_cbmem_ref {
uint64_t cbmem_addr;
};
#define LB_TAG_VBNV 0x0019
struct lb_vbnv {
uint32_t tag;
uint32_t size;
uint32_t vbnv_start;
uint32_t vbnv_size;
};
#define LB_TAB_VBOOT_HANDOFF 0x0020
struct lb_vboot_handoff {
uint32_t tag;
uint32_t size;
uint64_t vboot_handoff_addr;
uint32_t vboot_handoff_size;
};
#define LB_TAG_X86_ROM_MTRR 0x0021
struct lb_x86_rom_mtrr {
uint32_t tag;

View file

@ -195,25 +195,25 @@ static void lb_gpios(struct lb_header *header)
static void lb_vdat(struct lb_header *header)
{
#if CONFIG_GENERATE_ACPI_TABLES
struct lb_vdat* vdat;
struct lb_range *vdat;
vdat = (struct lb_vdat *)lb_new_record(header);
vdat = (struct lb_range *)lb_new_record(header);
vdat->tag = LB_TAG_VDAT;
vdat->size = sizeof(*vdat);
acpi_get_vdat_info(&vdat->vdat_addr, &vdat->vdat_size);
acpi_get_vdat_info(&vdat->range_start, &vdat->range_size);
#endif
}
static void lb_vbnv(struct lb_header *header)
{
#if CONFIG_PC80_SYSTEM
struct lb_vbnv* vbnv;
struct lb_range *vbnv;
vbnv = (struct lb_vbnv *)lb_new_record(header);
vbnv = (struct lb_range *)lb_new_record(header);
vbnv->tag = LB_TAG_VBNV;
vbnv->size = sizeof(*vbnv);
vbnv->vbnv_start = CONFIG_VBNV_OFFSET + 14;
vbnv->vbnv_size = CONFIG_VBNV_SIZE;
vbnv->range_start = CONFIG_VBNV_OFFSET + 14;
vbnv->range_size = CONFIG_VBNV_SIZE;
#endif
}
@ -222,16 +222,16 @@ static void lb_vboot_handoff(struct lb_header *header)
{
void *addr;
uint32_t size;
struct lb_vboot_handoff* vbho;
struct lb_range *vbho;
if (vboot_get_handoff_info(&addr, &size))
return;
vbho = (struct lb_vboot_handoff *)lb_new_record(header);
vbho = (struct lb_range *)lb_new_record(header);
vbho->tag = LB_TAB_VBOOT_HANDOFF;
vbho->size = sizeof(*vbho);
vbho->vboot_handoff_addr = (intptr_t)addr;
vbho->vboot_handoff_size = size;
vbho->range_start = (intptr_t)addr;
vbho->range_size = size;
}
#else
static inline void lb_vboot_handoff(struct lb_header *header) {}