diff --git a/bsp/qemu-virt64-aarch64/.config b/bsp/qemu-virt64-aarch64/.config index 8ba72f990bb1a5e74890136309389dd23b7869cc..2bd46d496d18bb4c565e2dd1a1b88bebadef75cb 100644 --- a/bsp/qemu-virt64-aarch64/.config +++ b/bsp/qemu-virt64-aarch64/.config @@ -85,6 +85,7 @@ CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" CONFIG_RT_VER_NUM=0x40100 CONFIG_ARCH_CPU_64BIT=y # CONFIG_RT_USING_CPU_FFS is not set +CONFIG_ARCH_ARMV8=y # CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set # @@ -686,7 +687,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 # CONFIG_PKG_USING_CONTROLLER is not set # CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set CONFIG_SOC_VIRT64_AARCH64=y -CONFIG_BSP_SUPPORT_FPU=y # # AARCH64 qemu virt64 configs diff --git a/bsp/qemu-virt64-aarch64/Kconfig b/bsp/qemu-virt64-aarch64/Kconfig index 9bc888eb72901c09da8379f8452b9b2b90f70e73..147645457503851124e6490741e6532232816dbc 100644 --- a/bsp/qemu-virt64-aarch64/Kconfig +++ b/bsp/qemu-virt64-aarch64/Kconfig @@ -20,14 +20,10 @@ source "$PKGS_DIR/Kconfig" config SOC_VIRT64_AARCH64 bool - select ARCH_ARM_CORTEX_A53 + select ARCH_ARMV8 select ARCH_CPU_64BIT select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN - select BSP_USING_GIC - select RT_USING_GIC - select BSP_USING_GIC390 - select RT_USING_RTC default y source "$BSP_DIR/driver/Kconfig" diff --git a/bsp/qemu-virt64-aarch64/driver/Kconfig b/bsp/qemu-virt64-aarch64/driver/Kconfig index 75ec6f588f043462271ad17d19aa0fe02d9d9874..acf9f082ea25ce8e88a8e526706d2960ad6ca1e7 100644 --- a/bsp/qemu-virt64-aarch64/driver/Kconfig +++ b/bsp/qemu-virt64-aarch64/driver/Kconfig @@ -1,7 +1,3 @@ -menuconfig BSP_SUPPORT_FPU - bool "Using Float" - default y - menu "AARCH64 qemu virt64 configs" menuconfig BSP_USING_UART diff --git a/bsp/qemu-virt64-aarch64/rtconfig.h b/bsp/qemu-virt64-aarch64/rtconfig.h index 3870c7f54a2cbdbc52ad3bd6dde32520e88f40ef..2aefe60171270fc3beded42d9b8e953164da8264 100644 --- a/bsp/qemu-virt64-aarch64/rtconfig.h +++ b/bsp/qemu-virt64-aarch64/rtconfig.h @@ -53,6 +53,7 @@ #define RT_CONSOLE_DEVICE_NAME "uart0" #define RT_VER_NUM 0x40100 #define ARCH_CPU_64BIT +#define ARCH_ARMV8 /* RT-Thread Components */ @@ -220,7 +221,6 @@ /* entertainment: terminal games and other interesting software packages */ #define SOC_VIRT64_AARCH64 -#define BSP_SUPPORT_FPU /* AARCH64 qemu virt64 configs */ diff --git a/bsp/raspberry-pi/raspi3-64/.config b/bsp/raspberry-pi/raspi3-64/.config index bd6091474d8da5d8267affa211d42cac998c6d53..b0ee49e13b9be8141a3bab7765fefd41b26f12fe 100644 --- a/bsp/raspberry-pi/raspi3-64/.config +++ b/bsp/raspberry-pi/raspi3-64/.config @@ -711,7 +711,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 # CONFIG_PKG_USING_CONTROLLER is not set # CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set CONFIG_BCM2836_SOC=y -CONFIG_BSP_SUPPORT_FPU=y # # Hardware Drivers Config diff --git a/bsp/raspberry-pi/raspi3-64/driver/Kconfig b/bsp/raspberry-pi/raspi3-64/driver/Kconfig index 37f7501cc0ccf4885a6a8dedef1e7e60188cd483..15f9fb94c928e6fbcd3b361abef6cd85c63e903f 100644 --- a/bsp/raspberry-pi/raspi3-64/driver/Kconfig +++ b/bsp/raspberry-pi/raspi3-64/driver/Kconfig @@ -1,8 +1,3 @@ - -config BSP_SUPPORT_FPU - bool "Using Float" - default n - menu "Hardware Drivers Config" menu "BCM Peripheral Drivers" menuconfig BSP_USING_UART diff --git a/bsp/raspberry-pi/raspi3-64/rtconfig.h b/bsp/raspberry-pi/raspi3-64/rtconfig.h index 4b560f13b86463e452d81b8bb0d5be2111cace21..6a8a03290b9385e47382b400fcf80db585b3b0b0 100644 --- a/bsp/raspberry-pi/raspi3-64/rtconfig.h +++ b/bsp/raspberry-pi/raspi3-64/rtconfig.h @@ -232,7 +232,6 @@ /* entertainment: terminal games and other interesting software packages */ #define BCM2836_SOC -#define BSP_SUPPORT_FPU /* Hardware Drivers Config */ diff --git a/bsp/raspberry-pi/raspi4-64/.config b/bsp/raspberry-pi/raspi4-64/.config index a3fd2291eadefa8499c11d010b90017d7f1d59d3..a2c217c07a062d3c562de85a341e334f337d5285 100644 --- a/bsp/raspberry-pi/raspi4-64/.config +++ b/bsp/raspberry-pi/raspi4-64/.config @@ -778,7 +778,6 @@ CONFIG_YMODEM_USING_FILE_TRANSFER=y # CONFIG_PKG_USING_CONTROLLER is not set # CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set CONFIG_BCM2711_SOC=y -CONFIG_BSP_SUPPORT_FPU=y # # Hardware Drivers Config diff --git a/bsp/raspberry-pi/raspi4-64/driver/Kconfig b/bsp/raspberry-pi/raspi4-64/driver/Kconfig index 28bc5ecfa542779d91d3a7256a17c68f79f12d01..1eaf56faca0a47d755c9be72a9df153e43a4b98e 100644 --- a/bsp/raspberry-pi/raspi4-64/driver/Kconfig +++ b/bsp/raspberry-pi/raspi4-64/driver/Kconfig @@ -1,8 +1,3 @@ - -config BSP_SUPPORT_FPU - bool "Using Float" - default n - menu "Hardware Drivers Config" menu "BCM Peripheral Drivers" menuconfig BSP_USING_UART diff --git a/bsp/raspberry-pi/raspi4-64/rtconfig.h b/bsp/raspberry-pi/raspi4-64/rtconfig.h index f233e32e0b1625dabdb95d9b6f09ce36e571dc84..3091cbfa2e48c709b65b12d5e647e1c444e47cbc 100644 --- a/bsp/raspberry-pi/raspi4-64/rtconfig.h +++ b/bsp/raspberry-pi/raspi4-64/rtconfig.h @@ -284,7 +284,6 @@ /* entertainment: terminal games and other interesting software packages */ #define BCM2711_SOC -#define BSP_SUPPORT_FPU /* Hardware Drivers Config */ diff --git a/libcpu/aarch64/common/context_gcc.S b/libcpu/aarch64/common/context_gcc.S index cad3b0db3f1bb7d62c074e5b98d504cab1729f83..20f65ffd358eaad19706463cf8a41f7f1c5c0c60 100644 --- a/libcpu/aarch64/common/context_gcc.S +++ b/libcpu/aarch64/common/context_gcc.S @@ -65,6 +65,19 @@ rt_hw_get_gtimer_frq: MRS X0,CNTFRQ_EL0 RET +/* + *set gtimer frq value (only in EL3) + */ +.globl rt_hw_set_gtimer_frq +rt_hw_set_gtimer_frq: + MRS X1, CurrentEL + CMP X1, 0xc + BNE rt_hw_set_gtimer_frq_exit + MSR CNTFRQ_EL0, X0 + MOV X0, XZR +rt_hw_set_gtimer_frq_exit: + RET + .macro SAVE_CONTEXT /* Save the entire context. */ SAVE_FPU SP diff --git a/libcpu/aarch64/common/gtimer.h b/libcpu/aarch64/common/gtimer.h index 956e2ed5aa2186c56fc03d39a59dc91995f863d1..c420c1f886a3032dd4d866018b1b2b8526a2721b 100644 --- a/libcpu/aarch64/common/gtimer.h +++ b/libcpu/aarch64/common/gtimer.h @@ -23,5 +23,6 @@ void rt_hw_set_gtimer_val(rt_uint64_t value); rt_uint64_t rt_hw_get_gtimer_val(); rt_uint64_t rt_hw_get_cntpct_val(); rt_uint64_t rt_hw_get_gtimer_frq(); +rt_uint64_t rt_hw_set_gtimer_frq(rt_uint64_t value); #endif /* __GTIMER_H__ */ diff --git a/libcpu/aarch64/common/stack.c b/libcpu/aarch64/common/stack.c index a0ec935e5da2aa51ccdde004b92df8b7087fb18c..2743fd3eee7b4c36831f877e467065cdeabd8f21 100644 --- a/libcpu/aarch64/common/stack.c +++ b/libcpu/aarch64/common/stack.c @@ -13,10 +13,6 @@ #include #include -#define INITIAL_SPSR_EL3 (PSTATE_EL3 | SP_ELx) -#define INITIAL_SPSR_EL2 (PSTATE_EL2 | SP_ELx) -#define INITIAL_SPSR_EL1 (PSTATE_EL1 | SP_ELx) - /** * This function will initialize thread stack * @@ -29,10 +25,14 @@ */ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, rt_uint8_t *stack_addr, void *texit) { - rt_ubase_t *stk; - rt_ubase_t current_el; - - stk = (rt_ubase_t*)stack_addr; + static const rt_ubase_t initial_spsr[] = + { + [1] = PSTATE_EL1 | SP_ELx, + [2] = PSTATE_EL2 | SP_ELx, + [3] = PSTATE_EL3 | SP_ELx + }; + /* The AAPCS64 requires 128-bit (16 byte) stack alignment */ + rt_ubase_t *stk = (rt_ubase_t*)RT_ALIGN_DOWN((rt_ubase_t)stack_addr, 16); *(--stk) = (rt_ubase_t) 0; /* Q0 */ *(--stk) = (rt_ubase_t) 0; /* Q0 */ @@ -102,21 +102,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, rt_uint8_t *stack_ad *(--stk) = ( rt_ubase_t ) 0; /* XZR - has no effect, used so there are an even number of registers. */ *(--stk) = ( rt_ubase_t ) texit; /* X30 - procedure call link register. */ - current_el = rt_hw_get_current_el(); - - if(current_el == 3) - { - *(--stk) = INITIAL_SPSR_EL3; - } - else if(current_el == 2) - { - *(--stk) = INITIAL_SPSR_EL2; - } - else - { - *(--stk) = INITIAL_SPSR_EL1; - } - + *(--stk) = initial_spsr[rt_hw_get_current_el()]; *(--stk) = ( rt_ubase_t ) tentry; /* Exception return address. */ /* return task's current stack address */ diff --git a/libcpu/aarch64/cortex-a/entry_point.S b/libcpu/aarch64/cortex-a/entry_point.S index 2228677f1cfa15038308c906dc039e93f78f97cd..5bf2b8a3a64a454bdfeb2f390ce84d5927f528cf 100644 --- a/libcpu/aarch64/cortex-a/entry_point.S +++ b/libcpu/aarch64/cortex-a/entry_point.S @@ -80,16 +80,19 @@ cpu_check_el: orr x2, x2, #(1 << 10) /* The next lower level is AArch64 */ msr scr_el3, x2 - /* Change execution level to EL2 */ - mov x2, #0x3c9 - msr spsr_el3, x2 /* 0b1111001001 */ - adr x2, cpu_not_in_el3 + mov x2, #9 /* Next level is 0b1001->EL2h */ + orr x2, x2, #(1 << 6) /* Mask FIQ */ + orr x2, x2, #(1 << 7) /* Mask IRQ */ + orr x2, x2, #(1 << 8) /* Mask SError */ + orr x2, x2, #(1 << 9) /* Mask Debug Exception */ + msr spsr_el3, x2 + adr x2, cpu_in_el2 msr elr_el3, x2 - eret /* Exception Return: from EL3, continue from cpu_not_in_el3 */ + eret cpu_not_in_el3: /* Running at EL2 or EL1 */ cmp x0, #4 /* EL1 = 0100 */ - beq cpu_in_el1 /* Halt this core if running in El1 */ + beq cpu_in_el1 cpu_in_el2: /* Enable CNTP for EL1 */ @@ -102,9 +105,12 @@ cpu_in_el2: orr x0, x0, #(1 << 1) /* SWIO hardwired on Pi3 */ msr hcr_el2, x0 - /* Change execution level to EL1 */ - mov x2, #0x3c4 - msr spsr_el2, x2 /* 0b1111000100 */ + mov x2, #5 /* Next level is 0b0101->EL1h */ + orr x2, x2, #(1 << 6) /* Mask FIQ */ + orr x2, x2, #(1 << 7) /* Mask IRQ */ + orr x2, x2, #(1 << 8) /* Mask SError */ + orr x2, x2, #(1 << 9) /* Mask Debug Exception */ + msr spsr_el2, x2 adr x2, cpu_in_el1 msr elr_el2, x2 eret