hujun260 opened a new pull request, #22295:
URL: https://github.com/apache/nuttx/pull/22295
# arm_m: consolidate exception and vector implementations
## Summary
Merge the duplicated ARMv6-M, ARMv7-M, and ARMv8-M exception entry and vector
table implementations into the common `arch/arm/src/arm_m` directory.
The common exception entry uses `r1` as the saved-register context pointer
before calling `arm_doirq()` and uses the context pointer returned in `r0`
for
restoration. It retains the profile-specific ARMv6-M register handling and
the
ARMv8-M stack-limit, FPU, and MVE handling through configuration guards.
## Changes
- Add the common `arm_m/arm_exception.S` exception entry implementation.
- Add the common `arm_m/arm_vectors.c` vector table implementation.
- Move `ghs_compat.S` into the common ARM-M directory.
- Remove the superseded ARMv6-M and ARMv7-M exception implementations.
- Remove the superseded ARMv7-M and ARMv8-M vector implementations.
- Update the ARM-M Make and CMake source lists so the common sources are
built
exactly once.
- Preserve ARMv6-M use of `PRIMASK` and low/high-register save and restore
sequences.
- Preserve ARMv7-M and ARMv8-M use of `BASEPRI`.
- Preserve ARMv8-M `MSPLIM`/`PSPLIM`, FPU, and MVE context handling.
- Add an explicit `REG_ALIGN` slot when
`CONFIG_ARMV8M_STACKCHECK_HARDWARE` is enabled, keeping the software
context
eight-byte aligned.
- Save both the stack-limit value and the alignment slot on exception entry,
then restore the stack-limit value and skip the alignment slot on exception
return.
## Context layout
With `CONFIG_ARMV8M_STACKCHECK_HARDWARE=y`, the software context contains two
additional words:
```text
REG_SPLIM = saved MSPLIM or PSPLIM
REG_ALIGN = four-byte alignment reserve
```
The matching assembly operations are:
```text
Entry: stmdb r1!, {r0, r3}
Return: ldmia r0!, {r1}
add r0, r0, #4
```
This keeps `SW_XCPT_SIZE` a multiple of eight and keeps the hardware
exception
frame at the offsets described by `REG_R0` through `REG_XPSR`.
## Commits
```text
34171e2b0e8f29bb9f15ad6cdd646ccf8b40ed24 armv8m: Register alignment,
interrupt push and pop synchronization operations
3a91e7f88814be786940dfeb26c280660b4dd485 arm_m: merge arm_exception.S &
arm_vector.c
```
## Testing
All commands below were executed from
`/home/hujun5/work/ssd/online_nuttx/nuttx`.
### Clean ARMv8-M Make build
Command:
```text
$ make distclean -j25
$ ./tools/configure.sh mps3-an547:nsh
$ make -j25
```
Relevant configuration:
```text
CONFIG_ARCH_ARMV8M=y
CONFIG_ARM_HAVE_MVE=y
CONFIG_ARMV8M_STACKCHECK_HARDWARE=y
CONFIG_ARCH_FPU=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ENABLE_ALL_SIGNALS=y
```
Result: **PASS**
```text
Create version.h
LN: platform/board to /home/hujun5/work/ssd/online_nuttx/apps/platform/dummy
Register: nsh
Register: dd
Register: sh
Register: getprime
Register: ostest
Register: hello
LD: nuttx
Memory region Used Size Region Size %age Used
flash: 361364 B 512 KB 68.92%
sram1: 16216 B 2 MB 0.77%
sram2: 0 GB 2 MB 0.00%
CP: nuttx.hex
CP: nuttx.bin
```
### MPS3-AN547 QEMU boot
Command:
```text
$ timeout 10s qemu-system-arm -M mps3-an547 -nographic -kernel nuttx.bin
```
Result: **PASS**
```text
ERROR: Failed to mount romfs at /mnt: -22
NuttShell (NSH) NuttX-13.1.1-RC0
nsh> qemu-system-arm: terminating on signal 15 from pid 864712 (timeout)
```
The process exit status was `124` because `timeout` stopped QEMU after ten
seconds. The guest reached the NSH prompt. The log above has only the
terminal
carriage-return and ANSI erase-line control characters removed. The ROMFS
mount
error is present in the real capture and was not investigated as part of this
PR. The captured output did not contain `Usage Fault`, `Hard Fault`,
`Invalid state`, or `PANIC`.
### Checkpatch
Command:
```text
$ ./tools/checkpatch.sh -c -u -m -g HEAD~2..HEAD
```
Result: **PASS**
```text
Used config files:
1: .codespellrc
✔️ All checks pass.
```
### Diff whitespace check
Command:
```text
$ git diff --check HEAD~2..HEAD
```
Result: **PASS**. The command returned success with no output.
## Scope not tested
- ARMv6-M and ARMv7-M builds were not run locally.
- CMake/Ninja builds were not run.
- Protected, kernel, SMP, and TrustZone configuration variants were not run.
- Signal delivery and nested interrupt paths were not exercised separately.
- Hardware-board testing and the complete CI ARM build matrix were not run.
--
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]