update arm/m syscall sequences to use pseudo.S

shorten armv6m/v8m.base MPU sequence using stmia
This commit is contained in:
Chris Copeland 2024-03-19 00:15:20 -07:00
parent ace7733ebd
commit ae18c72704
Signed by: chrisnc
GPG Key ID: 14550DA72485DF30
4 changed files with 28 additions and 17 deletions

View File

@ -27,8 +27,9 @@ extern "C" {
#define RT_MPU_TASK_CONFIG_OFFSET 32
#if RT_ARM_PROFILE_M
#define RT_MPU_REGION_NUMBER_REG 0xE000ED98UL
#define RT_MPU_REGION_REGS 0xE000ED9CUL
#define RT_MPU_BASE 0xE000ED90UL
#define RT_MPU_REGION_NUMBER_OFFSET 0x8UL
#define RT_MPU_REGION_OFFSET 0xCUL
#endif
#if !defined(__ASSEMBLER__)
@ -48,7 +49,7 @@ extern "C" {
#elif RT_ARM_PROFILE_R
#include <rt/arch/coprocessor.h>
#elif RT_ARM_PROFILE_M
#define RT_MPU_REGS ((volatile struct rt_mpu *)0xE000ED90UL)
#define RT_MPU_REGS ((volatile struct rt_mpu *)RT_MPU_BASE)
#endif
#if (__ARM_ARCH == 6) || (__ARM_ARCH == 7)
@ -351,10 +352,10 @@ static inline void rt_mpu_attr_set(uint32_t index, uint32_t attr)
#endif // __ARM_ARCH
#if RT_ARM_PROFILE_M
rt_static_assert((uintptr_t)&RT_MPU_REGS->number == RT_MPU_REGION_NUMBER_REG,
"RT_MPU_REGION_NUMBER_REG is incorrect");
rt_static_assert((uintptr_t)&RT_MPU_REGS->regions == RT_MPU_REGION_REGS,
"RT_MPU_REGION_REGS is incorrect");
rt_static_assert(offsetof(struct rt_mpu, number) == RT_MPU_REGION_NUMBER_OFFSET,
"RT_MPU_REGION_NUMBER_OFFSET is incorrect");
rt_static_assert(offsetof(struct rt_mpu, regions) == RT_MPU_REGION_OFFSET,
"RT_MPU_REGION_OFFSET is incorrect");
#endif // RT_ARM_PROFILE_M
static inline void rt_mpu_enable(void)

View File

@ -3,8 +3,12 @@
#include <rt/arch/profile.h>
.macro mov32 reg, literal
#if RT_ARM_V6M
ldr \reg, =\literal
#else // !RT_ARM_V6M
movw \reg, :lower16:\literal
movt \reg, :upper16:\literal
#endif // RT_ARM_V6M
.endm
#if !defined(__thumb__) || RT_ARM_V6M

View File

@ -19,7 +19,13 @@
mov32 r1, rt_active_task
ldr r1, [r1]
adds r1, RT_MPU_TASK_CONFIG_OFFSET
mov32 r2, RT_MPU_REGION_NUMBER_REG
#if __ARM_ARCH == 8
/* In armv8-m, the region number isn't part of the base address
* register and must be set separately. */
ldr r2, =(RT_MPU_BASE + RT_MPU_REGION_NUMBER_OFFSET)
#else // __ARM_ARCH == 6
ldr r2, =(RT_MPU_BASE + RT_MPU_REGION_OFFSET)
#endif // __ARM_ARCH
mpuset RT_MPU_TASK_REGION_START_ID, RT_MPU_NUM_TASK_REGIONS
dsb
.endm
@ -28,15 +34,15 @@
.if \n == 0
.exitm
.endif
#if __ARM_ARCH == 8
/* In armv8-m, the region number isn't part of the base address
* register and must be set separately. */
mov r3, \r
str r3, [r2]
#endif // __ARM_ARCH == 8
ldmia r1!, {r4-r5}
str r4, [r2, 4]
str r5, [r2, 8]
#if __ARM_ARCH == 8
mov r3, \r
stmia r2!, {r3, r4, r5}
subs r2, 12
#else // __ARM_ARCH == 6
stmia r2!, {r4, r5}
subs r2, 8
#endif // __ARM_ARCH
mpuset (\r + 1), (\n - 1)
.endm
#else // !RT_MPU_TASK_REGIONS_ENABLE

View File

@ -41,7 +41,7 @@
mov32 r1, rt_active_task
ldr r1, [r1]
adds r1, RT_MPU_TASK_CONFIG_OFFSET
mov32 r2, RT_MPU_REGION_REGS
mov32 r2, RT_MPU_BASE + RT_MPU_REGION_OFFSET
mpuset RT_MPU_TASK_REGION_START_ID, RT_MPU_NUM_TASK_REGIONS
dsb
.endm