Rev 3424 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3424 | Rev 4377 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | #ifdef mips32 |
- | |
| 30 | - | ||
| 31 | #include <print.h> |
29 | #include <print.h> |
| 32 | #include <debug.h> |
30 | #include <debug.h> |
| 33 | 31 | ||
| 34 | #include <test.h> |
32 | #include <test.h> |
| 35 | #include <atomic.h> |
33 | #include <atomic.h> |
| 36 | #include <proc/thread.h> |
34 | #include <proc/thread.h> |
| 37 | #include <time/delay.h> |
35 | #include <time/delay.h> |
| 38 | 36 | ||
| 39 | #include <arch.h> |
37 | #include <arch.h> |
| 40 | 38 | ||
| 41 | #define THREADS 50 |
39 | #define THREADS 50 |
| 42 | #define DELAY 10000L |
40 | #define DELAY 10000L |
| 43 | #define ATTEMPTS 5 |
41 | #define ATTEMPTS 5 |
| 44 | 42 | ||
| 45 | static atomic_t threads_ok; |
43 | static atomic_t threads_ok; |
| 46 | static atomic_t threads_fault; |
44 | static atomic_t threads_fault; |
| 47 | static waitq_t can_start; |
45 | static waitq_t can_start; |
| 48 | static bool sh_quiet; |
- | |
| 49 | 46 | ||
| 50 | static void testit1(void *data) |
47 | static void testit1(void *data) |
| 51 | { |
48 | { |
| 52 | int i; |
49 | int i; |
| 53 | int arg __attribute__((aligned(16))) = (int) ((unative_t) data); |
50 | int arg __attribute__((aligned(16))) = (int) ((unative_t) data); |
| 54 | int after_arg __attribute__((aligned(16))); |
51 | int after_arg __attribute__((aligned(16))); |
| 55 | 52 | ||
| 56 | thread_detach(THREAD); |
53 | thread_detach(THREAD); |
| 57 | 54 | ||
| 58 | waitq_sleep(&can_start); |
55 | waitq_sleep(&can_start); |
| 59 | 56 | ||
| 60 | for (i = 0; i < ATTEMPTS; i++) { |
57 | for (i = 0; i < ATTEMPTS; i++) { |
| 61 | asm volatile ( |
58 | asm volatile ( |
| 62 | "mtc1 %0,$1" |
59 | "mtc1 %0,$1" |
| 63 | : "=r" (arg) |
60 | : "=r" (arg) |
| 64 | ); |
61 | ); |
| Line 69... | Line 66... | ||
| 69 | "mfc1 %0, $1" |
66 | "mfc1 %0, $1" |
| 70 | : "=r" (after_arg) |
67 | : "=r" (after_arg) |
| 71 | ); |
68 | ); |
| 72 | 69 | ||
| 73 | if (arg != after_arg) { |
70 | if (arg != after_arg) { |
| 74 | if (!sh_quiet) |
- | |
| 75 | printf("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
71 | TPRINTF("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
| 76 | atomic_inc(&threads_fault); |
72 | atomic_inc(&threads_fault); |
| 77 | break; |
73 | break; |
| 78 | } |
74 | } |
| 79 | } |
75 | } |
| 80 | atomic_inc(&threads_ok); |
76 | atomic_inc(&threads_ok); |
| Line 87... | Line 83... | ||
| 87 | int after_arg __attribute__((aligned(16))); |
83 | int after_arg __attribute__((aligned(16))); |
| 88 | 84 | ||
| 89 | thread_detach(THREAD); |
85 | thread_detach(THREAD); |
| 90 | 86 | ||
| 91 | waitq_sleep(&can_start); |
87 | waitq_sleep(&can_start); |
| 92 | 88 | ||
| 93 | for (i = 0; i < ATTEMPTS; i++) { |
89 | for (i = 0; i < ATTEMPTS; i++) { |
| 94 | asm volatile ( |
90 | asm volatile ( |
| 95 | "mtc1 %0,$1" |
91 | "mtc1 %0,$1" |
| 96 | : "=r" (arg) |
92 | : "=r" (arg) |
| 97 | ); |
93 | ); |
| 98 | 94 | ||
| 99 | scheduler(); |
95 | scheduler(); |
| 100 | asm volatile ( |
96 | asm volatile ( |
| 101 | "mfc1 %0,$1" |
97 | "mfc1 %0,$1" |
| 102 | : "=r" (after_arg) |
98 | : "=r" (after_arg) |
| 103 | ); |
99 | ); |
| 104 | 100 | ||
| 105 | if (arg != after_arg) { |
101 | if (arg != after_arg) { |
| 106 | if (!sh_quiet) |
- | |
| 107 | printf("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
102 | TPRINTF("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg); |
| 108 | atomic_inc(&threads_fault); |
103 | atomic_inc(&threads_fault); |
| 109 | break; |
104 | break; |
| 110 | } |
105 | } |
| 111 | } |
106 | } |
| 112 | atomic_inc(&threads_ok); |
107 | atomic_inc(&threads_ok); |
| 113 | } |
108 | } |
| 114 | 109 | ||
| 115 | 110 | ||
| 116 | char * test_mips2(bool quiet) |
111 | char *test_mips2(void) |
| 117 | { |
112 | { |
| 118 | unsigned int i, total = 0; |
113 | unsigned int i, total = 0; |
| 119 | sh_quiet = quiet; |
- | |
| 120 | 114 | ||
| 121 | waitq_initialize(&can_start); |
115 | waitq_initialize(&can_start); |
| 122 | atomic_set(&threads_ok, 0); |
116 | atomic_set(&threads_ok, 0); |
| 123 | atomic_set(&threads_fault, 0); |
117 | atomic_set(&threads_fault, 0); |
| 124 | 118 | ||
| 125 | if (!quiet) |
- | |
| 126 | printf("Creating %u threads... ", 2 * THREADS); |
119 | TPRINTF("Creating %u threads... ", 2 * THREADS); |
| 127 | 120 | ||
| 128 | for (i = 0; i < THREADS; i++) { |
121 | for (i = 0; i < THREADS; i++) { |
| 129 | thread_t *t; |
122 | thread_t *t; |
| 130 | 123 | ||
| 131 | if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) { |
124 | if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) { |
| 132 | if (!quiet) |
- | |
| 133 | printf("could not create thread %u\n", 2 * i); |
125 | TPRINTF("could not create thread %u\n", 2 * i); |
| 134 | break; |
126 | break; |
| 135 | } |
127 | } |
| 136 | thread_ready(t); |
128 | thread_ready(t); |
| 137 | total++; |
129 | total++; |
| 138 | 130 | ||
| 139 | if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) { |
131 | if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) { |
| 140 | if (!quiet) |
- | |
| 141 | printf("could not create thread %u\n", 2 * i + 1); |
132 | TPRINTF("could not create thread %u\n", 2 * i + 1); |
| 142 | break; |
133 | break; |
| 143 | } |
134 | } |
| 144 | thread_ready(t); |
135 | thread_ready(t); |
| 145 | total++; |
136 | total++; |
| 146 | } |
137 | } |
| 147 | 138 | ||
| 148 | if (!quiet) |
- | |
| 149 | printf("ok\n"); |
139 | TPRINTF("ok\n"); |
| 150 | 140 | ||
| 151 | thread_sleep(1); |
141 | thread_sleep(1); |
| 152 | waitq_wakeup(&can_start, WAKEUP_ALL); |
142 | waitq_wakeup(&can_start, WAKEUP_ALL); |
| 153 | 143 | ||
| 154 | while (atomic_get(&threads_ok) != (long) total) { |
144 | while (atomic_get(&threads_ok) != (long) total) { |
| 155 | if (!quiet) |
- | |
| 156 | printf("Threads left: %d\n", total - atomic_get(&threads_ok)); |
145 | TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok)); |
| 157 | thread_sleep(1); |
146 | thread_sleep(1); |
| 158 | } |
147 | } |
| 159 | 148 | ||
| 160 | if (atomic_get(&threads_fault) == 0) |
149 | if (atomic_get(&threads_fault) == 0) |
| 161 | return NULL; |
150 | return NULL; |
| 162 | 151 | ||
| 163 | return "Test failed"; |
152 | return "Test failed"; |
| 164 | } |
153 | } |
| 165 | - | ||
| 166 | #endif |
- | |