Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 2 | |
| 3 | #ifndef __SYMBOLS_H |
| 4 | #define __SYMBOLS_H |
| 5 | |
| 6 | #include <types.h> |
| 7 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 8 | extern u8 _dram[]; |
| 9 | |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 10 | #define REGION_SIZE(name) ((size_t)_##name##_size) |
Aaron Durbin | 1936f6c | 2015-07-03 17:04:21 -0500 | [diff] [blame] | 11 | |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 12 | #define DECLARE_REGION(name) \ |
| 13 | extern u8 _##name[]; \ |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 14 | extern u8 _e##name[]; \ |
| 15 | extern u8 _##name##_size[]; |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 16 | |
Julius Werner | 644a512 | 2020-08-25 16:00:44 -0700 | [diff] [blame] | 17 | /* |
| 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 Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 27 | __weak extern u8 _e##name[]; \ |
| 28 | __weak extern u8 _##name##_size[]; |
Julius Werner | 644a512 | 2020-08-25 16:00:44 -0700 | [diff] [blame] | 29 | |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 30 | DECLARE_REGION(sram) |
Julius Werner | 644a512 | 2020-08-25 16:00:44 -0700 | [diff] [blame] | 31 | DECLARE_OPTIONAL_REGION(timestamp) |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 32 | DECLARE_REGION(preram_cbmem_console) |
| 33 | DECLARE_REGION(cbmem_init_hooks) |
| 34 | DECLARE_REGION(stack) |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 35 | DECLARE_OPTIONAL_REGION(preram_cbfs_cache) |
| 36 | DECLARE_OPTIONAL_REGION(postram_cbfs_cache) |
| 37 | DECLARE_OPTIONAL_REGION(cbfs_cache) |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 38 | DECLARE_REGION(cbfs_mcache) |
Julius Werner | cefe89e | 2019-11-06 19:29:44 -0800 | [diff] [blame] | 39 | DECLARE_REGION(fmap_cache) |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 40 | DECLARE_REGION(tpm_tcpa_log) |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 41 | |
Harshit Sharma | a6ebe08 | 2020-07-20 00:21:05 -0700 | [diff] [blame] | 42 | #if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE) |
| 43 | DECLARE_REGION(bss) |
| 44 | DECLARE_REGION(asan_shadow) |
| 45 | #endif |
| 46 | |
| 47 | #if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE) |
Harshit Sharma | 9c88fb8 | 2020-06-17 20:19:00 -0700 | [diff] [blame] | 48 | DECLARE_REGION(data) |
| 49 | DECLARE_REGION(heap) |
| 50 | DECLARE_REGION(asan_shadow) |
| 51 | #endif |
| 52 | |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 53 | /* Regions for execution units. */ |
| 54 | |
| 55 | DECLARE_REGION(payload) |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 56 | /* "program" always refers to the current execution unit. */ |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 57 | DECLARE_REGION(program) |
Julius Werner | 862c385 | 2016-02-18 15:46:15 -0800 | [diff] [blame] | 58 | /* _<stage>_size is always the maximum amount allocated in memlayout, whereas |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 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) |
Julius Werner | 862c385 | 2016-02-18 15:46:15 -0800 | [diff] [blame] | 66 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 67 | /* Arch-specific, move to <arch/symbols.h> if they become too many. */ |
| 68 | |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 69 | DECLARE_REGION(pagetables) |
| 70 | DECLARE_REGION(ttb) |
Julius Werner | 644a512 | 2020-08-25 16:00:44 -0700 | [diff] [blame] | 71 | DECLARE_OPTIONAL_REGION(ttb_subtables) |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 72 | DECLARE_REGION(dma_coherent) |
| 73 | DECLARE_REGION(soc_registers) |
| 74 | DECLARE_REGION(framebuffer) |
| 75 | DECLARE_REGION(pdpt) |
Julius Werner | 644a512 | 2020-08-25 16:00:44 -0700 | [diff] [blame] | 76 | DECLARE_OPTIONAL_REGION(opensbi) |
| 77 | DECLARE_OPTIONAL_REGION(bl31) |
Martin Roth | 0c12abe | 2020-06-26 08:40:56 -0600 | [diff] [blame] | 78 | DECLARE_REGION(transfer_buffer) |
Kyösti Mälkki | 662353a | 2021-02-11 07:18:29 +0200 | [diff] [blame] | 79 | DECLARE_OPTIONAL_REGION(watchdog_tombstone) |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 80 | |
Joel Kitching | 0bcee88 | 2019-02-11 15:37:49 +0800 | [diff] [blame] | 81 | /* Returns true when pre-RAM symbols are known to the linker. |
| 82 | * (Does not necessarily mean that the memory is accessible.) */ |
| 83 | static inline int preram_symbols_available(void) |
| 84 | { |
Kyösti Mälkki | 7336f97 | 2020-06-08 06:05:03 +0300 | [diff] [blame] | 85 | return !ENV_X86 || ENV_ROMSTAGE_OR_BEFORE; |
Joel Kitching | 0bcee88 | 2019-02-11 15:37:49 +0800 | [diff] [blame] | 86 | } |
| 87 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 88 | #endif /* __SYMBOLS_H */ |