Changeset 34db7fa in mainline for kernel/test/fpu/mips2.c
- Timestamp:
- 2006-12-12T12:32:02Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 96348adc
- Parents:
- df496c5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/fpu/mips2.c
rdf496c5 r34db7fa 27 27 */ 28 28 29 #ifdef mips32 30 29 31 #include <print.h> 30 32 #include <debug.h> … … 38 40 #include <arch.h> 39 41 40 #ifdef mips3241 42 42 #define THREADS 50 43 43 #define DELAY 10000L … … 45 45 46 46 static atomic_t threads_ok; 47 static atomic_t threads_fault; 47 48 static waitq_t can_start; 48 49 … … 50 51 { 51 52 int i; 52 int arg __attribute__((aligned(16))) = (int) ((unative_t) data);53 int arg __attribute__((aligned(16))) = (int) ((unative_t) data); 53 54 int after_arg __attribute__((aligned(16))); 54 55 55 56 thread_detach(THREAD); 56 57 57 58 waitq_sleep(&can_start); 58 59 59 for (i = 0; i <ATTEMPTS; i++) {60 __asm__volatile (60 for (i = 0; i < ATTEMPTS; i++) { 61 asm volatile ( 61 62 "mtc1 %0,$1" 62 : "=r"(arg)63 64 63 : "=r" (arg) 64 ); 65 65 66 delay(DELAY); 66 __asm__ volatile ( 67 68 asm volatile ( 67 69 "mfc1 %0, $1" 68 : "=r"(after_arg)69 70 : "=r" (after_arg) 71 ); 70 72 71 if(arg != after_arg) 72 panic("General reg tid%d: arg(%d) != %d\n", 73 THREAD->tid, arg, after_arg); 73 if (arg != after_arg) { 74 printf("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg); 75 atomic_inc(&threads_fault); 76 break; 77 } 74 78 } 75 76 79 atomic_inc(&threads_ok); 77 80 } … … 80 83 { 81 84 int i; 82 int arg __attribute__((aligned(16))) = (int) ((unative_t) data);85 int arg __attribute__((aligned(16))) = (int) ((unative_t) data); 83 86 int after_arg __attribute__((aligned(16))); 84 87 85 88 thread_detach(THREAD); 86 89 87 90 waitq_sleep(&can_start); 88 91 89 for (i = 0; i <ATTEMPTS; i++) {90 __asm__volatile (92 for (i = 0; i < ATTEMPTS; i++) { 93 asm volatile ( 91 94 "mtc1 %0,$1" 92 : "=r"(arg)93 95 : "=r" (arg) 96 ); 94 97 95 98 scheduler(); 96 __asm__volatile (99 asm volatile ( 97 100 "mfc1 %0,$1" 98 : "=r"(after_arg)99 101 : "=r" (after_arg) 102 ); 100 103 101 if(arg != after_arg) 102 panic("General reg tid%d: arg(%d) != %d\n", 103 THREAD->tid, arg, after_arg); 104 if (arg != after_arg) { 105 panic("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg); 106 atomic_inc(&threads_fault); 107 break; 108 } 104 109 } 105 106 110 atomic_inc(&threads_ok); 107 111 } 108 112 109 113 110 voidtest_mips2(void)114 char * test_mips2(void) 111 115 { 112 thread_t *t; 113 int i; 116 unsigned int i, total = 0; 117 118 waitq_initialize(&can_start); 119 atomic_set(&threads_ok, 0); 120 atomic_set(&threads_fault, 0); 121 printf("Creating %d threads... ", 2 * THREADS); 114 122 115 waitq_initialize(&can_start); 116 117 printf("MIPS test #1\n"); 118 printf("Creating %d threads... ", THREADS); 119 120 for (i=0; i<THREADS/2; i++) { 121 if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1"))) 122 panic("could not create thread\n"); 123 for (i = 0; i < THREADS; i++) { 124 thread_t *t; 125 126 if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1"))) { 127 printf("could not create thread %d\n", 2 * i); 128 break; 129 } 123 130 thread_ready(t); 124 if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2"))) 125 panic("could not create thread\n"); 131 total++; 132 133 if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2"))) { 134 printf("could not create thread %d\n", 2 * i + 1); 135 break; 136 } 126 137 thread_ready(t); 138 total++; 127 139 } 128 129 140 printf("ok\n"); 130 141 131 142 thread_sleep(1); 132 143 waitq_wakeup(&can_start, WAKEUP_ALL); 133 134 while (atomic_get(&threads_ok) != THREADS) 135 ; 136 137 printf("Test passed.\n"); 138 } 139 140 #else 141 142 void test_mips2(void) 143 { 144 printf("This test is availaible only on MIPS32 platform.\n"); 144 145 while (atomic_get(&threads_ok) != total) { 146 printf("Threads left: %d\n", total - atomic_get(&threads_ok)); 147 thread_sleep(1); 148 } 149 150 if (atomic_get(&threads_fault) == 0) 151 return NULL; 152 153 return "Test failed"; 145 154 } 146 155
Note:
See TracChangeset
for help on using the changeset viewer.