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/soc/mediatek | |
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/soc/mediatek')
-rw-r--r-- | src/soc/mediatek/common/include/soc/mmu_operations.h | 5 | ||||
-rw-r--r-- | src/soc/mediatek/common/mmu_operations.c | 8 | ||||
-rw-r--r-- | src/soc/mediatek/mt8173/flash_controller.c | 4 | ||||
-rw-r--r-- | src/soc/mediatek/mt8173/include/soc/symbols.h | 4 | ||||
-rw-r--r-- | src/soc/mediatek/mt8173/mmu_operations.c | 3 |
5 files changed, 11 insertions, 13 deletions
diff --git a/src/soc/mediatek/common/include/soc/mmu_operations.h b/src/soc/mediatek/common/include/soc/mmu_operations.h index 79c3ea022b..7fa847fd1d 100644 --- a/src/soc/mediatek/common/include/soc/mmu_operations.h +++ b/src/soc/mediatek/common/include/soc/mmu_operations.h @@ -17,6 +17,7 @@ #define __SOC_MEDIATEK_COMMON_MMU_OPERATIONS_H__ #include <arch/mmu.h> +#include <symbols.h> enum { DEV_MEM = MA_DEV | MA_S | MA_RW, @@ -26,9 +27,7 @@ enum { NONSECURE_UNCACHED_MEM = MA_MEM | MA_NS | MA_RW | MA_MEM_NC, }; -extern unsigned char _sram_l2c[]; -extern unsigned char _esram_l2c[]; -#define _sram_l2c_size (_esram_l2c - _sram_l2c) +DECLARE_REGION(sram_l2c) void mtk_soc_after_dram(void); void mtk_soc_disable_l2c_sram(void); diff --git a/src/soc/mediatek/common/mmu_operations.c b/src/soc/mediatek/common/mmu_operations.c index 44670702de..7292487bed 100644 --- a/src/soc/mediatek/common/mmu_operations.c +++ b/src/soc/mediatek/common/mmu_operations.c @@ -32,13 +32,13 @@ void mtk_mmu_init(void) mmu_config_range((void *)0, (uintptr_t)4U * GiB, DEV_MEM); /* SRAM is cached */ - mmu_config_range(_sram, _sram_size, SECURE_CACHED_MEM); + mmu_config_range(_sram, REGION_SIZE(sram), SECURE_CACHED_MEM); /* L2C SRAM is cached */ - mmu_config_range(_sram_l2c, _sram_l2c_size, SECURE_CACHED_MEM); + mmu_config_range(_sram_l2c, REGION_SIZE(sram_l2c), SECURE_CACHED_MEM); /* DMA is non-cached and is reserved for TPM & da9212 I2C DMA */ - mmu_config_range(_dma_coherent, _dma_coherent_size, + mmu_config_range(_dma_coherent, REGION_SIZE(dma_coherent), SECURE_UNCACHED_MEM); mmu_enable(); @@ -56,7 +56,7 @@ void mtk_mmu_disable_l2c_sram(void) { /* Unmap L2C SRAM so it can be reclaimed by L2 cache */ /* TODO: Implement true unmapping, and also use it for the zero-page! */ - mmu_config_range(_sram_l2c, _sram_l2c_size, DEV_MEM); + mmu_config_range(_sram_l2c, REGION_SIZE(sram_l2c), DEV_MEM); /* Careful: changing cache geometry while it's active is a bad idea! */ mmu_disable(); diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c index 0fe9bb4e57..d63b69c174 100644 --- a/src/soc/mediatek/mt8173/flash_controller.c +++ b/src/soc/mediatek/mt8173/flash_controller.c @@ -171,10 +171,10 @@ static int nor_read(const struct spi_flash *flash, u32 addr, size_t len, if (ENV_BOOTBLOCK || ENV_VERSTAGE) { dma_buf = (uintptr_t)_dma_coherent; - dma_buf_len = _dma_coherent_size; + dma_buf_len = REGION_SIZE(dma_coherent); } else { dma_buf = (uintptr_t)_dram_dma; - dma_buf_len = _dram_dma_size; + dma_buf_len = REGION_SIZE(dram_dma); } while (len - done >= SFLASH_DMA_ALIGN) { diff --git a/src/soc/mediatek/mt8173/include/soc/symbols.h b/src/soc/mediatek/mt8173/include/soc/symbols.h index 8e2d0a4fb3..85cfd789ff 100644 --- a/src/soc/mediatek/mt8173/include/soc/symbols.h +++ b/src/soc/mediatek/mt8173/include/soc/symbols.h @@ -16,8 +16,6 @@ #ifndef __SOC_MEDIATEK_MT8173_DRAM_DMA_H__ #define __SOC_MEDIATEK_MT8173_DRAM_DMA_H__ -extern unsigned char _dram_dma[]; -extern unsigned char _edram_dma[]; -#define _dram_dma_size (_edram_dma - _dram_dma) +DECLARE_REGION(dram_dma) #endif diff --git a/src/soc/mediatek/mt8173/mmu_operations.c b/src/soc/mediatek/mt8173/mmu_operations.c index 443bc6eb4d..c80226477a 100644 --- a/src/soc/mediatek/mt8173/mmu_operations.c +++ b/src/soc/mediatek/mt8173/mmu_operations.c @@ -23,7 +23,8 @@ void mtk_soc_after_dram(void) { - mmu_config_range(_dram_dma, _dram_dma_size, NONSECURE_UNCACHED_MEM); + mmu_config_range(_dram_dma, REGION_SIZE(dram_dma), + NONSECURE_UNCACHED_MEM); mtk_mmu_disable_l2c_sram(); } |