mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
refactor: rename DeviceList to PciDeviceList
Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
This commit is contained in:
parent
a162f6ffc5
commit
df8c26c79d
7 changed files with 26 additions and 25 deletions
|
@ -106,23 +106,23 @@ protected:
|
|||
std::ios_base::out) const;
|
||||
};
|
||||
|
||||
class DeviceList : public std::list<std::shared_ptr<PciDevice>> {
|
||||
class PciDeviceList : public std::list<std::shared_ptr<PciDevice>> {
|
||||
private:
|
||||
// Initialize Linux PCI handle.
|
||||
//
|
||||
// This search for all available PCI devices under /sys/bus/pci
|
||||
DeviceList();
|
||||
DeviceList &operator=(const DeviceList &);
|
||||
static DeviceList *instance;
|
||||
PciDeviceList();
|
||||
PciDeviceList &operator=(const PciDeviceList &);
|
||||
static PciDeviceList *instance;
|
||||
|
||||
public:
|
||||
static DeviceList *getInstance();
|
||||
static PciDeviceList *getInstance();
|
||||
|
||||
DeviceList::value_type lookupDevice(const Slot &s);
|
||||
PciDeviceList::value_type lookupDevice(const Slot &s);
|
||||
|
||||
DeviceList::value_type lookupDevice(const Id &i);
|
||||
PciDeviceList::value_type lookupDevice(const Id &i);
|
||||
|
||||
DeviceList::value_type lookupDevice(const PciDevice &f);
|
||||
PciDeviceList::value_type lookupDevice(const PciDevice &f);
|
||||
};
|
||||
|
||||
} // namespace pci
|
||||
|
|
|
@ -25,16 +25,16 @@ using namespace villas::kernel::pci;
|
|||
|
||||
#define PCI_BASE_ADDRESS_N(n) (PCI_BASE_ADDRESS_0 + sizeof(uint32_t) * (n))
|
||||
|
||||
DeviceList *DeviceList::instance = nullptr;
|
||||
PciDeviceList *PciDeviceList::instance = nullptr;
|
||||
|
||||
DeviceList *DeviceList::getInstance() {
|
||||
PciDeviceList *PciDeviceList::getInstance() {
|
||||
if (instance == nullptr) {
|
||||
instance = new DeviceList();
|
||||
instance = new PciDeviceList();
|
||||
}
|
||||
return instance;
|
||||
};
|
||||
|
||||
DeviceList::DeviceList() {
|
||||
PciDeviceList::PciDeviceList() {
|
||||
struct dirent *e;
|
||||
DIR *dp;
|
||||
FILE *f;
|
||||
|
@ -88,21 +88,22 @@ DeviceList::DeviceList() {
|
|||
closedir(dp);
|
||||
}
|
||||
|
||||
DeviceList::value_type DeviceList::lookupDevice(const Slot &s) {
|
||||
return *std::find_if(begin(), end(), [s](const DeviceList::value_type &d) {
|
||||
PciDeviceList::value_type PciDeviceList::lookupDevice(const Slot &s) {
|
||||
return *std::find_if(begin(), end(), [s](const PciDeviceList::value_type &d) {
|
||||
return d->slot == s;
|
||||
});
|
||||
}
|
||||
|
||||
DeviceList::value_type DeviceList::lookupDevice(const Id &i) {
|
||||
return *std::find_if(begin(), end(), [i](const DeviceList::value_type &d) {
|
||||
PciDeviceList::value_type PciDeviceList::lookupDevice(const Id &i) {
|
||||
return *std::find_if(begin(), end(), [i](const PciDeviceList::value_type &d) {
|
||||
return d->id == i;
|
||||
});
|
||||
}
|
||||
|
||||
DeviceList::value_type DeviceList::lookupDevice(const PciDevice &d) {
|
||||
auto dev = std::find_if(
|
||||
begin(), end(), [d](const DeviceList::value_type &e) { return *e == d; });
|
||||
PciDeviceList::value_type PciDeviceList::lookupDevice(const PciDevice &d) {
|
||||
auto dev =
|
||||
std::find_if(begin(), end(),
|
||||
[d](const PciDeviceList::value_type &e) { return *e == d; });
|
||||
|
||||
return dev == end() ? value_type() : *dev;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static std::shared_ptr<kernel::pci::DeviceList> pciDevices;
|
||||
static std::shared_ptr<kernel::pci::PciDeviceList> pciDevices;
|
||||
static auto logger = villas::Log::get("villasfpga_dma");
|
||||
|
||||
struct villasfpga_handle_t {
|
||||
|
|
|
@ -71,7 +71,7 @@ PCIeCardFactory::make(json_t *json_card, std::string card_name,
|
|||
filter.slot = kernel::pci::Slot(pci_slot);
|
||||
|
||||
// Search for FPGA card
|
||||
card->pdev = kernel::pci::DeviceList::getInstance()->lookupDevice(filter);
|
||||
card->pdev = kernel::pci::PciDeviceList::getInstance()->lookupDevice(filter);
|
||||
if (!card->pdev) {
|
||||
logger->warn("Failed to find PCI device");
|
||||
return nullptr;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static std::shared_ptr<kernel::pci::DeviceList> pciDevices;
|
||||
static std::shared_ptr<kernel::pci::PciDeviceList> pciDevices;
|
||||
static auto logger = villas::Log::get("ctrl");
|
||||
|
||||
void writeToDmaFromStdIn(std::shared_ptr<villas::fpga::ip::Dma> dma) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static std::shared_ptr<kernel::pci::DeviceList> pciDevices;
|
||||
static std::shared_ptr<kernel::pci::PciDeviceList> pciDevices;
|
||||
static auto logger = villas::Log::get("streamer");
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static kernel::pci::DeviceList *pciDevices;
|
||||
static kernel::pci::PciDeviceList *pciDevices;
|
||||
|
||||
FpgaState state;
|
||||
|
||||
|
@ -40,7 +40,7 @@ static void init() {
|
|||
|
||||
plugin::registry->dump();
|
||||
|
||||
pciDevices = kernel::pci::DeviceList::getInstance();
|
||||
pciDevices = kernel::pci::PciDeviceList::getInstance();
|
||||
|
||||
auto vfioContainer = std::make_shared<kernel::vfio::Container>();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue