1 /* SPDX-License-Identifier: GPL-2.0-only */
10 #define REGION_SIZE(name) ((size_t)_##name##_size)
12 #define DECLARE_REGION(name) \
13 extern u8 _##name[]; \
14 extern u8 _e##name[]; \
15 extern u8 _##name##_size[];
18 * Regions can be declared optional if not all configurations provide them in
19 * memlayout and you want code to be able to check for their existence at
20 * runtime. Not every region that is architecture or platform-specific should
21 * use this -- only declare regions optional if the code *accessing* them runs
22 * both on configurations that have the region and those that don't. That code
23 * should then check (REGION_SIZE(name) != 0) before accessing it.
25 #define DECLARE_OPTIONAL_REGION(name) \
26 __weak extern u8 _##name[]; \
27 __weak extern u8 _e##name[]; \
28 __weak extern u8 _##name##_size[];
31 DECLARE_OPTIONAL_REGION(timestamp
)
32 DECLARE_REGION(preram_cbmem_console
)
33 DECLARE_REGION(cbmem_init_hooks
)
35 DECLARE_OPTIONAL_REGION(preram_cbfs_cache
)
36 DECLARE_OPTIONAL_REGION(postram_cbfs_cache
)
37 DECLARE_OPTIONAL_REGION(cbfs_cache
)
38 DECLARE_REGION(cbfs_mcache
)
39 DECLARE_REGION(fmap_cache
)
40 DECLARE_REGION(tpm_tcpa_log
)
42 #if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
44 DECLARE_REGION(asan_shadow
)
47 #if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE)
50 DECLARE_REGION(asan_shadow
)
53 /* Regions for execution units. */
55 DECLARE_REGION(payload
)
56 /* "program" always refers to the current execution unit. */
57 DECLARE_REGION(program
)
58 /* _<stage>_size is always the maximum amount allocated in memlayout, whereas
59 _program_size gives the actual memory footprint *used* by current stage. */
60 DECLARE_REGION(decompressor
)
61 DECLARE_REGION(bootblock
)
62 DECLARE_REGION(verstage
)
63 DECLARE_REGION(romstage
)
64 DECLARE_REGION(postcar
)
65 DECLARE_REGION(ramstage
)
67 /* Arch-specific, move to <arch/symbols.h> if they become too many. */
69 DECLARE_REGION(pagetables
)
71 DECLARE_OPTIONAL_REGION(ttb_subtables
)
72 DECLARE_REGION(dma_coherent
)
73 DECLARE_REGION(soc_registers
)
74 DECLARE_REGION(framebuffer
)
76 DECLARE_OPTIONAL_REGION(opensbi
)
77 DECLARE_OPTIONAL_REGION(bl31
)
78 DECLARE_REGION(transfer_buffer
)
80 /* Returns true when pre-RAM symbols are known to the linker.
81 * (Does not necessarily mean that the memory is accessible.) */
82 static inline int preram_symbols_available(void)
84 return !ENV_X86
|| ENV_ROMSTAGE_OR_BEFORE
;
87 #endif /* __SYMBOLS_H */