Skip to content

Commit eb125ac

Browse files
nvlsianpunordicjm
authored andcommitted
[nrf fromtree] arch/arm/core/cortex_m: optional memory section for _cp_context
More complex suspend and resume scheme might require exactly defined location of this variable due to platform peculiar SW and HW requirement. DTS zephyr,memory-region node with nodelabel `pm_s2ram` shall be used to automatic definition of linker section for such objective. Signed-off-by: Andrzej Puzdrowski <[email protected]> (cherry picked from commit 20695ed)
1 parent 84ab620 commit eb125ac

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

arch/arm/core/cortex_m/pm_s2ram.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2022, Carlo Caione <[email protected]>
3+
* Copyright (c) 2025 Nordic Semiconductor ASA
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -14,7 +15,18 @@
1415
/**
1516
* CPU context for S2RAM
1617
*/
17-
__noinit _cpu_context_t _cpu_context;
18+
19+
#if DT_NODE_EXISTS(DT_NODELABEL(pm_s2ram)) &&\
20+
DT_NODE_HAS_COMPAT(DT_NODELABEL(pm_s2ram), zephyr_memory_region)
21+
22+
/* Linker section name is given by `zephyr,memory-region` property of
23+
* `zephyr,memory-region` compatible DT node with nodelabel `pm_s2ram`.
24+
*/
25+
__attribute__((section(DT_PROP(DT_NODELABEL(pm_s2ram), zephyr_memory_region))))
26+
#else
27+
__noinit
28+
#endif
29+
_cpu_context_t _cpu_context;
1830

1931
#ifndef CONFIG_PM_S2RAM_CUSTOM_MARKING
2032
/**

subsys/pm/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ config PM_S2RAM
3838
depends on ARCH_HAS_SUSPEND_TO_RAM
3939
help
4040
This option enables suspend-to-RAM (S2RAM).
41+
When enabled on Cortex-M, and a 'zephyr,memory-region' compatible node with nodelabel
42+
'pm_s2ram' is defined in DT, _cpu_context symbol (located in arch/arm/core/cortex_m/pm_s2ram.c)
43+
is placed in linker section given by 'zephyr,memory-region' property of aforementioned node.
4144

4245
config PM_S2RAM_CUSTOM_MARKING
4346
bool "Use custom marking functions"

0 commit comments

Comments
 (0)