]> git.sur5r.net Git - freertos/commitdiff
Add xTaskGetApplicationTaskTagFromISR(), which is an interrupt safe version of xTaskG...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 8 Oct 2018 15:10:18 +0000 (15:10 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 8 Oct 2018 15:10:18 +0000 (15:10 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2588 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo
FreeRTOS/Demo/WIN32-MingW/code_coverage_additions.c
FreeRTOS/Source/include/mpu_prototypes.h
FreeRTOS/Source/include/mpu_wrappers.h
FreeRTOS/Source/include/task.h
FreeRTOS/Source/portable/Common/mpu_wrappers.c
FreeRTOS/Source/tasks.c

index 138d3b80c5931bbe53fbc7bc6c1ff6b3c815347f..11cf75261bbdc5678c1a45f798db6cad9f36322d 100644 (file)
Binary files a/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo and b/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo differ
index 5aafe110b95e392d343fc10b1fa893deb9f7cfee..1c4ec671428110066ec539a1e7bc3856c230af37 100644 (file)
@@ -508,12 +508,22 @@ TaskHandle_t xTask;
                }\r
        }\r
 \r
+       /* Try FromISR version too. */\r
+       if( xTaskGetApplicationTaskTagFromISR( xTask ) != prvDummyTagFunction )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
        /* Now try with a NULL handle, so using this task. */\r
        vTaskSetApplicationTaskTag( NULL, NULL );\r
        if( xTaskGetApplicationTaskTag( NULL ) != NULL )\r
        {\r
                xReturn = pdFAIL;\r
        }\r
+       if( xTaskGetApplicationTaskTagFromISR( NULL ) != NULL )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
 \r
        vTaskSetApplicationTaskTag( NULL, prvDummyTagFunction );\r
        if( xTaskGetApplicationTaskTag( NULL ) != prvDummyTagFunction )\r
@@ -532,6 +542,12 @@ TaskHandle_t xTask;
                }\r
        }\r
 \r
+       /* Try FromISR version too. */\r
+       if( xTaskGetApplicationTaskTagFromISR( NULL ) != prvDummyTagFunction )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
        vTaskSetApplicationTaskTag( NULL, NULL );\r
        if( xTaskGetApplicationTaskTag( NULL ) != NULL )\r
        {\r
index 9b94922314d17d5beb4eceb8d1731fed83eff60c..55ee9a23e128d3c0dbb0e4ca96e696bb202207d7 100644 (file)
@@ -64,6 +64,7 @@ UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );\r
 void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );\r
 TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask );\r
+TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );\r
 void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue );\r
 void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex );\r
 BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );\r
index 96e94ffe40466c35a897455ddf96c8c580c05897..04348c6149bc2a90db5028d7765e42e146fb4d5c 100644 (file)
@@ -70,6 +70,7 @@ only for ports that are using the MPU. */
                #define uxTaskGetStackHighWaterMark2                    MPU_uxTaskGetStackHighWaterMark2\r
                #define vTaskSetApplicationTaskTag                              MPU_vTaskSetApplicationTaskTag\r
                #define xTaskGetApplicationTaskTag                              MPU_xTaskGetApplicationTaskTag\r
+               #define xTaskGetApplicationTaskTagFromISR               MPU_xTaskGetApplicationTaskTagFromISR\r
                #define vTaskSetThreadLocalStoragePointer               MPU_vTaskSetThreadLocalStoragePointer\r
                #define pvTaskGetThreadLocalStoragePointer              MPU_pvTaskGetThreadLocalStoragePointer\r
                #define xTaskCallApplicationTaskHook                    MPU_xTaskCallApplicationTaskHook\r
index a03ff82a6f702bd3e7e1c23c1c50e1ccc263af30..446f6fa88eeb7c39694fa03524bf06b0e887ccc6 100644 (file)
@@ -1477,9 +1477,20 @@ constant. */
                 * task.h\r
                 * <pre>void xTaskGetApplicationTaskTag( TaskHandle_t xTask );</pre>\r
                 *\r
-                * Returns the pxHookFunction value assigned to the task xTask.\r
+                * Returns the pxHookFunction value assigned to the task xTask.  Do not\r
+                * call from an interrupt service routine - call\r
+                * xTaskGetApplicationTaskTagFromISR() instead.\r
                 */\r
                TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+               /**\r
+                * task.h\r
+                * <pre>void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );</pre>\r
+                *\r
+                * Returns the pxHookFunction value assigned to the task xTask.  Can\r
+                * be called from an interrupt service routine.\r
+                */\r
+               TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
        #endif /* configUSE_APPLICATION_TASK_TAG ==1 */\r
 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */\r
 \r
index cb86b793ee193ba48d0877422df80f74bc670d46..ca490d6bfa20d94c2b8e945a130c88eee60ae430 100644 (file)
@@ -357,6 +357,19 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege();
 #endif\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+       TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask )\r
+       {\r
+       TaskHookFunction_t xReturn;\r
+       BaseType_t xRunningPrivileged = xPortRaisePrivilege();\r
+\r
+               xReturn = xTaskGetApplicationTaskTagFromISR( xTask );\r
+               vPortResetPrivilege( xRunningPrivileged );\r
+               return xReturn;\r
+       }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
        void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue )\r
        {\r
index e494bbcefab10ed5ef3a63dbc97c5cd8ca9d2ed5..75fa4631c67da11771850eac54405294d8eb8490 100644 (file)
@@ -2845,24 +2845,17 @@ BaseType_t xSwitchRequired = pdFALSE;
 \r
        TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask )\r
        {\r
-       TCB_t *xTCB;\r
+       TCB_t *pxTCB;\r
        TaskHookFunction_t xReturn;\r
 \r
-               /* If xTask is NULL then we are setting our own task hook. */\r
-               if( xTask == NULL )\r
-               {\r
-                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
-               }\r
-               else\r
-               {\r
-                       xTCB = xTask;\r
-               }\r
+               /* If xTask is NULL then set the calling task's hook. */\r
+               pxTCB = prvGetTCBFromHandle( xTask );\r
 \r
                /* Save the hook function in the TCB.  A critical section is required as\r
                the value can be accessed from an interrupt. */\r
                taskENTER_CRITICAL();\r
                {\r
-                       xReturn = xTCB->pxTaskTag;\r
+                       xReturn = pxTCB->pxTaskTag;\r
                }\r
                taskEXIT_CRITICAL();\r
 \r
@@ -2872,6 +2865,31 @@ BaseType_t xSwitchRequired = pdFALSE;
 #endif /* configUSE_APPLICATION_TASK_TAG */\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+\r
+       TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask )\r
+       {\r
+       TCB_t *pxTCB;\r
+       TaskHookFunction_t xReturn;\r
+       UBaseType_t uxSavedInterruptStatus;\r
+\r
+               /* If xTask is NULL then set the calling task's hook. */\r
+               pxTCB = prvGetTCBFromHandle( xTask );\r
+\r
+               /* Save the hook function in the TCB.  A critical section is required as\r
+               the value can be accessed from an interrupt. */\r
+               uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       xReturn = pxTCB->pxTaskTag;\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_APPLICATION_TASK_TAG */\r
+/*-----------------------------------------------------------*/\r
+\r
 #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
 \r
        BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )\r