arch: Move STACK_ALIGNMENT definition to up_internal.h

to avoid the same macro duplicate to many place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-02-16 00:59:06 +08:00 committed by archer
parent f42b56b1c4
commit 3bf416e8b8
59 changed files with 236 additions and 743 deletions

View file

@ -123,7 +123,7 @@ int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size)
tcb->adj_stack_size = SMP_STACK_SIZE;
tcb->stack_alloc_ptr = (FAR void *)stack_alloc;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
#endif
return OK;

View file

@ -40,24 +40,6 @@
#include "arm_arch.h"
#include "arm_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* Configuration */
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (CONFIG_STACK_ALIGNMENT - 1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -156,16 +138,14 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
if (ttype == TCB_FLAG_TTYPE_KERNEL)
{
tcb->stack_alloc_ptr =
kmm_memalign(CONFIG_STACK_ALIGNMENT, stack_size);
tcb->stack_alloc_ptr = kmm_memalign(STACK_ALIGNMENT, stack_size);
}
else
#endif
{
/* Use the user-space allocator if this is a task or pthread */
tcb->stack_alloc_ptr =
kumm_memalign(CONFIG_STACK_ALIGNMENT, stack_size);
tcb->stack_alloc_ptr = kumm_memalign(STACK_ALIGNMENT, stack_size);
}
#endif /* CONFIG_TLS_ALIGNED */
@ -191,7 +171,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
*/
/* Since both stack_alloc_ptr and stack_size are in
* CONFIG_STACK_ALIGNMENT, and the stack ptr is decremented before
* STACK_ALIGNMENT, and the stack ptr is decremented before
* the first write, we can directly save our variables to struct
* tcb_s.
*/

View file

@ -75,6 +75,18 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Macros to handle saving and restoring interrupt state. In the current ARM
* model, the state is always copied to and from the stack and TCB. In the
* Cortex-M0/3 model, the state is copied from the stack to the TCB, but only

View file

@ -34,30 +34,6 @@
#include "arm_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (CONFIG_STACK_ALIGNMENT-1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -113,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -37,22 +37,6 @@
#include "arm_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (CONFIG_STACK_ALIGNMENT - 1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -108,7 +92,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
* Items on the stack are referenced as positive word offsets from sp.
*/
/* We align all sizes and pointer to CONFIG_STACK_ALIGNMENT.
/* We align all sizes and pointer to STACK_ALIGNMENT.
* Since the stack ptr is decremented before
* the first write, we can directly save our variables to struct
* tcb_s.

View file

@ -38,16 +38,6 @@
#include "arm_vfork.h"
#include "sched/sched.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define CONFIG_STACK_ALIGNMENT 8
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -34,28 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* Stack can be aligned to 1 byte */
#define CONFIG_STACK_ALIGNMENT 1
/* Stack alignment macros */
#define STACK_ALIGN_MASK (CONFIG_STACK_ALIGNMENT-1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -95,10 +73,6 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
{
FAR void *ret;
/* Align the frame_size */
frame_size = STACK_ALIGN_UP(frame_size);
/* Is there already a stack allocated? Is it big enough? */
if (!tcb->stack_alloc_ptr || tcb->adj_stack_size <= frame_size)
@ -111,7 +85,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -36,6 +36,18 @@
* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Macros to handle saving and restore interrupt state. The state is copied
* from the stack to the TCB, but only a referenced is passed to get the
* state from the TCB.

View file

@ -34,30 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -113,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -47,11 +47,6 @@
# define HAVE_KERNEL_HEAP 1
#endif
/* Stack alignment macros */
#define STACK_ALIGN_MASK (sizeof(uint32_t) - 1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -71,6 +71,12 @@
# define USE_SERIALDRIVER 1
#endif
/* Stack alignment macros */
#define STACK_ALIGN_MASK (sizeof(uint32_t) - 1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Linker defined section addresses */
#define _START_TEXT ((const void *)&_stext)

View file

@ -27,22 +27,7 @@
#include <nuttx/arch.h>
#include <nuttx/sched.h>
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* Stack alignment macros */
#define STACK_ALIGN_MASK (sizeof(uint32_t) - 1)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
#include "up_internal.h"
/****************************************************************************
* Public Functions

View file

@ -32,15 +32,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* Stack alignment macros */
#define STACK_ALIGN_MASK (sizeof(uint32_t) - 1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -70,6 +70,18 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Macros to handle saving and restore interrupt state. In the current CPU12
* model, the state is copied from the stack to the TCB, but only
* a referenced is passed to get the state from the TCB.

View file

@ -34,30 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -113,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -118,7 +118,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->adj_stack_size = size_of_stack;
return OK;

View file

@ -39,34 +39,6 @@
#include "mips_arch.h"
#include "mips_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -69,6 +69,22 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* In the MIPS model, the state is copied from the stack to the TCB, but
* only a referenced is passed to get the state from the TCB.
*/

View file

@ -33,34 +33,6 @@
#include "mips_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -116,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -36,26 +36,6 @@
#include "mips_internal.h"
/****************************************************************************
* 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
/* Stack alignment macros */
#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)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -38,18 +38,6 @@
#include "mips_vfork.h"
#include "sched/sched.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_STACK_ALIGNMENT
# define CONFIG_STACK_ALIGNMENT 4
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -63,6 +63,22 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -38,34 +38,6 @@
#include "lm32.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -33,26 +33,6 @@
#include "lm32.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -108,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -63,6 +63,22 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -38,26 +38,6 @@
#include "minerva.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -33,26 +33,6 @@
#include "minerva.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -108,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -40,24 +40,6 @@
#include "up_arch.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* Configuration */
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (CONFIG_STACK_ALIGNMENT-1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -72,6 +72,18 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
#define up_savestate(regs) up_copyfullstate(regs, (uint32_t*)CURRENT_REGS)
#define up_restorestate(regs) up_copyfullstate((uint32_t*)CURRENT_REGS, regs)

View file

@ -34,22 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* For use with EABI and floating point, the stack must be aligned to 8-byte
* addresses.
*/
#define CONFIG_STACK_ALIGNMENT 8
/* Stack alignment macros */
#define STACK_ALIGN_MASK (CONFIG_STACK_ALIGNMENT-1)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -105,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -75,6 +75,18 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
#define up_savestate(regs) up_copystate(regs, (uint32_t *)g_current_regs)
/****************************************************************************

View file

@ -33,30 +33,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -112,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return a pointer to allocated memory */

View file

@ -39,28 +39,6 @@
#include "riscv_arch.h"
#include "riscv_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -46,6 +46,16 @@
#define INTSTACK_COLOR 0xdeadbeef
#define HEAP_COLOR 'h'
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/* Format output with register width and hex */
#ifdef CONFIG_ARCH_RV32

View file

@ -33,28 +33,6 @@
#include "riscv_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -110,7 +88,7 @@ void *up_stack_frame(struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -36,20 +36,6 @@
#include "riscv_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* RISC-V requires a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -123,7 +109,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->adj_stack_size = size_of_stack;
#if defined(CONFIG_STACK_COLORATION)

View file

@ -35,22 +35,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -55,6 +55,18 @@
# endif
#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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Simulated Heap Definitions ***********************************************/
/* Size of the simulated heap */

View file

@ -32,21 +32,7 @@
#include <nuttx/arch.h>
#include <arch/irq.h>
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
#include "up_internal.h"
/****************************************************************************
* Public Functions
@ -103,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return a pointer to the allocated memory */

View file

@ -34,22 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -37,30 +37,6 @@
#include "up_arch.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -80,6 +80,18 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* This is the value used to mark the stack for subsequent stack monitoring
* logic.
*/

View file

@ -33,30 +33,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -113,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -34,30 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* 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
/* Stack alignment macros */
#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)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -70,6 +70,19 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Macros to handle saving and restore interrupt state. In the current
* model, the state is copied from the stack to the TCB, but only a
* referenced is passed to get the state from the TCB.

View file

@ -34,31 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -114,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -89,6 +89,19 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Macros to handle saving and restore interrupt state. In the current
* model, the state is copied from the stack to the TCB, but only a
* referenced is passed to get the state from the TCB.

View file

@ -34,31 +34,6 @@
#include "up_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -114,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -81,6 +81,16 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* An IDLE thread stack size for CPU0 must be defined */
#if !defined(CONFIG_IDLETHREAD_STACKSIZE)

View file

@ -39,14 +39,6 @@
#ifdef CONFIG_STACK_COLORATION
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Private Function Prototypes
****************************************************************************/

View file

@ -42,20 +42,6 @@
#include "xtensa.h"
#include "xtensa_mm.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* XTENSA requires at least a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -33,20 +33,6 @@
#include "xtensa.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* XTENSA requires at least a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -102,7 +88,7 @@ void *up_stack_frame(struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return the pointer to the allocated region */

View file

@ -36,20 +36,6 @@
#include "xtensa.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* XTENSA requires at least a 16-byte stack alignment. */
#define STACK_ALIGNMENT 16
/* Stack alignment macros */
#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)
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -98,7 +98,7 @@ int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
tcb->stack_alloc_ptr = g_cpu1_idlestack;
tcb->adj_stack_size = CPU1_IDLETHREAD_STACKSIZE;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
#if XCHAL_CP_NUM > 0
/* REVISIT: Does it make since to have co-processors enabled on the IDLE

View file

@ -70,6 +70,18 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/* Macros for portability */
#define IN_INTERRUPT (g_current_regs != NULL)

View file

@ -34,22 +34,6 @@
#include "z16_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -105,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return a pointer to the allocated memory */

View file

@ -117,7 +117,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->adj_stack_size = size_of_stack;
return OK;

View file

@ -61,6 +61,18 @@
# 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -33,22 +33,6 @@
#include "z80_internal.h"
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
/* 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)
#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
#define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -104,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
/* Save the adjusted stack values in the struct tcb_s */
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
tcb->adj_stack_size -= frame_size;
/* And return a pointer to the allocated memory */