blob: 6fe24f5e44b7191b02c709a1633329547788e2ac [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 Werner7e0dea62019-02-20 18:39:22 -080010#define REGION_SIZE(name) (_e##name - _##name)
Aaron Durbin1936f6c2015-07-03 17:04:21 -050011
Julius Werner7e0dea62019-02-20 18:39:22 -080012#define DECLARE_REGION(name) \
13 extern u8 _##name[]; \
14 extern u8 _e##name[];
Julius Wernerec5e5e02014-08-20 15:29:56 -070015
Julius Werner644a5122020-08-25 16:00:44 -070016/*
17 * Regions can be declared optional if not all configurations provide them in
18 * memlayout and you want code to be able to check for their existence at
19 * runtime. Not every region that is architecture or platform-specific should
20 * use this -- only declare regions optional if the code *accessing* them runs
21 * both on configurations that have the region and those that don't. That code
22 * should then check (REGION_SIZE(name) != 0) before accessing it.
23 */
24#define DECLARE_OPTIONAL_REGION(name) \
25 __weak extern u8 _##name[]; \
26 __weak extern u8 _e##name[];
27
Julius Werner7e0dea62019-02-20 18:39:22 -080028DECLARE_REGION(sram)
Julius Werner644a5122020-08-25 16:00:44 -070029DECLARE_OPTIONAL_REGION(timestamp)
Julius Werner7e0dea62019-02-20 18:39:22 -080030DECLARE_REGION(preram_cbmem_console)
31DECLARE_REGION(cbmem_init_hooks)
32DECLARE_REGION(stack)
33DECLARE_REGION(preram_cbfs_cache)
34DECLARE_REGION(postram_cbfs_cache)
35DECLARE_REGION(cbfs_cache)
Julius Werner1e37c9c2019-12-11 17:09:39 -080036DECLARE_REGION(cbfs_mcache)
Julius Wernercefe89e2019-11-06 19:29:44 -080037DECLARE_REGION(fmap_cache)
Bill XIEc79e96b2019-08-22 20:28:36 +080038DECLARE_REGION(tpm_tcpa_log)
Julius Wernerec5e5e02014-08-20 15:29:56 -070039
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070040#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
41DECLARE_REGION(bss)
42DECLARE_REGION(asan_shadow)
43#endif
44
45#if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE)
Harshit Sharma9c88fb82020-06-17 20:19:00 -070046DECLARE_REGION(data)
47DECLARE_REGION(heap)
48DECLARE_REGION(asan_shadow)
49#endif
50
Bill XIEc79e96b2019-08-22 20:28:36 +080051/* Regions for execution units. */
52
53DECLARE_REGION(payload)
Aaron Durbin4de29d42015-09-03 22:49:36 -050054/* "program" always refers to the current execution unit. */
Julius Werner7e0dea62019-02-20 18:39:22 -080055DECLARE_REGION(program)
Julius Werner862c3852016-02-18 15:46:15 -080056/* _<stage>_size is always the maximum amount allocated in memlayout, whereas
Julius Werner7e0dea62019-02-20 18:39:22 -080057 _program_size gives the actual memory footprint *used* by current stage. */
58DECLARE_REGION(decompressor)
59DECLARE_REGION(bootblock)
60DECLARE_REGION(verstage)
61DECLARE_REGION(romstage)
62DECLARE_REGION(postcar)
63DECLARE_REGION(ramstage)
Julius Werner862c3852016-02-18 15:46:15 -080064
Julius Wernerec5e5e02014-08-20 15:29:56 -070065/* Arch-specific, move to <arch/symbols.h> if they become too many. */
66
Julius Werner7e0dea62019-02-20 18:39:22 -080067DECLARE_REGION(pagetables)
68DECLARE_REGION(ttb)
Julius Werner644a5122020-08-25 16:00:44 -070069DECLARE_OPTIONAL_REGION(ttb_subtables)
Julius Werner7e0dea62019-02-20 18:39:22 -080070DECLARE_REGION(dma_coherent)
71DECLARE_REGION(soc_registers)
72DECLARE_REGION(framebuffer)
73DECLARE_REGION(pdpt)
Julius Werner644a5122020-08-25 16:00:44 -070074DECLARE_OPTIONAL_REGION(opensbi)
75DECLARE_OPTIONAL_REGION(bl31)
Martin Roth0c12abe2020-06-26 08:40:56 -060076DECLARE_REGION(transfer_buffer)
Julius Wernerec5e5e02014-08-20 15:29:56 -070077
Joel Kitching0bcee882019-02-11 15:37:49 +080078/* Returns true when pre-RAM symbols are known to the linker.
79 * (Does not necessarily mean that the memory is accessible.) */
80static inline int preram_symbols_available(void)
81{
Kyösti Mälkki7336f972020-06-08 06:05:03 +030082 return !ENV_X86 || ENV_ROMSTAGE_OR_BEFORE;
Joel Kitching0bcee882019-02-11 15:37:49 +080083}
84
Julius Wernerec5e5e02014-08-20 15:29:56 -070085#endif /* __SYMBOLS_H */