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