1 |
2 |
dimamali |
/*****************************************************************************/
|
2 |
|
|
/* This file is a part of the GRLIB VHDL IP LIBRARY */
|
3 |
|
|
/* Copyright (C) 2004 GAISLER RESEARCH */
|
4 |
|
|
|
5 |
|
|
/* This program is free software; you can redistribute it and/or modify */
|
6 |
|
|
/* it under the terms of the GNU General Public License as published by */
|
7 |
|
|
/* the Free Software Foundation; either version 2 of the License, or */
|
8 |
|
|
/* (at your option) any later version. */
|
9 |
|
|
|
10 |
|
|
/* See the file COPYING for the full details of the license. */
|
11 |
|
|
/*****************************************************************************/
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
/*****************************************************************************/
|
15 |
|
|
/*Testroutine for GRSPW. Must be used with one device in loopback mode */
|
16 |
|
|
/*****************************************************************************/
|
17 |
|
|
#include <stdlib.h>
|
18 |
|
|
#include "spwapi.h"
|
19 |
|
|
#include "rmapapi.h"
|
20 |
|
|
|
21 |
|
|
#define SPW_ADDR 0x80000c00
|
22 |
|
|
#define AHBFREQ 40000
|
23 |
|
|
|
24 |
|
|
#define PKTTESTMAX 128
|
25 |
|
|
#define DESCPKT 1024
|
26 |
|
|
#define MAXSIZE 4194304
|
27 |
|
|
#define RMAPSIZE 1024
|
28 |
|
|
#define RMAPCRCSIZE 1024
|
29 |
|
|
|
30 |
|
|
static inline char loadb(int addr)
|
31 |
|
|
{
|
32 |
|
|
char tmp;
|
33 |
|
|
asm(" lduba [%1]1, %0 "
|
34 |
|
|
: "=r"(tmp)
|
35 |
|
|
: "r"(addr)
|
36 |
|
|
);
|
37 |
|
|
return tmp;
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
static inline int loadmem(int addr)
|
41 |
|
|
{
|
42 |
|
|
int tmp;
|
43 |
|
|
asm(" lda [%1]1, %0 "
|
44 |
|
|
: "=r"(tmp)
|
45 |
|
|
: "r"(addr)
|
46 |
|
|
);
|
47 |
|
|
return tmp;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
int main(void)
|
51 |
|
|
{
|
52 |
|
|
int i;
|
53 |
|
|
int j;
|
54 |
|
|
int k;
|
55 |
|
|
int m;
|
56 |
|
|
int l;
|
57 |
|
|
int data;
|
58 |
|
|
int hdr;
|
59 |
|
|
int notrx;
|
60 |
|
|
int tmp;
|
61 |
|
|
int eoplen;
|
62 |
|
|
int *size;
|
63 |
|
|
char *txbuf;
|
64 |
|
|
char *rxbuf;
|
65 |
|
|
char *rx0;
|
66 |
|
|
char *rx1;
|
67 |
|
|
char *rx2;
|
68 |
|
|
char *rx3;
|
69 |
|
|
char *tx0;
|
70 |
|
|
char *tx1;
|
71 |
|
|
char *tx2;
|
72 |
|
|
char *tx3;
|
73 |
|
|
char *tx[64];
|
74 |
|
|
char *rx[128];
|
75 |
|
|
struct rmap_pkt *cmd;
|
76 |
|
|
int *cmdsize;
|
77 |
|
|
struct rmap_pkt *reply;
|
78 |
|
|
int *replysize;
|
79 |
|
|
struct rxstatus *rxs;
|
80 |
|
|
struct spwvars *spw;
|
81 |
|
|
spw = (struct spwvars *) malloc(sizeof(struct spwvars));
|
82 |
|
|
rxs = (struct rxstatus *) malloc(sizeof(struct rxstatus));
|
83 |
|
|
size = (int *) malloc(sizeof(int));
|
84 |
|
|
|
85 |
|
|
printf("Test started\n");
|
86 |
|
|
/************************ TEST INIT ***********************************/
|
87 |
|
|
/*Initalize link*/
|
88 |
|
|
/*initialize parameters*/
|
89 |
|
|
if (spw_setparam(0x14, 0, 0xBF, 1, 1, 1, 1048576, SPW_ADDR, AHBFREQ, spw) ) {
|
90 |
|
|
printf("Illegal parameters to spacewire\n");
|
91 |
|
|
exit(1);
|
92 |
|
|
}
|
93 |
|
|
/*reset link*/
|
94 |
|
|
spw_reset(spw);
|
95 |
|
|
/*initialize link*/
|
96 |
|
|
if (spw_init(spw)) {
|
97 |
|
|
printf("Link initialization failed\n");
|
98 |
|
|
}
|
99 |
|
|
/************************ TEST 1 **************************************/
|
100 |
|
|
/*Simulatenous time-code and packet transmission/reception*/
|
101 |
|
|
printf("Test transmission and reception with simultaneous time-code transmissions\n");
|
102 |
|
|
rx0 = malloc(128);
|
103 |
|
|
rx1 = malloc(128);
|
104 |
|
|
rx2 = malloc(128);
|
105 |
|
|
rx3 = malloc(128);
|
106 |
|
|
tx0 = malloc(128);
|
107 |
|
|
tx1 = malloc(128);
|
108 |
|
|
tx2 = malloc(128);
|
109 |
|
|
tx3 = malloc(128);
|
110 |
|
|
for(i = 0; i < 128; i++) {
|
111 |
|
|
tx0[i] = (char)i;
|
112 |
|
|
tx1[i] = (char)~i;
|
113 |
|
|
tx2[i] = (char)(i ^ (i + ~i));
|
114 |
|
|
tx3[i] = (char)(i ^ (i + ~i + 5));
|
115 |
|
|
}
|
116 |
|
|
tx0[0] = 0x14;
|
117 |
|
|
tx1[0] = 0x14;
|
118 |
|
|
tx2[0] = 0x14;
|
119 |
|
|
tx3[0] = 0x14;
|
120 |
|
|
tx0[1] = 0x02;
|
121 |
|
|
tx1[1] = 0x02;
|
122 |
|
|
tx2[1] = 0x02;
|
123 |
|
|
tx3[1] = 0x02;
|
124 |
|
|
spw_rx(rx0, spw);
|
125 |
|
|
spw_rx(rx1, spw);
|
126 |
|
|
spw_rx(rx2, spw);
|
127 |
|
|
spw_rx(rx3, spw);
|
128 |
|
|
spw_tx(0, 0, 0, 0, tx0, 128, tx0, spw);
|
129 |
|
|
spw_tx(0, 0, 0, 0, tx1, 128, tx1, spw);
|
130 |
|
|
spw_tx(0, 0, 0, 0, tx2, 128, tx2, spw);
|
131 |
|
|
spw_tx(0, 0, 0, 0, tx3, 128, tx3, spw);
|
132 |
|
|
if (check_time(spw)) {
|
133 |
|
|
printf("Tick out set before any time-codes were sent\n");
|
134 |
|
|
exit(1);
|
135 |
|
|
}
|
136 |
|
|
if (get_time(spw)) {
|
137 |
|
|
printf("Time-code nonzero before any time-code were sent/received\n");
|
138 |
|
|
exit(1);
|
139 |
|
|
}
|
140 |
|
|
for(i = 0; i < 20; i++) {
|
141 |
|
|
send_time(spw);
|
142 |
|
|
}
|
143 |
|
|
for(i = 0; i < 4; i++) {
|
144 |
|
|
while(!(tmp = spw_checktx(spw))) {
|
145 |
|
|
for(j = 0; j < 64; j++) {}
|
146 |
|
|
}
|
147 |
|
|
if (tmp != 1) {
|
148 |
|
|
printf("Transmit error\n");
|
149 |
|
|
exit(1);
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
for(i = 0; i < 4; i++) {
|
153 |
|
|
while(!(tmp = spw_checkrx(size, rxs, spw))) {
|
154 |
|
|
for(j = 0; j < 64; j++) {}
|
155 |
|
|
}
|
156 |
|
|
if (rxs->truncated) {
|
157 |
|
|
printf("Received packet truncated\n");
|
158 |
|
|
exit(1);
|
159 |
|
|
}
|
160 |
|
|
if(rxs->eep) {
|
161 |
|
|
printf("Received packet terminated with eep\n");
|
162 |
|
|
exit(1);
|
163 |
|
|
}
|
164 |
|
|
if (*size != 128) {
|
165 |
|
|
printf("Received packet has wrong length\n");
|
166 |
|
|
exit(1);
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
for(j = 0; j < 128; j++) {
|
170 |
|
|
if (loadb((int)&(rx0[j])) != tx0[j]) {
|
171 |
|
|
printf("Compare error buf 0: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rx0[j])), (unsigned)tx0[j]);
|
172 |
|
|
exit(1);
|
173 |
|
|
}
|
174 |
|
|
if (loadb((int)&(rx1[j])) != tx1[j]) {
|
175 |
|
|
printf("Compare error buf 1: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rx1[j])), (unsigned)tx1[j]);
|
176 |
|
|
exit(1);
|
177 |
|
|
}
|
178 |
|
|
if (loadb((int)&(rx2[j])) != tx2[j]) {
|
179 |
|
|
printf("Compare error buf 2: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rx2[j])), (unsigned)tx2[j]);
|
180 |
|
|
exit(1);
|
181 |
|
|
}
|
182 |
|
|
if (loadb((int)&(rx3[j])) != tx3[j]) {
|
183 |
|
|
printf("Compare error buf 3: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rx3[j])), (unsigned)tx3[j]);
|
184 |
|
|
exit(1);
|
185 |
|
|
}
|
186 |
|
|
}
|
187 |
|
|
if(get_time(spw) != 20) {
|
188 |
|
|
printf("Time-counter has wrong value\n");
|
189 |
|
|
exit(1);
|
190 |
|
|
}
|
191 |
|
|
free(rx0);
|
192 |
|
|
free(rx1);
|
193 |
|
|
free(rx2);
|
194 |
|
|
free(rx3);
|
195 |
|
|
free(tx0);
|
196 |
|
|
free(tx1);
|
197 |
|
|
free(tx2);
|
198 |
|
|
free(tx3);
|
199 |
|
|
printf("Test 1 completed successfully\n");
|
200 |
|
|
/************************ TEST 2 **************************************/
|
201 |
|
|
printf("Test transmission and reception of different sized packets from DMA channel\n");
|
202 |
|
|
if ((txbuf = calloc(PKTTESTMAX, 1)) == NULL) {
|
203 |
|
|
printf("Transmit buffer initialization failed\n");
|
204 |
|
|
exit(1);
|
205 |
|
|
}
|
206 |
|
|
if ((rxbuf = calloc(PKTTESTMAX, 1)) == NULL) {
|
207 |
|
|
printf("Receive buffer initialization failed\n");
|
208 |
|
|
exit(1);
|
209 |
|
|
}
|
210 |
|
|
/*initialize data*/
|
211 |
|
|
for (j = 0; j < PKTTESTMAX; j++) {
|
212 |
|
|
txbuf[j] = (char)j;
|
213 |
|
|
}
|
214 |
|
|
txbuf[0] = 0x14;
|
215 |
|
|
txbuf[1] = 0x2;
|
216 |
|
|
for (i = 2; i < PKTTESTMAX; i++) {
|
217 |
|
|
for (j = 2; j < i; j++) {
|
218 |
|
|
txbuf[j] = ~txbuf[j];
|
219 |
|
|
}
|
220 |
|
|
while (spw_rx(rxbuf, spw)) {
|
221 |
|
|
for (k = 0; k < 64; k++) {}
|
222 |
|
|
}
|
223 |
|
|
if (spw_tx(0, 0, 0, 0, txbuf, i, txbuf, spw)) {
|
224 |
|
|
printf("Transmission failed\n");
|
225 |
|
|
exit(1);
|
226 |
|
|
}
|
227 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
228 |
|
|
for (k = 0; k < 64; k++) {}
|
229 |
|
|
}
|
230 |
|
|
if (tmp != 1) {
|
231 |
|
|
printf("Error in transmit \n");
|
232 |
|
|
exit(1);
|
233 |
|
|
}
|
234 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
235 |
|
|
for (k = 0; k < 64; k++) {}
|
236 |
|
|
}
|
237 |
|
|
if (rxs->truncated) {
|
238 |
|
|
printf("Received packet truncated\n");
|
239 |
|
|
exit(1);
|
240 |
|
|
}
|
241 |
|
|
if(rxs->eep) {
|
242 |
|
|
printf("Received packet terminated with eep\n");
|
243 |
|
|
exit(1);
|
244 |
|
|
}
|
245 |
|
|
if (*size != i) {
|
246 |
|
|
printf("Received packet has wrong length\n");
|
247 |
|
|
printf("Expected: %i, Got: %i \n", i, *size);
|
248 |
|
|
}
|
249 |
|
|
for(j = 0; j < i; j++) {
|
250 |
|
|
if (loadb((int)&(rxbuf[j])) != txbuf[j]) {
|
251 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rxbuf[j])), (unsigned)txbuf[j]);
|
252 |
|
|
//exit(1);
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
// printf("Packet %i transferred\n", i);
|
256 |
|
|
}
|
257 |
|
|
free(rxbuf);
|
258 |
|
|
free(txbuf);
|
259 |
|
|
printf("Test 2 completed successfully\n");
|
260 |
|
|
/************************ TEST 3 **************************************/
|
261 |
|
|
if (spw->rmap || spw->rxunaligned) {
|
262 |
|
|
printf("Test transmission and reception of different sized packets from DMA channel,\n");
|
263 |
|
|
printf("with different alignment,\n");
|
264 |
|
|
if ((txbuf = calloc(PKTTESTMAX, 1)) == NULL) {
|
265 |
|
|
printf("Transmit buffer initialization failed\n");
|
266 |
|
|
exit(1);
|
267 |
|
|
}
|
268 |
|
|
if ((rxbuf = calloc(PKTTESTMAX+4, 1)) == NULL) {
|
269 |
|
|
printf("Receive buffer initialization failed\n");
|
270 |
|
|
exit(1);
|
271 |
|
|
}
|
272 |
|
|
/*initialize data*/
|
273 |
|
|
for (j = 0; j < PKTTESTMAX; j++) {
|
274 |
|
|
txbuf[j] = (char)j;
|
275 |
|
|
}
|
276 |
|
|
txbuf[0] = 0x14;
|
277 |
|
|
txbuf[1] = 0x2;
|
278 |
|
|
for (i = 2; i < PKTTESTMAX; i++) {
|
279 |
|
|
for(m = 1; m < 4; m++) {
|
280 |
|
|
for (j = 2; j < i; j++) {
|
281 |
|
|
txbuf[j] = ~txbuf[j];
|
282 |
|
|
}
|
283 |
|
|
while (spw_rx((char *)&(rxbuf[m]), spw)) {
|
284 |
|
|
for (k = 0; k < 64; k++) {}
|
285 |
|
|
}
|
286 |
|
|
if (spw_tx(0, 0, 0, 0, txbuf, i, txbuf, spw)) {
|
287 |
|
|
printf("Transmission failed\n");
|
288 |
|
|
exit(1);
|
289 |
|
|
}
|
290 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
291 |
|
|
for (k = 0; k < 64; k++) {}
|
292 |
|
|
}
|
293 |
|
|
if (tmp != 1) {
|
294 |
|
|
printf("Error in transmit \n");
|
295 |
|
|
exit(1);
|
296 |
|
|
}
|
297 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
298 |
|
|
for (k = 0; k < 64; k++) {}
|
299 |
|
|
}
|
300 |
|
|
if (rxs->truncated) {
|
301 |
|
|
printf("Received packet truncated\n");
|
302 |
|
|
exit(1);
|
303 |
|
|
}
|
304 |
|
|
if(rxs->eep) {
|
305 |
|
|
printf("Received packet terminated with eep\n");
|
306 |
|
|
exit(1);
|
307 |
|
|
}
|
308 |
|
|
if (*size != i) {
|
309 |
|
|
printf("Received packet has wrong length\n");
|
310 |
|
|
printf("Expected: %i, Got: %i \n", i, *size);
|
311 |
|
|
}
|
312 |
|
|
for(j = 0; j < i; j++) {
|
313 |
|
|
if (loadb((int)&(rxbuf[j+m])) != txbuf[j]) {
|
314 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rxbuf[j+m])), (unsigned)txbuf[j]);
|
315 |
|
|
exit(1);
|
316 |
|
|
}
|
317 |
|
|
}
|
318 |
|
|
// printf("Packet %i transferred of aligment %i\n", i, m);
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
}
|
322 |
|
|
free(rxbuf);
|
323 |
|
|
free(txbuf);
|
324 |
|
|
printf("Test 3 completed successfully\n");
|
325 |
|
|
}
|
326 |
|
|
/************************ TEST 4 **************************************/
|
327 |
|
|
printf("Test transmission of packets with different alignment,\n");
|
328 |
|
|
if ((txbuf = calloc(PKTTESTMAX+4, 1)) == NULL) {
|
329 |
|
|
printf("Transmit buffer initialization failed\n");
|
330 |
|
|
exit(1);
|
331 |
|
|
}
|
332 |
|
|
if ((rxbuf = calloc(PKTTESTMAX+256, 1)) == NULL) {
|
333 |
|
|
printf("Receive buffer initialization failed\n");
|
334 |
|
|
exit(1);
|
335 |
|
|
}
|
336 |
|
|
/*initialize data*/
|
337 |
|
|
for (j = 0; j < PKTTESTMAX+4; j++) {
|
338 |
|
|
txbuf[j] = (char)j;
|
339 |
|
|
}
|
340 |
|
|
for(i = 2; i < PKTTESTMAX; i++) {
|
341 |
|
|
for(m = 0; m < 4; m++) {
|
342 |
|
|
for (j = 2; j < (i+m); j++) {
|
343 |
|
|
txbuf[j] = ~txbuf[j];
|
344 |
|
|
}
|
345 |
|
|
txbuf[m] = 0x14;
|
346 |
|
|
txbuf[m+1] = 0x2;
|
347 |
|
|
while (spw_rx(rxbuf, spw)) {
|
348 |
|
|
for (k = 0; k < 64; k++) {}
|
349 |
|
|
}
|
350 |
|
|
if (spw_tx(0, 0, 0, 0, txbuf, i, (char *)&(txbuf[m]), spw)) {
|
351 |
|
|
printf("Transmission failed\n");
|
352 |
|
|
exit(1);
|
353 |
|
|
}
|
354 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
355 |
|
|
for (k = 0; k < 64; k++) {}
|
356 |
|
|
}
|
357 |
|
|
if (tmp != 1) {
|
358 |
|
|
printf("Error in transmit \n");
|
359 |
|
|
exit(1);
|
360 |
|
|
}
|
361 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
362 |
|
|
for (k = 0; k < 64; k++) {}
|
363 |
|
|
}
|
364 |
|
|
if (rxs->truncated) {
|
365 |
|
|
printf("Received packet truncated\n");
|
366 |
|
|
exit(1);
|
367 |
|
|
}
|
368 |
|
|
if(rxs->eep) {
|
369 |
|
|
printf("Received packet terminated with eep\n");
|
370 |
|
|
exit(1);
|
371 |
|
|
}
|
372 |
|
|
if (*size != i) {
|
373 |
|
|
printf("Received packet has wrong length\n");
|
374 |
|
|
printf("Expected: %i, Got: %i \n", i, *size);
|
375 |
|
|
}
|
376 |
|
|
for(j = 0; j < i; j++) {
|
377 |
|
|
if (loadb((int)&(rxbuf[j])) != txbuf[j+m]) {
|
378 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rxbuf[j])), (unsigned)txbuf[j+m]);
|
379 |
|
|
exit(1);
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
// printf("Packet %i transferred of aligment %i\n", i, m);
|
383 |
|
|
}
|
384 |
|
|
|
385 |
|
|
}
|
386 |
|
|
free(rxbuf);
|
387 |
|
|
free(txbuf);
|
388 |
|
|
printf("Test 4 completed successfully\n");
|
389 |
|
|
/************************ TEST 5 **************************************/
|
390 |
|
|
printf("Test transmission of packets with different alignment, and header\n");
|
391 |
|
|
if ((txbuf = calloc(PKTTESTMAX+4, 1)) == NULL) {
|
392 |
|
|
printf("Transmit buffer initialization failed\n");
|
393 |
|
|
exit(1);
|
394 |
|
|
}
|
395 |
|
|
if ((rxbuf = calloc(PKTTESTMAX+256, 1)) == NULL) {
|
396 |
|
|
printf("Receive buffer initialization failed\n");
|
397 |
|
|
exit(1);
|
398 |
|
|
}
|
399 |
|
|
if ((tx0 = calloc(260, 1)) == NULL) {
|
400 |
|
|
printf("Receive buffer initialization failed\n");
|
401 |
|
|
exit(1);
|
402 |
|
|
}
|
403 |
|
|
/*initialize data*/
|
404 |
|
|
for (j = 0; j < PKTTESTMAX; j++) {
|
405 |
|
|
txbuf[j] = (char)j;
|
406 |
|
|
}
|
407 |
|
|
for (j = 0; j < 260; j++) {
|
408 |
|
|
tx0[j] = (char)~j;
|
409 |
|
|
}
|
410 |
|
|
txbuf[0] = 0x14;
|
411 |
|
|
txbuf[1] = 0x2;
|
412 |
|
|
for(i = 0; i < 256; i++) {
|
413 |
|
|
for(m = 0; m < 4; m++) {
|
414 |
|
|
for (j = 2; j < PKTTESTMAX; j++) {
|
415 |
|
|
txbuf[j] = ~txbuf[j];
|
416 |
|
|
}
|
417 |
|
|
for (j = 0; j < 260; j++) {
|
418 |
|
|
tx0[j] = ~tx0[j];
|
419 |
|
|
}
|
420 |
|
|
tx0[m] = 0x14;
|
421 |
|
|
tx0[m+1] = 0x2;
|
422 |
|
|
while (spw_rx(rxbuf, spw)) {
|
423 |
|
|
for (k = 0; k < 64; k++) {}
|
424 |
|
|
}
|
425 |
|
|
if (spw_tx(0, 0, 0, i,(char *)&(tx0[m]), PKTTESTMAX, txbuf, spw)) {
|
426 |
|
|
printf("Transmission failed\n");
|
427 |
|
|
exit(1);
|
428 |
|
|
}
|
429 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
430 |
|
|
for (k = 0; k < 64; k++) {}
|
431 |
|
|
}
|
432 |
|
|
if (tmp != 1) {
|
433 |
|
|
printf("Error in transmit \n");
|
434 |
|
|
exit(1);
|
435 |
|
|
}
|
436 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
437 |
|
|
for (k = 0; k < 64; k++) {}
|
438 |
|
|
}
|
439 |
|
|
if (rxs->truncated) {
|
440 |
|
|
printf("Received packet truncated\n");
|
441 |
|
|
exit(1);
|
442 |
|
|
}
|
443 |
|
|
if(rxs->eep) {
|
444 |
|
|
printf("Received packet terminated with eep\n");
|
445 |
|
|
exit(1);
|
446 |
|
|
}
|
447 |
|
|
if (*size != (PKTTESTMAX+i)) {
|
448 |
|
|
printf("Received packet has wrong length\n");
|
449 |
|
|
printf("Expected: %i, Got: %i \n", i+PKTTESTMAX, *size);
|
450 |
|
|
}
|
451 |
|
|
for(j = 0; j < i; j++) {
|
452 |
|
|
if (loadb((int)&(rxbuf[j])) != tx0[j+m]) {
|
453 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rxbuf[j])), (unsigned)tx0[j+m]);
|
454 |
|
|
}
|
455 |
|
|
}
|
456 |
|
|
for(j = 0; j < PKTTESTMAX; j++) {
|
457 |
|
|
if (loadb((int)&(rxbuf[j+i])) != txbuf[j]) {
|
458 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", j, (unsigned)loadb((int)&(rxbuf[j+i])), (unsigned)txbuf[j]);
|
459 |
|
|
}
|
460 |
|
|
}
|
461 |
|
|
if (i % 32 == 0 && m == 0)
|
462 |
|
|
printf("Packet %i transferred of aligment %i\n", i, m);
|
463 |
|
|
}
|
464 |
|
|
|
465 |
|
|
}
|
466 |
|
|
free(rxbuf);
|
467 |
|
|
free(txbuf);
|
468 |
|
|
free(tx0);
|
469 |
|
|
printf("Test 5 completed successfully\n");
|
470 |
|
|
/************************ TEST 6 **************************************/
|
471 |
|
|
printf("Test transmission of packets with different alignment, and header\n");
|
472 |
|
|
if ((txbuf = calloc(PKTTESTMAX+4, 1)) == NULL) {
|
473 |
|
|
printf("Transmit buffer initialization failed\n");
|
474 |
|
|
exit(1);
|
475 |
|
|
}
|
476 |
|
|
if ((rxbuf = calloc(PKTTESTMAX+256, 1)) == NULL) {
|
477 |
|
|
printf("Receive buffer initialization failed\n");
|
478 |
|
|
exit(1);
|
479 |
|
|
}
|
480 |
|
|
if ((tx0 = calloc(260, 1)) == NULL) {
|
481 |
|
|
printf("Receive buffer initialization failed\n");
|
482 |
|
|
exit(1);
|
483 |
|
|
}
|
484 |
|
|
/*initialize data*/
|
485 |
|
|
for (j = 0; j < PKTTESTMAX; j++) {
|
486 |
|
|
txbuf[j] = (char)j;
|
487 |
|
|
}
|
488 |
|
|
for (j = 0; j < 260; j++) {
|
489 |
|
|
tx0[j] = (char)~j;
|
490 |
|
|
}
|
491 |
|
|
notrx = 0;
|
492 |
|
|
for(i = 0; i < 256; i++) {
|
493 |
|
|
printf(".");
|
494 |
|
|
// printf("Packet with header %i, alignment: %i and data: %i, alignment: %i transferred\n", i, m, j, l);
|
495 |
|
|
for(j = 0; j < PKTTESTMAX; j++) {
|
496 |
|
|
for(m = 0; m < 4; m++) {
|
497 |
|
|
for(l = 0; l < 4; l++) {
|
498 |
|
|
for (k = 0; k < PKTTESTMAX; k++) {
|
499 |
|
|
txbuf[k] = ~txbuf[k];
|
500 |
|
|
}
|
501 |
|
|
for (k = 0; k < 260; k++) {
|
502 |
|
|
tx0[k] = ~tx0[k];
|
503 |
|
|
}
|
504 |
|
|
tx0[m] = 0x14;
|
505 |
|
|
tx0[m+1] = 0x2;
|
506 |
|
|
txbuf[l] = 0x14;
|
507 |
|
|
txbuf[l+1] = 0x2;
|
508 |
|
|
if (!notrx) {
|
509 |
|
|
while (spw_rx(rxbuf, spw)) {
|
510 |
|
|
for (k = 0; k < 64; k++) {}
|
511 |
|
|
}
|
512 |
|
|
}
|
513 |
|
|
if (spw_tx(0, 0, 0, i,(char *)&(tx0[m]), j, (char *)&(txbuf[l]), spw)) {
|
514 |
|
|
printf("Transmission failed\n");
|
515 |
|
|
exit(1);
|
516 |
|
|
}
|
517 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
518 |
|
|
for (k = 0; k < 64; k++) {}
|
519 |
|
|
}
|
520 |
|
|
if (tmp != 1) {
|
521 |
|
|
printf("Error in transmit \n");
|
522 |
|
|
exit(1);
|
523 |
|
|
}
|
524 |
|
|
if( (i+j) > 1) {
|
525 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
526 |
|
|
for (k = 0; k < 64; k++) {}
|
527 |
|
|
}
|
528 |
|
|
if (rxs->truncated) {
|
529 |
|
|
printf("Received packet truncated\n");
|
530 |
|
|
exit(1);
|
531 |
|
|
}
|
532 |
|
|
if(rxs->eep) {
|
533 |
|
|
printf("Received packet terminated with eep\n");
|
534 |
|
|
exit(1);
|
535 |
|
|
}
|
536 |
|
|
if (*size != (j+i)) {
|
537 |
|
|
printf("Received packet has wrong length\n");
|
538 |
|
|
printf("Expected: %i, Got: %i \n", i+j, *size);
|
539 |
|
|
}
|
540 |
|
|
for(k = 0; k < i; k++) {
|
541 |
|
|
if (loadb((int)&(rxbuf[k])) != tx0[k+m]) {
|
542 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k])), (unsigned)tx0[k+m]);
|
543 |
|
|
exit(1);
|
544 |
|
|
}
|
545 |
|
|
}
|
546 |
|
|
for(k = 0; k < j; k++) {
|
547 |
|
|
if (loadb((int)&(rxbuf[k+i])) != txbuf[k+l]) {
|
548 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k+i])), (unsigned)txbuf[k+l]);
|
549 |
|
|
exit(1);
|
550 |
|
|
}
|
551 |
|
|
}
|
552 |
|
|
notrx = 0;
|
553 |
|
|
} else {
|
554 |
|
|
for(k = 0; k < 1048576; k++) {}
|
555 |
|
|
if (spw_checkrx(size, rxs, spw)) {
|
556 |
|
|
printf("Packet recevied/sent although length was too small\n");
|
557 |
|
|
exit(1);
|
558 |
|
|
}
|
559 |
|
|
notrx = 1;
|
560 |
|
|
}
|
561 |
|
|
}
|
562 |
|
|
|
563 |
|
|
}
|
564 |
|
|
}
|
565 |
|
|
|
566 |
|
|
|
567 |
|
|
|
568 |
|
|
}
|
569 |
|
|
free(rxbuf);
|
570 |
|
|
free(txbuf);
|
571 |
|
|
free(tx0);
|
572 |
|
|
printf("\nTest 6 completed successfully\n");
|
573 |
|
|
/************************ TEST 7 **************************************/
|
574 |
|
|
printf("Test to fill descriptor tables completely\n");
|
575 |
|
|
for(i = 0; i < 64; i++) {
|
576 |
|
|
tx[i] = malloc(DESCPKT);
|
577 |
|
|
}
|
578 |
|
|
for(i = 0; i < 128; i++) {
|
579 |
|
|
rx[i] = malloc(DESCPKT+256);
|
580 |
|
|
}
|
581 |
|
|
txbuf = malloc(256);
|
582 |
|
|
/*initialize data*/
|
583 |
|
|
for(i = 0; i < 64; i++) {
|
584 |
|
|
tx[i][0] = 0x14;
|
585 |
|
|
tx[i][1] = 0x2;
|
586 |
|
|
for(j = 2; j < DESCPKT; j++) {
|
587 |
|
|
tx[i][j] = j ^ i;
|
588 |
|
|
}
|
589 |
|
|
}
|
590 |
|
|
txbuf[0] = 0x14;
|
591 |
|
|
txbuf[1] = 0x2;
|
592 |
|
|
for(i = 2; i < 256; i++) {
|
593 |
|
|
txbuf[i] = i;
|
594 |
|
|
}
|
595 |
|
|
for(i = 0; i < 128; i++) {
|
596 |
|
|
while (spw_rx(rx[i], spw)) {
|
597 |
|
|
for (k = 0; k < 64; k++) {}
|
598 |
|
|
}
|
599 |
|
|
}
|
600 |
|
|
for(i = 0; i < 64; i++) {
|
601 |
|
|
if (spw_tx(0, 0, 0, 255, txbuf, DESCPKT, tx[i], spw)) {
|
602 |
|
|
printf("Transmission failed\n");
|
603 |
|
|
exit(1);
|
604 |
|
|
}
|
605 |
|
|
}
|
606 |
|
|
for(i = 0; i < 64; i++) {
|
607 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
608 |
|
|
for (k = 0; k < 64; k++) {}
|
609 |
|
|
}
|
610 |
|
|
if (tmp != 1) {
|
611 |
|
|
printf("Error in transmit \n");
|
612 |
|
|
exit(1);
|
613 |
|
|
}
|
614 |
|
|
}
|
615 |
|
|
for(i = 0; i < 64; i++) {
|
616 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
617 |
|
|
for (k = 0; k < 64; k++) {}
|
618 |
|
|
}
|
619 |
|
|
if (rxs->truncated) {
|
620 |
|
|
printf("Received packet truncated\n");
|
621 |
|
|
exit(1);
|
622 |
|
|
}
|
623 |
|
|
if(rxs->eep) {
|
624 |
|
|
printf("Received packet terminated with eep\n");
|
625 |
|
|
exit(1);
|
626 |
|
|
}
|
627 |
|
|
if (*size != (255+DESCPKT)) {
|
628 |
|
|
printf("Received packet has wrong length\n");
|
629 |
|
|
printf("Expected: %i, Got: %i \n", 255+DESCPKT, *size);
|
630 |
|
|
}
|
631 |
|
|
for(k = 0; k < 255; k++) {
|
632 |
|
|
if (loadb((int)&(rx[i][k])) != txbuf[k]) {
|
633 |
|
|
printf("Txbuf: %x Rxbuf: %x\n", (int)txbuf, (int)rx[i]);
|
634 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx[i][k])), (unsigned)txbuf[k]);
|
635 |
|
|
exit(1);
|
636 |
|
|
}
|
637 |
|
|
}
|
638 |
|
|
for(k = 0; k < DESCPKT; k++) {
|
639 |
|
|
if (loadb((int)&(rx[i][k+255])) != tx[i][k]) {
|
640 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx[i][k+255])), (unsigned)tx[i][k]);
|
641 |
|
|
exit(1);
|
642 |
|
|
}
|
643 |
|
|
}
|
644 |
|
|
}
|
645 |
|
|
/*second transmit loop*/
|
646 |
|
|
for(i = 0; i < 64; i++) {
|
647 |
|
|
if (spw_tx(0, 0, 0, 255, txbuf, DESCPKT, tx[i], spw)) {
|
648 |
|
|
printf("Transmission failed\n");
|
649 |
|
|
exit(1);
|
650 |
|
|
}
|
651 |
|
|
}
|
652 |
|
|
for(i = 0; i < 64; i++) {
|
653 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
654 |
|
|
for (k = 0; k < 64; k++) {}
|
655 |
|
|
}
|
656 |
|
|
if (tmp != 1) {
|
657 |
|
|
printf("Error in transmit \n");
|
658 |
|
|
exit(1);
|
659 |
|
|
}
|
660 |
|
|
}
|
661 |
|
|
for(i = 0; i < 64; i++) {
|
662 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
663 |
|
|
for (k = 0; k < 64; k++) {}
|
664 |
|
|
}
|
665 |
|
|
if (rxs->truncated) {
|
666 |
|
|
printf("Received packet truncated\n");
|
667 |
|
|
exit(1);
|
668 |
|
|
}
|
669 |
|
|
if(rxs->eep) {
|
670 |
|
|
printf("Received packet terminated with eep\n");
|
671 |
|
|
exit(1);
|
672 |
|
|
}
|
673 |
|
|
if (*size != (255+DESCPKT)) {
|
674 |
|
|
printf("Received packet has wrong length\n");
|
675 |
|
|
printf("Expected: %i, Got: %i \n", 255+DESCPKT, *size);
|
676 |
|
|
}
|
677 |
|
|
for(k = 0; k < 255; k++) {
|
678 |
|
|
if (loadb((int)&(rx[i+64][k])) != txbuf[k]) {
|
679 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx[i][k])), (unsigned)txbuf[k]);
|
680 |
|
|
exit(1);
|
681 |
|
|
}
|
682 |
|
|
}
|
683 |
|
|
for(k = 0; k < DESCPKT; k++) {
|
684 |
|
|
if (loadb((int)&(rx[i+64][k+255])) != tx[i][k]) {
|
685 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k+255])), (unsigned)tx[i][k]);
|
686 |
|
|
exit(1);
|
687 |
|
|
}
|
688 |
|
|
}
|
689 |
|
|
}
|
690 |
|
|
for(i = 0; i < 64; i++) {
|
691 |
|
|
free(tx[i]);
|
692 |
|
|
}
|
693 |
|
|
for(i = 0; i < 128; i++) {
|
694 |
|
|
free(rx[i]);
|
695 |
|
|
}
|
696 |
|
|
free(txbuf);
|
697 |
|
|
printf("Test 7 completed successfully\n");
|
698 |
|
|
/************************ TEST 8 **************************************/
|
699 |
|
|
printf("Test transmission and reception of maximum size packets\n");
|
700 |
|
|
txbuf = malloc(MAXSIZE+1);
|
701 |
|
|
rxbuf = malloc(MAXSIZE);
|
702 |
|
|
if ((rxbuf == NULL) || (txbuf == NULL)) {
|
703 |
|
|
printf("Memory allocation failed\n");
|
704 |
|
|
exit(1);
|
705 |
|
|
}
|
706 |
|
|
txbuf[0] = 0x14;
|
707 |
|
|
txbuf[1] = 0x2;
|
708 |
|
|
for(i = 2; i < MAXSIZE; i++) {
|
709 |
|
|
txbuf[i] = i;
|
710 |
|
|
}
|
711 |
|
|
while (spw_rx(rxbuf, spw)) {
|
712 |
|
|
for (k = 0; k < 64; k++) {}
|
713 |
|
|
}
|
714 |
|
|
spw->rxmaxlen = MAXSIZE;
|
715 |
|
|
if (spw_set_rxmaxlength(spw) ) {
|
716 |
|
|
printf("Max length change failed\n");
|
717 |
|
|
exit(1);
|
718 |
|
|
}
|
719 |
|
|
if (spw_tx(0, 0, 0, 0, txbuf, MAXSIZE, txbuf, spw)) {
|
720 |
|
|
printf("Transmission failed\n");
|
721 |
|
|
exit(1);
|
722 |
|
|
}
|
723 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
724 |
|
|
for (k = 0; k < 64; k++) {}
|
725 |
|
|
}
|
726 |
|
|
if (tmp != 1) {
|
727 |
|
|
printf("Error in transmit \n");
|
728 |
|
|
exit(1);
|
729 |
|
|
}
|
730 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
731 |
|
|
for (k = 0; k < 64; k++) {}
|
732 |
|
|
}
|
733 |
|
|
if (rxs->truncated) {
|
734 |
|
|
printf("Received packet truncated\n");
|
735 |
|
|
exit(1);
|
736 |
|
|
}
|
737 |
|
|
if(rxs->eep) {
|
738 |
|
|
printf("Received packet terminated with eep\n");
|
739 |
|
|
exit(1);
|
740 |
|
|
}
|
741 |
|
|
if (*size != (MAXSIZE)) {
|
742 |
|
|
printf("Received packet has wrong length\n");
|
743 |
|
|
printf("Expected: %i, Got: %i \n", MAXSIZE, *size);
|
744 |
|
|
}
|
745 |
|
|
for(k = 0; k < MAXSIZE; k++) {
|
746 |
|
|
if (loadb((int)&(rxbuf[k])) != txbuf[k]) {
|
747 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k])), (unsigned)txbuf[k]);
|
748 |
|
|
exit(1);
|
749 |
|
|
}
|
750 |
|
|
}
|
751 |
|
|
for(i = 2; i < MAXSIZE; i++) {
|
752 |
|
|
txbuf[i] = ~txbuf[i];
|
753 |
|
|
}
|
754 |
|
|
while (spw_rx(rxbuf, spw)) {
|
755 |
|
|
for (k = 0; k < 64; k++) {}
|
756 |
|
|
}
|
757 |
|
|
if (spw_tx(0, 0, 0, 0, txbuf, MAXSIZE+1, txbuf, spw)) {
|
758 |
|
|
printf("Transmission failed\n");
|
759 |
|
|
exit(1);
|
760 |
|
|
}
|
761 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
762 |
|
|
for (k = 0; k < 64; k++) {}
|
763 |
|
|
}
|
764 |
|
|
if (tmp != 1) {
|
765 |
|
|
printf("Error in transmit \n");
|
766 |
|
|
exit(1);
|
767 |
|
|
}
|
768 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
769 |
|
|
for (k = 0; k < 64; k++) {}
|
770 |
|
|
}
|
771 |
|
|
if (!rxs->truncated) {
|
772 |
|
|
printf("Received packet not truncated\n");
|
773 |
|
|
exit(1);
|
774 |
|
|
}
|
775 |
|
|
if(rxs->eep) {
|
776 |
|
|
printf("Received packet terminated with eep\n");
|
777 |
|
|
exit(1);
|
778 |
|
|
}
|
779 |
|
|
if (*size != (MAXSIZE)) {
|
780 |
|
|
printf("Received packet has wrong length\n");
|
781 |
|
|
printf("Expected: %i, Got: %i \n", MAXSIZE, *size);
|
782 |
|
|
}
|
783 |
|
|
for(k = 0; k < MAXSIZE; k++) {
|
784 |
|
|
if (loadb((int)&(rxbuf[k])) != txbuf[k]) {
|
785 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k])), (unsigned)txbuf[k]);
|
786 |
|
|
exit(1);
|
787 |
|
|
}
|
788 |
|
|
}
|
789 |
|
|
for(i = 2; i < MAXSIZE; i++) {
|
790 |
|
|
txbuf[i] = ~txbuf[i];
|
791 |
|
|
}
|
792 |
|
|
while (spw_rx(rxbuf, spw)) {
|
793 |
|
|
for (k = 0; k < 64; k++) {}
|
794 |
|
|
}
|
795 |
|
|
if (spw_tx(0, 0, 0, 0, txbuf, MAXSIZE, txbuf, spw)) {
|
796 |
|
|
printf("Transmission failed\n");
|
797 |
|
|
exit(1);
|
798 |
|
|
}
|
799 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
800 |
|
|
for (k = 0; k < 64; k++) {}
|
801 |
|
|
}
|
802 |
|
|
if (tmp != 1) {
|
803 |
|
|
printf("Error in transmit \n");
|
804 |
|
|
exit(1);
|
805 |
|
|
}
|
806 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
807 |
|
|
for (k = 0; k < 64; k++) {}
|
808 |
|
|
}
|
809 |
|
|
if (rxs->truncated) {
|
810 |
|
|
printf("Received packet truncated\n");
|
811 |
|
|
exit(1);
|
812 |
|
|
}
|
813 |
|
|
if(rxs->eep) {
|
814 |
|
|
printf("Received packet terminated with eep\n");
|
815 |
|
|
exit(1);
|
816 |
|
|
}
|
817 |
|
|
if (*size != (MAXSIZE)) {
|
818 |
|
|
printf("Received packet has wrong length\n");
|
819 |
|
|
printf("Expected: %i, Got: %i \n", MAXSIZE, *size);
|
820 |
|
|
}
|
821 |
|
|
for(k = 0; k < MAXSIZE; k++) {
|
822 |
|
|
if (loadb((int)&(rxbuf[k])) != txbuf[k]) {
|
823 |
|
|
printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k])), (unsigned)txbuf[k]);
|
824 |
|
|
exit(1);
|
825 |
|
|
}
|
826 |
|
|
}
|
827 |
|
|
free(rxbuf);
|
828 |
|
|
free(txbuf);
|
829 |
|
|
printf("Test 8 completed successfully\n");
|
830 |
|
|
/************************ TEST 9 **************************************/
|
831 |
|
|
/* printf("Test crc\n"); */
|
832 |
|
|
/* if (spw->rmap || spw->rmapcrc) { */
|
833 |
|
|
/* printf("Test transmission of packets with different alignment, and header\n"); */
|
834 |
|
|
/* if ((txbuf = calloc(PKTTESTMAX+4, 1)) == NULL) { */
|
835 |
|
|
/* printf("Transmit buffer initialization failed\n"); */
|
836 |
|
|
/* exit(1); */
|
837 |
|
|
/* } */
|
838 |
|
|
/* if ((rxbuf = calloc(PKTTESTMAX+256+2, 1)) == NULL) { */
|
839 |
|
|
/* printf("Receive buffer initialization failed\n"); */
|
840 |
|
|
/* exit(1); */
|
841 |
|
|
/* } */
|
842 |
|
|
/* if ((tx0 = calloc(260, 1)) == NULL) { */
|
843 |
|
|
/* printf("Receive buffer initialization failed\n"); */
|
844 |
|
|
/* exit(1); */
|
845 |
|
|
/* } */
|
846 |
|
|
/* /\*initialize data*\/ */
|
847 |
|
|
/* for (j = 0; j < PKTTESTMAX; j++) { */
|
848 |
|
|
/* txbuf[j] = (char)j; */
|
849 |
|
|
/* } */
|
850 |
|
|
/* for (j = 0; j < 260; j++) { */
|
851 |
|
|
/* tx0[j] = (char)~j; */
|
852 |
|
|
/* } */
|
853 |
|
|
/* notrx = 0; data = 0; hdr = 0; */
|
854 |
|
|
/* for(i = 0; i < 256; i++) { */
|
855 |
|
|
/* // printf("Packet with header %i, alignment: %i and data: %i, alignment: %i transferred\n", i, m, j, l); */
|
856 |
|
|
/* for(j = 0; j < PKTTESTMAX; j++) { */
|
857 |
|
|
/* for(m = 0; m < 4; m++) { */
|
858 |
|
|
/* for(l = 0; l < 4; l++) { */
|
859 |
|
|
/* for (k = 0; k < PKTTESTMAX; k++) { */
|
860 |
|
|
/* txbuf[k] = ~txbuf[k]; */
|
861 |
|
|
/* } */
|
862 |
|
|
/* for (k = 0; k < 260; k++) { */
|
863 |
|
|
/* tx0[k] = ~tx0[k]; */
|
864 |
|
|
/* } */
|
865 |
|
|
/* if (i != 0) { */
|
866 |
|
|
/* hdr = 1; */
|
867 |
|
|
/* } else { */
|
868 |
|
|
/* hdr = 0; */
|
869 |
|
|
/* } */
|
870 |
|
|
/* if (j != 0) { */
|
871 |
|
|
/* data = 1; */
|
872 |
|
|
|
873 |
|
|
/* } else { */
|
874 |
|
|
/* data = 0; */
|
875 |
|
|
/* } */
|
876 |
|
|
/* tx0[m] = 0x14; */
|
877 |
|
|
/* tx0[m+1] = 0x2; */
|
878 |
|
|
/* txbuf[l] = 0x14; */
|
879 |
|
|
/* txbuf[l+1] = 0x2; */
|
880 |
|
|
/* if (!notrx) { */
|
881 |
|
|
/* while (spw_rx(rxbuf, spw)) { */
|
882 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
883 |
|
|
/* } */
|
884 |
|
|
/* } */
|
885 |
|
|
/* if (spw_tx(1, 1, 0, i,(char *)&(tx0[m]), j, (char *)&(txbuf[l]), spw)) { */
|
886 |
|
|
/* printf("Transmission failed\n"); */
|
887 |
|
|
/* exit(1); */
|
888 |
|
|
/* } */
|
889 |
|
|
/* while (!(tmp = spw_checktx(spw))) { */
|
890 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
891 |
|
|
/* } */
|
892 |
|
|
/* if (tmp != 1) { */
|
893 |
|
|
/* printf("Error in transmit \n"); */
|
894 |
|
|
/* exit(1); */
|
895 |
|
|
/* } */
|
896 |
|
|
/* if( (i+j+hdr+data) > 1) { */
|
897 |
|
|
/* while (!(tmp = spw_checkrx(size, rxs, spw))) { */
|
898 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
899 |
|
|
/* } */
|
900 |
|
|
/* if (rxs->truncated) { */
|
901 |
|
|
/* printf("Received packet truncated\n"); */
|
902 |
|
|
/* exit(1); */
|
903 |
|
|
/* } */
|
904 |
|
|
/* if(rxs->eep) { */
|
905 |
|
|
/* printf("Received packet terminated with eep\n"); */
|
906 |
|
|
/* exit(1); */
|
907 |
|
|
/* } */
|
908 |
|
|
/* if (*size != (j+i+hdr+data)) { */
|
909 |
|
|
/* printf("Received packet has wrong length\n"); */
|
910 |
|
|
/* printf("Expected: %i, Got: %i \n", i+j, *size); */
|
911 |
|
|
/* } */
|
912 |
|
|
/* for(k = 0; k < i; k++) { */
|
913 |
|
|
/* if (loadb((int)&(rxbuf[k])) != tx0[k+m]) { */
|
914 |
|
|
/* printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k])), (unsigned)tx0[k+m]); */
|
915 |
|
|
/* exit(1); */
|
916 |
|
|
/* } */
|
917 |
|
|
/* } */
|
918 |
|
|
/* for(k = 0; k < j; k++) { */
|
919 |
|
|
/* if (loadb((int)&(rxbuf[k+i+hdr])) != txbuf[k+l]) { */
|
920 |
|
|
/* printf("Compare error: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rxbuf[k+i+hdr])), (unsigned)txbuf[k+l]); */
|
921 |
|
|
/* exit(1); */
|
922 |
|
|
/* } */
|
923 |
|
|
/* } */
|
924 |
|
|
/* notrx = 0; */
|
925 |
|
|
/* } else { */
|
926 |
|
|
/* for(k = 0; k < 1048576; k++) {} */
|
927 |
|
|
/* if (spw_checkrx(size, rxs, spw)) { */
|
928 |
|
|
/* printf("Packet recevied/sent although length was too small\n"); */
|
929 |
|
|
/* exit(1); */
|
930 |
|
|
/* } */
|
931 |
|
|
/* notrx = 1; */
|
932 |
|
|
/* } */
|
933 |
|
|
/* } */
|
934 |
|
|
|
935 |
|
|
/* } */
|
936 |
|
|
/* } */
|
937 |
|
|
|
938 |
|
|
|
939 |
|
|
|
940 |
|
|
/* } */
|
941 |
|
|
/* free(rxbuf); */
|
942 |
|
|
/* free(txbuf); */
|
943 |
|
|
/* free(tx0); */
|
944 |
|
|
/* printf("Test 9 completed successfully\n"); */
|
945 |
|
|
/* } */
|
946 |
|
|
/************************ TEST 10 **************************************/
|
947 |
|
|
if (spw->rmap == 1) {
|
948 |
|
|
printf("Test RMAP, including transmit spa test\n");
|
949 |
|
|
tx0 = (char *)malloc(64);
|
950 |
|
|
tx1 = (char *)calloc(RMAPSIZE, 1);
|
951 |
|
|
rx0 = (char *)malloc(RMAPSIZE+4);
|
952 |
|
|
rx1 = (char *)malloc(32+RMAPSIZE);
|
953 |
|
|
rx2 = (char *)malloc(32+RMAPSIZE);
|
954 |
|
|
if( (tx0 == NULL) || (tx1 == NULL) || (rx0 == NULL) ||
|
955 |
|
|
(rx1 == NULL) || (rx2 == NULL) ) {
|
956 |
|
|
printf("Memory initialization error\n");
|
957 |
|
|
exit(1);
|
958 |
|
|
}
|
959 |
|
|
cmd = (struct rmap_pkt *) malloc(sizeof(struct rmap_pkt));
|
960 |
|
|
reply = (struct rmap_pkt *) malloc(sizeof(struct rmap_pkt));
|
961 |
|
|
cmdsize = (int *) malloc(sizeof(int));
|
962 |
|
|
replysize = (int *) malloc(sizeof(int));
|
963 |
|
|
/* enable rmap*/
|
964 |
|
|
spw_rmapen(spw);
|
965 |
|
|
for(i = 0; i < RMAPSIZE; i++) {
|
966 |
|
|
for(m = 0; m < 8; m++) {
|
967 |
|
|
for(j = 0; j < i; j++) {
|
968 |
|
|
tx1[j] = ~tx1[j];
|
969 |
|
|
}
|
970 |
|
|
if (m >= 4) {
|
971 |
|
|
cmd->incr = no;
|
972 |
|
|
} else {
|
973 |
|
|
cmd->incr = yes;
|
974 |
|
|
}
|
975 |
|
|
cmd->type = writecmd;
|
976 |
|
|
cmd->verify = no;
|
977 |
|
|
cmd->ack = yes;
|
978 |
|
|
cmd->destaddr = 0x14;
|
979 |
|
|
cmd->destkey = 0xBF;
|
980 |
|
|
cmd->srcaddr = 0x14;
|
981 |
|
|
cmd->tid = i;
|
982 |
|
|
cmd->addr = (int)&(rx0[(m%4)]);
|
983 |
|
|
cmd->len = i;
|
984 |
|
|
cmd->status = 0;
|
985 |
|
|
cmd->dstspalen = 0;
|
986 |
|
|
cmd->dstspa = (char *)NULL;
|
987 |
|
|
cmd->srcspalen = 0;
|
988 |
|
|
cmd->srcspa = (char *)NULL;
|
989 |
|
|
if (build_rmap_hdr(cmd, tx0, cmdsize)) {
|
990 |
|
|
printf("RMAP cmd build failed\n");
|
991 |
|
|
exit(1);
|
992 |
|
|
}
|
993 |
|
|
reply->type = writerep;
|
994 |
|
|
reply->verify = no;
|
995 |
|
|
reply->ack = yes;
|
996 |
|
|
if (m >= 4) {
|
997 |
|
|
reply->incr = no;
|
998 |
|
|
if ( ((((int)&(rx0[(m%4)])) % 4) != 0) || ((cmd->len % 4) != 0) ) {
|
999 |
|
|
reply->status = 10;
|
1000 |
|
|
} else {
|
1001 |
|
|
reply->status = 0;
|
1002 |
|
|
}
|
1003 |
|
|
} else {
|
1004 |
|
|
reply->incr = yes;
|
1005 |
|
|
reply->status = 0;
|
1006 |
|
|
}
|
1007 |
|
|
reply->destaddr = 0x14;
|
1008 |
|
|
reply->destkey = 0XBF;
|
1009 |
|
|
reply->srcaddr = 0x14;
|
1010 |
|
|
reply->tid = i;
|
1011 |
|
|
reply->addr = (int)&(rx0[(m%4)]);
|
1012 |
|
|
reply->len = i;
|
1013 |
|
|
reply->dstspalen = 0;
|
1014 |
|
|
reply->dstspa = (char *)NULL;
|
1015 |
|
|
reply->srcspalen = 0;
|
1016 |
|
|
reply->srcspa = (char *)NULL;
|
1017 |
|
|
if (build_rmap_hdr(reply, rx2, replysize)) {
|
1018 |
|
|
printf("RMAP reply build failed\n");
|
1019 |
|
|
exit(1);
|
1020 |
|
|
}
|
1021 |
|
|
while (spw_rx(rx1, spw)) {
|
1022 |
|
|
for (k = 0; k < 64; k++) {}
|
1023 |
|
|
}
|
1024 |
|
|
if (spw_tx(1, 1, 0, *cmdsize, tx0, j, tx1, spw)) {
|
1025 |
|
|
printf("Transmission failed\n");
|
1026 |
|
|
exit(1);
|
1027 |
|
|
}
|
1028 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
1029 |
|
|
for (k = 0; k < 64; k++) {}
|
1030 |
|
|
}
|
1031 |
|
|
if (tmp != 1) {
|
1032 |
|
|
printf("Error in transmit \n");
|
1033 |
|
|
exit(1);
|
1034 |
|
|
}
|
1035 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
1036 |
|
|
for (k = 0; k < 64; k++) {}
|
1037 |
|
|
}
|
1038 |
|
|
if (rxs->truncated) {
|
1039 |
|
|
printf("Received packet truncated\n");
|
1040 |
|
|
exit(1);
|
1041 |
|
|
}
|
1042 |
|
|
if(rxs->eep) {
|
1043 |
|
|
printf("Received packet terminated with eep\n");
|
1044 |
|
|
exit(1);
|
1045 |
|
|
}
|
1046 |
|
|
if(rxs->hcrcerr) {
|
1047 |
|
|
printf("Received packet header crc error detected\n");
|
1048 |
|
|
exit(1);
|
1049 |
|
|
}
|
1050 |
|
|
if(rxs->dcrcerr) {
|
1051 |
|
|
printf("Received packet data crc error detected\n");
|
1052 |
|
|
exit(1);
|
1053 |
|
|
}
|
1054 |
|
|
if (*size != (*replysize+1)) {
|
1055 |
|
|
printf("Received packet has wrong length\n");
|
1056 |
|
|
printf("Expected: %i, Got: %i \n", *replysize+1, *size);
|
1057 |
|
|
}
|
1058 |
|
|
for(k = 0; k < *replysize; k++) {
|
1059 |
|
|
if (loadb((int)&(rx1[k])) != rx2[k]) {
|
1060 |
|
|
printf("Compare error 0: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)rx2[k]);
|
1061 |
|
|
exit(1);
|
1062 |
|
|
}
|
1063 |
|
|
}
|
1064 |
|
|
if (reply->status == 0) {
|
1065 |
|
|
if (m < 4) {
|
1066 |
|
|
for(k = 0; k < i; k++) {
|
1067 |
|
|
if (loadb((int)&(rx0[k+(m%4)])) != tx1[k]) {
|
1068 |
|
|
printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx0[k+(m%4)])), (unsigned)tx1[k]);
|
1069 |
|
|
exit(1);
|
1070 |
|
|
}
|
1071 |
|
|
}
|
1072 |
|
|
} else {
|
1073 |
|
|
if (i != 0) {
|
1074 |
|
|
for(k = 0; k < 4; k++) {
|
1075 |
|
|
if (loadb((int)&(rx0[k+(m%4)])) != tx1[k + (i - 4)]) {
|
1076 |
|
|
printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx0[k+(m%4)])), (unsigned)tx1[k+(i-4)]);
|
1077 |
|
|
exit(1);
|
1078 |
|
|
}
|
1079 |
|
|
}
|
1080 |
|
|
}
|
1081 |
|
|
}
|
1082 |
|
|
}
|
1083 |
|
|
if ((i % 512) == 0) {
|
1084 |
|
|
printf("Packet %i, alignment %i\n", i, m);
|
1085 |
|
|
}
|
1086 |
|
|
}
|
1087 |
|
|
}
|
1088 |
|
|
printf("Non-verified write test passed\n");
|
1089 |
|
|
for(i = 0; i < 64; i++) {
|
1090 |
|
|
for(m = 0; m < 8; m++) {
|
1091 |
|
|
for(j = 0; j < i; j++) {
|
1092 |
|
|
tx1[j] = ~tx1[j];
|
1093 |
|
|
}
|
1094 |
|
|
if (m >= 4) {
|
1095 |
|
|
cmd->incr = no;
|
1096 |
|
|
} else {
|
1097 |
|
|
cmd->incr = yes;
|
1098 |
|
|
}
|
1099 |
|
|
cmd->type = writecmd;
|
1100 |
|
|
cmd->verify = yes;
|
1101 |
|
|
cmd->ack = yes;
|
1102 |
|
|
cmd->destaddr = 0x14;
|
1103 |
|
|
cmd->destkey = 0xBF;
|
1104 |
|
|
cmd->srcaddr = 0x14;
|
1105 |
|
|
cmd->tid = i;
|
1106 |
|
|
cmd->addr = (int)&(rx0[(m%4)]);
|
1107 |
|
|
cmd->len = i;
|
1108 |
|
|
cmd->status = 0;
|
1109 |
|
|
cmd->dstspalen = 0;
|
1110 |
|
|
cmd->dstspa = (char *)NULL;
|
1111 |
|
|
cmd->srcspalen = 0;
|
1112 |
|
|
cmd->srcspa = (char *)NULL;
|
1113 |
|
|
if (build_rmap_hdr(cmd, tx0, cmdsize)) {
|
1114 |
|
|
printf("RMAP cmd build failed\n");
|
1115 |
|
|
exit(1);
|
1116 |
|
|
}
|
1117 |
|
|
reply->type = writerep;
|
1118 |
|
|
reply->verify = yes;
|
1119 |
|
|
reply->ack = yes;
|
1120 |
|
|
if (m >= 4) {
|
1121 |
|
|
reply->incr = no;
|
1122 |
|
|
|
1123 |
|
|
} else {
|
1124 |
|
|
reply->incr = yes;
|
1125 |
|
|
}
|
1126 |
|
|
if ( (((((int)&(rx0[(m%4)])) % 2) != 0) && (cmd->len == 2)) ||
|
1127 |
|
|
(((((int)&(rx0[(m%4)])) % 4) != 0) && (cmd->len == 4)) ||
|
1128 |
|
|
(cmd->len == 3) ) {
|
1129 |
|
|
reply->status = 10;
|
1130 |
|
|
} else {
|
1131 |
|
|
reply->status = 0;
|
1132 |
|
|
}
|
1133 |
|
|
if (cmd->len > 4) {
|
1134 |
|
|
reply->status = 9;
|
1135 |
|
|
|
1136 |
|
|
}
|
1137 |
|
|
reply->destaddr = 0x14;
|
1138 |
|
|
reply->destkey = 0XBF;
|
1139 |
|
|
reply->srcaddr = 0x14;
|
1140 |
|
|
reply->tid = i;
|
1141 |
|
|
reply->addr = (int)&(rx0[(m%4)]);
|
1142 |
|
|
reply->len = i;
|
1143 |
|
|
reply->dstspalen = 0;
|
1144 |
|
|
reply->dstspa = (char *)NULL;
|
1145 |
|
|
reply->srcspalen = 0;
|
1146 |
|
|
reply->srcspa = (char *)NULL;
|
1147 |
|
|
if (build_rmap_hdr(reply, rx2, replysize)) {
|
1148 |
|
|
printf("RMAP reply build failed\n");
|
1149 |
|
|
exit(1);
|
1150 |
|
|
}
|
1151 |
|
|
while (spw_rx(rx1, spw)) {
|
1152 |
|
|
for (k = 0; k < 64; k++) {}
|
1153 |
|
|
}
|
1154 |
|
|
if (spw_tx(1, 1, 0, *cmdsize, tx0, j, tx1, spw)) {
|
1155 |
|
|
printf("Transmission failed\n");
|
1156 |
|
|
exit(1);
|
1157 |
|
|
}
|
1158 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
1159 |
|
|
for (k = 0; k < 64; k++) {}
|
1160 |
|
|
}
|
1161 |
|
|
if (tmp != 1) {
|
1162 |
|
|
printf("Error in transmit \n");
|
1163 |
|
|
exit(1);
|
1164 |
|
|
}
|
1165 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
1166 |
|
|
for (k = 0; k < 64; k++) {}
|
1167 |
|
|
}
|
1168 |
|
|
if (rxs->truncated) {
|
1169 |
|
|
printf("Received packet truncated\n");
|
1170 |
|
|
exit(1);
|
1171 |
|
|
}
|
1172 |
|
|
if(rxs->eep) {
|
1173 |
|
|
printf("Received packet terminated with eep\n");
|
1174 |
|
|
exit(1);
|
1175 |
|
|
}
|
1176 |
|
|
if(rxs->hcrcerr) {
|
1177 |
|
|
printf("Received packet header crc error detected\n");
|
1178 |
|
|
exit(1);
|
1179 |
|
|
}
|
1180 |
|
|
if(rxs->dcrcerr) {
|
1181 |
|
|
printf("Received packet data crc error detected\n");
|
1182 |
|
|
exit(1);
|
1183 |
|
|
}
|
1184 |
|
|
if (*size != (*replysize+1)) {
|
1185 |
|
|
printf("Received packet has wrong length\n");
|
1186 |
|
|
printf("Expected: %i, Got: %i \n", *replysize+1, *size);
|
1187 |
|
|
exit(1);
|
1188 |
|
|
}
|
1189 |
|
|
for(k = 0; k < *replysize; k++) {
|
1190 |
|
|
if (loadb((int)&(rx1[k])) != rx2[k]) {
|
1191 |
|
|
printf("Compare error 0: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)rx2[k]);
|
1192 |
|
|
exit(1);
|
1193 |
|
|
}
|
1194 |
|
|
}
|
1195 |
|
|
if (reply->status == 0) {
|
1196 |
|
|
for(k = 0; k < i; k++) {
|
1197 |
|
|
if (loadb((int)&(rx0[k+(m%4)])) != tx1[k]) {
|
1198 |
|
|
printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx0[k+(m%4)])), (unsigned)tx1[k]);
|
1199 |
|
|
exit(1);
|
1200 |
|
|
}
|
1201 |
|
|
}
|
1202 |
|
|
|
1203 |
|
|
}
|
1204 |
|
|
if (((i % 4) == 0) && ((m % 8) == 0)) {
|
1205 |
|
|
printf("Packet %i, alignment %i\n", i, m);
|
1206 |
|
|
}
|
1207 |
|
|
}
|
1208 |
|
|
}
|
1209 |
|
|
printf("Verified write test passed\n");
|
1210 |
|
|
|
1211 |
|
|
/* for(i = 0; i < 64; i++) { */
|
1212 |
|
|
/* for(m = 0; m < 8; m++) { */
|
1213 |
|
|
/* for(j = 0; j < i; j++) { */
|
1214 |
|
|
/* tx1[j] = ~tx1[j]; */
|
1215 |
|
|
/* } */
|
1216 |
|
|
/* if (m >= 4) { */
|
1217 |
|
|
/* cmd->incr = no; */
|
1218 |
|
|
/* } else { */
|
1219 |
|
|
/* cmd->incr = yes; */
|
1220 |
|
|
/* } */
|
1221 |
|
|
/* cmd->type = rmwcmd; */
|
1222 |
|
|
/* cmd->verify = yes; */
|
1223 |
|
|
/* cmd->ack = yes; */
|
1224 |
|
|
/* cmd->destaddr = 0x14; */
|
1225 |
|
|
/* cmd->destkey = 0xBF; */
|
1226 |
|
|
/* cmd->srcaddr = 0x14; */
|
1227 |
|
|
/* cmd->tid = i; */
|
1228 |
|
|
/* cmd->addr = (int)&(rx0[(m%4)]); */
|
1229 |
|
|
/* cmd->len = i; */
|
1230 |
|
|
/* cmd->status = 0; */
|
1231 |
|
|
/* cmd->dstspalen = 0; */
|
1232 |
|
|
/* cmd->dstspa = (char *)NULL; */
|
1233 |
|
|
/* cmd->srcspalen = 0; */
|
1234 |
|
|
/* cmd->srcspa = (char *)NULL; */
|
1235 |
|
|
/* if (build_rmap_hdr(cmd, tx0, cmdsize)) { */
|
1236 |
|
|
/* printf("RMAP cmd build failed\n"); */
|
1237 |
|
|
/* exit(1); */
|
1238 |
|
|
/* } */
|
1239 |
|
|
/* reply->type = rmwrep; */
|
1240 |
|
|
/* reply->verify = yes; */
|
1241 |
|
|
/* reply->ack = yes; */
|
1242 |
|
|
/* if (m >= 4) { */
|
1243 |
|
|
/* reply->incr = no; */
|
1244 |
|
|
|
1245 |
|
|
/* } else { */
|
1246 |
|
|
/* reply->incr = yes; */
|
1247 |
|
|
/* } */
|
1248 |
|
|
/* if ( (((((int)&(rx0[(m%4)])) % 2) != 0) && ((cmd->len/2) == 2)) || */
|
1249 |
|
|
/* (((((int)&(rx0[(m%4)])) % 4) != 0) && ((cmd->len/2) == 4)) || */
|
1250 |
|
|
/* ((cmd->len/2) == 3) ) { */
|
1251 |
|
|
/* reply->status = 10; */
|
1252 |
|
|
/* } else { */
|
1253 |
|
|
/* reply->status = 0; */
|
1254 |
|
|
/* } */
|
1255 |
|
|
/* if ( (cmd->len != 0) && (cmd->len != 2) && (cmd->len != 4) && */
|
1256 |
|
|
/* (cmd->len != 6) && (cmd->len != 8)) { */
|
1257 |
|
|
/* reply->status = 11; */
|
1258 |
|
|
/* } */
|
1259 |
|
|
/* if (m >= 4) { */
|
1260 |
|
|
/* reply->status = 2; */
|
1261 |
|
|
/* } */
|
1262 |
|
|
/* if (reply->status == 0) { */
|
1263 |
|
|
/* for(k = 0; k < (i/2); k++) { */
|
1264 |
|
|
/* rx2[*replysize+1+k] = rx0[k+m]; */
|
1265 |
|
|
/* } */
|
1266 |
|
|
/* } */
|
1267 |
|
|
/* reply->destaddr = 0x14; */
|
1268 |
|
|
/* reply->destkey = 0XBF; */
|
1269 |
|
|
/* reply->srcaddr = 0x14; */
|
1270 |
|
|
/* reply->tid = i; */
|
1271 |
|
|
/* reply->addr = (int)&(rx0[(m%4)]); */
|
1272 |
|
|
/* if (reply->status == 0) { */
|
1273 |
|
|
/* reply->len = (i/2); */
|
1274 |
|
|
/* } else { */
|
1275 |
|
|
/* reply->len = 0; */
|
1276 |
|
|
/* } */
|
1277 |
|
|
/* reply->dstspalen = 0; */
|
1278 |
|
|
/* reply->dstspa = (char *)NULL; */
|
1279 |
|
|
/* reply->srcspalen = 0; */
|
1280 |
|
|
/* reply->srcspa = (char *)NULL; */
|
1281 |
|
|
/* if (build_rmap_hdr(reply, rx2, replysize)) { */
|
1282 |
|
|
/* printf("RMAP reply build failed\n"); */
|
1283 |
|
|
/* exit(1); */
|
1284 |
|
|
/* } */
|
1285 |
|
|
/* while (spw_rx(rx1, spw)) { */
|
1286 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1287 |
|
|
/* } */
|
1288 |
|
|
/* if (spw_tx(1, 1, 0, *cmdsize, tx0, j, tx1, spw)) { */
|
1289 |
|
|
/* printf("Transmission failed\n"); */
|
1290 |
|
|
/* exit(1); */
|
1291 |
|
|
/* } */
|
1292 |
|
|
/* while (!(tmp = spw_checktx(spw))) { */
|
1293 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1294 |
|
|
/* } */
|
1295 |
|
|
/* if (tmp != 1) { */
|
1296 |
|
|
/* printf("Error in transmit \n"); */
|
1297 |
|
|
/* exit(1); */
|
1298 |
|
|
/* } */
|
1299 |
|
|
/* while (!(tmp = spw_checkrx(size, rxs, spw))) { */
|
1300 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1301 |
|
|
/* } */
|
1302 |
|
|
/* if (rxs->truncated) { */
|
1303 |
|
|
/* printf("Received packet truncated\n"); */
|
1304 |
|
|
/* exit(1); */
|
1305 |
|
|
/* } */
|
1306 |
|
|
/* if(rxs->eep) { */
|
1307 |
|
|
/* printf("Received packet terminated with eep\n"); */
|
1308 |
|
|
/* exit(1); */
|
1309 |
|
|
/* } */
|
1310 |
|
|
/* if(rxs->hcrcerr) { */
|
1311 |
|
|
/* printf("Received packet header crc error detected\n"); */
|
1312 |
|
|
/* exit(1); */
|
1313 |
|
|
/* } */
|
1314 |
|
|
/* if(rxs->dcrcerr) { */
|
1315 |
|
|
/* printf("Received packet data crc error detected\n"); */
|
1316 |
|
|
/* exit(1); */
|
1317 |
|
|
/* } */
|
1318 |
|
|
/* if ((reply->status == 0) && (i != 0)) { */
|
1319 |
|
|
/* if (*size != (*replysize+1+(i/2)+1)) { */
|
1320 |
|
|
/* printf("Received packet has wrong length\n"); */
|
1321 |
|
|
/* printf("Expected: %i, Got: %i \n", *replysize+2+(i/2), *size); */
|
1322 |
|
|
/* exit(1); */
|
1323 |
|
|
/* } */
|
1324 |
|
|
/* } else { */
|
1325 |
|
|
/* if (*size != (*replysize+1)) { */
|
1326 |
|
|
/* printf("Received packet has wrong length\n"); */
|
1327 |
|
|
/* printf("Expected: %i, Got: %i \n", *replysize+1, *size); */
|
1328 |
|
|
/* exit(1); */
|
1329 |
|
|
/* } */
|
1330 |
|
|
/* } */
|
1331 |
|
|
/* for(k = 0; k < *replysize; k++) { */
|
1332 |
|
|
/* if (loadb((int)&(rx1[k])) != rx2[k]) { */
|
1333 |
|
|
/* printf("Compare error 0: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)rx2[k]); */
|
1334 |
|
|
/* exit(1); */
|
1335 |
|
|
/* } */
|
1336 |
|
|
/* } */
|
1337 |
|
|
/* if (reply->status == 0) { */
|
1338 |
|
|
/* for(k = *replysize+1; k < *replysize+1+(i/2); k++) { */
|
1339 |
|
|
/* if (loadb((int)&(rx1[k])) != rx2[k]) { */
|
1340 |
|
|
/* printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)rx2[k]); */
|
1341 |
|
|
/* exit(1); */
|
1342 |
|
|
/* } */
|
1343 |
|
|
/* } */
|
1344 |
|
|
/* for(k = 0; k < (i/2); k++) { */
|
1345 |
|
|
/* if (loadb((int)&(rx0[k+(m%4)])) != ((tx1[k] & tx1[k+(i/2)]) | (rx2[*replysize+1+k] & ~tx1[k+(i/2)]) )) { */
|
1346 |
|
|
/* printf("Compare error 2: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx0[k+(m%4)])), (unsigned)tx1[k]); */
|
1347 |
|
|
/* exit(1); */
|
1348 |
|
|
/* } */
|
1349 |
|
|
/* } */
|
1350 |
|
|
|
1351 |
|
|
/* } */
|
1352 |
|
|
/* if (((i % 4) == 0) && ((m % 8) == 0)) { */
|
1353 |
|
|
/* printf("Packet %i, alignment %i\n", i, m); */
|
1354 |
|
|
/* } */
|
1355 |
|
|
/* } */
|
1356 |
|
|
/* } */
|
1357 |
|
|
/* printf("RMW test passed\n"); */
|
1358 |
|
|
|
1359 |
|
|
/* for(i = 0; i < RMAPSIZE; i++) { */
|
1360 |
|
|
/* for(m = 0; m < 8; m++) { */
|
1361 |
|
|
/* for(j = 0; j < i+4; j++) { */
|
1362 |
|
|
/* rx0[j] = ~rx0[j]; */
|
1363 |
|
|
/* } */
|
1364 |
|
|
/* if (m >= 4) { */
|
1365 |
|
|
/* cmd->incr = no; */
|
1366 |
|
|
/* } else { */
|
1367 |
|
|
/* cmd->incr = yes; */
|
1368 |
|
|
/* } */
|
1369 |
|
|
/* cmd->type = readcmd; */
|
1370 |
|
|
/* cmd->verify = no; */
|
1371 |
|
|
/* cmd->ack = yes; */
|
1372 |
|
|
/* cmd->destaddr = 0x14; */
|
1373 |
|
|
/* cmd->destkey = 0xBF; */
|
1374 |
|
|
/* cmd->srcaddr = 0x14; */
|
1375 |
|
|
/* cmd->tid = i; */
|
1376 |
|
|
/* cmd->addr = (int)&(rx0[(m%4)]); */
|
1377 |
|
|
/* cmd->len = i; */
|
1378 |
|
|
/* cmd->status = 0; */
|
1379 |
|
|
/* cmd->dstspalen = 0; */
|
1380 |
|
|
/* cmd->dstspa = (char *)NULL; */
|
1381 |
|
|
/* cmd->srcspalen = 0; */
|
1382 |
|
|
/* cmd->srcspa = (char *)NULL; */
|
1383 |
|
|
/* if (build_rmap_hdr(cmd, tx0, cmdsize)) { */
|
1384 |
|
|
/* printf("RMAP cmd build failed\n"); */
|
1385 |
|
|
/* exit(1); */
|
1386 |
|
|
/* } */
|
1387 |
|
|
/* reply->type = readrep; */
|
1388 |
|
|
/* reply->verify = no; */
|
1389 |
|
|
/* reply->ack = yes; */
|
1390 |
|
|
/* if (m >= 4) { */
|
1391 |
|
|
/* reply->incr = no; */
|
1392 |
|
|
/* if ( ((((int)&(rx0[(m%4)])) % 4) != 0) || ((cmd->len % 4) != 0) ) { */
|
1393 |
|
|
/* reply->status = 10; */
|
1394 |
|
|
/* } else { */
|
1395 |
|
|
/* reply->status = 0; */
|
1396 |
|
|
/* } */
|
1397 |
|
|
/* } else { */
|
1398 |
|
|
/* reply->incr = yes; */
|
1399 |
|
|
/* reply->status = 0; */
|
1400 |
|
|
/* } */
|
1401 |
|
|
/* if (reply->status == 0) { */
|
1402 |
|
|
/* reply->len = i; */
|
1403 |
|
|
/* } else { */
|
1404 |
|
|
/* reply->len = 0; */
|
1405 |
|
|
/* } */
|
1406 |
|
|
/* reply->destaddr = 0x14; */
|
1407 |
|
|
/* reply->destkey = 0XBF; */
|
1408 |
|
|
/* reply->srcaddr = 0x14; */
|
1409 |
|
|
/* reply->tid = i; */
|
1410 |
|
|
/* reply->addr = (int)&(rx0[(m%4)]); */
|
1411 |
|
|
/* reply->dstspalen = 0; */
|
1412 |
|
|
/* reply->dstspa = (char *)NULL; */
|
1413 |
|
|
/* reply->srcspalen = 0; */
|
1414 |
|
|
/* reply->srcspa = (char *)NULL; */
|
1415 |
|
|
/* if (build_rmap_hdr(reply, rx2, replysize)) { */
|
1416 |
|
|
/* printf("RMAP reply build failed\n"); */
|
1417 |
|
|
/* exit(1); */
|
1418 |
|
|
/* } */
|
1419 |
|
|
/* while (spw_rx(rx1, spw)) { */
|
1420 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1421 |
|
|
/* } */
|
1422 |
|
|
/* if (spw_tx(1, 0, 0, *cmdsize, tx0, 0, tx1, spw)) { */
|
1423 |
|
|
/* printf("Transmission failed\n"); */
|
1424 |
|
|
/* exit(1); */
|
1425 |
|
|
/* } */
|
1426 |
|
|
/* while (!(tmp = spw_checktx(spw))) { */
|
1427 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1428 |
|
|
/* } */
|
1429 |
|
|
/* if (tmp != 1) { */
|
1430 |
|
|
/* printf("Error in transmit \n"); */
|
1431 |
|
|
/* exit(1); */
|
1432 |
|
|
/* } */
|
1433 |
|
|
/* while (!(tmp = spw_checkrx(size, rxs, spw))) { */
|
1434 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1435 |
|
|
/* } */
|
1436 |
|
|
/* if (rxs->truncated) { */
|
1437 |
|
|
/* printf("Received packet truncated\n"); */
|
1438 |
|
|
/* exit(1); */
|
1439 |
|
|
/* } */
|
1440 |
|
|
/* if(rxs->eep) { */
|
1441 |
|
|
/* printf("Received packet terminated with eep\n"); */
|
1442 |
|
|
/* exit(1); */
|
1443 |
|
|
/* } */
|
1444 |
|
|
/* if(rxs->hcrcerr) { */
|
1445 |
|
|
/* printf("Received packet header crc error detected\n"); */
|
1446 |
|
|
/* exit(1); */
|
1447 |
|
|
/* } */
|
1448 |
|
|
/* if(rxs->dcrcerr) { */
|
1449 |
|
|
/* printf("Received packet data crc error detected\n"); */
|
1450 |
|
|
/* exit(1); */
|
1451 |
|
|
/* } */
|
1452 |
|
|
/* for (k = 0; k < *replysize; k++) { */
|
1453 |
|
|
/* if (loadb((int)&(rx1[k])) != rx2[k]) { */
|
1454 |
|
|
/* printf("Compare error 0: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)rx2[k]); */
|
1455 |
|
|
/* exit(1); */
|
1456 |
|
|
/* } */
|
1457 |
|
|
/* } */
|
1458 |
|
|
/* if ((reply->status) == 0 && (i != 0)) { */
|
1459 |
|
|
/* if (*size != (*replysize+2+i)) { */
|
1460 |
|
|
/* printf("Received packet has wrong length\n"); */
|
1461 |
|
|
/* printf("Expected: %i, Got: %i \n", *replysize+2+i, *size); */
|
1462 |
|
|
/* } */
|
1463 |
|
|
/* if (cmd->incr == yes) { */
|
1464 |
|
|
/* for(k = 0; k < i; k++) { */
|
1465 |
|
|
/* if (loadb((int)&(rx1[*replysize+1+k])) != rx0[k+(m%4)]) { */
|
1466 |
|
|
/* printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[*replysize+1+k])), (unsigned)rx0[k+(m%4)]); */
|
1467 |
|
|
/* exit(1); */
|
1468 |
|
|
/* } */
|
1469 |
|
|
/* } */
|
1470 |
|
|
/* } else { */
|
1471 |
|
|
/* for(k = 0; k < i; k++) { */
|
1472 |
|
|
/* if (loadb((int)&(rx1[*replysize+1+k])) != rx0[(k%4)+(m%4)]) { */
|
1473 |
|
|
/* printf("Compare error 2: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[*replysize+1+k])), (unsigned)rx0[(k%4)+(m%4)]); */
|
1474 |
|
|
/* printf("Rx1: %x, Rx0: %x\n", (int)rx1, (int)rx0); */
|
1475 |
|
|
/* //exit(1); */
|
1476 |
|
|
/* } */
|
1477 |
|
|
/* } */
|
1478 |
|
|
/* } */
|
1479 |
|
|
/* } else { */
|
1480 |
|
|
/* if (*size != (*replysize+1)) { */
|
1481 |
|
|
/* printf("Received packet has wrong length\n"); */
|
1482 |
|
|
/* printf("Expected: %i, Got: %i \n", *replysize+1, *size); */
|
1483 |
|
|
/* } */
|
1484 |
|
|
/* } */
|
1485 |
|
|
/* if ((i % 512) == 0) { */
|
1486 |
|
|
/* printf("Packet %i, alignment %i\n", i, m); */
|
1487 |
|
|
/* } */
|
1488 |
|
|
/* } */
|
1489 |
|
|
/* } */
|
1490 |
|
|
/* printf("Read test passed\n"); */
|
1491 |
|
|
|
1492 |
|
|
/* /\*late and early eop tests*\/ */
|
1493 |
|
|
/* for(i = 0; i < RMAPSIZE; i++) { */
|
1494 |
|
|
/* if (i < 16) { */
|
1495 |
|
|
/* tmp = -i; */
|
1496 |
|
|
/* } else { */
|
1497 |
|
|
/* tmp = -16; */
|
1498 |
|
|
/* } */
|
1499 |
|
|
/* for (j = tmp; j < i; j++) { */
|
1500 |
|
|
/* for (m = 0; m < 3; m++) { */
|
1501 |
|
|
/* for(k = 0; k < i; k++) { */
|
1502 |
|
|
/* tx1[k] = ~tx1[k]; */
|
1503 |
|
|
/* } */
|
1504 |
|
|
/* if (m == 0) { */
|
1505 |
|
|
/* cmd->type = writecmd; */
|
1506 |
|
|
/* cmd->verify = no; */
|
1507 |
|
|
/* reply->type = writerep; */
|
1508 |
|
|
/* reply->verify = no; */
|
1509 |
|
|
/* } else if (m == 2) { */
|
1510 |
|
|
/* cmd->type = rmwcmd; */
|
1511 |
|
|
/* cmd->verify = yes; */
|
1512 |
|
|
/* reply->type = rmwrep; */
|
1513 |
|
|
/* reply->verify = yes; */
|
1514 |
|
|
/* } else { */
|
1515 |
|
|
/* cmd->type = writecmd; */
|
1516 |
|
|
/* cmd->verify = yes; */
|
1517 |
|
|
/* reply->type = writerep; */
|
1518 |
|
|
/* reply->verify = yes; */
|
1519 |
|
|
/* } */
|
1520 |
|
|
/* cmd->incr = yes; */
|
1521 |
|
|
/* cmd->ack = yes; */
|
1522 |
|
|
/* cmd->destaddr = 0x14; */
|
1523 |
|
|
/* cmd->destkey = 0xBF; */
|
1524 |
|
|
/* cmd->srcaddr = 0x14; */
|
1525 |
|
|
/* cmd->tid = i; */
|
1526 |
|
|
/* cmd->addr = (int)rx0; */
|
1527 |
|
|
/* cmd->len = i; */
|
1528 |
|
|
/* cmd->status = 0; */
|
1529 |
|
|
/* cmd->dstspalen = 0; */
|
1530 |
|
|
/* cmd->dstspa = (char *)NULL; */
|
1531 |
|
|
/* cmd->srcspalen = 0; */
|
1532 |
|
|
/* cmd->srcspa = (char *)NULL; */
|
1533 |
|
|
/* if (build_rmap_hdr(cmd, tx0, cmdsize)) { */
|
1534 |
|
|
/* printf("RMAP cmd build failed\n"); */
|
1535 |
|
|
/* exit(1); */
|
1536 |
|
|
/* } */
|
1537 |
|
|
/* reply->len = 0; */
|
1538 |
|
|
/* if (j < 0 ) { */
|
1539 |
|
|
/* reply->status = 5; */
|
1540 |
|
|
/* } else if (j == 0) { */
|
1541 |
|
|
/* reply->status = 0; */
|
1542 |
|
|
|
1543 |
|
|
/* } else { */
|
1544 |
|
|
/* reply->status = 6; */
|
1545 |
|
|
/* for(l = 0; l < i; l++) { */
|
1546 |
|
|
/* if ((int)tx1[l] != 0) { */
|
1547 |
|
|
/* reply->status = 4; */
|
1548 |
|
|
/* } */
|
1549 |
|
|
/* } */
|
1550 |
|
|
/* } */
|
1551 |
|
|
/* if(m == 2 ) { */
|
1552 |
|
|
/* if((cmd->len != 0) && (cmd->len != 2) && (cmd->len != 4) && */
|
1553 |
|
|
/* (cmd->len != 6) && (cmd->len != 8)) { */
|
1554 |
|
|
/* reply->status = 11; */
|
1555 |
|
|
/* } else if( (((cmd->len/2) == 2) && (cmd->addr % 2 != 0)) || */
|
1556 |
|
|
/* (((cmd->len/2) == 4) && (cmd->addr % 4 != 0)) || */
|
1557 |
|
|
/* ((cmd->len/2) == 3) ) { */
|
1558 |
|
|
/* reply->status = 10; */
|
1559 |
|
|
/* } else { */
|
1560 |
|
|
/* if ((reply->status != 0) && (reply->status != 6)) { */
|
1561 |
|
|
/* reply->len = 0; */
|
1562 |
|
|
/* } else { */
|
1563 |
|
|
/* reply->len = cmd->len/2; */
|
1564 |
|
|
/* } */
|
1565 |
|
|
/* } */
|
1566 |
|
|
/* } else if (m != 0) { */
|
1567 |
|
|
/* if(cmd->len > 4) { */
|
1568 |
|
|
/* reply->status = 9; */
|
1569 |
|
|
/* } else if( (((cmd->len) == 2) && (cmd->addr % 2 != 0)) || */
|
1570 |
|
|
/* (((cmd->len) == 4) && (cmd->addr % 4 != 0)) || */
|
1571 |
|
|
/* ((cmd->len) == 3) ) { */
|
1572 |
|
|
/* reply->status = 10; */
|
1573 |
|
|
/* } */
|
1574 |
|
|
/* } */
|
1575 |
|
|
/* reply->incr = yes; */
|
1576 |
|
|
/* reply->ack = yes; */
|
1577 |
|
|
/* reply->destaddr = 0x14; */
|
1578 |
|
|
/* reply->destkey = 0xBF; */
|
1579 |
|
|
/* reply->srcaddr = 0x14; */
|
1580 |
|
|
/* reply->tid = i; */
|
1581 |
|
|
/* reply->addr = (int)rx0; */
|
1582 |
|
|
/* reply->dstspalen = 0; */
|
1583 |
|
|
/* reply->dstspa = (char *) NULL; */
|
1584 |
|
|
/* reply->srcspalen = 0; */
|
1585 |
|
|
/* reply->srcspa = (char *) NULL; */
|
1586 |
|
|
/* if (build_rmap_hdr(reply, rx2, replysize)) { */
|
1587 |
|
|
/* printf("RMAP reply build failed\n"); */
|
1588 |
|
|
/* exit(1); */
|
1589 |
|
|
/* } */
|
1590 |
|
|
/* if ((reply->status == 0) || (reply->status == 6)) { */
|
1591 |
|
|
/* for(k = 0; k < reply->len; k++) { */
|
1592 |
|
|
/* rx2[*replysize+1+k] = loadb((int)&(rx0[k])); */
|
1593 |
|
|
/* } */
|
1594 |
|
|
/* } */
|
1595 |
|
|
/* while (spw_rx(rx1, spw)) { */
|
1596 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1597 |
|
|
/* } */
|
1598 |
|
|
/* if (spw_tx(1, 1, 0, *cmdsize, tx0, i+j, tx1, spw)) { */
|
1599 |
|
|
/* printf("Transmission failed\n"); */
|
1600 |
|
|
/* exit(1); */
|
1601 |
|
|
/* } */
|
1602 |
|
|
/* while (!(tmp = spw_checktx(spw))) { */
|
1603 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1604 |
|
|
/* } */
|
1605 |
|
|
/* if (tmp != 1) { */
|
1606 |
|
|
/* printf("Error in transmit \n"); */
|
1607 |
|
|
/* exit(1); */
|
1608 |
|
|
/* } */
|
1609 |
|
|
/* while (!(tmp = spw_checkrx(size, rxs, spw))) { */
|
1610 |
|
|
/* for (k = 0; k < 64; k++) {} */
|
1611 |
|
|
/* } */
|
1612 |
|
|
/* if (rxs->truncated) { */
|
1613 |
|
|
/* printf("Received packet truncated\n"); */
|
1614 |
|
|
/* exit(1); */
|
1615 |
|
|
/* } */
|
1616 |
|
|
/* if(rxs->eep) { */
|
1617 |
|
|
/* printf("Received packet terminated with eep\n"); */
|
1618 |
|
|
/* exit(1); */
|
1619 |
|
|
/* } */
|
1620 |
|
|
/* if(rxs->hcrcerr) { */
|
1621 |
|
|
/* printf("Received packet header crc error detected\n"); */
|
1622 |
|
|
/* exit(1); */
|
1623 |
|
|
/* } */
|
1624 |
|
|
/* if(rxs->dcrcerr) { */
|
1625 |
|
|
/* printf("Received packet data crc error detected\n"); */
|
1626 |
|
|
/* exit(1); */
|
1627 |
|
|
/* } */
|
1628 |
|
|
/* if (m == 2) { */
|
1629 |
|
|
/* if ((i != 0) && ((reply->status == 0) || (reply->status == 6))) { */
|
1630 |
|
|
/* tmp = reply->len+1; */
|
1631 |
|
|
/* } else { */
|
1632 |
|
|
/* tmp = 0; */
|
1633 |
|
|
/* } */
|
1634 |
|
|
/* } else { */
|
1635 |
|
|
/* tmp = 0; */
|
1636 |
|
|
/* } */
|
1637 |
|
|
/* if (*size != (*replysize+1+tmp)) { */
|
1638 |
|
|
/* printf("Received packet has wrong length\n"); */
|
1639 |
|
|
/* printf("Expected: %i, Got: %i \n", *replysize+1+tmp, *size); */
|
1640 |
|
|
/* exit(1); */
|
1641 |
|
|
/* } */
|
1642 |
|
|
/* if (tmp == 0) { */
|
1643 |
|
|
/* tmp++; */
|
1644 |
|
|
/* } */
|
1645 |
|
|
/* for(k = 0; k < *replysize; k++) { */
|
1646 |
|
|
/* if (loadb((int)&(rx1[k])) != rx2[k]) { */
|
1647 |
|
|
/* if (k != 3) { */
|
1648 |
|
|
/* printf("Compare error 0: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)rx2[k]); */
|
1649 |
|
|
/* printf("Packet %i, type %i, offset: %i\n", i, m, j); */
|
1650 |
|
|
/* exit(1); */
|
1651 |
|
|
/* } */
|
1652 |
|
|
/* } */
|
1653 |
|
|
/* } */
|
1654 |
|
|
/* if ((reply->status == 0) || (reply->status == 6)) { */
|
1655 |
|
|
/* if (m == 2) { */
|
1656 |
|
|
/* for(k = 0; k < reply->len; k++) { */
|
1657 |
|
|
/* if (loadb((int)&(rx1[k+*replysize+1])) != rx2[k+*replysize+1]) { */
|
1658 |
|
|
/* printf("Compare error 2: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k+*replysize+1])), (unsigned)rx2[k+*replysize+1]); */
|
1659 |
|
|
/* printf("Rx0: %x, Rx1: %x, Rx2: %x\n", (int)rx0, (int)rx1, (int)rx2); */
|
1660 |
|
|
/* exit(1); */
|
1661 |
|
|
/* } */
|
1662 |
|
|
/* } */
|
1663 |
|
|
/* for(k = 0; k < (reply->len/2); k++) { */
|
1664 |
|
|
/* if (loadb((int)&(rx0[k])) != ((tx1[k] & tx1[k+(i/2)]) | (rx2[*replysize+1+k] & ~tx1[k+(i/2)]) )) { */
|
1665 |
|
|
/* printf("Compare error 3: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx0[k])), (unsigned)tx1[k]); */
|
1666 |
|
|
/* exit(1); */
|
1667 |
|
|
/* } */
|
1668 |
|
|
/* } */
|
1669 |
|
|
/* } else { */
|
1670 |
|
|
/* for (k = 0; k < i; k++) { */
|
1671 |
|
|
/* if (loadb((int)&(rx0[k])) != tx1[k]) { */
|
1672 |
|
|
/* printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx0[k])), (unsigned)tx1[k]); */
|
1673 |
|
|
/* exit(1); */
|
1674 |
|
|
/* } */
|
1675 |
|
|
/* } */
|
1676 |
|
|
/* } */
|
1677 |
|
|
/* } */
|
1678 |
|
|
/* if (((i % 8) == 0) && (m == 0) && (j == 0)) { */
|
1679 |
|
|
/* printf("Packet %i, type %i, offset: %i\n", i, m, j); */
|
1680 |
|
|
/* } */
|
1681 |
|
|
/* } */
|
1682 |
|
|
/* } */
|
1683 |
|
|
|
1684 |
|
|
/* } */
|
1685 |
|
|
/* printf("Test 10 completed successfully\n"); */
|
1686 |
|
|
}
|
1687 |
|
|
|
1688 |
|
|
/************************ TEST 11 **************************************/
|
1689 |
|
|
printf("Dma channel RMAP CRC test\n");
|
1690 |
|
|
if ((spw->rmapcrc == 1) && (spw->rmap == 0)) {
|
1691 |
|
|
tx0 = (char *)malloc(64);
|
1692 |
|
|
tx1 = (char *)calloc(RMAPCRCSIZE, 1);
|
1693 |
|
|
rx1 = (char *)malloc(32+RMAPCRCSIZE);
|
1694 |
|
|
for(i = 0; i < RMAPCRCSIZE; i++) {
|
1695 |
|
|
for(m = 0; m < 6; m++) {
|
1696 |
|
|
for(k = 0; k < i; k++) {
|
1697 |
|
|
tx1[k] = ~tx1[k];
|
1698 |
|
|
}
|
1699 |
|
|
switch (m) {
|
1700 |
|
|
case 0:
|
1701 |
|
|
cmd->type = writecmd;
|
1702 |
|
|
cmd->verify = no;
|
1703 |
|
|
j = i;
|
1704 |
|
|
break;
|
1705 |
|
|
case 1:
|
1706 |
|
|
cmd->type = readcmd;
|
1707 |
|
|
cmd->verify = no;
|
1708 |
|
|
j = 0;
|
1709 |
|
|
break;
|
1710 |
|
|
case 2:
|
1711 |
|
|
cmd->type = rmwcmd;
|
1712 |
|
|
j = (i % 8);
|
1713 |
|
|
cmd->verify = yes;
|
1714 |
|
|
break;
|
1715 |
|
|
case 3:
|
1716 |
|
|
cmd->type = writerep;
|
1717 |
|
|
j = 0;
|
1718 |
|
|
cmd->verify = no;
|
1719 |
|
|
break;
|
1720 |
|
|
case 4:
|
1721 |
|
|
cmd->type = readrep;
|
1722 |
|
|
cmd->verify = no;
|
1723 |
|
|
j = i;
|
1724 |
|
|
break;
|
1725 |
|
|
case 5:
|
1726 |
|
|
cmd->type = rmwrep;
|
1727 |
|
|
j = (i/2);
|
1728 |
|
|
cmd->verify = yes;
|
1729 |
|
|
break;
|
1730 |
|
|
default:
|
1731 |
|
|
break;
|
1732 |
|
|
}
|
1733 |
|
|
cmd->incr = no;
|
1734 |
|
|
cmd->ack = yes;
|
1735 |
|
|
cmd->destaddr = 0x14;
|
1736 |
|
|
cmd->destkey = 0xBF;
|
1737 |
|
|
cmd->srcaddr = 0x14;
|
1738 |
|
|
cmd->tid = i;
|
1739 |
|
|
cmd->addr = (int)(rx0);
|
1740 |
|
|
cmd->len = i;
|
1741 |
|
|
cmd->status = 0;
|
1742 |
|
|
cmd->dstspalen = 0;
|
1743 |
|
|
cmd->dstspa = (char *)NULL;
|
1744 |
|
|
cmd->srcspalen = 0;
|
1745 |
|
|
cmd->srcspa = (char *)NULL;
|
1746 |
|
|
if (build_rmap_hdr(cmd, tx0, cmdsize)) {
|
1747 |
|
|
printf("RMAP cmd build failed\n");
|
1748 |
|
|
exit(1);
|
1749 |
|
|
}
|
1750 |
|
|
while (spw_rx(rx1, spw)) {
|
1751 |
|
|
for (k = 0; k < 64; k++) {}
|
1752 |
|
|
}
|
1753 |
|
|
if (spw_tx(1, 1, 0, *cmdsize, tx0, j, tx1, spw)) {
|
1754 |
|
|
printf("Transmission failed\n");
|
1755 |
|
|
exit(1);
|
1756 |
|
|
}
|
1757 |
|
|
while (!(tmp = spw_checktx(spw))) {
|
1758 |
|
|
for (k = 0; k < 64; k++) {}
|
1759 |
|
|
}
|
1760 |
|
|
if (tmp != 1) {
|
1761 |
|
|
printf("Error in transmit \n");
|
1762 |
|
|
exit(1);
|
1763 |
|
|
}
|
1764 |
|
|
while (!(tmp = spw_checkrx(size, rxs, spw))) {
|
1765 |
|
|
for (k = 0; k < 64; k++) {}
|
1766 |
|
|
}
|
1767 |
|
|
if (rxs->truncated) {
|
1768 |
|
|
printf("Received packet truncated\n");
|
1769 |
|
|
exit(1);
|
1770 |
|
|
}
|
1771 |
|
|
if(rxs->eep) {
|
1772 |
|
|
printf("Received packet terminated with eep\n");
|
1773 |
|
|
exit(1);
|
1774 |
|
|
}
|
1775 |
|
|
if(rxs->hcrcerr) {
|
1776 |
|
|
printf("Received packet header crc error detected\n");
|
1777 |
|
|
exit(1);
|
1778 |
|
|
}
|
1779 |
|
|
if(rxs->dcrcerr) {
|
1780 |
|
|
printf("Received packet data crc error detected\n");
|
1781 |
|
|
exit(1);
|
1782 |
|
|
}
|
1783 |
|
|
if (j != 0) {
|
1784 |
|
|
l = 1;
|
1785 |
|
|
} else {
|
1786 |
|
|
l = 0;
|
1787 |
|
|
}
|
1788 |
|
|
if (*size != (*cmdsize+1+j+l)) {
|
1789 |
|
|
printf("Received packet has wrong length\n");
|
1790 |
|
|
printf("Expected: %i, Got: %i \n", *cmdsize+1+j+l, *size);
|
1791 |
|
|
exit(1);
|
1792 |
|
|
}
|
1793 |
|
|
for(k = 0; k < *cmdsize; k++) {
|
1794 |
|
|
if (loadb((int)&(rx1[k])) != tx0[k]) {
|
1795 |
|
|
printf("Compare error 0: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k])), (unsigned)tx0[k]);
|
1796 |
|
|
printf("Packet %i, type %i\n", i, m);
|
1797 |
|
|
exit(1);
|
1798 |
|
|
}
|
1799 |
|
|
}
|
1800 |
|
|
for(k = 0; k < j; k++) {
|
1801 |
|
|
if (loadb((int)&(rx1[k+*cmdsize+1])) != tx1[k]) {
|
1802 |
|
|
printf("Compare error 1: %u Data: %x Expected: %x \n", k, (unsigned)loadb((int)&(rx1[k+*cmdsize+1])), (unsigned)tx1[k]);
|
1803 |
|
|
exit(1);
|
1804 |
|
|
}
|
1805 |
|
|
}
|
1806 |
|
|
if (((i % 4) == 0) && ((m % 3) == 0)) {
|
1807 |
|
|
printf("Packet %i, type %i\n", i, m);
|
1808 |
|
|
}
|
1809 |
|
|
}
|
1810 |
|
|
}
|
1811 |
|
|
}
|
1812 |
|
|
printf("Test 11 completed successfully\n");
|
1813 |
|
|
printf("*********** Test suite completed successfully ************\n");
|
1814 |
|
|
exit(0);
|
1815 |
|
|
|
1816 |
|
|
}
|