#include #include #include #include #include #include #include #include #include #include "abi_functions.h" #include "rcu2_functions.h" //========================================================================================== // Used by main to communicate with ARGP parse_opt struct args { int verbose, rp, check; }; //========================================================================================== void print_usage() { printf("Usage: rolm_dump [OPTION]...\n"); printf("Purpose: Dump RCU2 ReadOut List Memories\n"); printf("Options:\n"); printf("-v[LEVEL] : Set verbosity level (default is 1)\n"); printf("-c : Check content (by default we only dump)\n"); printf("-p[NUM] : Use this partition number for the ROLM content check (not used for dump)\n"); } //========================================================================================== //========================================================================================== //========================================================================================== int main(int argc, char ** argv) { struct args args; // Default values args.verbose = 1; args.check = 0; args.rp = 99; int branch; while ( 1 ) { int result = getopt(argc, argv, "hcv:p:"); if (result == -1) break; /* end of list */ switch (result) { case '?': /* unknown parameter */ fprintf(stderr, "Error: Unknown parameter\n"); exit(EXIT_FAILURE); case ':': /* missing argument of a parameter */ fprintf(stderr, "Error: Missing argument\n"); exit(EXIT_FAILURE); case 'h': print_usage(); exit(EXIT_SUCCESS); case 'c': args.check = 1; // break; case 'p': args.rp = atoi(optarg); // break; case 'v': args.verbose = atoi(optarg); // break; } } if (optind < argc) { //if (args.verbose) printf("Using file <%s>\n", argv[optind]); //sprintf(filename, argv[optind++]); } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// int ctr, eoc_ctr[0], check1[4], check2[4], marker[4]; unsigned int rp; unsigned int value = 0; rbm_init( args.verbose ); // Init bus (command mode) rbm_read(get_Address_RCU_VERSION(), &value, args.verbose); printf("RCU_VERSION = %X\n", value); if (args.rp == 99) { // Read partition number rbm_read(get_Address_PARTITION_NUMBER(), &rp, args.verbose); if (args.verbose > 1) printf("Using currently configured partition number: %i\n", rp); } else { rp = args.rp; } // Check and set ROLM access if (args.verbose > 1) printf("Read status of ROLM access and enable access to the ROLM via the RCU Bus\n"); for (branch=0; branch<4; branch++) { rbm_read(get_Address_ROLM_SEL(branch), &value, args.verbose); printf("ROLM%d SEL value before dump: 0x%X\n", branch, value); rbm_write(get_Address_ROLM_SEL(branch), 0x1, args.verbose); marker[branch] = 0; check1[branch] = 0; check2[branch] = 0; eoc_ctr[branch] = 0; } if (args.check) { // Check ROLMs for (branch=0; branch<4; branch++) { printf("Checking ROLM for branch %d\n", branch); for (ctr=0; ctr<1024; ctr++) { rbm_read(get_Address_ROLM(branch)+ctr, &value, args.verbose); printf("0x%04X => ", value); if ( value == 0xFFF ) { printf("End Of ROLM for branch %d\n", branch); break; } else { unsigned int fec = (value>>7)&0x1F; printf("FEC%02d ", fec); unsigned int bbranch = getBranchFromFec(fec, rp); if (bbranch != branch) printf("!!This FEC does not belong here!! "); if ( value=0x1700 ) { printf("End Of Chunk"); eoc_ctr[branch]++; } printf("\n"); } } } } else { // Dump ROLM if (args.verbose > 1) printf("Dumping ROLMs\n"); unsigned int value = 0; printf("CTR ROLM0 ROLM1 ROLM2 ROLM3\n", value); for (ctr=0; ctr<1024; ctr++) { check1[0] = check1[1] = check1[2] = check1[3] = 0; check2[0] = check2[1] = check2[2] = check2[3] = 0; rbm_read(get_Address_ROLM(0)+ctr, &value, args.verbose); if (value == 0xFFF) { marker[0] = 1; check1[0] = 1; } if (value == 0x1700) { check2[0] = 1; eoc_ctr[0]++; } printf("%04d 0x%04X ", ctr, value); rbm_read(get_Address_ROLM(1)+ctr, &value, args.verbose); if (value == 0xFFF) { marker[1] = 1; check1[1] = 1; } if (value == 0x1700) { check2[1] = 1; eoc_ctr[1]++; } printf("0x%04X ", value); rbm_read(get_Address_ROLM(2)+ctr, &value, args.verbose); if (value == 0xFFF) { marker[2] = 1; check1[2] = 1; } if (value == 0x1700) { check2[2] = 1; eoc_ctr[2]++; } printf("0x%04X ", value); rbm_read(get_Address_ROLM(3)+ctr, &value, args.verbose); if (value == 0xFFF) { marker[3] = 1; check1[3] = 1; } if (value == 0x1700) { check2[3] = 1; eoc_ctr[3]++; } printf("0x%04X ", value); if (check1[0]) printf("EOR[0] "); if (check1[1]) printf("EOR[1] "); if (check1[2]) printf("EOR[2] "); if (check1[3]) printf("EOR[3] "); if (check2[0]) printf("EOC[0] "); if (check2[1]) printf("EOC[1] "); if (check2[2]) printf("EOC[2] "); if (check2[3]) printf("EOC[3] "); printf("\n"); if ( marker[0] && marker[1] && marker[2] && marker[3] ) break; } } if ( marker[0] && marker[1] && marker[2] && marker[3] ) printf("Found all 4 EOR markers\n"); else printf("ERROR!!! Not all EOR markers found\n"); for (branch=0; branch<4; branch++) { printf("Found %d EOC markers in branch %d\n", eoc_ctr[branch], branch); } if (args.verbose > 1) printf("Enable access to the ROLM via the readout\n"); for (branch=0; branch<4; branch++) { rbm_write(get_Address_ROLM_SEL(branch), 0x0, args.verbose); } // DONE! rbm_direct( args.verbose ); // Set RBM back to direct mode (for feeserver and buspoke) return 0; }