1 /* 2 * FreeRTOS Kernel V11.0.1 3 * license and copyright intentionally withheld to promote copying into user code. 4 */ 5 6 #include "FreeRTOS.h" 7 #include "task.h" 8 xPortStartScheduler(void)9BaseType_t xPortStartScheduler( void ) 10 { 11 return pdTRUE; 12 } 13 vPortEndScheduler(void)14void vPortEndScheduler( void ) 15 { 16 } 17 pxPortInitialiseStack(StackType_t * pxTopOfStack,TaskFunction_t pxCode,void * pvParameters)18StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, 19 TaskFunction_t pxCode, 20 void * pvParameters ) 21 { 22 return NULL; 23 } 24 vPortYield(void)25void vPortYield( void ) 26 { 27 /* Save the current Context */ 28 29 /* Switch to the highest priority task that is ready to run. */ 30 #if ( configNUMBER_OF_CORES == 1 ) 31 { 32 vTaskSwitchContext(); 33 } 34 #else 35 { 36 vTaskSwitchContext( portGET_CORE_ID() ); 37 } 38 #endif 39 40 /* Start executing the task we have just switched to. */ 41 } 42 prvTickISR(void)43static void prvTickISR( void ) 44 { 45 /* Interrupts must have been enabled for the ISR to fire, so we have to 46 * save the context with interrupts enabled. */ 47 48 #if ( configNUMBER_OF_CORES == 1 ) 49 { 50 /* Maintain the tick count. */ 51 if( xTaskIncrementTick() != pdFALSE ) 52 { 53 /* Switch to the highest priority task that is ready to run. */ 54 vTaskSwitchContext(); 55 } 56 } 57 #else 58 { 59 UBaseType_t ulPreviousMask; 60 61 /* Tasks or ISRs running on other cores may still in critical section in 62 * multiple cores environment. Incrementing tick needs to performed in 63 * critical section. */ 64 ulPreviousMask = taskENTER_CRITICAL_FROM_ISR(); 65 66 /* Maintain the tick count. */ 67 if( xTaskIncrementTick() != pdFALSE ) 68 { 69 /* Switch to the highest priority task that is ready to run. */ 70 vTaskSwitchContext( portGET_CORE_ID() ); 71 } 72 73 taskEXIT_CRITICAL_FROM_ISR( ulPreviousMask ); 74 } 75 #endif /* if ( configNUMBER_OF_CORES == 1 ) */ 76 77 /* start executing the new task */ 78 } 79