Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * FreeRTOS Kernel <DEVELOPMENT BRANCH> |
Joseph Julicher | 5cdb1bc | 2023-10-03 10:43:45 -0700 | [diff] [blame] | 3 | * license and copyright intentionally withheld to promote copying into user code. |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include "FreeRTOS.h" |
| 7 | #include "task.h" |
| 8 | |
| 9 | BaseType_t xPortStartScheduler( void ) |
| 10 | { |
| 11 | return pdTRUE; |
| 12 | } |
| 13 | |
| 14 | void vPortEndScheduler( void ) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, |
| 19 | TaskFunction_t pxCode, |
| 20 | void * pvParameters ) |
| 21 | { |
Aniruddha Kanhere | 2fcb0f4 | 2024-02-20 08:49:41 -0800 | [diff] [blame] | 22 | ( void ) pxTopOfStack; |
| 23 | ( void ) pvParameters; |
| 24 | ( void ) * pxCode; |
| 25 | |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 26 | return NULL; |
| 27 | } |
| 28 | |
| 29 | void vPortYield( void ) |
| 30 | { |
| 31 | /* Save the current Context */ |
chinglee-iot | c0ce725 | 2023-12-04 10:49:41 +0800 | [diff] [blame] | 32 | |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 33 | /* Switch to the highest priority task that is ready to run. */ |
chinglee-iot | c0ce725 | 2023-12-04 10:49:41 +0800 | [diff] [blame] | 34 | #if ( configNUMBER_OF_CORES == 1 ) |
| 35 | { |
| 36 | vTaskSwitchContext(); |
| 37 | } |
| 38 | #else |
| 39 | { |
| 40 | vTaskSwitchContext( portGET_CORE_ID() ); |
| 41 | } |
| 42 | #endif |
| 43 | |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 44 | /* Start executing the task we have just switched to. */ |
| 45 | } |
| 46 | |
| 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 | |
chinglee-iot | c0ce725 | 2023-12-04 10:49:41 +0800 | [diff] [blame] | 52 | #if ( configNUMBER_OF_CORES == 1 ) |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 53 | { |
chinglee-iot | c0ce725 | 2023-12-04 10:49:41 +0800 | [diff] [blame] | 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 | } |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 60 | } |
chinglee-iot | c0ce725 | 2023-12-04 10:49:41 +0800 | [diff] [blame] | 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 ) */ |
Joseph Julicher | 5a9d7c8 | 2023-09-29 19:11:55 -0700 | [diff] [blame] | 80 | |
| 81 | /* start executing the new task */ |
| 82 | } |