-static void prvRegTest1Task( void *pvParameters )\r
-{\r
-/* This task is created in privileged mode so can access the file scope\r
-queue variable. Take a stack copy of this before the task is set into user\r
-mode. Once this task is in user mode the file scope queue variable will no\r
-longer be accessible but the stack copy will. */\r
-QueueHandle_t xQueue = xFileScopeCheckQueue;\r
-\r
- /* Now the queue handle has been obtained the task can switch to user\r
- mode. This is just one method of passing a handle into a protected\r
- task, the other reg test task uses the task parameter instead. */\r
- portSWITCH_TO_USER_MODE();\r
-\r
- /* First check that the parameter value is as expected. */\r
- if( pvParameters != ( void * ) 0x12345678 )\r
- {\r
- /* Error detected. Delete the task so it stops communicating with\r
- the check task. */\r
- prvDeleteMe();\r
- }\r
-\r
-\r
- for( ;; )\r
- {\r
- /* This task tests the kernel context switch mechanism by reading and\r
- writing directly to registers - which requires the test to be written\r
- in assembly code. */\r
- __asm volatile\r
- (\r
- " MOV R4, #104 \n" /* Set registers to a known value. R0 to R1 are done in the loop below. */\r
- " MOV R5, #105 \n"\r
- " MOV R6, #106 \n"\r
- " MOV R8, #108 \n"\r
- " MOV R9, #109 \n"\r
- " MOV R10, #110 \n"\r
- " MOV R11, #111 \n"\r
- "reg1loop: \n"\r
- " MOV R0, #100 \n" /* Set the scratch registers to known values - done inside the loop as they get clobbered. */\r
- " MOV R1, #101 \n"\r
- " MOV R2, #102 \n"\r
- " MOV R3, #103 \n"\r
- " MOV R12, #112 \n"\r
- " SVC #1 \n" /* Yield just to increase test coverage. */\r
- " CMP R0, #100 \n" /* Check all the registers still contain their expected values. */\r
- " BNE prvDeleteMe \n" /* Value was not as expected, delete the task so it stops communicating with the check task. */\r
- " CMP R1, #101 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R2, #102 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R3, #103 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R4, #104 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R5, #105 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R6, #106 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R8, #108 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R9, #109 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R10, #110 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R11, #111 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R12, #112 \n"\r
- " BNE prvDeleteMe \n"\r
- :::"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r8", "r9", "r10", "r11", "r12"\r
- );\r
-\r
- /* Send mainREG_TEST_1_STILL_EXECUTING to the check task to indicate that this\r
- task is still functioning. */\r
- prvSendImAlive( xQueue, mainREG_TEST_1_STILL_EXECUTING );\r
-\r
- /* Go back to check all the register values again. */\r
- __asm volatile( " B reg1loop " );\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvRegTest2Task( void *pvParameters )\r
-{\r
-/* The queue handle is passed in as the task parameter. This is one method of\r
-passing data into a protected task, the other reg test task uses a different\r
-method. */\r
-QueueHandle_t xQueue = ( QueueHandle_t ) pvParameters;\r
-\r
- for( ;; )\r
- {\r
- /* This task tests the kernel context switch mechanism by reading and\r
- writing directly to registers - which requires the test to be written\r
- in assembly code. */\r
- __asm volatile\r
- (\r
- " MOV R4, #4 \n" /* Set registers to a known value. R0 to R1 are done in the loop below. */\r
- " MOV R5, #5 \n"\r
- " MOV R6, #6 \n"\r
- " MOV R8, #8 \n" /* Frame pointer is omitted as it must not be changed. */\r
- " MOV R9, #9 \n"\r
- " MOV R10, 10 \n"\r
- " MOV R11, #11 \n"\r
- "reg2loop: \n"\r
- " MOV R0, #13 \n" /* Set the scratch registers to known values - done inside the loop as they get clobbered. */\r
- " MOV R1, #1 \n"\r
- " MOV R2, #2 \n"\r
- " MOV R3, #3 \n"\r
- " MOV R12, #12 \n"\r
- " CMP R0, #13 \n" /* Check all the registers still contain their expected values. */\r
- " BNE prvDeleteMe \n" /* Value was not as expected, delete the task so it stops communicating with the check task */\r
- " CMP R1, #1 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R2, #2 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R3, #3 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R4, #4 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R5, #5 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R6, #6 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R8, #8 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R9, #9 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R10, #10 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R11, #11 \n"\r
- " BNE prvDeleteMe \n"\r
- " CMP R12, #12 \n"\r
- " BNE prvDeleteMe \n"\r
- :::"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r8", "r9", "r10", "r11", "r12"\r
- );\r
-\r
- /* Send mainREG_TEST_2_STILL_EXECUTING to the check task to indicate that this\r
- task is still functioning. */\r
- prvSendImAlive( xQueue, mainREG_TEST_2_STILL_EXECUTING );\r
-\r
- /* Go back to check all the register values again. */\r
- __asm volatile( " B reg2loop " );\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r