/* * FreeRTOS Kernel <DEVELOPMENT BRANCH> * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: MIT AND BSD-3-Clause * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * https://www.FreeRTOS.org * https://github.com/FreeRTOS * *//* ... */#ifndefPORTMACRO_H#definePORTMACRO_H/* *INDENT-OFF* */#ifdef__cplusplusextern"C"{#endif/* *INDENT-ON* */#include"pico.h"#include"hardware/sync.h"/*----------------------------------------------------------- * Port specific definitions. * * The settings in this file configure FreeRTOS correctly for the * given hardware and compiler. * * These settings should not be altered. *----------------------------------------------------------- *//* ... *//* Type definitions. */#defineportCHARchar#defineportFLOATfloat#defineportDOUBLEdouble#defineportLONGlong#defineportSHORTshort#defineportSTACK_TYPEuint32_t#defineportBASE_TYPElong7 definestypedefportSTACK_TYPEStackType_t;typedefint32_tBaseType_t;typedefuint32_tUBaseType_t;#if(configTICK_TYPE_WIDTH_IN_BITS==TICK_TYPE_WIDTH_16_BITS)typedefuint16_tTickType_t;#defineportMAX_DELAY(TickType_t)0xffff/* ... */#elif(configTICK_TYPE_WIDTH_IN_BITS==TICK_TYPE_WIDTH_32_BITS)typedefuint32_tTickType_t;#defineportMAX_DELAY(TickType_t)0xffffffffUL/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do * not need to be guarded with a critical section. *//* ... */#defineportTICK_TYPE_IS_ATOMIC1/* ... */#else#errorconfigTICK_TYPE_WIDTH_IN_BITSsettounsupportedticktypewidth.#endif/*-----------------------------------------------------------*//* Architecture specifics. */#defineportSTACK_GROWTH(-1)#defineportTICK_PERIOD_MS((TickType_t)1000/configTICK_RATE_HZ)#defineportBYTE_ALIGNMENT8#defineportDONT_DISCARD__attribute__((used))/* We have to use PICO_DIVIDER_DISABLE_INTERRUPTS as the source of truth rathern than our config, * as our FreeRTOSConfig.h header cannot be included by ASM code - which is what this affects in the SDK *//* ... */#defineportUSE_DIVIDER_SAVE_RESTORE!PICO_DIVIDER_DISABLE_INTERRUPTS5 defines#ifportUSE_DIVIDER_SAVE_RESTORE#defineportSTACK_LIMIT_PADDING4#endif/*-----------------------------------------------------------*//* Scheduler utilities. */externvoidvPortYield(void);#defineportNVIC_INT_CTRL_REG(*((volatileuint32_t*)0xe000ed04))#defineportNVIC_PENDSVSET_BIT(1UL<<28UL)#defineportYIELD()vPortYield()#defineportEND_SWITCHING_ISR(xSwitchRequired)\do\{\if(xSwitchRequired)\{\traceISR_EXIT_TO_SCHEDULER();\portNVIC_INT_CTRL_REG=portNVIC_PENDSVSET_BIT;\...}\else\{\traceISR_EXIT();\...}\...}while(0)...#defineportYIELD_FROM_ISR(x)portEND_SWITCHING_ISR(x)5 defines/*-----------------------------------------------------------*//* Exception handlers */#if(configUSE_DYNAMIC_EXCEPTION_HANDLERS==0)/* We only need to override the SDK's weak functions if we want to replace them at compile time */#definevPortSVCHandlerisr_svcall#definexPortPendSVHandlerisr_pendsv#definexPortSysTickHandlerisr_systick/* ... */#endif/*-----------------------------------------------------------*//* Multi-core */#defineportMAX_CORE_COUNT2/* Check validity of number of cores specified in config */#if(configNUMBER_OF_CORES<1||portMAX_CORE_COUNT<configNUMBER_OF_CORES)#error"Invalid number of cores specified in config!"#endif#if(configTICK_CORE<0||configTICK_CORE>configNUMBER_OF_CORES)#error"Invalid tick core specified in config!"#endif/* FreeRTOS core id is always zero based, so always 0 if we're running on only one core */#ifconfigNUMBER_OF_CORES==portMAX_CORE_COUNT#defineportGET_CORE_ID()get_core_num()#else#defineportGET_CORE_ID()0#endif#defineportCHECK_IF_IN_ISR()\({\uint32_tulIPSR;\__asmvolatile("mrs %0, IPSR":"=r"(ulIPSR)::);\((uint8_t)ulIPSR)>0;...})...voidvYieldCore(intxCoreID);#defineportYIELD_CORE(a)vYieldCore(a)#defineportRESTORE_INTERRUPTS(ulState)__asmvolatile("msr PRIMASK,%0"::"r"(ulState):)/*-----------------------------------------------------------*//* Critical nesting count management. */externUBaseType_tuxCriticalNestings[configNUMBER_OF_CORES];#defineportGET_CRITICAL_NESTING_COUNT()(uxCriticalNestings[portGET_CORE_ID()])#defineportSET_CRITICAL_NESTING_COUNT(x)(uxCriticalNestings[portGET_CORE_ID()]=(x))#defineportINCREMENT_CRITICAL_NESTING_COUNT()(uxCriticalNestings[portGET_CORE_ID()]++)#defineportDECREMENT_CRITICAL_NESTING_COUNT()(uxCriticalNestings[portGET_CORE_ID()]--)/*-----------------------------------------------------------*//* Critical section management. */#defineportSET_INTERRUPT_MASK()\({\uint32_tulState;\__asmvolatile("mrs %0, PRIMASK":"=r"(ulState)::);\__asmvolatile(" cpsid i ":::"memory");\ulState;...})...#defineportCLEAR_INTERRUPT_MASK(ulState)__asmvolatile("msr PRIMASK,%0"::"r"(ulState):)6 definesexternuint32_tulSetInterruptMaskFromISR(void)__attribute__((naked));externvoidvClearInterruptMaskFromISR(uint32_tulMask)__attribute__((naked));#defineportSET_INTERRUPT_MASK_FROM_ISR()ulSetInterruptMaskFromISR()#defineportCLEAR_INTERRUPT_MASK_FROM_ISR(x)vClearInterruptMaskFromISR(x)#defineportDISABLE_INTERRUPTS()__asmvolatile(" cpsid i ":::"memory")externvoidvPortEnableInterrupts();#defineportENABLE_INTERRUPTS()vPortEnableInterrupts()#if(configNUMBER_OF_CORES==1)externvoidvPortEnterCritical(void);externvoidvPortExitCritical(void);#defineportENTER_CRITICAL()vPortEnterCritical()#defineportEXIT_CRITICAL()vPortExitCritical()/* ... */#elseexternvoidvTaskEnterCritical(void);externvoidvTaskExitCritical(void);externUBaseType_tvTaskEnterCriticalFromISR(void);externvoidvTaskExitCriticalFromISR(UBaseType_tuxSavedInterruptStatus);#defineportENTER_CRITICAL()vTaskEnterCritical()#defineportEXIT_CRITICAL()vTaskExitCritical()#defineportENTER_CRITICAL_FROM_ISR()vTaskEnterCriticalFromISR()#defineportEXIT_CRITICAL_FROM_ISR(x)vTaskExitCriticalFromISR(x)/* ... */#endif/* if ( configNUMBER_OF_CORES == 1 ) */#defineportRTOS_SPINLOCK_COUNT2/* 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! *//* ... */staticinlinevoidvPortRecursiveLock(uint32_tulLockNum,spin_lock_t*pxSpinLock,BaseType_tuxAcquire){staticuint8_tucOwnedByCore[portMAX_CORE_COUNT];staticuint8_tucRecursionCountByLock[portRTOS_SPINLOCK_COUNT];configASSERT(ulLockNum<portRTOS_SPINLOCK_COUNT);uint32_tulCoreNum=get_core_num();uint32_tulLockBit=1u<<ulLockNum;configASSERT(ulLockBit<256u);if(uxAcquire){if(__builtin_expect(!*pxSpinLock,0)){if(ucOwnedByCore[ulCoreNum]&ulLockBit){configASSERT(ucRecursionCountByLock[ulLockNum]!=255u);ucRecursionCountByLock[ulLockNum]++;return;}if (ucOwnedByCore[ ulCoreNum ] & ulLockBit) { ... }while(__builtin_expect(!*pxSpinLock,0)){}while (__builtin_expect( !*pxSpinLock, 0 )) { ... }}if (__builtin_expect( !*pxSpinLock, 0 )) { ... }__mem_fence_acquire();configASSERT(ucRecursionCountByLock[ulLockNum]==0);ucRecursionCountByLock[ulLockNum]=1;ucOwnedByCore[ulCoreNum]|=ulLockBit;}if (uxAcquire) { ... }else{configASSERT((ucOwnedByCore[ulCoreNum]&ulLockBit)!=0);configASSERT(ucRecursionCountByLock[ulLockNum]!=0);if(!--ucRecursionCountByLock[ulLockNum]){ucOwnedByCore[ulCoreNum]&=~ulLockBit;__mem_fence_release();*pxSpinLock=1;}if (!--ucRecursionCountByLock[ ulLockNum ]) { ... }}else { ... }}{ ... }#if(configNUMBER_OF_CORES==1)#defineportGET_ISR_LOCK()#defineportRELEASE_ISR_LOCK()#defineportGET_TASK_LOCK()#defineportRELEASE_TASK_LOCK()/* ... */#else#defineportGET_ISR_LOCK()vPortRecursiveLock(0,spin_lock_instance(configSMP_SPINLOCK_0),pdTRUE)#defineportRELEASE_ISR_LOCK()vPortRecursiveLock(0,spin_lock_instance(configSMP_SPINLOCK_0),pdFALSE)#defineportGET_TASK_LOCK()vPortRecursiveLock(1,spin_lock_instance(configSMP_SPINLOCK_1),pdTRUE)#defineportRELEASE_TASK_LOCK()vPortRecursiveLock(1,spin_lock_instance(configSMP_SPINLOCK_1),pdFALSE)/* ... */#endif/*-----------------------------------------------------------*//* Tickless idle/low power functionality. */#ifndefportSUPPRESS_TICKS_AND_SLEEPexternvoidvPortSuppressTicksAndSleep(TickType_txExpectedIdleTime);#defineportSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime)vPortSuppressTicksAndSleep(xExpectedIdleTime)/* ... */#endif/*-----------------------------------------------------------*//* Task function macros as described on the FreeRTOS.org WEB site. */#defineportTASK_FUNCTION_PROTO(vFunction,pvParameters)voidvFunction(void*pvParameters)#defineportTASK_FUNCTION(vFunction,pvParameters)voidvFunction(void*pvParameters)#defineportNOP()__asmvolatile("nop")#defineportMEMORY_BARRIER()__asmvolatile("":::"memory")/* *INDENT-OFF* */#ifdef__cplusplus}extern "C" { ... }#endif/* *INDENT-ON* *//* ... */#endif/* PORTMACRO_H */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.