arch: move STACK_ALIGNMENT to irq.h

Move STACK_ALIGNMENT macro definitions from architecture-specific internal
headers to public irq.h headers. This enables common code to directly access
STACK_ALIGNMENT without requiring internal header inclusion, improving code
organization and reducing header dependencies. Applies to all architectures:
ARM, ARM64, AVR, HC, MIPS, or1k, Renesas, RISC-V, SIM, SPARC, TriCore, x86,
x86_64, Xtensa, Z16, and Z80.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2025-04-11 15:34:54 +08:00 committed by GUIDINGLI
parent 79c349b779
commit 8bb250a4c0
35 changed files with 104 additions and 118 deletions

View file

@ -94,6 +94,12 @@
} while (0)
#endif
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define STACK_ALIGNMENT 8
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"

View file

@ -80,12 +80,6 @@
# define USE_SERIALDRIVER 1
#endif
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -243,6 +243,10 @@
#define IRQ_SPSR_MASK (IRQ_DAIF_MASK << 6)
/* AArch64 the stack-pointer must be 128-bit aligned */
#define STACK_ALIGNMENT 16
#ifndef __ASSEMBLY__
#ifdef __cplusplus

View file

@ -93,10 +93,6 @@
#define STACK_COLOR 0xdeaddead
#define HEAP_COLOR 'h'
/* AArch64 the stack-pointer must be 128-bit aligned */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -58,6 +58,12 @@
* Pre-processor Definitions
****************************************************************************/
/* The AVR32 stack must be aligned at word (4 byte) boundaries. If necessary
* frame_size must be rounded up to the next boundary
*/
#define STACK_ALIGNMENT 4
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -38,12 +38,6 @@
* Pre-processor Definitions
****************************************************************************/
/* The AVR32 stack must be aligned at word (4 byte) boundaries. If necessary
* frame_size must be rounded up to the next boundary
*/
#define STACK_ALIGNMENT 4
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -58,6 +58,12 @@
* Pre-processor Definitions
****************************************************************************/
/* The CPU12 stack should be aligned at half-word (2 byte) boundaries. If
* necessary frame_size must be rounded up to the next boundary
*/
#define STACK_ALIGNMENT 2
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -73,12 +73,6 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* The CPU12 stack should be aligned at half-word (2 byte) boundaries. If
* necessary frame_size must be rounded up to the next boundary
*/
#define STACK_ALIGNMENT 2
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -56,6 +56,16 @@
* Pre-processor Definitions
****************************************************************************/
/* MIPS requires at least a 4-byte stack alignment. For floating point use,
* however, the stack must be aligned to 8-byte addresses.
*/
#ifdef CONFIG_LIBC_FLOATINGPOINT
# define STACK_ALIGNMENT 8
#else
# define STACK_ALIGNMENT 4
#endif
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -71,16 +71,6 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* MIPS requires at least a 4-byte stack alignment. For floating point use,
* however, the stack must be aligned to 8-byte addresses.
*/
#ifdef CONFIG_LIBC_FLOATINGPOINT
# define STACK_ALIGNMENT 8
#else
# define STACK_ALIGNMENT 4
#endif
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -66,16 +66,6 @@
# endif
#endif
/* LM32 requires at least a 4-byte stack alignment. For floating point use,
* however, the stack must be aligned to 8-byte addresses.
*/
#ifdef CONFIG_LIBC_FLOATINGPOINT
# define STACK_ALIGNMENT 8
#else
# define STACK_ALIGNMENT 4
#endif
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -65,16 +65,6 @@
# endif
#endif
/* MINERVA requires at least a 4-byte stack alignment. For floating point
* use, however, the stack must be aligned to 8-byte addresses.
*/
#ifdef CONFIG_LIBC_FLOATINGPOINT
# define STACK_ALIGNMENT 8
#else
# define STACK_ALIGNMENT 4
#endif
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -44,6 +44,16 @@
#include <arch/chip/irq.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define STACK_ALIGNMENT 8
/****************************************************************************
* Inline functions
****************************************************************************/

View file

@ -74,12 +74,6 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -43,6 +43,12 @@
* Pre-processor Definitions
****************************************************************************/
/* The SH stack must be aligned at word (4 byte) boundaries. If necessary
* frame_size must be rounded up to the next boundary
*/
#define STACK_ALIGNMENT 4
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -77,12 +77,6 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* The SH stack must be aligned at word (4 byte) boundaries. If necessary
* frame_size must be rounded up to the next boundary
*/
#define STACK_ALIGNMENT 4
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -52,6 +52,10 @@
#endif
#define __XSTR(s) __STR(s)
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/****************************************************************************
* Map RISC-V exception code to NuttX IRQ,
* the exception that code > 19 is reserved or custom exception.

View file

@ -72,9 +72,6 @@
#define INTSTACK_COLOR 0xdeadbeef
#define HEAP_COLOR 'h'
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
#define STACK_FRAME_SIZE __XSTR(STACK_ALIGNMENT)
/* Stack alignment macros */

View file

@ -62,9 +62,6 @@
#define MTIMER_TIME_BASE (CONFIG_NUTTSBI_MTIME_BASE)
#define MTIMER_CMP_BASE (CONFIG_NUTTSBI_MTIMECMP_BASE)
/* For stack alignment */
#define STACK_ALIGNMENT 16
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)

View file

@ -43,6 +43,12 @@
#define NR_IRQS 64
/* Use a stack alignment of 16 bytes. If necessary frame_size must be
* rounded up to the next boundary
*/
#define STACK_ALIGNMENT 16
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -84,12 +84,6 @@
# define CONFIG_SIM_FB_INTERVAL_LINE 0
#endif
/* Use a stack alignment of 16 bytes. If necessary frame_size must be
* rounded up to the next boundary
*/
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -56,6 +56,12 @@
* Pre-processor Definitions
****************************************************************************/
/* sparc requires at least a 4-byte stack alignment. For floating point use,
* however, the stack must be aligned to 8-byte addresses.
*/
#define STACK_ALIGNMENT 8
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -84,12 +84,6 @@
#define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~STACK_ALIGN_MASK)
/* sparc requires at least a 4-byte stack alignment. For floating point use,
* however, the stack must be aligned to 8-byte addresses.
*/
#define STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -60,6 +60,12 @@
#define tricore_addr2csa(addr) ((uintptr_t)(((((uintptr_t)(addr)) & 0xF0000000) >> 12) \
| (((uintptr_t)(addr) & 0x003FFFC0) >> 6)))
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define STACK_ALIGNMENT 8
#ifndef __ASSEMBLY__
#ifdef __cplusplus

View file

@ -85,12 +85,6 @@
# define USE_SERIALDRIVER 1
#endif
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -55,6 +55,13 @@
* Pre-processor Definitions
****************************************************************************/
/* The initial stack point is aligned at word (4 byte) boundaries. If
* necessary frame_size must be rounded up to the next boundary to retain
* this alignment.
*/
#define STACK_ALIGNMENT 4
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -73,13 +73,6 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* The initial stack point is aligned at word (4 byte) boundaries. If
* necessary frame_size must be rounded up to the next boundary to retain
* this alignment.
*/
#define STACK_ALIGNMENT 4
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -55,6 +55,13 @@
#define X86_64_CPUPRIV_UVBASE_OFFSET (24)
#define X86_64_CPUPRIV_KTOPSTK_OFFSET (32)
/* The initial stack point is aligned at 16 bytes boundaries. If
* necessary frame_size must be rounded up to the next boundary to retain
* this alignment.
*/
#define STACK_ALIGNMENT 16
/****************************************************************************
* Public Data
****************************************************************************/

View file

@ -94,13 +94,6 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* The initial stack point is aligned at 16 bytes boundaries. If
* necessary frame_size must be rounded up to the next boundary to retain
* this alignment.
*/
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -71,6 +71,10 @@
* Pre-processor Definitions
****************************************************************************/
/* XTENSA requires at least a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* IRQ Stack Frame Format. Each value is a uint32_t register index */
#define REG_PC (0) /* Return PC */

View file

@ -84,10 +84,6 @@
# define INTSTACK_SIZE INTSTACK_ALIGNUP(CONFIG_ARCH_INTERRUPTSTACK)
#endif
/* XTENSA requires at least a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -43,6 +43,12 @@
* Pre-processor Definitions
****************************************************************************/
/* Align the stack to word (4 byte) boundaries. This is probablya greater
* alignment than is required.
*/
#define STACK_ALIGNMENT 4
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -72,12 +72,6 @@
# define USE_SERIALDRIVER 1
#endif
/* Align the stack to word (4 byte) boundaries. This is probablya greater
* alignment than is required.
*/
#define STACK_ALIGNMENT 4
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)

View file

@ -34,6 +34,16 @@
#include <nuttx/irq.h>
#include <arch/chip/irq.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The Z80 stack does not need to be aligned. Here is is aligned at word
* (4 byte) boundary.
*/
#define STACK_ALIGNMENT 4
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -63,12 +63,6 @@
# define USE_SERIALDRIVER 1
#endif
/* The Z80 stack does not need to be aligned. Here is is aligned at word
* (4 byte) boundary.
*/
#define STACK_ALIGNMENT 4
/* Stack alignment macros */
#define STACK_ALIGN_MASK (STACK_ALIGNMENT - 1)