From e87d067ae157eeb738373fba8d3f0815396f0848 Mon Sep 17 00:00:00 2001 From: rtel Date: Thu, 2 Jan 2020 18:55:20 +0000 Subject: [PATCH] Added xTaskAbortDelayFromISR() and ulTaskNotifyValueClear() API functions. Added tests for xTaskAbortDelayFromISR() into Demo/Common/Minimal/AbortDelay.c. Added tests for ulTaskNotifyValueClear() into Demo/Common/Minimal/TaskNotify.c. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2793 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../settings/RTOSDemo.wsdt | 40 +++--- FreeRTOS/Demo/Common/Minimal/AbortDelay.c | 84 ++++++++++++- FreeRTOS/Demo/Common/Minimal/TaskNotify.c | 38 +++++- FreeRTOS/History.txt | 17 +++ FreeRTOS/Source/include/mpu_prototypes.h | 1 + FreeRTOS/Source/include/mpu_wrappers.h | 1 + FreeRTOS/Source/include/task.h | 51 ++++++++ .../Source/portable/Common/mpu_wrappers.c | 13 ++ FreeRTOS/Source/tasks.c | 118 +++++++++++++++++- 9 files changed, 336 insertions(+), 27 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/settings/RTOSDemo.wsdt b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/settings/RTOSDemo.wsdt index 61070a010..1f60c71cb 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/settings/RTOSDemo.wsdt +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/settings/RTOSDemo.wsdt @@ -1,9 +1,7 @@ - - RTOSDemo/Debug - + @@ -240,7 +238,7 @@ 26 3389 2 - + 0 -1 @@ -251,9 +249,7 @@ 30 30 - - RTOSDemo - + 14 @@ -267,16 +263,16 @@ 1 1 1 - 1F000000110000DA000001000000108600000100000005B00000010000000F810000010000001BB000000100000004B000000100000001B00000010000001A860000010000000E8100001E000000058100000100000055860000010000001AB000000100000011860000010000004681000001000000608600000100000000B00000010000000886000001000000 + 20000000120000DA000001000000108600000100000005B00000010000000F810000010000001BB0000001000000148100000100000004B000000100000001B00000010000001A860000010000000E8100001E000000058100000100000055860000010000001AB000000100000011860000010000004681000001000000608600000100000000B00000010000000886000001000000 30000D8400000F84000008840000FFFFFFFF54840000328100001C81000009840000D484000020F1000010F0000000F0000020F0000030F0000060F0000000880000018800000288000003880000048800000588000008800000098000000A8000000B8000000C800000158000000A81000001E80000D6840000D7840000D8840000D9840000DA840000DB840000DC840000DD840000DE840000DF840000E0840000E1840000E2840000EA840000248100000C840000338400007884000011840000 - 0C0004840000470000000481000016000000268100002700000009810000180000000684000049000000308400004C0000000E8400004A0000000B81000019000000058100001700000035E100003E00000002E10000310000000D8100001B000000 + 1A000484000047000000158100001C0000000481000016000000268100002700000007E100003200000004E100003000000001E100002D0000000D8000000E00000009810000180000000684000049000000178100001E000000148100001B0000000081000010000000308400004C0000000E8400004A00000003E100002F00000000E100002C0000000B8100001900000041E100003C000000168100001D000000058100001700000005E1000031000000518400004D00000035E100003E00000002E100002E0000000D8100001B000000 0 0A0000000A0000006E0000006E000000 - 0000000054050000700D000067050000 + 0000000058050000700D00006B050000 4096 0 0 @@ -288,8 +284,8 @@ 4294967295 - 00000000490000001A0100003F040000 - 00000000320000001A01000028040000 + 00000000490000001A01000042040000 + 00000000320000001A0100002C040000 4096 0 0 @@ -316,7 +312,7 @@ 34051 00000000220000003801000004010000 - 04000000440400006C0D00003A050000 + 04000000480400006C0D00003E050000 4096 0 0 @@ -366,7 +362,7 @@ 34057 00000000220000003801000004010000 - 04000000440400006C0D00003A050000 + 04000000480400006C0D00003E050000 4096 0 0 @@ -381,14 +377,14 @@ 171 2054 2 - + 0 -1 34058 00000000220000003801000004010000 - 04000000440400006C0D00003A050000 + 0400000048040000FC0900003E050000 4096 0 0 @@ -402,7 +398,7 @@ 34059 00000000220000003801000004010000 - 04000000440400006C0D00003A050000 + 0400000048040000FC0900003E050000 4096 0 0 @@ -416,7 +412,7 @@ 34060 00000000220000003801000004010000 - 04000000440400006C0D00003A050000 + 0400000048040000FC0900003E050000 4096 0 0 @@ -430,7 +426,7 @@ 34062 00000000220000003801000004010000 - 04000000440400006C0D00003A050000 + 0400000048040000FC0900003E050000 4096 0 0 @@ -503,7 +499,7 @@ 34063 00000000220000001A010000E0010000 - 00000000460000001A01000028040000 + 00000000460000001A0100002C040000 4096 0 0 @@ -514,7 +510,7 @@ 1 - 000000000E000000000000000010000001000000FFFFFFFFFFFFFFFF1A010000320000001E01000028040000010000000200001004000000010000000000000000000000FFFFFFFF010000000F850000FFFF02000B004354616262656450616E65001000000100000000000000490000001A0100003F04000000000000320000001A01000028040000000000004010005601000000FFFEFF0957006F0072006B0073007000610063006500010000000F85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0F85000001000000FFFFFFFF0F850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000078500000000000000000000000000000000000001000000078500000100000007850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000048500000000000000000000000000000000000001000000048500000100000004850000000000000080000001000000FFFFFFFFFFFFFFFF0000000028040000700D00002C04000001000000010000100400000001000000AAFDFFFF45000000FFFFFFFF0600000003850000098500000A8500000B8500000C8500000E850000018000800000010000000000000043040000700D00006B050000000000002C040000700D000054050000000000004080005606000000FFFEFF054200750069006C006400010000000385000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300010000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000C85000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000E85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0385000001000000FFFFFFFF03850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000138500000000000000000000000000000000000001000000138500000100000013850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000128500000000000000000000000000000000000001000000128500000100000012850000000000000080000000000000FFFFFFFFFFFFFFFF000000009F040000700D0000A3040000000000000100000004000000010000000000000000000000FFFFFFFF0200000002850000088500000180008000000000000000000000BA040000700D00006B05000000000000A3040000700D000054050000000000004080004602000000FFFEFF0B42007200650061006B0070006F0069006E0074007300000000000285000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700000000000885000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFF0285000001000000FFFFFFFF0285000001000000FFFF02001200434D756C746950616E654672616D65576E64000100840000000022000000380100000401000000000000000000000200000000000000068500000000000000000000000000000000000001000000068500000000000000000000 + 000000000C000000000000000010000001000000FFFFFFFFFFFFFFFF1A010000320000001E0100002C040000010000000200001004000000010000000000000000000000FFFFFFFF010000000F850000FFFF02000B004354616262656450616E65001000000100000000000000490000001A0100004204000000000000320000001A0100002C040000000000004010005601000000FFFEFF0957006F0072006B0073007000610063006500010000000F85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0F85000001000000FFFFFFFF0F850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000078500000000000000000000000000000000000001000000078500000100000007850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000048500000000000000000000000000000000000001000000048500000100000004850000000000000080000001000000FFFFFFFFFFFFFFFF000000002C040000700D00003004000001000000010000100400000001000000AAFDFFFF45000000FFFFFFFF0600000003850000098500000A8500000B8500000C8500000E850000018000800000010000000000000046040000000A00006E0500000000000030040000700D000058050000000000004080005606000000FFFEFF054200750069006C006400010000000385000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300010000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000C85000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000E85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0385000001000000FFFFFFFF03850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000138500000000000000000000000000000000000001000000138500000100000013850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000128500000000000000000000000000000000000001000000128500000100000012850000000000000000000000000000 CMSIS-Pack @@ -663,7 +659,7 @@ - 010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000001000000050000000000000001000000FFFEFF0F2400570053005F0044004900520024005C006D00610069006E002E00630001000000FFFF010014004966436F6E74656E7453746F72616765496D706CFFFEFF00FFFEFFFF22013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E003100370038003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0030003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0030003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF066D00610069006E002E00630000000000FFFFFFFFFFFFFFFFFFFEFF312400570053005F0044004900520024005C002E002E005C002E002E005C0053006F0075007200630065005C0070006F0072007400610062006C0065005C004900410052005C00410052004D005F0043004D0033005C0070006F00720074002E006300010000000180FFFEFF00FFFEFFFF20013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E0030003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0030003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0030003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0670006F00720074002E00630000000000FFFFFFFFFFFFFFFFFFFEFF252400570053005F0044004900520024005C002E002E005C002E002E005C0053006F0075007200630065005C00730074007200650061006D005F006200750066006600650072002E006300010000000180FFFEFF00FFFEFFFF2A013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E003500300034003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E00310039003500380032003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E00310039003500380032003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0F730074007200650061006D005F006200750066006600650072002E00630000000000FFFFFFFFFFFFFFFFFFFEFF342400570053005F0044004900520024005C002E002E005C002E002E005C0053006F0075007200630065005C0070006F0072007400610062006C0065005C004900410052005C00410052004D005F0043004D0033005C0070006F0072007400610073006D002E007300010000000180FFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00330036003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0031003500390035003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0031003500390035003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0970006F0072007400610073006D002E00730000000000FFFFFFFFFFFFFFFFFFFEFF1D2400570053005F0044004900520024005C002E002E005C002E002E005C0053006F0075007200630065005C007400610073006B0073002E006300010000000180FFFEFF00FFFEFFFF2D013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E0035003100330030003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E003100370034003200310038003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E003100370034003200310038003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF077400610073006B0073002E00630000000000FFFFFFFFFFFFFFFF0000000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000001000000020000001E01000049000000700D00003F040000 + 010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000000000000 diff --git a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c index fc4e36f4d..9fc8cfeb0 100644 --- a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c +++ b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c @@ -101,6 +101,12 @@ static void prvTestAbortingEventGroupWait( void ); static void prvTestAbortingQueueSend( void ); static void prvTestAbortingStreamBufferReceive( void ); +/* + * Performs a few tests to cover code paths not otherwise covered by the continuous + * tests. + */ +static void prvPerformSingleTaskTests( void ); + /* * Checks the amount of time a task spent in the Blocked state is within the * expected bounds. @@ -143,6 +149,10 @@ uint32_t ulTestToPerform = abtNOTIFY_WAIT_ABORTS; TickType_t xTimeAtStart; const TickType_t xStartMargin = 2UL; +/* Used to control whether to use xTaskAbortDelay() or xTaskAbortDelayFromISR() so +both are used with all the tests. */ +BaseType_t xUseFromISRVersion = pdFALSE, xHigherPriorityTaskWoken; + /* Just to remove compiler warnings. */ ( void ) pvParameters; @@ -167,10 +177,46 @@ const TickType_t xStartMargin = 2UL; raise the priority of the controlling task to that of the blocking task to minimise discrepancies. */ vTaskPrioritySet( NULL, abtBLOCKING_PRIORITY ); + vTaskDelay( xMaxBlockTime + xHalfMaxBlockTime + xStartMargin ); - if( xTaskAbortDelay( xBlockingTask ) != pdPASS ) + + /* For test coverage sometimes xTaskAbortDelay() is used and sometimes + xTaskAbortDelayFromISR() is used. */ + if( xUseFromISRVersion == pdFALSE ) { - xErrorOccurred = pdTRUE; + if( xTaskAbortDelay( xBlockingTask ) != pdPASS ) + { + xErrorOccurred = pdTRUE; + } + } + else + { + xHigherPriorityTaskWoken = pdFALSE; + + /* For test coverage, sometimes xHigherPriorityTaskWoken is used, and + sometimes NULL is used. */ + + if( ( xControllingCycles % 2 ) == 0 ) + { + if( xTaskAbortDelayFromISR( xBlockingTask, &xHigherPriorityTaskWoken ) != pdPASS ) + { + xErrorOccurred = pdTRUE; + } + } + else + { + if( xTaskAbortDelayFromISR( xBlockingTask, NULL ) != pdPASS ) + { + xErrorOccurred = pdTRUE; + } + } + + /* The tasks have the same priority so xHigherPriorityTaskWoken should + never get set. */ + if( xHigherPriorityTaskWoken != pdFALSE ) + { + xErrorOccurred = pdTRUE; + } } /* Reset the priority to the normal controlling priority. */ @@ -195,6 +241,13 @@ const TickType_t xStartMargin = 2UL; /* To indicate this task is still executing. */ xControllingCycles++; + + if( ( xControllingCycles % abtMAX_TESTS ) == 0 ) + { + /* Looped through all the tests. Switch between using xTaskAbortDelay() + and xTaskAbortDelayFromISR() for the next round of tests. */ + xUseFromISRVersion = !xUseFromISRVersion; + } } } /*-----------------------------------------------------------*/ @@ -208,6 +261,10 @@ const uint32_t ulMax = 0xffffffffUL; /* Just to remove compiler warnings. */ ( void ) pvParameters; + /* Start by performing a few tests to cover code not exercised in the loops + below. */ + prvPerformSingleTaskTests(); + xControllingTask = xTaskGetHandle( pcControllingTaskName ); configASSERT( xControllingTask ); @@ -264,6 +321,29 @@ const uint32_t ulMax = 0xffffffffUL; } /*-----------------------------------------------------------*/ +static void prvPerformSingleTaskTests( void ) +{ +TaskHandle_t xThisTask; +BaseType_t xReturned; + + /* Try unblocking this task using both the task and ISR versions of the API - + both should return false as this task is not blocked. */ + xThisTask = xTaskGetCurrentTaskHandle(); + + xReturned = xTaskAbortDelay( xThisTask ); + if( xReturned != pdFALSE ) + { + xErrorOccurred = pdTRUE; + } + + xReturned = xTaskAbortDelayFromISR( xThisTask, NULL ); + if( xReturned != pdFALSE ) + { + xErrorOccurred = pdTRUE; + } +} +/*-----------------------------------------------------------*/ + static void prvTestAbortingTaskDelayUntil( void ) { TickType_t xTimeAtStart, xLastBlockTime; diff --git a/FreeRTOS/Demo/Common/Minimal/TaskNotify.c b/FreeRTOS/Demo/Common/Minimal/TaskNotify.c index 4adc06f56..8ee87051f 100644 --- a/FreeRTOS/Demo/Common/Minimal/TaskNotify.c +++ b/FreeRTOS/Demo/Common/Minimal/TaskNotify.c @@ -47,7 +47,12 @@ #endif #define notifyTASK_PRIORITY ( tskIDLE_PRIORITY ) -#define notifyUINT32_MAX ( ( uint32_t ) 0xffffffff ) + +/* Constants used in tests when setting/clearing bits. */ +#define notifyUINT32_MAX ( ( uint32_t ) 0xffffffff ) +#define notifyUINT32_HIGH_BYTE ( ( uint32_t ) 0xff000000 ) +#define notifyUINT32_LOW_BYTE ( ( uint32_t ) 0x000000ff ) + #define notifySUSPENDED_TEST_TIMER_PERIOD pdMS_TO_TICKS( 50 ) /*-----------------------------------------------------------*/ @@ -403,6 +408,37 @@ TimerHandle_t xSingleTaskTimer; + /* ------------------------------------------------------------------------ + Clear bits in the notification value. */ + + /* Get the task to set all bits its own notification value. This is not a + normal thing to do, and is only done here for test purposes. */ + xTaskNotify( xTaskToNotify, notifyUINT32_MAX, eSetBits ); + + /* Now clear the top bytes - the returned value from the first call should + indicate that previously all bits were set. */ + configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_HIGH_BYTE ) == notifyUINT32_MAX ); + + /* Next clear the bottom bytes - the returned value this time should indicate + that the top byte was clear (before the bottom byte was cleared. */ + configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_LOW_BYTE ) == ( notifyUINT32_MAX & ~notifyUINT32_HIGH_BYTE ) ); + + /* Next clear all bytes - the returned value should indicate that previously the + high and low bytes were clear. */ + configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_MAX ) == ( notifyUINT32_MAX & ~notifyUINT32_HIGH_BYTE & ~notifyUINT32_LOW_BYTE ) ); + + /* Now all bits should be clear. */ + configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_MAX ) == 0 ); + configASSERT( ulTaskNotifyValueClear( xTaskToNotify, 0UL ) == 0 ); + configASSERT( ulTaskNotifyValueClear( xTaskToNotify, notifyUINT32_MAX ) == 0 ); + + /* Now the notification state should be eNotified, so it should now be + possible to clear the notification state. */ + configASSERT( xTaskNotifyStateClear( NULL ) == pdTRUE ); + configASSERT( xTaskNotifyStateClear( NULL ) == pdFALSE ); + + + /* ------------------------------------------------------------------------ Create a timer that will try notifying this task while it is suspended. */ xSingleTaskTimer = xTimerCreate( "SingleNotify", notifySUSPENDED_TEST_TIMER_PERIOD, pdFALSE, NULL, prvSuspendedTaskTimerTestCallback ); diff --git a/FreeRTOS/History.txt b/FreeRTOS/History.txt index e040bd086..35080124e 100644 --- a/FreeRTOS/History.txt +++ b/FreeRTOS/History.txt @@ -17,6 +17,21 @@ Changes since the last release: the variable xPendingTicks. + Correct alignment of stack top in RISC-V port when configISR_STACK_SIZE_WORDS is defined to a non zero value. + + RISC-V port updates: The machine timer compare register can now be for + any HART, and correct the sequence used to update the 64-bit machine timer + compare register on 32-bit cores. + + Update Keil projects that use the MPU so memory regions come from linker + script (scatter file) variables instead of being hard coded. + + Added tickless low power modes into the ARM, IAR and GCC Cortex-M0 compiler + ports. + + Updated the behaviour of the ARMv7-M MPU (Memory Protection Unit) ports to + match that of the ARMv8-M ports whereby privilege escalations can only + originate from within the kernel's own memory segment. + + Added LPC51U68 Cortex-M0+ port for GCC (MCUXpresso), Keil and IAR + compilers. + + Added CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube demo. + + Added xTaskAbortDelayFromISR() API function. + + Added xTaskNotifyValueClear() API function. Changes between FreeRTOS V10.2.1 and FreeRTOS V10.2.0 released May 13 2019: @@ -515,6 +530,8 @@ Changes between V8.2.0 and V8.2.1 released 24th March 2015. Windows port. + Update the PIC32 port to remove deprecation warnings output by the latest XC32 compilers. + + Fix bug when xQueueOverwrite() and xQueueOverwrite() from ISR are used to + overwrite items in two queues that are part of the same set. Demo application updates: diff --git a/FreeRTOS/Source/include/mpu_prototypes.h b/FreeRTOS/Source/include/mpu_prototypes.h index 766197ab1..08b2d1aac 100644 --- a/FreeRTOS/Source/include/mpu_prototypes.h +++ b/FreeRTOS/Source/include/mpu_prototypes.h @@ -76,6 +76,7 @@ BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL; BaseType_t MPU_xTaskIncrementTick( void ) FREERTOS_SYSTEM_CALL; TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL; void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL; diff --git a/FreeRTOS/Source/include/mpu_wrappers.h b/FreeRTOS/Source/include/mpu_wrappers.h index 2c0ee7549..6ac0a3e92 100644 --- a/FreeRTOS/Source/include/mpu_wrappers.h +++ b/FreeRTOS/Source/include/mpu_wrappers.h @@ -82,6 +82,7 @@ only for ports that are using the MPU. */ #define xTaskNotifyWait MPU_xTaskNotifyWait #define ulTaskNotifyTake MPU_ulTaskNotifyTake #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear + #define ulTaskNotifyValueClear MPU_ulTaskNotifyValueClear #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle diff --git a/FreeRTOS/Source/include/task.h b/FreeRTOS/Source/include/task.h index 6d9548ea1..40e1e533d 100644 --- a/FreeRTOS/Source/include/task.h +++ b/FreeRTOS/Source/include/task.h @@ -841,6 +841,39 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT */ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; +/** +* task. h +*
BaseType_t xTaskAbortDelayFromISR( TaskHandle_t xTask, BaseType_t * const pxHigherPriorityTaskWoken )
+* +* INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this +* function to be available. +* +* A version of xTaskAbortDelay() that can be used from an interrupt service routine. +* +* A task will enter the Blocked state when it is waiting for an event. The +* event it is waiting for can be a temporal event (waiting for a time), such +* as when vTaskDelay() is called, or an event on an object, such as when +* xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task +* that is in the Blocked state is used in a call to xTaskAbortDelay() then the +* task will leave the Blocked state, and return from whichever function call +* placed the task into the Blocked state. +* +* @param xTask The handle of the task to remove from the Blocked state. +* +* @param pxHigherPriorityTaskWoken xTaskAbortDelayFromISR() will set +* *pxHigherPriorityTaskWoken to pdTRUE if a task was removed from the Blocked state, +* and the task that was removed from the Blocked state has a priority higher than the +* currently running task. If xTaskAbortDelayFromISR() sets this value to pdTRUE then +* a context switch should be requested before the interrupt is exited. +* +* @return If the task referenced by xTask was not in the Blocked state then +* pdFAIL is returned. Otherwise pdPASS is returned. +* +* \defgroup xTaskAbortDelay xTaskAbortDelayFromISR +* \ingroup TaskCtrl +*/ +BaseType_t xTaskAbortDelayFromISR( TaskHandle_t xTask, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + /** * task. h *
UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
@@ -2201,6 +2234,24 @@ uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait */ BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); +/** +* task. h +*
uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
+* +* Clears the bits specified by the ulBitsToClear bit mask in the notification +* value of the task referenced by xTask. +* +* Set ulBitsToClear to to 0xffffffff (UINT_MAX on 32-bit architectures) to clear +* the notification value to 0. Set ulBitsToClear to 0 to query the task's +* notification value without clearing any bits. +* +* @return The value of the target task's notification value before the bits +* specified by ulBitsToClear were cleared. +* \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear +* \ingroup TaskNotifications +*/ +uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; + /** * task.h *
void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )
diff --git a/FreeRTOS/Source/portable/Common/mpu_wrappers.c b/FreeRTOS/Source/portable/Common/mpu_wrappers.c index 5df7d4089..39d9c9617 100644 --- a/FreeRTOS/Source/portable/Common/mpu_wrappers.c +++ b/FreeRTOS/Source/portable/Common/mpu_wrappers.c @@ -586,6 +586,19 @@ BaseType_t xRunningPrivileged = xPortRaisePrivilege(); #endif /*-----------------------------------------------------------*/ +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t MPU_ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) /* FREERTOS_SYSTEM_CALL */ + { + uint32_t ulReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + ulReturn = ulTaskNotifyValueClear( xTask, ulBitsToClear ); + vPortResetPrivilege( xRunningPrivileged ); + return ulReturn; + } +#endif +/*-----------------------------------------------------------*/ + #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ { diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index c5b225681..c6bcb6828 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -2626,7 +2626,7 @@ BaseType_t xYieldRequired = pdFALSE; relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */ configASSERT( uxSchedulerSuspended == 0 ); - /* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occuring when + /* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occurring when the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */ vTaskSuspendAll(); xPendedTicks += xTicksToCatchUp; @@ -2636,6 +2636,91 @@ BaseType_t xYieldRequired = pdFALSE; } /*----------------------------------------------------------*/ +#if ( INCLUDE_xTaskAbortDelay == 1 ) + + BaseType_t xTaskAbortDelayFromISR( TaskHandle_t xTask, BaseType_t * const pxHigherPriorityTaskWoken ) + { + TCB_t *pxTCB = xTask; + BaseType_t xReturn; + UBaseType_t uxSavedInterruptStatus; + + configASSERT( pxTCB ); + + /* RTOS ports that support interrupt nesting have the concept of a maximum + system call (or maximum API call) interrupt priority. Interrupts that are + above the maximum system call priority are kept permanently enabled, even + when the RTOS kernel is in a critical section, but cannot make any calls to + FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h + then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion + failure if a FreeRTOS API function is called from an interrupt that has been + assigned a priority above the configured maximum system call priority. + Only FreeRTOS functions that end in FromISR can be called from interrupts + that have been assigned a priority at or (logically) below the maximum + system call interrupt priority. FreeRTOS maintains a separate interrupt + safe API to ensure interrupt entry is as fast and as simple as possible. + More information (albeit Cortex-M specific) is provided on the following + link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ + portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); + + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + { + /* A task can only be prematurely removed from the Blocked state if + it is actually in the Blocked state. */ + if( eTaskGetState( xTask ) == eBlocked ) + { + xReturn = pdPASS; + + /* Remove the reference to the task from the blocked list. A higher + priority interrupt won't touch the xStateListItem because of the + critical section. */ + ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + + /* Is the task waiting on an event also? If so remove it from + the event list too. */ + if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) + { + ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + + /* This lets the task know it was forcibly removed from the + blocked state so it should not re-evaluate its block time and + then block again. */ + pxTCB->ucDelayAborted = pdTRUE; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Place the unblocked task into the appropriate ready list. */ + prvAddTaskToReadyList( pxTCB ); + + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) + { + if( pxHigherPriorityTaskWoken != NULL ) + { + /* Pend the yield to be performed when the scheduler + is unsuspended. */ + *pxHigherPriorityTaskWoken = pdTRUE; + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + xReturn = pdFAIL; + } + } + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + + return xReturn; + } + +#endif +/*----------------------------------------------------------*/ + #if ( INCLUDE_xTaskAbortDelay == 1 ) BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) @@ -2667,6 +2752,10 @@ BaseType_t xYieldRequired = pdFALSE; if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) { ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + + /* This lets the task know it was forcibly removed from the + blocked state so it should not re-evaluate its block time and + then block again. */ pxTCB->ucDelayAborted = pdTRUE; } else @@ -5096,7 +5185,6 @@ TickType_t uxReturn; } #endif /* configUSE_TASK_NOTIFICATIONS */ - /*-----------------------------------------------------------*/ #if( configUSE_TASK_NOTIFICATIONS == 1 ) @@ -5130,6 +5218,32 @@ TickType_t uxReturn; #endif /* configUSE_TASK_NOTIFICATIONS */ /*-----------------------------------------------------------*/ +#if( configUSE_TASK_NOTIFICATIONS == 1 ) + + uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) + { + TCB_t *pxTCB; + uint32_t ulReturn; + + /* If null is passed in here then it is the calling task that is having + its notification state cleared. */ + pxTCB = prvGetTCBFromHandle( xTask ); + + taskENTER_CRITICAL(); + { + /* Return the notification as it was before the bits were cleared, + then clear the bit mask. */ + ulReturn = pxCurrentTCB->ulNotifiedValue; + pxTCB->ulNotifiedValue &= ~ulBitsToClear; + } + taskEXIT_CRITICAL(); + + return ulReturn; + } + +#endif /* configUSE_TASK_NOTIFICATIONS */ +/*-----------------------------------------------------------*/ + #if( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) uint32_t ulTaskGetIdleRunTimeCounter( void ) -- 2.39.2