LCOV - code coverage report
Current view: top level - src/config - config_file.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 32 53 60.4 %
Date: 2025-09-09 12:09:29 Functions: 4 9 44.4 %

          Line data    Source code
       1             : #include "config.hpp"
       2             : #include "device.hpp"
       3             : 
       4          27 : ConfigFile::ConfigFile() {}
       5             : 
       6          27 : ConfigFile::~ConfigFile() {}
       7             : 
       8           0 : std::ostream& ConfigFile::format(std::ostream& os) const {
       9           0 :     os << "ConfigFile" << std::endl;
      10           0 :     os << "regmap: " << regmap << std::endl;
      11           0 :     os << "vmem: " << vmem << std::endl;
      12           0 :     os << "file: " << file << std::endl;
      13           0 :     os << "channels: " << channels << std::endl;
      14           0 :     os << "block_size: " << block_size << std::endl;
      15           0 :     os << "toflx_dmaid: " << toflx_dmaid << std::endl;
      16           0 :     os << "firmware: " << firmware << std::endl;
      17           0 :     os << std::endl;
      18           0 :     return os;
      19             : }
      20             : 
      21           0 : std::ostream& operator<<(std::ostream& os, const ConfigFile& c) {
      22           0 :     return c.format(os);
      23             : }
      24             : 
      25          27 : std::string ConfigFile::options() {
      26          27 :     return
      27          27 : R"(
      28             :     File Options:
      29             :     -e, --elink=DMAID:LID ...       Enable e-link LID on DMAID e.g. 0:0x08 or 1:0x09.
      30             :         --no-of-elinks=N            Enable N additional elinks to the list passed with -e. [default: 0]
      31             :                                     Added sequentially wrt the last elink passed on same DMA id.
      32             :         --block-size=SIZE           ToHost block size, multiple of 1024. [default: 1024]
      33             :         --channels=SIZE             Number of links of emulated PCIe endpoint. [default: 12]
      34             :         --firmware=SIZE             Emulated firmware: GBT=0, FULL=1, LPGBT=9. [default: 0]
      35             :         --pcie-gen=VALUE            Used to determine FromHost data format. [default: 3]
      36             :         --file-is-fifo              Use a FIFO instead of a file. [default: 0]
      37             :         --regmap=hex_version        Register map version. [calculated: from compile definition of REGMAP_VERSION]
      38             :         --toflx-dma=VALUE           Last DMA id per PCIe endpoint, reserved for ToFlx [default: 5]
      39             :         --vmem                      Use virtual memory instead of cmem. [default: 0]
      40             : )";
      41             : }
      42             : 
      43          27 : void ConfigFile::handle_cmd_line(std::map<std::string, docopt::value> args) {
      44             : 
      45          54 :     file = args["FILE"].asString();
      46             : 
      47          27 :     int last_dmaid = 0;
      48          64 :     for(auto entry : args["--elink"].asStringList() ){
      49          37 :         std::string::size_type n = entry.find(":");
      50          74 :         int dmaid = stoi(entry.substr(0, n));
      51          74 :         uint16_t elink = std::stoul(entry.substr(n+1), nullptr, 16);
      52          37 :         elinks[dmaid].push_back(elink);
      53          37 :         last_dmaid = dmaid;
      54          37 :     }
      55             : 
      56          27 :     unsigned no_of_elinks = args["--no-of-elinks"].asLong();
      57          27 :     if (no_of_elinks > 0){
      58           0 :         uint16_t last_elink = elinks.at(last_dmaid).back();
      59           0 :         for (unsigned int i = last_elink + 1; i <= no_of_elinks; ++i){
      60           0 :             elinks.at(last_dmaid).push_back(i);
      61             :         }
      62             :     }
      63             : 
      64          27 :     vmem = args["--vmem"].asBool();
      65          27 :     regmap = args["--regmap"] ? args["--regmap"].asLong() : REGMAP_VERSION;
      66          27 :     block_size = args["--block-size"].asLong();
      67          27 :     channels = args["--channels"].asLong();
      68          27 :     toflx_dmaid = args["--toflx-dma"].asLong();
      69          27 :     firmware = args["--firmware"].asLong();
      70          27 :     fifo_as_file = args["--file-is-fifo"].asBool();
      71             : 
      72          27 :     int pcie_gen = args["--pcie-gen"].asLong();
      73          27 :     if (pcie_gen == 0){
      74           0 :         fromHostDataFormat = flx_fromhost_format::FROMHOST_FORMAT_5BIT_LENGTH;
      75             :     }
      76             :     else if (pcie_gen == 1){
      77           0 :         fromHostDataFormat = flx_fromhost_format::FROMHOST_FORMAT_HDR32_PACKET32;
      78             :     }
      79             :     else if (pcie_gen == 2){
      80           0 :         fromHostDataFormat = flx_fromhost_format::FROMHOST_FORMAT_HDR32_PACKET64;
      81             :     }
      82             :     else if (pcie_gen == 5){
      83           0 :         fromHostDataFormat = flx_fromhost_format::FROMHOST_FORMAT_HDR32_PACKET128_8B;
      84             :     }
      85             :     else if (pcie_gen == 4){
      86           0 :         fromHostDataFormat = flx_fromhost_format::FROMHOST_FORMAT_HDR32_PACKET64_8B;
      87             :     } else {
      88          27 :         fromHostDataFormat = flx_fromhost_format::FROMHOST_FORMAT_HDR32_PACKET32_8B;
      89             :     }
      90             : 
      91             :     //Variables for device emulation
      92          27 :     lock_mask = 0;
      93          27 :     wide_mode = false;
      94          27 :     status_leds = 0;
      95          27 :     max_tlp_bytes = 512;
      96          27 : }

Generated by: LCOV version 1.0