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/include/symbols.h | |
parent | 314b5c370b4655bc701985ddf1d1d478067e7baa (diff) |
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/include/symbols.h')
-rw-r--r-- | src/include/symbols.h | 124 |
1 files changed, 33 insertions, 91 deletions
diff --git a/src/include/symbols.h b/src/include/symbols.h index abb9fbecbc..8786db78bd 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -18,111 +18,53 @@ #include <types.h> -extern u8 _sram[]; -extern u8 _esram[]; -#define _sram_size (_esram - _sram) - extern u8 _dram[]; -extern u8 _timestamp[]; -extern u8 _etimestamp[]; -#define _timestamp_size (_etimestamp - _timestamp) - -extern u8 _preram_cbmem_console[]; -extern u8 _epreram_cbmem_console[]; -#define _preram_cbmem_console_size \ - (_epreram_cbmem_console - _preram_cbmem_console) - -extern u8 _cbmem_init_hooks[]; -extern u8 _ecbmem_init_hooks[]; -#define _cbmem_init_hooks_size (_ecbmem_init_hooks - _cbmem_init_hooks) - -extern u8 _stack[]; -extern u8 _estack[]; -#define _stack_size (_estack - _stack) - -extern u8 _pagetables[]; -extern u8 _epagetables[]; -#define _pagetables_size (_epagetables - _pagetables) +#define REGION_SIZE(name) (_e##name - _##name) -extern u8 _preram_cbfs_cache[]; -extern u8 _epreram_cbfs_cache[]; -#define _preram_cbfs_cache_size (_epreram_cbfs_cache - _preram_cbfs_cache) +#define DECLARE_REGION(name) \ + extern u8 _##name[]; \ + extern u8 _e##name[]; -extern u8 _postram_cbfs_cache[]; -extern u8 _epostram_cbfs_cache[]; -#define _postram_cbfs_cache_size (_epostram_cbfs_cache - _postram_cbfs_cache) - -extern u8 _cbfs_cache[]; -extern u8 _ecbfs_cache[]; -#define _cbfs_cache_size (_ecbfs_cache - _cbfs_cache) - -extern u8 _payload[]; -extern u8 _epayload[]; -#define _payload_size (_epayload - _payload) +DECLARE_REGION(sram) +DECLARE_REGION(timestamp) +DECLARE_REGION(preram_cbmem_console) +DECLARE_REGION(cbmem_init_hooks) +DECLARE_REGION(stack) +DECLARE_REGION(preram_cbfs_cache) +DECLARE_REGION(postram_cbfs_cache) +DECLARE_REGION(cbfs_cache) +DECLARE_REGION(payload) /* "program" always refers to the current execution unit. */ -extern u8 _program[]; -extern u8 _eprogram[]; -#define _program_size (_eprogram - _program) - +DECLARE_REGION(program) /* _<stage>_size is always the maximum amount allocated in memlayout, whereas - * _program_size gives the actual memory footprint *used* by current stage. */ -extern u8 _decompressor[]; -extern u8 _edecompressor[]; -#define _decompressor_size (_edecompressor - _decompressor) - -extern u8 _bootblock[]; -extern u8 _ebootblock[]; -#define _bootblock_size (_ebootblock - _bootblock) - -extern u8 _romstage[]; -extern u8 _eromstage[]; -#define _romstage_size (_eromstage - _romstage) - -extern u8 _ramstage[]; -extern u8 _eramstage[]; -#define _ramstage_size (_eramstage - _ramstage) - -extern u8 _verstage[]; -extern u8 _everstage[]; -#define _verstage_size (_everstage - _verstage) + _program_size gives the actual memory footprint *used* by current stage. */ +DECLARE_REGION(decompressor) +DECLARE_REGION(bootblock) +DECLARE_REGION(verstage) +DECLARE_REGION(romstage) +DECLARE_REGION(postcar) +DECLARE_REGION(ramstage) /* Arch-specific, move to <arch/symbols.h> if they become too many. */ -extern u8 _ttb[]; -extern u8 _ettb[]; -#define _ttb_size (_ettb - _ttb) - -extern u8 _ttb_subtables[]; -extern u8 _ettb_subtables[]; -#define _ttb_subtables_size (_ettb_subtables - _ttb_subtables) - -extern u8 _dma_coherent[]; -extern u8 _edma_coherent[]; -#define _dma_coherent_size (_edma_coherent - _dma_coherent) - -extern u8 _soc_registers[]; -extern u8 _esoc_registers[]; -#define _soc_registers_size (_esoc_registers - _soc_registers) +DECLARE_REGION(pagetables) +DECLARE_REGION(ttb) +DECLARE_REGION(ttb_subtables) +DECLARE_REGION(dma_coherent) +DECLARE_REGION(soc_registers) +DECLARE_REGION(framebuffer) +DECLARE_REGION(pdpt) +DECLARE_REGION(bl31) -extern u8 _framebuffer[]; -extern u8 _eframebuffer[]; -#define _framebuffer_size (_eframebuffer - _framebuffer) - -extern u8 _pdpt[]; -extern u8 _epdpt[]; -#define _pdpt_size (_epdpt - _pdpt) - -extern u8 _bl31[]; -extern u8 _ebl31[]; -#define _bl31_size (_ebl31 - _bl31) - -/* Put this into a .c file accessing a linker script region to mark that region +/* + * Put this into a .c file accessing a linker script region to mark that region * as "optional". If it is defined in memlayout.ld (or anywhere else), the * values from that definition will be used. If not, start, end and size will * all evaluate to 0. (We can't explicitly assign the symbols to 0 in the - * assembly due to https://sourceware.org/bugzilla/show_bug.cgi?id=1038.) */ + * assembly due to https://sourceware.org/bugzilla/show_bug.cgi?id=1038.) + */ #define DECLARE_OPTIONAL_REGION(name) asm (".weak _" #name ", _e" #name) #endif /* __SYMBOLS_H */ |