|
| 1 | +/* |
| 2 | +********************************************************************************************************* |
| 3 | +* uC/OS-III |
| 4 | +* The Real-Time Kernel |
| 5 | +* |
| 6 | +* Copyright 2009-2020 Silicon Laboratories Inc. www.silabs.com |
| 7 | +* |
| 8 | +* SPDX-License-Identifier: APACHE-2.0 |
| 9 | +* |
| 10 | +* This software is subject to an open source license and is distributed by |
| 11 | +* Silicon Laboratories Inc. pursuant to the terms of the Apache License, |
| 12 | +* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. |
| 13 | +* |
| 14 | +********************************************************************************************************* |
| 15 | +*/ |
| 16 | + |
| 17 | +/* |
| 18 | +********************************************************************************************************* |
| 19 | +* |
| 20 | +* APPLICATION HOOKS |
| 21 | +* |
| 22 | +* Filename : os_app_hooks.c |
| 23 | +* Version : V3.08.00 |
| 24 | +********************************************************************************************************* |
| 25 | +*/ |
| 26 | + |
| 27 | +#define MICRIUM_SOURCE |
| 28 | +#include <os.h> |
| 29 | +#include "os_app_hooks.h" |
| 30 | + |
| 31 | + |
| 32 | +/* |
| 33 | +************************************************************************************************************************ |
| 34 | +* SET ALL APPLICATION HOOKS |
| 35 | +* |
| 36 | +* Description: Set ALL application hooks. |
| 37 | +* |
| 38 | +* Arguments : none. |
| 39 | +* |
| 40 | +* Note(s) : none |
| 41 | +************************************************************************************************************************ |
| 42 | +*/ |
| 43 | + |
| 44 | +void App_OS_SetAllHooks (void) |
| 45 | +{ |
| 46 | +#if OS_CFG_APP_HOOKS_EN > 0u |
| 47 | + CPU_SR_ALLOC(); |
| 48 | + |
| 49 | + |
| 50 | + CPU_CRITICAL_ENTER(); |
| 51 | + OS_AppIdleTaskHookPtr = App_OS_IdleTaskHook; |
| 52 | + |
| 53 | +#if (OS_CFG_TASK_STK_REDZONE_EN > 0u) |
| 54 | + OS_AppRedzoneHitHookPtr = App_OS_RedzoneHitHook; |
| 55 | +#endif |
| 56 | + |
| 57 | + OS_AppStatTaskHookPtr = App_OS_StatTaskHook; |
| 58 | + |
| 59 | + OS_AppTaskCreateHookPtr = App_OS_TaskCreateHook; |
| 60 | + |
| 61 | + OS_AppTaskDelHookPtr = App_OS_TaskDelHook; |
| 62 | + |
| 63 | + OS_AppTaskReturnHookPtr = App_OS_TaskReturnHook; |
| 64 | + |
| 65 | + OS_AppTaskSwHookPtr = App_OS_TaskSwHook; |
| 66 | + |
| 67 | + OS_AppTimeTickHookPtr = App_OS_TimeTickHook; |
| 68 | + CPU_CRITICAL_EXIT(); |
| 69 | +#endif |
| 70 | +} |
| 71 | + |
| 72 | + |
| 73 | +/* |
| 74 | +************************************************************************************************************************ |
| 75 | +* CLEAR ALL APPLICATION HOOKS |
| 76 | +* |
| 77 | +* Description: Clear ALL application hooks. |
| 78 | +* |
| 79 | +* Arguments : none. |
| 80 | +* |
| 81 | +* Note(s) : none |
| 82 | +************************************************************************************************************************ |
| 83 | +*/ |
| 84 | + |
| 85 | +void App_OS_ClrAllHooks (void) |
| 86 | +{ |
| 87 | +#if OS_CFG_APP_HOOKS_EN > 0u |
| 88 | + CPU_SR_ALLOC(); |
| 89 | + |
| 90 | + |
| 91 | + CPU_CRITICAL_ENTER(); |
| 92 | + OS_AppIdleTaskHookPtr = (OS_APP_HOOK_VOID)0; |
| 93 | + |
| 94 | +#if (OS_CFG_TASK_STK_REDZONE_EN > 0u) |
| 95 | + OS_AppRedzoneHitHookPtr = (OS_APP_HOOK_TCB)0; |
| 96 | +#endif |
| 97 | + |
| 98 | + OS_AppStatTaskHookPtr = (OS_APP_HOOK_VOID)0; |
| 99 | + |
| 100 | + OS_AppTaskCreateHookPtr = (OS_APP_HOOK_TCB)0; |
| 101 | + |
| 102 | + OS_AppTaskDelHookPtr = (OS_APP_HOOK_TCB)0; |
| 103 | + |
| 104 | + OS_AppTaskReturnHookPtr = (OS_APP_HOOK_TCB)0; |
| 105 | + |
| 106 | + OS_AppTaskSwHookPtr = (OS_APP_HOOK_VOID)0; |
| 107 | + |
| 108 | + OS_AppTimeTickHookPtr = (OS_APP_HOOK_VOID)0; |
| 109 | + CPU_CRITICAL_EXIT(); |
| 110 | +#endif |
| 111 | +} |
| 112 | + |
| 113 | +/* |
| 114 | +************************************************************************************************************************ |
| 115 | +* APPLICATION IDLE TASK HOOK |
| 116 | +* |
| 117 | +* Description: This function is called by the idle task. This hook has been added to allow you to do such things as |
| 118 | +* STOP the CPU to conserve power. |
| 119 | +* |
| 120 | +* Arguments : none |
| 121 | +* |
| 122 | +* Note(s) : none |
| 123 | +************************************************************************************************************************ |
| 124 | +*/ |
| 125 | + |
| 126 | +void App_OS_IdleTaskHook (void) |
| 127 | +{ |
| 128 | + |
| 129 | +} |
| 130 | + |
| 131 | +/* |
| 132 | +************************************************************************************************************************ |
| 133 | +* APPLICATION REDZONE HIT HOOK |
| 134 | +* |
| 135 | +* Description: This function is called when a task's stack overflowed. |
| 136 | +* |
| 137 | +* Arguments : p_tcb is a pointer to the task control block of the offending task. NULL if ISR. |
| 138 | +* |
| 139 | +* Note(s) : None. |
| 140 | +************************************************************************************************************************ |
| 141 | +*/ |
| 142 | +#if (OS_CFG_TASK_STK_REDZONE_EN > 0u) |
| 143 | +void App_OS_RedzoneHitHook (OS_TCB *p_tcb) |
| 144 | +{ |
| 145 | + (void)&p_tcb; |
| 146 | + CPU_SW_EXCEPTION(;); |
| 147 | +} |
| 148 | +#endif |
| 149 | + |
| 150 | + |
| 151 | +/* |
| 152 | +************************************************************************************************************************ |
| 153 | +* APPLICATION STATISTIC TASK HOOK |
| 154 | +* |
| 155 | +* Description: This function is called every second by uC/OS-III's statistics task. This allows your application to add |
| 156 | +* functionality to the statistics task. |
| 157 | +* |
| 158 | +* Arguments : none |
| 159 | +* |
| 160 | +* Note(s) : none |
| 161 | +************************************************************************************************************************ |
| 162 | +*/ |
| 163 | + |
| 164 | +void App_OS_StatTaskHook (void) |
| 165 | +{ |
| 166 | + |
| 167 | +} |
| 168 | + |
| 169 | + |
| 170 | +/* |
| 171 | +************************************************************************************************************************ |
| 172 | +* APPLICATION TASK CREATION HOOK |
| 173 | +* |
| 174 | +* Description: This function is called when a task is created. |
| 175 | +* |
| 176 | +* Arguments : p_tcb is a pointer to the task control block of the task being created. |
| 177 | +* |
| 178 | +* Note(s) : none |
| 179 | +************************************************************************************************************************ |
| 180 | +*/ |
| 181 | + |
| 182 | +void App_OS_TaskCreateHook (OS_TCB *p_tcb) |
| 183 | +{ |
| 184 | + (void)p_tcb; |
| 185 | +} |
| 186 | + |
| 187 | + |
| 188 | +/* |
| 189 | +************************************************************************************************************************ |
| 190 | +* APPLICATION TASK DELETION HOOK |
| 191 | +* |
| 192 | +* Description: This function is called when a task is deleted. |
| 193 | +* |
| 194 | +* Arguments : p_tcb is a pointer to the task control block of the task being deleted. |
| 195 | +* |
| 196 | +* Note(s) : none |
| 197 | +************************************************************************************************************************ |
| 198 | +*/ |
| 199 | + |
| 200 | +void App_OS_TaskDelHook (OS_TCB *p_tcb) |
| 201 | +{ |
| 202 | + (void)p_tcb; |
| 203 | +} |
| 204 | + |
| 205 | + |
| 206 | +/* |
| 207 | +************************************************************************************************************************ |
| 208 | +* APPLICATION TASK RETURN HOOK |
| 209 | +* |
| 210 | +* Description: This function is called if a task accidentally returns. In other words, a task should either be an |
| 211 | +* infinite loop or delete itself when done. |
| 212 | +* |
| 213 | +* Arguments : p_tcb is a pointer to the OS_TCB of the task that is returning. |
| 214 | +* |
| 215 | +* Note(s) : none |
| 216 | +************************************************************************************************************************ |
| 217 | +*/ |
| 218 | + |
| 219 | +void App_OS_TaskReturnHook (OS_TCB *p_tcb) |
| 220 | +{ |
| 221 | + (void)p_tcb; |
| 222 | +} |
| 223 | + |
| 224 | + |
| 225 | +/* |
| 226 | +************************************************************************************************************************ |
| 227 | +* APPLICATION TASK SWITCH HOOK |
| 228 | +* |
| 229 | +* Description: This function is called when a task switch is performed. This allows you to perform other operations |
| 230 | +* during a context switch. |
| 231 | +* |
| 232 | +* Arguments : none |
| 233 | +* |
| 234 | +* Note(s) : 1) Interrupts are disabled during this call. |
| 235 | +* 2) It is assumed that the global pointer 'OSTCBHighRdyPtr' points to the TCB of the task that will be |
| 236 | +* 'switched in' (i.e. the highest priority task) and, 'OSTCBCurPtr' points to the task being switched out |
| 237 | +* (i.e. the preempted task). |
| 238 | +************************************************************************************************************************ |
| 239 | +*/ |
| 240 | + |
| 241 | +void App_OS_TaskSwHook (void) |
| 242 | +{ |
| 243 | + |
| 244 | +} |
| 245 | + |
| 246 | + |
| 247 | +/* |
| 248 | +************************************************************************************************************************ |
| 249 | +* APPLICATION TICK HOOK |
| 250 | +* |
| 251 | +* Description: This function is called every tick. |
| 252 | +* |
| 253 | +* Arguments : none |
| 254 | +* |
| 255 | +* Note(s) : 1) This function is assumed to be called from the Tick ISR. |
| 256 | +************************************************************************************************************************ |
| 257 | +*/ |
| 258 | + |
| 259 | +void App_OS_TimeTickHook (void) |
| 260 | +{ |
| 261 | + |
| 262 | +} |
0 commit comments