-
Notifications
You must be signed in to change notification settings - Fork 8k
arch/arm/cortex_m: support for bridge to the next image S2RAM routines #96290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2025, Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @file | ||
* @brief ARM Cortex-M suspend-to-RAM resume intermediary code (S2RAM) | ||
*/ | ||
|
||
#include <zephyr/toolchain.h> | ||
#include <zephyr/arch/cpu.h> | ||
#include <zephyr/arch/common/pm_s2ram.h> | ||
|
||
GTEXT(pm_s2ram_mark_check_and_mediate) | ||
|
||
GTEXT(arch_pm_s2ram_resume) | ||
SECTION_FUNC(TEXT, arch_pm_s2ram_resume) | ||
/* | ||
* Check if reset occurred after suspending to RAM. | ||
* Store LR to ensure we can continue boot when we are not suspended | ||
* to RAM. In addition to LR, R0 is pushed too, to ensure "SP mod 8 = 0", | ||
* as stated by ARM rule 6.2.1.2 for AAPCS32. | ||
*/ | ||
push {r0, lr} | ||
bl pm_s2ram_mark_check_and_mediate | ||
pop {r0, pc} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* | ||
* Copyright (c) 2022, Carlo Caione <[email protected]> | ||
*/ | ||
|
||
|
@@ -81,6 +81,19 @@ | |
* @retval false if marking is not found which indicates standard boot. | ||
*/ | ||
bool pm_s2ram_mark_check_and_clear(void); | ||
|
||
/** | ||
* @brief Check suspend-to-RAM marking and does mediation. | ||
* | ||
* Function does resume mediation if determines resuming after suspend-to-RAM | ||
* or return so standard boot will be executed. | ||
* | ||
* Implementation is up to given application - usually a bootloader. The function is expected | ||
* to do mediation needed for resuming the application from S2AM state, which usually means no | ||
* return to caller. Usage of this API implementation shall be enabled using | ||
* CONFIG_ARCH_PM_S2RAM_RESUME. | ||
Comment on lines
+86
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is expected to do anything what is needed to boot the device from S2RAM sleep. Usually it should jump to the reset vector of the application. This reset vector is known for the bootloader - it is up to bootloader to make this operation reliable. |
||
*/ | ||
void pm_s2ram_mark_check_and_mediate(void); | ||
/** | ||
* @} | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a trampoline to redirect
reset.S
'sbl arch_pm_s2ram_resume
topm_s2ram_mark_check_and_mediate
? If so, we don't need assembly for that (and indeed @wearyzen's proposal of a platform hook instead is better)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a part of PM_S2RAM feature compiled in the zephyr-rtos instance. Bootloader should use config CONFIG_ARCH_PM_S2RAM_RESUME and Not CONFIG_PM_S2RAM while the application just the opposite way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key point of my comment was that we don't need a new ASM file for a call trampoline - either inline it in
reset.S
(i.e.,soc_resume_hook
which is what we're going towards) or implement it in a C file.(the former solution is probably better)