示例#1
0
std::string hw::PCI_Device::to_string() const {
  std::stringstream str;
  str << PCI::classcode_str(classcode()) << ", "
      << PCI::vendor_str((PCI::vendor_t)vendor_id())
      << std::hex << " ("<< vendor_id() << " / " << product_id() << ")";
  return str.str();
};
示例#2
0
std::string hw::PCI_Device::to_string() const {
  char buffer[512];
  int len = snprintf(buffer, sizeof(buffer),
          "%s %s (V %#x / P %#x)",
          PCI::classcode_str(classcode()),
          PCI::vendor_str((PCI::vendor_t)vendor_id()),
          vendor_id(), product_id());
  return std::string(buffer, len);
}
示例#3
0
  PCI_Device::PCI_Device(const uint16_t pci_addr,
                         const uint32_t device_id,
                         const uint32_t devclass)
      : pci_addr_{pci_addr}, device_id_{device_id}
  {
    // set master, mem and io flags
    uint32_t cmd = read_dword(PCI_CMD_REG);
    cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEM | PCI_COMMAND_IO;
    write_dword(PCI_CMD_REG, cmd);

    // device class info is coming from pci manager to save a PCI read
    this->devtype_.reg = devclass;

    INFO2("|");
    switch (PCI::classcode(devtype_.classcode)) {
    case PCI::classcode::BRIDGE:
      INFO2("+--[ %s, %s, %s (0x%x) ]",
            PCI::classcode_str(classcode()),
            PCI::vendor_str(vendor_id()),
            bridge_subclasses[devtype_.subclass < SS_BR ? devtype_.subclass : SS_BR-1],
            devtype_.subclass);
      break;
    case PCI::classcode::NIC:
      INFO2("+--[ %s, %s, %s (0x%x) ]",
            PCI::classcode_str(devtype_.classcode),
            PCI::vendor_str(vendor_id()),
            nic_subclasses[devtype_.subclass < SS_NIC ? devtype_.subclass : SS_NIC-1],
            devtype_.subclass);
      break;
    default:
      INFO2("+--[ %s, %s ]",
            PCI::classcode_str(devtype_.classcode),
            PCI::vendor_str(vendor_id()));
    } //< switch (devtype_.classcode)

    // bridges are different from other PCI devices
    if (classcode() == PCI::classcode::BRIDGE) return;
  }