From 1347fb0cdf7f9eaa383116b066e2484b699df97f Mon Sep 17 00:00:00 2001 From: sherecho <2443397610@qq.com> Date: Sat, 12 Oct 2024 17:27:28 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=88=A0=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E6=B3=A8=E9=87=8A=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=92=8C=E4=B8=8D=E4=BD=BF=E7=94=A8SMP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=8D=E5=85=BC=E5=AE=B9=E7=9A=84=E9=83=A8=E5=88=86=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm/pico-RP2040/gcc/picoPortMacro.h | 30 ++++-------------------- arch/arm/pico-RP2040/gcc/port_c.c | 2 -- arch/arm/pico-RP2040/gcc/port_s.S | 2 +- core/include/tos_global.h | 5 +++- core/include/tos_task.h | 6 ++--- core/tos_global.c | 8 ++++--- core/tos_sys.c | 5 +++- 7 files changed, 22 insertions(+), 36 deletions(-) diff --git a/arch/arm/pico-RP2040/gcc/picoPortMacro.h b/arch/arm/pico-RP2040/gcc/picoPortMacro.h index 720c653..9448dc8 100644 --- a/arch/arm/pico-RP2040/gcc/picoPortMacro.h +++ b/arch/arm/pico-RP2040/gcc/picoPortMacro.h @@ -20,29 +20,14 @@ /* Define to trap errors during development. */ #define configASSERT(x) assert(x) #define INVALID_PRIMARY_CORE_NUM 0xffu - #define portMIN_INTERRUPT_PRIORITY ( 255UL ) -// + #define portMIN_INTERRUPT_PRIORITY ( 255UL ) + typedef uint32_t BaseType_t; + #if(USE_SMP==1u) /* Multi-core */ - #define portMAX_CORE_COUNT 2 -/* Requires for SMP */ - #define portCRITICAL_NESTING_IN_TCB 1 - +#define portMAX_CORE_COUNT 2 //获取core ID #define port_GET_CORE_ID() get_core_num() -//这些宏定义在实现实时操作系统(RTOS)时,用于控制中断和任务切换的操作 -#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) ) -#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) -#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT -//决定是否需要任务切换 -#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) - -typedef uint32_t BaseType_t; #define portRTOS_SPINLOCK_COUNT 2 -#define portRESTORE_INTERRUPTS(ulState) __asm volatile ("msr PRIMASK,%0"::"r" (ulState) : ) - - /* Note this is a single method with uxAcquire parameter since we have - * static vars, the method is always called with a compile time constant for - * uxAcquire, and the compiler should dothe right thing! */ extern uint8_t ucOwnedByCore[ portMAX_CORE_COUNT ]; extern uint8_t ucRecursionCountByLock[ portRTOS_SPINLOCK_COUNT ]; static void vPortRecursiveLock(uint32_t ulLockNum, spin_lock_t *pxSpinLock, BaseType_t uxAcquire) { @@ -85,12 +70,7 @@ extern uint8_t ucRecursionCountByLock[ portRTOS_SPINLOCK_COUNT ]; #define portRELEASE_ISR_LOCK() vPortRecursiveLock(0, spin_lock_instance(configSMP_SPINLOCK_0), (BaseType_t)0) #define portGET_TASK_LOCK() vPortRecursiveLock(1, spin_lock_instance(configSMP_SPINLOCK_1), (BaseType_t)1) #define portRELEASE_TASK_LOCK() vPortRecursiveLock(1, spin_lock_instance(configSMP_SPINLOCK_1), (BaseType_t) 0) - -#define portCHECK_IF_IN_ISR() ({ \ - uint32_t ulIPSR; \ - __asm volatile ("mrs %0, IPSR" : "=r" (ulIPSR)::); \ - ((uint8_t)ulIPSR)>0;}) - +#endif #endif diff --git a/arch/arm/pico-RP2040/gcc/port_c.c b/arch/arm/pico-RP2040/gcc/port_c.c index 156427e..4b2c30d 100644 --- a/arch/arm/pico-RP2040/gcc/port_c.c +++ b/arch/arm/pico-RP2040/gcc/port_c.c @@ -156,8 +156,6 @@ __PORT__ __STATIC__ void prvFIFOInterruptHandler(void) /* And explicitly clear any other IRQ flags */ multicore_fifo_clear_irq(); #if (USE_SMP == 1u) - //portYIELD_FROM_ISR(1); - //port_context_switch(); knl_sched(); #endif /* portRUNNING_ON_BOTH_CORES */ } diff --git a/arch/arm/pico-RP2040/gcc/port_s.S b/arch/arm/pico-RP2040/gcc/port_s.S index 5b6d330..3203222 100644 --- a/arch/arm/pico-RP2040/gcc/port_s.S +++ b/arch/arm/pico-RP2040/gcc/port_s.S @@ -1,4 +1,4 @@ - .equ SMP, 1 + @.equ SMP, 1 .global port_int_disable .global port_int_enable diff --git a/core/include/tos_global.h b/core/include/tos_global.h index 84e831a..42f1d03 100644 --- a/core/include/tos_global.h +++ b/core/include/tos_global.h @@ -36,9 +36,12 @@ extern readyqueue_t k_rdyq; extern k_tick_t k_tick_count; /* current task */ -extern k_task_t *k_curr_task; extern k_task_t *k_curr_tasks[configNUM_CORES]; +#if(USE_SMP==1u) #define k_curr_task TaskGetCurrentKernelTaskHandle() +#else +extern k_task_t *k_curr_task; +#endif k_task_t * TaskGetCurrentKernelTaskHandle(void); /* next task to run */ extern k_task_t *k_next_task; diff --git a/core/include/tos_task.h b/core/include/tos_task.h index 1f2762a..f214827 100644 --- a/core/include/tos_task.h +++ b/core/include/tos_task.h @@ -132,10 +132,10 @@ struct k_task_st { by tos_event_pend to the caller */ #endif #if (USE_SMP == 1u ) - BaseType_t RunningOnCore; - BaseType_t IsIDLE; + BaseType_t RunningOnCore; /**< when the task is running on the core this is the coreID if the task is not running this would be set as -1*/ + BaseType_t IsIDLE; /** 0u pm_power_manager(); #endif + #if(USE_SMP==1u) if(k_rdyq.highest_prio