Skip to content

Conversation

@mathieuchopstm
Copy link
Contributor

Final step of #90001: edit the architecture layer to automatically handle save/restore of CPU state that goes beyond the mere general-purpose and special registers.

Also cleans up the implementation a tiny bit, and add an assertion to prevent usage of S2RAM in unsupported configuration.

NOTE: PR is marked as draft for now as NVIC save/restore is not yet implemented. There is also some cleanup to be done.

Mathieu CHOPLAIN added 3 commits August 27, 2025 11:04
The current implementation of S2RAM for Cortex-M does
not work on SoCs with multiple CPUs. Make sure it is not
possible to build S2RAM on such SoCs.

Signed-off-by: Mathieu CHOPLAIN <[email protected]>
Use the toolchain-agnostic Z_GENERIC_SECTION() macro
in place of the GCC-ism used to place the CPU context in
a specific section.

Also wrap the section selector into a new "__s2ram_ctx" macro
to allow re-use for other structures S2RAM might have to save.

Signed-off-by: Mathieu CHOPLAIN <[email protected]>
Save/restore additional CPU state when entering/existing S2RAM states:
the SCB, MPU and FPU (if enabled) registers are now saved and restored
appropriately at architecture level.

Implement the feature in C to reduce the amount of assembly required.

Signed-off-by: Mathieu CHOPLAIN <[email protected]>
@mathieuchopstm mathieuchopstm force-pushed the arm_s2ram_ctx_save_restore branch from f6b41fb to 00d65a2 Compare August 27, 2025 10:45
@sonarqubecloud
Copy link

@mathieuchopstm
Copy link
Contributor Author

CI breakage is expected (Nordic board doesn't reserve enough room for the now-larger state)

@mathieuchopstm mathieuchopstm added this to the future milestone Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant