memlayout: Store region sizes as separate symbols
This patch changes the memlayout macro infrastructure so that the size of a region "xxx" (i.e. the distance between the symbols _xxx and _exxx) is stored in a separate _xxx_size symbol. This has the advantage that region sizes can be used inside static initializers, and also saves an extra subtraction at runtime. Since linker symbols can only be treated as addresses (not as raw integers) by C, retain the REGION_SIZE() accessor macro to hide the necessary typecast. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Ifd89708ca9bd3937d0db7308959231106a6aa373 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49332 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
Patrick Georgi
parent
422501fb14
commit
82d16b150c
@@ -7,11 +7,12 @@
|
||||
|
||||
extern u8 _dram[];
|
||||
|
||||
#define REGION_SIZE(name) (_e##name - _##name)
|
||||
#define REGION_SIZE(name) ((size_t)_##name##_size)
|
||||
|
||||
#define DECLARE_REGION(name) \
|
||||
extern u8 _##name[]; \
|
||||
extern u8 _e##name[];
|
||||
extern u8 _e##name[]; \
|
||||
extern u8 _##name##_size[];
|
||||
|
||||
/*
|
||||
* Regions can be declared optional if not all configurations provide them in
|
||||
@@ -23,7 +24,8 @@ extern u8 _dram[];
|
||||
*/
|
||||
#define DECLARE_OPTIONAL_REGION(name) \
|
||||
__weak extern u8 _##name[]; \
|
||||
__weak extern u8 _e##name[];
|
||||
__weak extern u8 _e##name[]; \
|
||||
__weak extern u8 _##name##_size[];
|
||||
|
||||
DECLARE_REGION(sram)
|
||||
DECLARE_OPTIONAL_REGION(timestamp)
|
||||
|
Reference in New Issue
Block a user