]> git.sur5r.net Git - freertos/blobdiff - Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/RegisterTests.c
Comment the peripheral helper files for the new MicroBlaze demo application.
[freertos] / Demo / MicroBlaze_Spartan-6_EthernetLite / SDKProjects / RTOSDemoSource / RegisterTests.c
index 867d56fa1eab00e44a91ca37ecb0e385078452b1..1aa696a939ad138e8c3c4548320caca5fc014faa 100644 (file)
 \r
 /* Scheduler includes. */\r
 #include "FreeRTOS.h"\r
+#include "task.h"\r
 \r
 /*\r
- * The register test task as described at the top of this file.\r
+ * The register test task as described in the comments at the top of main-full.c.\r
  */\r
 void vRegisterTest1( void *pvParameters );\r
 void vRegisterTest2( void *pvParameters );\r
 \r
 /* Variables that are incremented on each iteration of the reg test tasks -\r
-provided the tasks have not reported any errors.  The check task inspects these\r
+provided the tasks have not reported any errors.  The check timer inspects these\r
 variables to ensure they are still incrementing as expected.  If a variable\r
-stops incrementing then it is likely that its associate task has stalled. */\r
+stops incrementing then it is likely that its associate task has stalled or\r
+detected an error. */\r
 volatile unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 void vRegisterTest1( void *pvParameters )\r
 {\r
-//_RB_ Why can R5 not be used in this test?\r
-\r
        /* This task uses an infinite loop that is implemented in the assembly \r
        code.\r
        \r
-       First fill the registers with known values. */\r
+       First fill the relevant registers with known values. */\r
        asm volatile (  "       addi r3, r0, 3          \n\t" \\r
                                        "       addi r4, r0, 4          \n\t" \\r
                                        "       addi r6, r0, 6          \n\t" \\r
@@ -104,7 +104,10 @@ void vRegisterTest1( void *pvParameters )
        /* Now test the register values to ensure they contain the same value that\r
        was written to them above.       This task will get preempted frequently so \r
        other tasks are likely to have executed since the register values were \r
-       written. */\r
+       written.  If any register contains an unexpected value then the task will\r
+       branch to Error_Loop_1, which in turn prevents it from incrementing its\r
+       loop counter, enabling the check timer to determine that all is not as it\r
+       should be. */\r
 \r
        asm volatile (  "Loop_Start_1:                          \n\t" \\r
                                        "       xori r18, r3, 3                 \n\t" \\r
@@ -156,9 +159,9 @@ void vRegisterTest1( void *pvParameters )
                                 );\r
 \r
        /* If this task has not branched to the error loop, then everything is ok,\r
-       and the check variable should be incremented to indicate that this task\r
-       is still running.  Then, brach back to the top to check the registers\r
-       again. */\r
+       and the check variable can be incremented to indicate that this task\r
+       is still running.  Then, brach back to the top to check the register\r
+       contents again. */\r
        asm volatile (  "       lwi r18, r0, ulRegTest1CycleCount       \n\t" \\r
                                        "       addik r18, r18, 1                                       \n\t" \\r
                                        "       swi r18, r0, ulRegTest1CycleCount       \n\t" \\r
@@ -183,16 +186,7 @@ void vRegisterTest2( void *pvParameters )
        code.\r
        \r
        First fill the registers with known values. */\r
-       asm volatile (  "       addi r3, r0, 103        \n\t" \\r
-                                       "       addi r4, r0, 104        \n\t" \\r
-                                       "       addi r6, r0, 106        \n\t" \\r
-                                       "       addi r7, r0, 107        \n\t" \\r
-                                       "       addi r8, r0, 108        \n\t" \\r
-                                       "       addi r9, r0, 109        \n\t" \\r
-                                       "       addi r10, r0, 1010      \n\t" \\r
-                                       "       addi r11, r0, 1011      \n\t" \\r
-                                       "       addi r12, r0, 1012      \n\t" \\r
-                                       "       addi r16, r0, 1016      \n\t" \\r
+       asm volatile (  "       addi r16, r0, 1016      \n\t" \\r
                                        "       addi r19, r0, 1019      \n\t" \\r
                                        "       addi r20, r0, 1020      \n\t" \\r
                                        "       addi r21, r0, 1021      \n\t" \\r
@@ -205,16 +199,35 @@ void vRegisterTest2( void *pvParameters )
                                        "       addi r28, r0, 1028      \n\t" \\r
                                        "       addi r29, r0, 1029      \n\t" \\r
                                        "       addi r30, r0, 1030      \n\t" \\r
-                                       "       addi r31, r0, 1031      \n\t"\r
+                                       "       addi r31, r0, 1031      \n\t" \\r
+                                       "                                                       " \\r
+                                       "Loop_Start_2:                          "\r
                                );\r
 \r
+       /* Unlike vRegisterTest1, vRegisterTest2 performs a yield.  This increases\r
+       the test coverage, but does mean volatile registers need re-loading with \r
+       their exepcted values. */\r
+       taskYIELD();\r
+\r
+       /* taskYIELD() could have changed temporaries - set them back to those\r
+       expected by the reg test task. */\r
+       asm volatile (  "       addi r3, r0, 103        \n\t" \\r
+                                       "       addi r4, r0, 104        \n\t" \\r
+                                       "       addi r6, r0, 106        \n\t" \\r
+                                       "       addi r7, r0, 107        \n\t" \\r
+                                       "       addi r8, r0, 108        \n\t" \\r
+                                       "       addi r9, r0, 109        \n\t" \\r
+                                       "       addi r10, r0, 1010      \n\t" \\r
+                                       "       addi r11, r0, 1011      \n\t" \\r
+                                       "       addi r12, r0, 1012      \n\t" \\r
+                               );\r
+\r
+\r
        /* Now test the register values to ensure they contain the same value that\r
        was written to them above.       This task will get preempted frequently so \r
        other tasks are likely to have executed since the register values were \r
        written. */\r
-\r
-       asm volatile (  "Loop_Start_2:                          \n\t" \\r
-                                       "       xori r18, r3, 103               \n\t" \\r
+       asm volatile (  "       xori r18, r3, 103               \n\t" \\r
                                        "       bnei r18, Error_Loop_2  \n\t" \\r
                                        "       xori r18, r4, 104               \n\t" \\r
                                        "       bnei r18, Error_Loop_2  \n\t" \\r