include/spd_bin.h: Add SPD IO layer
[coreboot2.git] / src / include / symbols.h
blobef2381432fed292cd2c93a1b15d9a244d1e27e97
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef __SYMBOLS_H
4 #define __SYMBOLS_H
6 #include <types.h>
8 extern u8 _dram[];
10 #define REGION_SIZE(name) ((size_t)_##name##_size)
12 #define DECLARE_REGION(name) \
13 __maybe_unused extern u8 _##name[]; \
14 __maybe_unused extern u8 _e##name[]; \
15 __maybe_unused 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 __maybe_unused __weak extern u8 _##name[]; \
27 __maybe_unused __weak extern u8 _e##name[]; \
28 __maybe_unused __weak extern u8 _##name##_size[];
30 DECLARE_REGION(sram)
31 DECLARE_OPTIONAL_REGION(timestamp)
32 DECLARE_REGION(preram_cbmem_console)
33 DECLARE_REGION(cbmem_init_hooks)
34 DECLARE_REGION(stack)
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_log)
42 #if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
43 DECLARE_REGION(bss)
44 DECLARE_REGION(asan_shadow)
45 #endif
47 #if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE)
48 DECLARE_REGION(data)
49 DECLARE_REGION(heap)
50 DECLARE_REGION(asan_shadow)
51 #endif
53 #if ENV_SEPARATE_DATA_AND_BSS
54 DECLARE_REGION(data)
55 DECLARE_REGION(data_load)
56 #endif
58 /* Regions for execution units. */
60 DECLARE_REGION(payload)
61 /* "program" always refers to the current execution unit. */
62 DECLARE_REGION(program)
63 /* _<stage>_size is always the maximum amount allocated in memlayout, whereas
64 _program_size gives the actual memory footprint *used* by current stage. */
65 DECLARE_REGION(decompressor)
66 DECLARE_REGION(bootblock)
67 DECLARE_REGION(verstage)
68 DECLARE_REGION(romstage)
69 DECLARE_REGION(postcar)
70 DECLARE_REGION(ramstage)
72 /* Arch-specific, move to <arch/symbols.h> if they become too many. */
74 DECLARE_REGION(pagetables)
75 DECLARE_REGION(ttb)
76 DECLARE_OPTIONAL_REGION(ttb_subtables)
77 DECLARE_REGION(dma_coherent)
78 DECLARE_REGION(soc_registers)
79 DECLARE_REGION(framebuffer)
80 DECLARE_REGION(pdpt)
81 DECLARE_OPTIONAL_REGION(opensbi)
82 DECLARE_OPTIONAL_REGION(bl31)
83 DECLARE_REGION(transfer_buffer)
84 DECLARE_OPTIONAL_REGION(watchdog_tombstone)
86 /* Returns true when pre-RAM symbols are known to the linker.
87 * (Does not necessarily mean that the memory is accessible.) */
88 static inline int preram_symbols_available(void)
90 return !ENV_X86 || ENV_ROMSTAGE_OR_BEFORE;
93 #endif /* __SYMBOLS_H */