From f92473dc33599dcff9f4941942721de7552ae5b9 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Fri, 3 Aug 2012 15:21:21 +0000 Subject: [PATCH] Add vQueueDelete() to the MPU port. Added volatile key word to the queue xRxLock and xTxLock members. Ensure the portPRIVILEGED_BIT bit is set when the timer task is being created by the kernel - as it was for the idle task. Necessary for MPU port. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1760 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../src/ParTest.c | 16 ++++++++++------ .../src/serial.c | 9 +++++++++ Demo/WIN32-MSVC-lwIP/WIN32.suo | Bin 104960 -> 104960 bytes Source/portable/GCC/ARM_CM3_MPU/port.c | 11 +++++++++++ Source/queue.c | 6 +++--- Source/timers.c | 6 +++--- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c index 54fe4976e..dd35507fe 100644 --- a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c +++ b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c @@ -82,7 +82,7 @@ /* The number of LEDs available to the user on the evaluation kit. */ #define partestNUM_LEDS ( 3UL ) -/* Definitions not included in sam3s_ek.h. */ +/* Definitions not included in sam4s_ek.h. */ #define LED2_GPIO ( PIO_PC20_IDX ) /* One of the LEDs is wired in the inverse to the others as it is also used as @@ -121,20 +121,20 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) if( xValue != pdFALSE ) { /* Turn the LED on. */ - portENTER_CRITICAL(); + taskENTER_CRITICAL(); { gpio_set_pin_low( ulLED[ uxLED ]); } - portEXIT_CRITICAL(); + taskEXIT_CRITICAL(); } else { /* Turn the LED off. */ - portENTER_CRITICAL(); + taskENTER_CRITICAL(); { gpio_set_pin_high( ulLED[ uxLED ]); } - portEXIT_CRITICAL(); + taskEXIT_CRITICAL(); } } } @@ -144,7 +144,11 @@ void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { if( uxLED < partestNUM_LEDS ) { - gpio_toggle_pin( ulLED[ uxLED ] ); + taskENTER_CRITICAL(); + { + gpio_toggle_pin( ulLED[ uxLED ] ); + } + taskEXIT_CRITICAL(); } } diff --git a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c index ed407a217..e71158ebe 100644 --- a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c +++ b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c @@ -110,6 +110,7 @@ static xQueueHandle xCharsForTx; /*-----------------------------------------------------------*/ + /* * See the serial.h header file. */ @@ -239,6 +240,14 @@ void vSerialClose( xComPortHandle xPort ) } /*-----------------------------------------------------------*/ +/* + * It should be noted that the com test tasks (which use make use of this file) + * are included to demonstrate queues being used to communicate between tasks + * and interrupts, and to demonstrate a context switch being performed from + * inside an interrupt service routine. The serial driver used here is *not* + * intended to represent an efficient implementation. Real applications should + * make use of the USARTS peripheral DMA channel (PDC). + */ void USART1_Handler( void ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; diff --git a/Demo/WIN32-MSVC-lwIP/WIN32.suo b/Demo/WIN32-MSVC-lwIP/WIN32.suo index 05a748979c55d34f38b6b0af75ad1809893b1aa9..4f0b2bb74289d282b393863c464b87af31f81e70 100644 GIT binary patch delta 3098 zcmZ`*3sh9s6@6zIhG87W5vPcNFcN~s3O>+)zu+LGn)sXeX;T;x7?>rfh{LG(&1ezO zpaBkYit&S}F&d-5P%tWppRBAZQM6gM6-qTryW%H^E}E*#NY9%YKW$gvtUK@Bd)|5X z+_U#S_u3m2_69}mEg4M4+p=Mhi9Q~aU_Q?9NPtmT=Fy>PH~s5m|BP?JLl6Xeony89 zg154dFK_Ob-x}_)X=Z^pv~W-B9_j6Glqs9J#v8C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?&@=7Lmcv+IWC?W3u)ZdWyGY4*%LflHQ0?zo;ENv% zi;3Q}fJmc1FoFuPwEmmW7!``vxpK%A`#KXd!$g^hpdUBFyR1Oxsdpo1PrnHciVYkm z{&KOBY7?{LEB{5Nr?~10I6G8mWvgl){3A=YpZl$WHf)AuG)e>M+-682*Ji#-AI}m{ z>RM0EEnvb@m+^o71gKd^rXp}wZv!WtD&n&frAlfmhIl$y4V5CCC^F4w;4TNKSbg@f zcfRM$H;PH&1|_xcfD;UaX1O6ztg||A%}mQ8v)#TbD{oDXeWjgFx*^FI=7xU;{ue6I B@MZu2 diff --git a/Source/portable/GCC/ARM_CM3_MPU/port.c b/Source/portable/GCC/ARM_CM3_MPU/port.c index 5d8993d36..9c424bcc6 100644 --- a/Source/portable/GCC/ARM_CM3_MPU/port.c +++ b/Source/portable/GCC/ARM_CM3_MPU/port.c @@ -210,6 +210,7 @@ portBASE_TYPE MPU_xQueueGiveMutexRecursive( xQueueHandle xMutex ); signed portBASE_TYPE MPU_xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE MPU_xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); void MPU_vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName ); +void MPU_vQueueDelete( xQueueHandle xQueue ); void *MPU_pvPortMalloc( size_t xSize ); void MPU_vPortFree( void *pv ); void MPU_vPortInitialiseBlocks( void ); @@ -1071,6 +1072,16 @@ signed portBASE_TYPE xReturn; #endif /*-----------------------------------------------------------*/ +void MPU_vQueueDelete( xQueueHandle xQueue ) +{ +portBASE_TYPE xRunningPrivileged = prvRaisePrivilege(); + + vQueueDelete( xQueue ); + + portRESET_PRIVILEGE( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + void *MPU_pvPortMalloc( size_t xSize ) { void *pvReturn; diff --git a/Source/queue.c b/Source/queue.c index a546dcc08..dff11b1b4 100644 --- a/Source/queue.c +++ b/Source/queue.c @@ -85,7 +85,7 @@ task.h is included from an application file. */ * PUBLIC LIST API documented in list.h *----------------------------------------------------------*/ -/* Constants used with the cRxLock and cTxLock structure members. */ +/* Constants used with the cRxLock and xTxLock structure members. */ #define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 ) #define queueLOCKED_UNMODIFIED ( ( signed portBASE_TYPE ) 0 ) @@ -133,8 +133,8 @@ typedef struct QueueDefinition unsigned portBASE_TYPE uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ unsigned portBASE_TYPE uxItemSize; /*< The size of each items that the queue will hold. */ - signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ #if ( configUSE_TRACE_FACILITY == 1 ) unsigned char ucQueueNumber; diff --git a/Source/timers.c b/Source/timers.c index 2dd68db7e..947e044ad 100644 --- a/Source/timers.c +++ b/Source/timers.c @@ -200,12 +200,12 @@ portBASE_TYPE xReturn = pdFAIL; { /* Create the timer task, storing its handle in xTimerTaskHandle so it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */ - xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, &xTimerTaskHandle ); + xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle ); } #else { /* Create the timer task without storing its handle. */ - xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, NULL); + xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL); } #endif } @@ -442,7 +442,7 @@ portTickType xNextExpireTime; static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched ) { portTickType xTimeNow; -static portTickType xLastTime = ( portTickType ) 0U; +PRIVILEGED_DATA static portTickType xLastTime = ( portTickType ) 0U; xTimeNow = xTaskGetTickCount(); -- 2.39.5