blob: b1e44e113ff1ca9d5e77b8efcc16e990fe1e811b [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Julius Wernerec5e5e02014-08-20 15:29:56 -07002
3#ifndef __SYMBOLS_H
4#define __SYMBOLS_H
5
6#include <types.h>
7
Julius Wernerec5e5e02014-08-20 15:29:56 -07008extern u8 _dram[];
9
Julius Werner82d16b12020-12-30 15:51:10 -080010#define REGION_SIZE(name) ((size_t)_##name##_size)
Aaron Durbin1936f6c2015-07-03 17:04:21 -050011
Julius Werner7e0dea62019-02-20 18:39:22 -080012#define DECLARE_REGION(name) \
13 extern u8 _##name[]; \
Julius Werner82d16b12020-12-30 15:51:10 -080014 extern u8 _e##name[]; \
15 extern u8 _##name##_size[];
Julius Wernerec5e5e02014-08-20 15:29:56 -070016
Julius Werner644a5122020-08-25 16:00:44 -070017/*
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.
24 */
25#define DECLARE_OPTIONAL_REGION(name) \
26 __weak extern u8 _##name[]; \
Julius Werner82d16b12020-12-30 15:51:10 -080027 __weak extern u8 _e##name[]; \
28 __weak extern u8 _##name##_size[];
Julius Werner644a5122020-08-25 16:00:44 -070029
Julius Werner7e0dea62019-02-20 18:39:22 -080030DECLARE_REGION(sram)
Julius Werner644a5122020-08-25 16:00:44 -070031DECLARE_OPTIONAL_REGION(timestamp)
Julius Werner7e0dea62019-02-20 18:39:22 -080032DECLARE_REGION(preram_cbmem_console)
33DECLARE_REGION(cbmem_init_hooks)
34DECLARE_REGION(stack)
Julius Werner9b1f3cc2020-12-30 17:30:12 -080035DECLARE_OPTIONAL_REGION(preram_cbfs_cache)
36DECLARE_OPTIONAL_REGION(postram_cbfs_cache)
37DECLARE_OPTIONAL_REGION(cbfs_cache)
Julius Werner1e37c9c2019-12-11 17:09:39 -080038DECLARE_REGION(cbfs_mcache)
Julius Wernercefe89e2019-11-06 19:29:44 -080039DECLARE_REGION(fmap_cache)
Sergii Dmytruk2710df72022-11-10 00:40:51 +020040DECLARE_REGION(tpm_log)
Julius Wernerec5e5e02014-08-20 15:29:56 -070041
Arthur Heymansa2bc2542021-05-29 08:10:49 +020042#if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070043DECLARE_REGION(bss)
44DECLARE_REGION(asan_shadow)
45#endif
46
47#if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE)
Harshit Sharma9c88fb82020-06-17 20:19:00 -070048DECLARE_REGION(data)
49DECLARE_REGION(heap)
50DECLARE_REGION(asan_shadow)
51#endif
52
Jeremy Compostellab7832de2023-08-30 15:42:09 -070053#if ENV_SEPARATE_DATA_AND_BSS
54DECLARE_REGION(data)
55DECLARE_REGION(data_load)
56#endif
57
Bill XIEc79e96b2019-08-22 20:28:36 +080058/* Regions for execution units. */
59
60DECLARE_REGION(payload)
Aaron Durbin4de29d42015-09-03 22:49:36 -050061/* "program" always refers to the current execution unit. */
Julius Werner7e0dea62019-02-20 18:39:22 -080062DECLARE_REGION(program)
Julius Werner862c3852016-02-18 15:46:15 -080063/* _<stage>_size is always the maximum amount allocated in memlayout, whereas
Julius Werner7e0dea62019-02-20 18:39:22 -080064 _program_size gives the actual memory footprint *used* by current stage. */
65DECLARE_REGION(decompressor)
66DECLARE_REGION(bootblock)
67DECLARE_REGION(verstage)
68DECLARE_REGION(romstage)
69DECLARE_REGION(postcar)
70DECLARE_REGION(ramstage)
Julius Werner862c3852016-02-18 15:46:15 -080071
Julius Wernerec5e5e02014-08-20 15:29:56 -070072/* Arch-specific, move to <arch/symbols.h> if they become too many. */
73
Julius Werner7e0dea62019-02-20 18:39:22 -080074DECLARE_REGION(pagetables)
75DECLARE_REGION(ttb)
Julius Werner644a5122020-08-25 16:00:44 -070076DECLARE_OPTIONAL_REGION(ttb_subtables)
Julius Werner7e0dea62019-02-20 18:39:22 -080077DECLARE_REGION(dma_coherent)
78DECLARE_REGION(soc_registers)
79DECLARE_REGION(framebuffer)
80DECLARE_REGION(pdpt)
Julius Werner644a5122020-08-25 16:00:44 -070081DECLARE_OPTIONAL_REGION(opensbi)
82DECLARE_OPTIONAL_REGION(bl31)
Martin Roth0c12abe2020-06-26 08:40:56 -060083DECLARE_REGION(transfer_buffer)
Kyösti Mälkki662353a2021-02-11 07:18:29 +020084DECLARE_OPTIONAL_REGION(watchdog_tombstone)
Julius Wernerec5e5e02014-08-20 15:29:56 -070085
Joel Kitching0bcee882019-02-11 15:37:49 +080086/* Returns true when pre-RAM symbols are known to the linker.
87 * (Does not necessarily mean that the memory is accessible.) */
88static inline int preram_symbols_available(void)
89{
Kyösti Mälkki7336f972020-06-08 06:05:03 +030090 return !ENV_X86 || ENV_ROMSTAGE_OR_BEFORE;
Joel Kitching0bcee882019-02-11 15:37:49 +080091}
92
Julius Wernerec5e5e02014-08-20 15:29:56 -070093#endif /* __SYMBOLS_H */