1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

make DeviceList a singleton and expose the eventFd in Device

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2023-12-12 09:43:06 +01:00 committed by Steffen Vogel
parent e46eb94804
commit 4c03d948da
4 changed files with 20 additions and 1 deletions

View file

@ -107,11 +107,16 @@ protected:
};
class DeviceList : public std::list<std::shared_ptr<Device>> {
public:
private:
// Initialize Linux PCI handle.
//
// This search for all available PCI devices under /sys/bus/pci
DeviceList();
DeviceList &operator=(const DeviceList &);
static DeviceList *instance;
public:
static DeviceList *getInstance();
DeviceList::value_type lookupDevice(const Slot &s);

View file

@ -60,6 +60,7 @@ public:
bool pciHotReset();
int getFileDescriptor() const { return fd; }
std::vector<int> &getEventfdList() { return eventfdList; }
void dump();
@ -78,6 +79,9 @@ private:
bool attachedToGroup;
int groupFd;
// Interrupt eventfds
std::vector<int> eventfdList;
struct vfio_device_info info;
std::vector<struct vfio_irq_info> irqs;

View file

@ -25,6 +25,15 @@ using namespace villas::kernel::pci;
#define PCI_BASE_ADDRESS_N(n) (PCI_BASE_ADDRESS_0 + sizeof(uint32_t) * (n))
DeviceList *DeviceList::instance = nullptr;
DeviceList *DeviceList::getInstance() {
if (instance == nullptr) {
instance = new DeviceList();
}
return instance;
};
DeviceList::DeviceList() {
struct dirent *e;
DIR *dp;

View file

@ -277,6 +277,7 @@ int Device::pciMsiInit(int efds[]) {
delete[] irqSetBuf;
return -1;
}
eventfdList.push_back(efds[i]);
}
memcpy(irqSet->data, efds, sizeof(int) * irqCount);