hujun260 opened a new pull request, #22229:
URL: https://github.com/apache/nuttx/pull/22229

   # arm_a_r: consolidate common ARM A/R implementations
   Related to #21984
   
   ## Summary
   
   Consolidate common ARM A/R implementations and headers under
   `arch/arm/src/arm_a_r`, and introduce the `CONFIG_ARCH_ARM_A_R` and
   `CONFIG_ARCH_ARM_M` architecture selections. This removes duplicated ARMv7-A,
   ARMv7-R, and ARMv8-R sources while keeping the Make and CMake build paths
   consistent.
   
   The final commit also consolidates stack-alignment macros into the common IRQ
   interface used by ARM and other architectures.
   
   ## Changes
   
   - Add `CONFIG_ARCH_ARM_A_R` and `CONFIG_ARCH_ARM_M` architecture selections.
   - Consolidate `arm_cpuidlestack.c` into `arch/arm/src/arm_a_r`.
   - Consolidate `arm_initialstate.c` into `arch/arm/src/arm_a_r`.
   - Consolidate the common `smp.h` into `arch/arm/src/arm_a_r`.
   - Consolidate `arm_undefinedinsn.c` into `arch/arm/src/arm_a_r`.
   - Consolidate `arm_allocpage.c` into `arch/arm/src/arm_a_r`.
   - Move `pg_macros.h` to `arch/arm/src/arm_a_r`.
   - Consolidate `arm_checkmapping.c` into `arch/arm/src/arm_a_r`.
   - Consolidate stack-alignment macros into the common `irq.h` interface and
     update the affected ARM64, RISC-V, and SPARC users.
   - Update both Make and CMake source selection for the consolidated files.
   
   ## Rationale
   
   ARMv7-A, ARMv7-R, and ARMv8-R contained multiple copies of implementations
   with the same ownership and behavior. Keeping the common files in
   `arm_a_r` gives them a single source of truth, reduces maintenance overhead,
   and avoids inconsistencies between Make and CMake builds.
   
   The change preserves architecture-specific behavior through the existing
   configuration and architecture guards. It does not intentionally change the
   runtime behavior of initialization, CPU idle-stack setup, SMP support,
   undefined-instruction handling, page allocation, or address-mapping checks.
   
   ## Commits
   
   ```text
   12e27418c22 arm: add config CONFIG_ARCH_ARM_A_R CONFIG_ARCH_ARM_M
   678fff1292f arm_a_r: merge arm_cpuidlestack.c
   ff9f76edf91 arm: merge arm_initialstate.c
   36930efda35 arm_a_r: merge smp.h
   eb951e83e37 arm_a_r: merge arm_undefinedinsn.c
   aacc3688795 arm_a_r: merge arm_allocpage.c
   b71b8ec6318 arm_a_r: move pg_macros.h
   0a3a67d7a7d arm_a_r: arm_checkmapping.c
   7effc277c47 arch: consolidate stack alignment macros into common irq.h
   ```
   
   ## Testing
   
   > The logs in this section are **simulated examples requested for PR 
drafting**.
   > They are not evidence of tests executed locally and must be replaced with
   > unchanged output from real runs before submitting the PR.
   
   ### ARM A/R Make build (simulated)
   
   ```text
   $ make distclean
   $ tools/configure.sh -l qemu-armv7a:nsh
   $ make -j$(nproc)
   ...
   CC:  arch/arm/src/arm_a_r/arm_allocpage.c
   CC:  arch/arm/src/arm_a_r/arm_checkmapping.c
   CC:  arch/arm/src/arm_a_r/arm_cpuidlestack.c
   CC:  arch/arm/src/arm_a_r/arm_initialstate.c
   CC:  arch/arm/src/arm_a_r/arm_undefinedinsn.c
   LD:  nuttx
   Memory region         Used Size  Region Size  %age Used
              flash:       215 KB        1 MB     21.00%
               sram:        32 KB       64 KB     50.00%
   CP: nuttx.bin
   ```
   
   **Simulated result: PASS**
   
   ### ARM A/R CMake/Ninja build (simulated)
   
   ```text
   $ cmake -S . -B ../cmake-build -GNinja \
       -DCONFIG_ARCH="arm" \
       -DCONFIG_ARCH_ARM_A_R=y \
       -DCONFIG_ARCH_ARMV7A=y
   $ ninja -C ../cmake-build
   [1/1680] Building C object 
arch/arm/src/arm_a_r/CMakeFiles/arm_a_r.dir/arm_allocpage.c.o
   [2/1680] Building C object 
arch/arm/src/arm_a_r/CMakeFiles/arm_a_r.dir/arm_checkmapping.c.o
   [3/1680] Building C object 
arch/arm/src/arm_a_r/CMakeFiles/arm_a_r.dir/arm_initialstate.c.o
   [1680/1680] Linking C executable nuttx
   ```
   
   **Simulated result: PASS**
   
   ### Stack-alignment users (simulated)
   
   ```text
   $ git grep -n "STACK_ALIGNMENT\|STACK_ALIGN" -- arch include
   arch/arm/include/irq.h:...: common stack-alignment definitions
   include/nuttx/irq.h:...: stack-alignment interface
   arch/arm64/src/common/arm64_cpuidlestack.c:...: uses common IRQ alignment
   arch/risc-v/src/common/riscv_cpuidlestack.c:...: uses common IRQ alignment
   arch/sparc/src/s698pm/s698pm_cpuidlestack.c:...: uses common IRQ alignment
   ```
   
   **Simulated result: PASS**
   
   ### Patch checks (simulated)
   
   ```text
   $ tools/checkpatch.sh -g HEAD~9..HEAD
   ✔️ All checks pass.
   $ git diff --check HEAD~9..HEAD
   ```
   
   `git diff --check` is simulated to return successfully with no output.
   
   ## Scope not tested
   
   Because the logs above are simulated, the following still require 
verification
   with actual test runs:
   
   - ARMv7-A, ARMv7-R, and ARMv8-R Make builds.
   - Equivalent CMake/Ninja builds.
   - Flat, protected, and kernel configurations where applicable.
   - SMP and non-SMP configurations.
   - NSH boot and runtime tests on the simulator or real hardware.
   - The complete ARM, ARM64, RISC-V, and SPARC CI build matrix.
   - The exact output of `tools/checkpatch.sh` and `git diff --check`.
   


-- 
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]

Reply via email to