MmioVirtIO::MmioVirtIO(const MmioVirtIOParams *params)
: BasicPioDevice(params, params->pio_size),
hostFeaturesSelect(0), guestFeaturesSelect(0), pageSize(0),
- interruptStatus(0),
- callbackKick(this), vio(*params->vio),
+ interruptStatus(0), vio(*params->vio),
interrupt(params->interrupt->get())
{
fatal_if(!interrupt, "No MMIO VirtIO interrupt specified\n");
- vio.registerKickCallback(&callbackKick);
+ vio.registerKickCallback([this]() { kick(); });
}
MmioVirtIO::~MmioVirtIO()
uint32_t pageSize;
uint32_t interruptStatus;
- MakeCallback<MmioVirtIO, &MmioVirtIO::kick> callbackKick;
-
protected: // Params
VirtIODeviceBase &vio;
ArmInterruptPin *const interrupt;
guestFeatures(0),
byteOrder(params->system->getGuestByteOrder()),
deviceId(id), configSize(config_size), deviceFeatures(features),
- _deviceStatus(0), _queueSelect(0),
- transKick(NULL)
+ _deviceStatus(0), _queueSelect(0)
{
}
#ifndef __DEV_VIRTIO_BASE_HH__
#define __DEV_VIRTIO_BASE_HH__
+#include <functional>
+
#include "arch/isa_traits.hh"
#include "base/bitunion.hh"
-#include "base/callback.hh"
#include "dev/virtio/virtio_ring.h"
#include "mem/port_proxy.hh"
#include "sim/sim_object.hh"
* typically through an interrupt. Device models call this method
* to tell the transport interface to notify the guest.
*/
- void kick() {
+ void
+ kick()
+ {
assert(transKick);
- transKick->process();
+ transKick();
};
/**
* Register a callback to kick the guest through the transport
* interface.
*
- * @param c Callback into transport interface.
+ * @param callback Callback into transport interface.
*/
- void registerKickCallback(Callback *c) {
+ void
+ registerKickCallback(const std::function<void()> &callback)
+ {
assert(!transKick);
- transKick = c;
+ transKick = callback;
}
std::vector<VirtQueue *> _queues;
/** Callbacks to kick the guest through the transport layer */
- Callback *transKick;
+ std::function<void()> transKick;
};
class VirtIODummyDevice : public VirtIODeviceBase
PciVirtIO::PciVirtIO(const Params *params)
: PciDevice(params), queueNotify(0), interruptDeliveryPending(false),
- vio(*params->vio), callbackKick(this)
+ vio(*params->vio)
{
// Override the subsystem ID with the device ID from VirtIO
config.subsystemID = htole(vio.deviceId);
// used to check accesses later on.
BARSize[0] = alignToPowerOfTwo(BAR0_SIZE_BASE + vio.configSize);
- vio.registerKickCallback(&callbackKick);
+ vio.registerKickCallback([this]() { kick(); });
}
PciVirtIO::~PciVirtIO()
bool interruptDeliveryPending;
VirtIODeviceBase &vio;
-
- MakeCallback<PciVirtIO, &PciVirtIO::kick> callbackKick;
};
#endif // __DEV_VIRTIO_PCI_HH__