161
163
for (i = 0; i < MAX_BANKS; i++) {
162
164
if (board_info.bar_length[i] > 0) {
163
printf(" BAR %d - Start: 0x%x, Length: 0x%x\n", i, board_info.bar_start[i], board_info.bar_length[i] );
165
printf(" BAR %d - ", i);
167
switch ( board_info.bar_flags[i]&IORESOURCE_TYPE_BITS) {
168
case IORESOURCE_IO: printf(" IO"); break;
169
case IORESOURCE_MEM: printf("MEM"); break;
170
case IORESOURCE_IRQ: printf("IRQ"); break;
171
case IORESOURCE_DMA: printf("DMA"); break;
174
if (board_info.bar_flags[i]&IORESOURCE_MEM_64) printf("64");
177
printf(", Start: 0x%08lx, Length: 0x% 8lx, Flags: 0x%08lx\n", board_info.bar_start[i], board_info.bar_length[i], board_info.bar_flags[i] );
168
182
void Info(int handle) {
169
183
GetBoardInfo(handle);
171
printf("Vendor: %lx, Device: %lx, Interrupt Pin: %i, Interrupt Line: %i\n", board_info.vendor_id, board_info.device_id, board_info.interrupt_pin, board_info.interrupt_line);
185
printf("Vendor: %x, Device: %x, Interrupt Pin: %i, Interrupt Line: %i\n", board_info.vendor_id, board_info.device_id, board_info.interrupt_pin, board_info.interrupt_line);
283
297
int Benchmark(int handle, int bar) {
285
299
void *data, *buf, *check;
286
300
struct timeval start, end;
287
301
unsigned long time;
358
372
printf(", write: %8.2lf MB/s", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024 * 1024));
360
374
gettimeofday(&start,NULL);
361
for (i = 0; i < BENCHMARK_ITERATIONS; i++) {
375
for (i = 0, errors = 0; i < BENCHMARK_ITERATIONS; i++) {
362
376
Write(buf, handle, bar, 0, size);
363
377
Read(check, handle, bar, 0, size);
364
memcmp(buf, check, size);
378
if (memcmp(buf, check, size)) ++errors;
366
380
gettimeofday(&end,NULL);
368
382
time = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
369
printf(", write-verify: %8.2lf MB/s\n", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024 * 1024));
383
printf(", write-verify: %8.2lf MB/s", 1000000. * size * BENCHMARK_ITERATIONS / (time * 1024 * 1024));
384
if (errors) printf(", errors: %u of %u", errors, BENCHMARK_ITERATIONS);
397
413
Read(buf, handle, bar, addr, size);
399
415
for (i = 0; i < n; i++) {
400
if ((i)&&(i%numbers_per_line == 0)) printf("\n");
401
else if ((i)&&(i%numbers_per_block == 0)) printf("%*s", BLOCK_SEPARATOR_WIDTH, "");
403
if (i%numbers_per_line == 0) printf("%8lx: ", addr + i * abs(access));
417
if (i%numbers_per_line == 0) printf("\n");
419
printf("%*s", SEPARATOR_WIDTH, "");
420
if (i%numbers_per_block == 0) printf("%*s", BLOCK_SEPARATOR_WIDTH, "");
424
if (i%numbers_per_line == 0) printf("%8lx: ", addr + i * abs(access));
405
426
switch (access) {
406
case 1: printf("% *hhx", access * 2 + SEPARATOR_WIDTH, ((uint8_t*)buf)[i]); break;
407
case 2: printf("% *hx", access * 2 + SEPARATOR_WIDTH, ((uint16_t*)buf)[i]); break;
408
case 4: printf("% *x", access * 2 + SEPARATOR_WIDTH, ((uint32_t*)buf)[i]); break;
409
case 8: printf("% *lx", access * 2 + SEPARATOR_WIDTH, ((uint64_t*)buf)[i]); break;
427
case 1: printf("%0*hhx", access * 2, ((uint8_t*)buf)[i]); break;
428
case 2: printf("%0*hx", access * 2, ((uint16_t*)buf)[i]); break;
429
case 4: printf("%0*x", access * 2, ((uint32_t*)buf)[i]); break;
430
case 8: printf("%0*lx", access * 2, ((uint64_t*)buf)[i]); break;
439
460
// ReadData(handle, bar, addr, n, access);
440
461
Read(check, handle, bar, addr, size);
442
if (memcmp(buf, check, size)) Error("Write failed, the data written and read differ");
463
if (memcmp(buf, check, size)) {
464
printf("Write failed: the data written and read differ, the foolowing is read back:");
465
ReadData(handle, bar, addr, n, access);