blob: 7cac1c9919b4fcca5914b043622ec0612208e826 [file] [log] [blame]
Joseph Julicher5a9d7c82023-09-29 19:11:55 -07001/*
2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
Joseph Julicher5cdb1bc2023-10-03 10:43:45 -07003 * license and copyright intentionally withheld to promote copying into user code.
Joseph Julicher5a9d7c82023-09-29 19:11:55 -07004 */
5
6#include "FreeRTOS.h"
7#include "task.h"
8
9BaseType_t xPortStartScheduler( void )
10{
11 return pdTRUE;
12}
13
14void vPortEndScheduler( void )
15{
16}
17
18StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
19 TaskFunction_t pxCode,
20 void * pvParameters )
21{
Aniruddha Kanhere2fcb0f42024-02-20 08:49:41 -080022 ( void ) pxTopOfStack;
23 ( void ) pvParameters;
24 ( void ) * pxCode;
25
Joseph Julicher5a9d7c82023-09-29 19:11:55 -070026 return NULL;
27}
28
29void vPortYield( void )
30{
31 /* Save the current Context */
chinglee-iotc0ce7252023-12-04 10:49:41 +080032
Joseph Julicher5a9d7c82023-09-29 19:11:55 -070033 /* Switch to the highest priority task that is ready to run. */
chinglee-iotc0ce7252023-12-04 10:49:41 +080034 #if ( configNUMBER_OF_CORES == 1 )
35 {
36 vTaskSwitchContext();
37 }
38 #else
39 {
40 vTaskSwitchContext( portGET_CORE_ID() );
41 }
42 #endif
43
Joseph Julicher5a9d7c82023-09-29 19:11:55 -070044 /* Start executing the task we have just switched to. */
45}
46
47static 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
chinglee-iotc0ce7252023-12-04 10:49:41 +080052 #if ( configNUMBER_OF_CORES == 1 )
Joseph Julicher5a9d7c82023-09-29 19:11:55 -070053 {
chinglee-iotc0ce7252023-12-04 10:49:41 +080054 /* Maintain the tick count. */
55 if( xTaskIncrementTick() != pdFALSE )
56 {
57 /* Switch to the highest priority task that is ready to run. */
58 vTaskSwitchContext();
59 }
Joseph Julicher5a9d7c82023-09-29 19:11:55 -070060 }
chinglee-iotc0ce7252023-12-04 10:49:41 +080061 #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 ) */
Joseph Julicher5a9d7c82023-09-29 19:11:55 -070080
81 /* start executing the new task */
82}