int rtems_shell_main_mwdump( int argc, char *argv[] ) { unsigned char n; unsigned char m; int max; int res; void *addr = 0; unsigned char *pb; if ( argc > 1 ) { if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) { printf( "Address argument (%s) is not a number\n", argv[1] ); return -1; } } if ( argc > 2 ) { if ( rtems_string_to_int(argv[2], &max, NULL, 0) ) { printf( "Address argument (%s) is not a number\n", argv[1] ); return -1; } if (max <= 0) { max = 1; /* print 1 item if 0 or neg. */ res = 0; } else { max--; res = max & 0xf;/* num bytes in last row */ max >>= 4; /* div by 16 */ max++; /* num of rows to print */ if (max > 20) { /* limit to 20 */ max = 20; res = 0xf; /* 16 bytes print in last row */ } } } else {
int main_pcmmio_dac(int argc, char **argv) { int dac; float low_voltage; float high_voltage; float step_voltage; float current_voltage; float current_step; int step_time; int maximum_time; uint32_t step_ticks; bool fail = false; int elapsed; /* * Verify that we have the right number of arguments. */ if ( (argc != 3) && (argc != 7) ) { printf( "Incorrect number of arguments\n" ); PRINT_USAGE(); return -1; } /* * Convert the string arguments into number values */ if ( rtems_string_to_int( argv[1], &dac, NULL, 0 ) ) { printf( "DAC (%s) is not a number\n", argv[1] ); fail = true; } if ( rtems_string_to_float( argv[2], &low_voltage, NULL ) ) { printf( "Voltage (%s) is not a number\n", argv[2] ); fail = true; } /* * Validate the output dac and voltage. */ if ( dac < 0 || dac > 7 ) { puts( "DAC number must be 0-7" ); fail = true; } VALIDATE_VOLTAGE( low_voltage ); /* * Now do a single write to the DAC */ if ( argc == 3 ) { if ( fail ) { PRINT_USAGE(); return -1; } printf( "Write %6.4f to to dac %d\n", low_voltage, dac ); set_dac_voltage(dac, low_voltage); return 0; } /* * Finish parsing the arguments to do a pattern */ fail = false; if ( rtems_string_to_float( argv[3], &high_voltage, NULL ) ) { printf( "Voltage (%s) is not a number\n", argv[3] ); fail = true; } VALIDATE_VOLTAGE( high_voltage ); if ( rtems_string_to_float( argv[4], &step_voltage, NULL ) ) { printf( "Step voltage (%s) is not a number\n", argv[4] ); fail = true; } VALIDATE_VOLTAGE( step_voltage ); if ( step_voltage < 0.0 ) { printf( "Step voltage must be greater than 0\n" ); fail = true; } if ( rtems_string_to_int( argv[5], &step_time, NULL, 0 ) ) { printf( "Step time (%s) is not a number\n", argv[5] ); fail = true; } if ( rtems_string_to_int( argv[6], &maximum_time, NULL, 0 ) ) { printf( "Maximum time (%s) is not a number\n", argv[6] ); fail = true; } if ( step_time >= maximum_time ) { printf( "Step time (%d) must be less than maximum time (%d)\n", step_time, maximum_time ); fail = true; } if ( step_time < 0 ) { printf( "Step time must be greater than 0\n" ); fail = true; } if ( maximum_time < 0 ) { printf( "Maximum time must be greater than 0\n" ); fail = true; } /* * Now write the pattern to the DAC */ if ( fail ) { PRINT_USAGE(); return -1; } printf( "Write %6.4f-%6.4f step=%6.4f stepTime=%d msecs dac=%d max=%d msecs\n", low_voltage, high_voltage, step_voltage, step_time, dac, maximum_time ); elapsed = 0; step_ticks = RTEMS_MILLISECONDS_TO_TICKS(step_time); current_voltage = low_voltage; current_step = step_voltage; if ( low_voltage > high_voltage ) current_step *= -1.0; while (1) { #if defined(TESTING) printf( "%d: Write %6.4f to to dac %d\n", elapsed, current_voltage, dac ); #endif set_dac_voltage(dac, current_voltage); current_voltage += current_step; if ( current_voltage < low_voltage ) { current_step = step_voltage; current_voltage = low_voltage; } else if ( current_voltage > high_voltage ) { current_step = -1.0 * step_voltage; current_voltage = high_voltage; } elapsed += step_time; if ( elapsed > maximum_time ) break; rtems_task_wake_after( step_ticks ); } return 0; }
int main_pcmmio_benchmark(int argc, char **argv) { int maximum; int sc; char ch; bool verbose; struct getopt_data getopt_reent; const char *s; int interrupts; uint64_t timestamp; uint64_t now; uint32_t min_cycles; uint32_t max_cycles; uint64_t total_cycles; uint64_t cycles; /* * Parse arguments here */ maximum = 1; verbose = false; memset(&getopt_reent, 0, sizeof(getopt_data)); while ((ch = getopt_r(argc, argv, "i:v", &getopt_reent)) != -1) { switch (ch) { case 'i': /* maximum interrupts */ s = getopt_reent.optarg; if ( rtems_string_to_int( s, &maximum, NULL, 0 ) ) { printf( "Maximum interrupts (%s) is not a number\n", s ); PRINT_USAGE(); return -1; } if ( maximum <= 0 ) { printf( "Maximum interrupts (%d) is invalid\n", maximum ); PRINT_USAGE(); return -1; } break; case 'v': /* verbose */ verbose = true; break; default: printf( pcmmio_benchmark_usage, argv[0] ); return -1; } } printf( "Benchmarking for DIN IRQ for %d interrupts\n", maximum ); /* * Now catch interrupts in the loop */ interrupts = 0; min_cycles = 0xffffffff; max_cycles = 0; total_cycles = 0; flush_buffered_ints(); while (1) { sc = 0; sc = wait_dio_int_with_timestamp(0, ×tamp); if ( sc == -1 ) continue; now = rdtsc(); cycles = now - timestamp; total_cycles += cycles; if ( cycles < min_cycles ) min_cycles = cycles; if ( cycles > max_cycles ) max_cycles = cycles; interrupts++; if (interrupts >= maximum ) break; } printf( "Number of Interrupts: %d\n" "Total Cycles: %lld\n" "min/max/avg cycles: %ld/%ld/%lld\n" "min/max/avg microseconds: %lld/%lld/%lld\n", maximum, total_cycles, min_cycles, max_cycles, total_cycles / maximum, to_usecs( min_cycles ), to_usecs( max_cycles ), to_usecs( total_cycles / maximum ) ); return 0; }