diff options
author | Julius Werner <jwerner@chromium.org> | 2019-02-20 18:39:22 -0800 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2019-02-22 06:44:02 +0000 |
commit | 7e0dea6317dc74f8aba8c91d0f8e8a7237261c49 (patch) | |
tree | c9f476b75f0f9fcfe84aeb00b396723b3bcf7f5b /src/lib | |
parent | 314b5c370b4655bc701985ddf1d1d478067e7baa (diff) | |
download | coreboot-7e0dea6317dc74f8aba8c91d0f8e8a7237261c49.tar.xz |
symbols.h: Add macro to define memlayout region symbols
When <symbols.h> was first introduced, it only declared a handful of
regions and we didn't expect that too many architectures and platforms
would need to add their own later. However, our amount of platforms has
greatly expanded since, and with them the need for more special memory
regions. The amount of code duplication is starting to get unsightly,
and platforms keep defining their own <soc/symbols.h> files that need
this as well.
This patch adds another macro to cut down the definition boilerplate.
Unfortunately, macros cannot define other macros when they're called, so
referring to region sizes as _name_size doesn't work anymore. This patch
replaces the scheme with REGION_SIZE(name).
Not touching the regions in the x86-specific <arch/symbols.h> yet since
they don't follow the standard _region/_eregion naming scheme. They can
be converted later if desired.
Change-Id: I44727d77d1de75882c72a94f29bd7e2c27741dd8
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/31539
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/bootblock.c | 3 | ||||
-rw-r--r-- | src/lib/bootmem.c | 6 | ||||
-rw-r--r-- | src/lib/cbmem_common.c | 2 | ||||
-rw-r--r-- | src/lib/cbmem_console.c | 3 | ||||
-rw-r--r-- | src/lib/stack.c | 3 | ||||
-rw-r--r-- | src/lib/timestamp.c | 6 |
6 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/bootblock.c b/src/lib/bootblock.c index f2ada522eb..037e913e93 100644 --- a/src/lib/bootblock.c +++ b/src/lib/bootblock.c @@ -33,7 +33,8 @@ asmlinkage void bootblock_main_with_timestamp(uint64_t base_timestamp, struct timestamp_entry *timestamps, size_t num_timestamps) { /* Initialize timestamps if we have TIMESTAMP region in memlayout.ld. */ - if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS) && _timestamp_size > 0) { + if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS) && + REGION_SIZE(timestamp) > 0) { int i; timestamp_init(base_timestamp); for (i = 0; i < num_timestamps; i++) diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c index 7cc8fff2e4..01ad3e841b 100644 --- a/src/lib/bootmem.c +++ b/src/lib/bootmem.c @@ -89,8 +89,10 @@ static void bootmem_init(void) /* Add memory used by CBMEM. */ cbmem_add_bootmem(); - bootmem_add_range((uintptr_t)_stack, _stack_size, BM_MEM_RAMSTAGE); - bootmem_add_range((uintptr_t)_program, _program_size, BM_MEM_RAMSTAGE); + bootmem_add_range((uintptr_t)_stack, REGION_SIZE(stack), + BM_MEM_RAMSTAGE); + bootmem_add_range((uintptr_t)_program, REGION_SIZE(program), + BM_MEM_RAMSTAGE); bootmem_arch_add_ranges(); bootmem_platform_add_ranges(); diff --git a/src/lib/cbmem_common.c b/src/lib/cbmem_common.c index 4010494118..d86edf013a 100644 --- a/src/lib/cbmem_common.c +++ b/src/lib/cbmem_common.c @@ -24,7 +24,7 @@ void cbmem_run_init_hooks(int is_recovery) cbmem_init_hook_t *einit_hook_ptr = (cbmem_init_hook_t *)&_ecbmem_init_hooks; - if (_cbmem_init_hooks_size == 0) + if (REGION_SIZE(cbmem_init_hooks) == 0) return; while (init_hook_ptr != einit_hook_ptr) { diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index 2f60fb5a7f..b05b747bf2 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -111,7 +111,8 @@ void cbmemc_init(void) { #ifdef __PRE_RAM__ /* Pre-RAM environments use special buffer placed by linker script. */ - init_console_ptr(_preram_cbmem_console, _preram_cbmem_console_size); + init_console_ptr(_preram_cbmem_console, + REGION_SIZE(preram_cbmem_console)); #else /* Post-RAM uses static (BSS) buffer before CBMEM is reinitialized. */ init_console_ptr(static_console, sizeof(static_console)); diff --git a/src/lib/stack.c b/src/lib/stack.c index ef45e2aee4..479ed93c05 100644 --- a/src/lib/stack.c +++ b/src/lib/stack.c @@ -30,7 +30,8 @@ it with the version available from LANL. int checkstack(void *top_of_stack, int core) { /* Not all archs use CONFIG_STACK_SIZE, those who don't set it to 0. */ - size_t stack_size = CONFIG_STACK_SIZE ? CONFIG_STACK_SIZE : _stack_size; + size_t stack_size = CONFIG_STACK_SIZE ? + CONFIG_STACK_SIZE : REGION_SIZE(stack); int i; u32 *stack = (u32 *) (top_of_stack - stack_size); diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index f84b9d5bc7..d2012d4059 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -42,7 +42,7 @@ struct __packed timestamp_cache { DECLARE_OPTIONAL_REGION(timestamp); #if defined(__PRE_RAM__) -#define USE_TIMESTAMP_REGION (_timestamp_size > 0) +#define USE_TIMESTAMP_REGION (REGION_SIZE(timestamp) > 0) #else #define USE_TIMESTAMP_REGION 0 #endif @@ -70,7 +70,7 @@ static void timestamp_cache_init(struct timestamp_cache *ts_cache, ts_cache->cache_state = TIMESTAMP_CACHE_INITIALIZED; if (USE_TIMESTAMP_REGION) - ts_cache->table.max_entries = (_timestamp_size - + ts_cache->table.max_entries = (REGION_SIZE(timestamp) - offsetof(struct timestamp_cache, entries)) / sizeof(struct timestamp_entry); } @@ -82,7 +82,7 @@ static struct timestamp_cache *timestamp_cache_get(void) if (TIMESTAMP_CACHE_IN_BSS) { ts_cache = ×tamp_cache; } else if (USE_TIMESTAMP_REGION) { - if (_timestamp_size < sizeof(*ts_cache)) + if (REGION_SIZE(timestamp) < sizeof(*ts_cache)) BUG(); ts_cache = car_get_var_ptr((void *)_timestamp); } |