hujun260 opened a new pull request, #22210:
URL: https://github.com/apache/nuttx/pull/22210
# arm_m: Consolidate Common ARM-M Implementations and Headers
## Summary
Consolidate duplicated ARM-M implementations from ARMv6-M, ARMv7-M, and
ARMv8-M into the shared `arch/arm/src/arm_m` directory. This reduces
maintenance overhead and keeps the Make and CMake build paths consistent
across the ARM-M profiles.
This PR includes the following changes:
- Move `arm_saveusercontext.S` into `arch/arm/src/arm_m`.
- Merge `psr.h` into `arch/arm/src/arm_m`.
- Merge `exc_return.h` into `arch/arm/src/arm_m`.
- Move `arm_schedulesigaction.c` and `arm_sigdeliver.c` into `arm_m`.
- Fix the `SRCS` typo in `arm_m/CMakeLists.txt`.
- Place assembly sources before C sources in `arm_m/Make.defs`.
- Update the ARMv6-M, ARMv7-M, and ARMv8-M Make/CMake source selections so
that each shared implementation is compiled exactly once.
## Changes
### Shared Directory
The shared directory contains:
```text
arch/arm/src/arm_m/
├── CMakeLists.txt
├── Make.defs
├── arm_saveusercontext.S
├── arm_schedulesigaction.c
├── arm_sigdeliver.c
├── exc_return.h
└── psr.h
```
### Build-System Integration
All three ARM-M profiles select the shared directory:
```text
ARMv6-M -> arch/arm/src/arm_m
ARMv7-M -> arch/arm/src/arm_m
ARMv8-M -> arch/arm/src/arm_m
```
Both `Make.defs` and `CMakeLists.txt` add the shared implementations only
once. Profile-specific implementations remain in their respective
architecture directories.
### Architecture Differences
The merge preserves the conditional compilation and assembly differences
required by ARMv6-M, ARMv7-M, and ARMv8-M. This change does not alter public
interfaces or exception-handling behavior; it only changes source ownership
and build-system selection.
## Rationale
These implementations were duplicated across multiple ARM-M profile
directories. As a result, the same fix had to be applied to several copies,
and the Make and CMake source lists could become inconsistent. Moving the
common implementations into `arm_m` gives them a single, well-defined owner
and simplifies future maintenance.
## Commits
```text
925b605226c3709e1fb997568c45498772542759 arm_m: merge arm_saveusercontext
into arm_m
74dbc70e016f92ccde85537f5b86b5b44ce09499 arch/arm/src: merge psr.h into arm_m
fed3217cbf8bd31c840f07da51d44cfd4fb7adf7 arch/arm/src: merge exc_return.h
3f73265f3433257b23799a49376aaf13bc2d2dcd arch/arm/arm_m: fix CMake SRCS
typo, move asm before C in Make.defs
3c55467ce1c22f95627a097354779df31d790a4c arch/arm/src: merge
arm_schedulesigaction & arm_sigdeliver into arm_m
```
## Testing
> The logs below are **simulated logs** for the PR description example. They
> do not represent builds or runtime tests that have actually been executed
> locally. Replace or verify them with real results before submitting the PR.
### ARMv6-M Make Build (Simulated)
```text
$ cd nuttx
$ make distclean
$ tools/configure.sh -l stm32f051-discovery:nsh
$ make -j$(nproc)
...
CC: arch/arm/src/arm_m/arm_sigdeliver.c
CC: arch/arm/src/arm_m/arm_schedulesigaction.c
AS: arch/arm/src/arm_m/arm_saveusercontext.S
LD: nuttx
Memory region Used Size Region Size %age Used
flash: 34640 B 64 KB 52.86%
sram: 1704 B 8 KB 20.80%
CP: nuttx.bin
```
**Simulated result: PASS**
### ARMv7-M Make Build (Simulated)
```text
$ make distclean
$ tools/configure.sh -l stm32f4discovery:nsh
$ make -j$(nproc)
...
CC: arch/arm/src/arm_m/arm_sigdeliver.c
CC: arch/arm/src/arm_m/arm_schedulesigaction.c
AS: arch/arm/src/arm_m/arm_saveusercontext.S
LD: nuttx
Memory region Used Size Region Size %age Used
flash: 96852 B 1 MB 9.24%
sram: 5840 B 112 KB 5.09%
CP: nuttx.hex
CP: nuttx.bin
```
**Simulated result: PASS**
### ARMv8-M Make Build (Simulated)
```text
$ make distclean
$ tools/configure.sh -l mps2-an521:nsh
$ make -j$(nproc)
...
CC: arch/arm/src/arm_m/arm_sigdeliver.c
CC: arch/arm/src/arm_m/arm_schedulesigaction.c
AS: arch/arm/src/arm_m/arm_saveusercontext.S
LD: nuttx
Memory region Used Size Region Size %age Used
flash: 348216 B 4 MB 8.30%
sram1: 11952 B 4 MB 0.28%
CP: nuttx.hex
CP: nuttx.bin
```
**Simulated result: PASS**
### CMake/Ninja Build (Simulated)
```text
$ cmake -S . -B ../cmake-build -GNinja \
-DCONFIG_ARCH="arm" \
-DCONFIG_ARCH_ARM="y" \
-DCONFIG_ARCH_ARM_ARM_M="y"
$ ninja -C ../cmake-build
[1/1842] Building C object
arch/arm/src/arm_m/CMakeFiles/arm_m.dir/arm_sigdeliver.c.o
[2/1842] Building C object
arch/arm/src/arm_m/CMakeFiles/arm_m.dir/arm_schedulesigaction.c.o
[3/1842] Building ASM object
arch/arm/src/arm_m/CMakeFiles/arm_m.dir/arm_saveusercontext.S.o
[1842/1842] Linking C executable nuttx
```
**Simulated result: PASS**
### Patch Checks (Simulated)
```text
$ tools/checkpatch.sh -g 925b605226c3^..HEAD
✔️ All checks pass.
$ git diff --check 925b605226c3^..HEAD
```
`git diff --check` is simulated to return successfully with no output.
## Scope Not Tested
Because the logs above are simulated, the following items still require
verification with actual test runs:
- Actual ARMv6-M, ARMv7-M, and ARMv8-M Make builds.
- CMake/Ninja builds, including incremental builds.
- NSH boot, exception return, and signal-handling runtime tests.
- Protected, SMP, and other non-default configuration combinations.
- Hardware-board testing and the complete CI ARM build matrix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]