|
23 | 23 | #define CLEANUP_RAM_GAP_START ((int)__ramfunc_region_start) |
24 | 24 | #define CLEANUP_RAM_GAP_SIZE ((int) (__ramfunc_end - __ramfunc_region_start)) |
25 | 25 |
|
| 26 | +#ifdef CONFIG_SB_CLEANUP_RAM |
| 27 | +#define REGIONS_OVERLAP(addr1, size1, addr2, size2) \ |
| 28 | + ((addr1) < ((addr2) + (size2)) && (addr2) < ((addr1) + (size1))) |
| 29 | + |
| 30 | +#define RETAINED_RAM_ADDR(ret_ram_node) DT_REG_ADDR(DT_PARENT(ret_ram_node)) |
| 31 | +#define RETAINED_RAM_SIZE(ret_ram_node) DT_REG_SIZE(DT_PARENT(ret_ram_node)) |
| 32 | + |
| 33 | + |
| 34 | +#define CHECK_RETAINED_RAM_NO_SRAM_OVERLAP(ret_ram_node) \ |
| 35 | + BUILD_ASSERT(!REGIONS_OVERLAP(CONFIG_SRAM_BASE_ADDRESS, CONFIG_SRAM_SIZE * 1024, \ |
| 36 | + RETAINED_RAM_ADDR(ret_ram_node), RETAINED_RAM_SIZE(ret_ram_node)), \ |
| 37 | + "Retained RAM region overlaps with defined SRAM, cannot cleanup RAM") |
| 38 | + |
| 39 | +/* Ensure that the retained RAM region does not overlap with the defined SRAM region. |
| 40 | + * Otherwise, the RAM cleanup would overwrite the retained RAM region. |
| 41 | + */ |
| 42 | +DT_FOREACH_STATUS_OKAY(zephyr_retained_ram, CHECK_RETAINED_RAM_NO_SRAM_OVERLAP); |
| 43 | +#endif |
| 44 | + |
26 | 45 | #if defined(CONFIG_SB_DISABLE_NEXT_W) |
27 | 46 | #include <hal/nrf_rramc.h> |
28 | 47 | #define RRAMC_REGION_FOR_NEXT_W 4 |
@@ -175,8 +194,8 @@ static void __ramfunc jump_in(uint32_t reset) |
175 | 194 | " bx r0\n" |
176 | 195 | : |
177 | 196 | : "r" (reset), |
178 | | - "i" (CONFIG_SRAM_BASE_ADDRESS), |
179 | | - "i" (CONFIG_SRAM_SIZE * 1024), |
| 197 | + "r" (CONFIG_SRAM_BASE_ADDRESS), |
| 198 | + "r" (CONFIG_SRAM_SIZE * 1024), |
180 | 199 | "r" (CLEANUP_RAM_GAP_START), |
181 | 200 | "r" (CLEANUP_RAM_GAP_SIZE), |
182 | 201 | "i" (0) |
|
0 commit comments