From ffe4c2c0ca0182e9565be9f4c9a424573f4cd540 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Tue, 3 Jul 2012 09:38:09 +0000 Subject: [PATCH] Add the macro xSemaphoreTakeFromISR(). Add #error strings if configMAX_SYSCALL_INTERRUPT_PRIORITY is set to 0. Corrected the prototype of vApplicationStackOverflowHook(). Changed the dimensioning of the buffer declared in prvListTaskWithinSingleList() to make use of the configMAX_TASK_NAME_LEN setting. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1752 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/include/semphr.h | 34 +++++++++++++++++++++++++ Source/portable/GCC/ARM_CM3/port.c | 4 +++ Source/portable/GCC/ARM_CM3_MPU/port.c | 4 +++ Source/portable/GCC/ARM_CM4F/port.c | 4 +++ Source/portable/IAR/ARM_CM3/port.c | 4 +++ Source/portable/IAR/ARM_CM4F/port.c | 4 +++ Source/portable/RVDS/ARM_CM3/port.c | 4 +++ Source/portable/RVDS/ARM_CM4F/port.c | 4 +++ Source/portable/Tasking/ARM_CM4F/port.c | 4 +++ Source/tasks.c | 4 +-- 10 files changed, 68 insertions(+), 2 deletions(-) diff --git a/Source/include/semphr.h b/Source/include/semphr.h index ca335d535..b523c723e 100644 --- a/Source/include/semphr.h +++ b/Source/include/semphr.h @@ -554,6 +554,40 @@ typedef xQueueHandle xSemaphoreHandle; */ #define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +/** + * semphr. h + *
+ xSemaphoreTakeFromISR( 
+                          xSemaphoreHandle xSemaphore, 
+                          signed portBASE_TYPE *pxHigherPriorityTaskWoken
+                      )
+ * + * Macro to take a semaphore from an ISR. The semaphore must have + * previously been created with a call to vSemaphoreCreateBinary() or + * xSemaphoreCreateCounting(). + * + * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) + * must not be used with this macro. + * + * This macro can be used from an ISR, however taking a semaphore from an ISR + * is not a common operation. It is likely to only be useful when taking a + * counting semaphore when an interrupt is obtaining an object from a resource + * pool (when the semaphore count indicates the number of resources available). + * + * @param xSemaphore A handle to the semaphore being taken. This is the + * handle returned when the semaphore was created. + * + * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set + * *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task + * to unblock, and the unblocked task has a priority higher than the currently + * running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then + * a context switch should be requested before the interrupt is exited. + * + * @return pdTRUE if the semaphore was successfully taken, otherwise + * pdFALSE + */ +#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) + /** * semphr. h *
xSemaphoreHandle xSemaphoreCreateMutex( void )
diff --git a/Source/portable/GCC/ARM_CM3/port.c b/Source/portable/GCC/ARM_CM3/port.c index 4d6ef60b1..344b381eb 100644 --- a/Source/portable/GCC/ARM_CM3/port.c +++ b/Source/portable/GCC/ARM_CM3/port.c @@ -79,6 +79,10 @@ FreeRTOS.org versions prior to V4.4.0 did not include this definition. */ #define configKERNEL_INTERRUPT_PRIORITY 255 #endif +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long *) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long *) 0xe000e014 ) diff --git a/Source/portable/GCC/ARM_CM3_MPU/port.c b/Source/portable/GCC/ARM_CM3_MPU/port.c index 01dcf8bfc..5d8993d36 100644 --- a/Source/portable/GCC/ARM_CM3_MPU/port.c +++ b/Source/portable/GCC/ARM_CM3_MPU/port.c @@ -78,6 +78,10 @@ task.h is included from an application file. */ #include "task.h" #include "queue.h" +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* Constants required to access and manipulate the NVIC. */ diff --git a/Source/portable/GCC/ARM_CM4F/port.c b/Source/portable/GCC/ARM_CM4F/port.c index d91fde9e3..b9fd31c30 100644 --- a/Source/portable/GCC/ARM_CM4F/port.c +++ b/Source/portable/GCC/ARM_CM4F/port.c @@ -76,6 +76,10 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long * ) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long * ) 0xe000e014 ) diff --git a/Source/portable/IAR/ARM_CM3/port.c b/Source/portable/IAR/ARM_CM3/port.c index 32d03fa64..7cbb22a27 100644 --- a/Source/portable/IAR/ARM_CM3/port.c +++ b/Source/portable/IAR/ARM_CM3/port.c @@ -72,6 +72,10 @@ #include "FreeRTOS.h" #include "task.h" +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long *) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long *) 0xe000e014 ) diff --git a/Source/portable/IAR/ARM_CM4F/port.c b/Source/portable/IAR/ARM_CM4F/port.c index 6b4b054c4..28d606ab8 100644 --- a/Source/portable/IAR/ARM_CM4F/port.c +++ b/Source/portable/IAR/ARM_CM4F/port.c @@ -76,6 +76,10 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long * ) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long * ) 0xe000e014 ) diff --git a/Source/portable/RVDS/ARM_CM3/port.c b/Source/portable/RVDS/ARM_CM3/port.c index e76d795db..0c0418c36 100644 --- a/Source/portable/RVDS/ARM_CM3/port.c +++ b/Source/portable/RVDS/ARM_CM3/port.c @@ -76,6 +76,10 @@ #define configKERNEL_INTERRUPT_PRIORITY 255 #endif +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long *) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long *) 0xe000e014 ) diff --git a/Source/portable/RVDS/ARM_CM4F/port.c b/Source/portable/RVDS/ARM_CM4F/port.c index fed77e539..e11d8f5bf 100644 --- a/Source/portable/RVDS/ARM_CM4F/port.c +++ b/Source/portable/RVDS/ARM_CM4F/port.c @@ -76,6 +76,10 @@ #error This port can only be used when the project options are configured to enable hardware floating point support. #endif +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long *) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long *) 0xe000e014 ) diff --git a/Source/portable/Tasking/ARM_CM4F/port.c b/Source/portable/Tasking/ARM_CM4F/port.c index 9b3d119a6..aa3ed04f7 100644 --- a/Source/portable/Tasking/ARM_CM4F/port.c +++ b/Source/portable/Tasking/ARM_CM4F/port.c @@ -72,6 +72,10 @@ #include "FreeRTOS.h" #include "task.h" +#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0 + #error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html +#endif + /* Constants required to manipulate the NVIC. */ #define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long * ) 0xe000e010 ) #define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long * ) 0xe000e014 ) diff --git a/Source/tasks.c b/Source/tasks.c index e319c2f8d..85e41a05f 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -296,7 +296,7 @@ portTickType xItemValue; \ #define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) ( pxHandle ) ) /* Callback function prototypes. --------------------------*/ -extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); +extern void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName ); extern void vApplicationTickHook( void ); /* File private functions. --------------------------------*/ @@ -2165,7 +2165,7 @@ tskTCB *pxNewTCB; { volatile tskTCB *pxNextTCB, *pxFirstTCB; unsigned short usStackRemaining; - PRIVILEGED_DATA static char pcStatusString[ 50 ]; + PRIVILEGED_DATA static char pcStatusString[ configMAX_TASK_NAME_LEN + 30 ]; /* Write the details of all the TCB's in pxList into the buffer. */ listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); -- 2.39.5