From 7e0dea6317dc74f8aba8c91d0f8e8a7237261c49 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 20 Feb 2019 18:39:22 -0800 Subject: symbols.h: Add macro to define memlayout region symbols When 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 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 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 Reviewed-on: https://review.coreboot.org/c/31539 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/soc/rockchip/rk3399/decompressor.c | 2 +- src/soc/rockchip/rk3399/include/soc/symbols.h | 9 +++------ src/soc/rockchip/rk3399/soc.c | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/soc/rockchip/rk3399') diff --git a/src/soc/rockchip/rk3399/decompressor.c b/src/soc/rockchip/rk3399/decompressor.c index f4ca5d111f..a17900de50 100644 --- a/src/soc/rockchip/rk3399/decompressor.c +++ b/src/soc/rockchip/rk3399/decompressor.c @@ -30,7 +30,7 @@ void decompressor_soc_init(void) */ mmu_config_range((void *)0, (uintptr_t)4 * GiB, DEV_MEM); - mmu_config_range(_sram, _sram_size, SECURE_MEM); + mmu_config_range(_sram, REGION_SIZE(sram), SECURE_MEM); mmu_enable(); } diff --git a/src/soc/rockchip/rk3399/include/soc/symbols.h b/src/soc/rockchip/rk3399/include/soc/symbols.h index f1487d0cb6..a40a7c48d3 100644 --- a/src/soc/rockchip/rk3399/include/soc/symbols.h +++ b/src/soc/rockchip/rk3399/include/soc/symbols.h @@ -16,12 +16,9 @@ #ifndef __SOC_SYMBOLS_H__ #define __SOC_SYMBOLS_H__ -extern unsigned char _bl31_sram[]; -extern unsigned char _ebl31_sram[]; -#define _bl31_sram_size (_ebl31_sram - _bl31_sram) +#include -extern unsigned char _pmu_sram[]; -extern unsigned char _epmu_sram[]; -#define _pmu_sram_size (_epmu_sram - _pmu_sram) +DECLARE_REGION(bl31_sram) +DECLARE_REGION(pmu_sram) #endif diff --git a/src/soc/rockchip/rk3399/soc.c b/src/soc/rockchip/rk3399/soc.c index 8960c9e202..6e5e1a7f96 100644 --- a/src/soc/rockchip/rk3399/soc.c +++ b/src/soc/rockchip/rk3399/soc.c @@ -30,8 +30,10 @@ void bootmem_platform_add_ranges(void) { - bootmem_add_range((uintptr_t)_pmu_sram, _pmu_sram_size, BM_MEM_BL31); - bootmem_add_range((uintptr_t)_bl31_sram, _bl31_sram_size, BM_MEM_BL31); + bootmem_add_range((uintptr_t)_pmu_sram, REGION_SIZE(pmu_sram), + BM_MEM_BL31); + bootmem_add_range((uintptr_t)_bl31_sram, REGION_SIZE(bl31_sram), + BM_MEM_BL31); } static void soc_read_resources(struct device *dev) -- cgit v1.2.3