Leroy P Leahy (leroy.p.leahy@intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14554
-gerrit
commit e3fb08f2d7334da0924395b73188c65e93bc339e Author: Lee Leahy leroy.p.leahy@intel.com Date: Fri Apr 29 17:26:36 2016 -0700
lib/reg_script: Allow multiple independent handlers
Remove the platform_bus_table routine and replace it with a link time table. This allows the handlers to be spread across multiple modules without any one module knowing about all of the handlers.
Establish number ranges for both the SOC and mainboard.
TEST=Build and run on Galileo Gen2
Change-Id: I0823d443d3352f31ba7fa20845bbf550b585c86f Signed-off-by: Lee Leahy leroy.p.leahy@intel.com --- src/include/reg_script.h | 14 ++++++++------ src/lib/program.ld | 6 ++++++ src/lib/reg_script.c | 27 ++++++++------------------- src/soc/intel/braswell/iosf.c | 12 +++--------- 4 files changed, 25 insertions(+), 34 deletions(-)
diff --git a/src/include/reg_script.h b/src/include/reg_script.h index 741641a..da01481 100644 --- a/src/include/reg_script.h +++ b/src/include/reg_script.h @@ -60,7 +60,9 @@ enum {
/* Insert other platform independent values above this comment */
- REG_SCRIPT_TYPE_PLATFORM_BASE = 0x10000 + REG_SCRIPT_TYPE_PLATFORM_BASE = 0x10000, + REG_SCRIPT_TYPE_SOC_BASE = REG_SCRIPT_TYPE_PLATFORM_BASE, + REG_SCRIPT_TYPE_MAINBOARD_BASE = 0x20000 };
enum { @@ -92,17 +94,17 @@ struct reg_script_context { const struct reg_script *step; };
-#ifndef __PRE_RAM__ struct reg_script_bus_entry { - int type; + uint32_t type; uint64_t (*reg_script_read)(struct reg_script_context *ctx); void (*reg_script_write)(struct reg_script_context *ctx); };
-/* Get the address and length of the platform bus table */ -const struct reg_script_bus_entry *platform_bus_table(size_t *table_entries); +#define REG_SCRIPT_TABLE_ATTRIBUTE __attribute__ ((used,section (".rsbe_init")))
-#endif /* __PRE_RAM */ +#define REG_SCRIPT_BUS_ENTRY(bus_entry_) \ + const struct reg_script_bus_entry *rsbe_ ## bus_entry_ \ + REG_SCRIPT_TABLE_ATTRIBUTE = &bus_entry_;
/* Internal helper Macros. */
diff --git a/src/lib/program.ld b/src/lib/program.ld index 6ffa82a..53c4cd0 100644 --- a/src/lib/program.ld +++ b/src/lib/program.ld @@ -107,6 +107,12 @@ LONG(0); _ebs_init_begin = .; #endif +#if IS_ENABLED(CONFIG_REG_SCRIPT) + . = ALIGN(ARCH_POINTER_ALIGN_SIZE); + _rsbe_init_begin = .; + KEEP(*(.rsbe_init)); + _ersbe_init_begin = .; +#endif
. = ALIGN(ARCH_POINTER_ALIGN_SIZE); _edata = .; diff --git a/src/lib/reg_script.c b/src/lib/reg_script.c index 7530dc3..4de0fe2 100644 --- a/src/lib/reg_script.c +++ b/src/lib/reg_script.c @@ -393,35 +393,28 @@ static void reg_script_write_msr(struct reg_script_context *ctx) #endif }
-#ifndef __PRE_RAM__ -/* Default routine provided for systems without platform specific busses */ -const struct reg_script_bus_entry *__attribute__((weak)) - platform_bus_table(size_t *table_entries) -{ - /* No platform bus type table supplied */ - *table_entries = 0; - return NULL; -} - /* Locate the structure containing the platform specific bus access routines */ static const struct reg_script_bus_entry *find_bus(const struct reg_script *step) { - const struct reg_script_bus_entry *bus; + extern const struct reg_script_bus_entry *_rsbe_init_begin[]; + extern const struct reg_script_bus_entry *_ersbe_init_begin[]; + const struct reg_script_bus_entry * const * bus; size_t table_entries; size_t i;
/* Locate the platform specific bus */ - bus = platform_bus_table(&table_entries); + bus = _rsbe_init_begin; + table_entries = ((void *)&_ersbe_init_begin - (void *)&_rsbe_init_begin) + / sizeof(void *); for (i = 0; i < table_entries; i++) { - if (bus[i].type == step->type) - return &bus[i]; + if (bus[i]->type == step->type) + return bus[i]; }
/* Bus not found */ return NULL; } -#endif
static uint64_t reg_script_read(struct reg_script_context *ctx) { @@ -443,7 +436,6 @@ static uint64_t reg_script_read(struct reg_script_context *ctx) return reg_script_read_iosf(ctx); #endif /* HAS_IOSF */ default: -#ifndef __PRE_RAM__ { const struct reg_script_bus_entry *bus;
@@ -452,7 +444,6 @@ static uint64_t reg_script_read(struct reg_script_context *ctx) if (NULL != bus) return bus->reg_script_read(ctx); } -#endif printk(BIOS_ERR, "Unsupported read type (0x%x) for this device!\n", step->type); @@ -487,7 +478,6 @@ static void reg_script_write(struct reg_script_context *ctx) break; #endif /* HAS_IOSF */ default: -#ifndef __PRE_RAM__ { const struct reg_script_bus_entry *bus;
@@ -498,7 +488,6 @@ static void reg_script_write(struct reg_script_context *ctx) return; } } -#endif printk(BIOS_ERR, "Unsupported write type (0x%x) for this device!\n", step->type); diff --git a/src/soc/intel/braswell/iosf.c b/src/soc/intel/braswell/iosf.c index 98d1610..8befc5e 100644 --- a/src/soc/intel/braswell/iosf.c +++ b/src/soc/intel/braswell/iosf.c @@ -190,16 +190,10 @@ void reg_script_write_iosf(struct reg_script_context *ctx) } }
-const struct reg_script_bus_entry reg_script_bus_table[] = { - {REG_SCRIPT_TYPE_IOSF, reg_script_read_iosf, reg_script_write_iosf} +const struct reg_script_bus_entry reg_script_bus_table = { + REG_SCRIPT_TYPE_IOSF, reg_script_read_iosf, reg_script_write_iosf };
-const struct reg_script_bus_entry *platform_bus_table(size_t *table_entries) -{ - /* Return the table size and address */ - *table_entries = sizeof(reg_script_bus_table) - / sizeof(reg_script_bus_table[0]); - return ®_script_bus_table[0]; -} +REG_SCRIPT_BUS_ENTRY(reg_script_bus_table);
#endif /* ENV_RAMSTAGE */