fp@1142: /***************************************************************************** fp@1142: * fp@1142: * $Id$ fp@1142: * fp@1142: ****************************************************************************/ fp@1142: fp@1142: #include fp@1142: #include fp@1142: using namespace std; fp@1142: fp@1142: #include "CommandDomains.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: CommandDomains::CommandDomains(): fp@1142: Command("domains", "Show configured domains.") fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: string CommandDomains::helpString() const fp@1142: { fp@1142: stringstream str; fp@1142: fp@1144: str << getName() << " [OPTIONS]" << endl fp@1142: << endl fp@1142: << getBriefDescription() << endl fp@1142: << endl fp@1142: << "Without the --verbose option, the domains are displayed" << endl fp@1142: << "one-per-line. Example:" << endl fp@1142: << endl fp@1142: << "Domain0: LogBaseAddr 0x00000000, Size 6, WorkingCounter 0/1" fp@1142: << endl << endl fp@1142: << "The domain's base address for the logical datagram" << endl fp@1142: << "(LRD/LWR/LRW) is displayed followed by the domain's" << endl fp@1142: << "process data size in byte. The last values are the current" << endl fp@1142: << "datagram working counter sum and the expected working" << endl fp@1144: << "counter sum. If the values are equal, all Pdos were exchanged." fp@1142: << endl << endl fp@1142: << "If the --verbose option is given, the participating slave" << endl fp@1142: << "configurations/FMMUs and the current process data are" << endl fp@1142: << "additionally displayed:" << endl fp@1142: << endl fp@1142: << "Domain1: LogBaseAddr 0x00000006, Size 6, WorkingCounter 0/1" fp@1142: << endl fp@1142: << " SlaveConfig 1001:0, SM3 ( Input), LogAddr 0x00000006, Size 6" fp@1142: << endl fp@1144: << " 0x00 0x00 0x00 0x00 0x00 0x00" << endl fp@1142: << endl fp@1142: << "The process data are displayed as hexadecimal bytes." << endl fp@1142: << endl fp@1142: << "Command-specific options:" << endl fp@1142: << " --domain -d Positive numerical domain index," << endl fp@1142: << " or 'all' for all domains (default)." fp@1142: << endl fp@1142: << " --verbose -v Show FMMUs and process data" << endl fp@1144: << " in addition." << endl fp@1142: << endl fp@1142: << numericInfo(); fp@1142: fp@1142: return str.str(); fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandDomains::execute(MasterDevice &m, const StringVector &args) fp@1142: { fp@1142: m.open(MasterDevice::Read); fp@1142: fp@1142: if (domainIndex == -1) { fp@1142: unsigned int i; fp@1142: ec_ioctl_master_t master; fp@1142: fp@1142: m.getMaster(&master); fp@1142: fp@1142: for (i = 0; i < master.domain_count; i++) { fp@1142: showDomain(m, i); fp@1142: } fp@1142: } else { fp@1142: showDomain(m, domainIndex); fp@1142: } fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandDomains::showDomain(MasterDevice &m, unsigned int domainIndex) fp@1142: { fp@1142: ec_ioctl_domain_t domain; fp@1142: unsigned char *processData; fp@1142: ec_ioctl_domain_data_t data; fp@1142: unsigned int i, j; fp@1142: ec_ioctl_domain_fmmu_t fmmu; fp@1142: unsigned int dataOffset; fp@1142: fp@1142: m.getDomain(&domain, domainIndex); fp@1142: fp@1142: cout << "Domain" << dec << domainIndex << ":" fp@1142: << " LogBaseAddr 0x" fp@1142: << hex << setfill('0') fp@1142: << setw(8) << domain.logical_base_address fp@1142: << ", Size " << dec << setfill(' ') fp@1142: << setw(3) << domain.data_size fp@1142: << ", WorkingCounter " fp@1142: << domain.working_counter << "/" fp@1142: << domain.expected_working_counter << endl; fp@1142: fp@1142: if (!domain.data_size || getVerbosity() != Verbose) fp@1142: return; fp@1142: fp@1142: processData = new unsigned char[domain.data_size]; fp@1142: fp@1142: try { fp@1142: m.getData(&data, domainIndex, domain.data_size, processData); fp@1142: } catch (MasterDeviceException &e) { fp@1142: delete [] processData; fp@1142: throw e; fp@1142: } fp@1142: fp@1142: for (i = 0; i < domain.fmmu_count; i++) { fp@1142: m.getFmmu(&fmmu, domainIndex, i); fp@1142: fp@1142: cout << " SlaveConfig " fp@1142: << dec << fmmu.slave_config_alias fp@1142: << ":" << fmmu.slave_config_position fp@1142: << ", SM" << (unsigned int) fmmu.sync_index << " (" fp@1142: << setfill(' ') << setw(6) fp@1142: << (fmmu.dir == EC_DIR_INPUT ? "Input" : "Output") fp@1142: << "), LogAddr 0x" fp@1142: << hex << setfill('0') fp@1142: << setw(8) << fmmu.logical_address fp@1142: << ", Size " << dec << fmmu.data_size << endl; fp@1142: fp@1142: dataOffset = fmmu.logical_address - domain.logical_base_address; fp@1142: if (dataOffset + fmmu.data_size > domain.data_size) { fp@1142: stringstream err; fp@1142: delete [] processData; fp@1142: err << "Fmmu information corrupted!"; fp@1142: throwCommandException(err); fp@1142: } fp@1142: fp@1142: cout << " " << hex << setfill('0'); fp@1142: for (j = 0; j < fmmu.data_size; j++) { fp@1142: if (j && !(j % BreakAfterBytes)) fp@1142: cout << endl << " "; fp@1144: cout << "0x" << setw(2) fp@1142: << (unsigned int) *(processData + dataOffset + j) << " "; fp@1142: } fp@1142: cout << endl; fp@1142: } fp@1142: fp@1142: delete [] processData; fp@1142: } fp@1142: fp@1142: /*****************************************************************************/