gem5  v21.1.0.2
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
gem5::KvmDevice Class Reference

KVM device wrapper. More...

#include <device.hh>

Public Member Functions

 KvmDevice (int fd)
 
virtual ~KvmDevice ()
 
template<typename T >
getAttr (uint32_t group, uint64_t attr) const
 Get the value of an attribute. More...
 
template<typename T >
void setAttr (uint32_t group, uint64_t attr, const T &data) const
 Get the value of an attribute. More...
 
void getAttrPtr (uint32_t group, uint64_t attr, void *data) const
 
void setAttrPtr (uint32_t group, uint64_t attr, const void *data) const
 
bool hasAttr (uint32_t group, uint64_t attr) const
 Check if a device attribute is valid. More...
 

Protected Member Functions

int ioctl (int request, long p1) const
 
int ioctl (int request, void *p1) const
 
int ioctl (int request) const
 

Private Attributes

int fd
 

Detailed Description

KVM device wrapper.

This is a wrapper around a device emulated by KVM. Such devices can be created using KvmVM::createDevice() API. They are typically used for in-kernel interrupt controllers and similar devices.

Each device has a device-specific set of attributes which are mapped into groups. The available attributes are described in the device's documentation in the kernel source tree (Documentation/virtual/kvm/devices/). Each attribute can be accessed with the getAttr() and setAttr() access methods. The presence of an attribute can be queried using the hasAttr() method.

Definition at line 60 of file device.hh.

Constructor & Destructor Documentation

◆ KvmDevice()

gem5::KvmDevice::KvmDevice ( int  fd)

Definition at line 52 of file device.cc.

◆ ~KvmDevice()

gem5::KvmDevice::~KvmDevice ( )
virtual

Definition at line 57 of file device.cc.

References fd.

Member Function Documentation

◆ getAttr()

template<typename T >
T gem5::KvmDevice::getAttr ( uint32_t  group,
uint64_t  attr 
) const
inline

Get the value of an attribute.

See KVM's documentation, and specifically the device-specific documentation, for available attributes and attribute groups.

Parameters
groupAttribute group
attrAttribute ID within group
Returns
Attribute value

Definition at line 78 of file device.hh.

References gem5::ArmISA::attr, data, and getAttrPtr().

◆ getAttrPtr()

void gem5::KvmDevice::getAttrPtr ( uint32_t  group,
uint64_t  attr,
void *  data 
) const

Definition at line 63 of file device.cc.

References gem5::ArmISA::attr, data, ioctl(), and panic.

Referenced by getAttr(), and gem5::KvmKernelGicV2::getGicReg().

◆ hasAttr()

bool gem5::KvmDevice::hasAttr ( uint32_t  group,
uint64_t  attr 
) const

Check if a device attribute is valid.

See KVM's documentation, and specifically the device-specific documentation, for available attributes and attribute groups.

Parameters
groupAttribute group
attrAttribute ID within group
Returns
true if attribute is valid, false otherwise.

Definition at line 105 of file device.cc.

References gem5::ArmISA::attr, ioctl(), and panic.

◆ ioctl() [1/3]

int gem5::KvmDevice::ioctl ( int  request) const
inlineprotected

Definition at line 119 of file device.hh.

References ioctl(), and gem5::X86ISA::L.

◆ ioctl() [2/3]

int gem5::KvmDevice::ioctl ( int  request,
long  p1 
) const
protected

Definition at line 123 of file device.cc.

References fd.

Referenced by getAttrPtr(), hasAttr(), ioctl(), and setAttrPtr().

◆ ioctl() [3/3]

int gem5::KvmDevice::ioctl ( int  request,
void *  p1 
) const
inlineprotected

Definition at line 116 of file device.hh.

References ioctl().

◆ setAttr()

template<typename T >
void gem5::KvmDevice::setAttr ( uint32_t  group,
uint64_t  attr,
const T &  data 
) const
inline

Get the value of an attribute.

See KVM's documentation, and specifically the device-specific documentation, for available attributes and attribute groups.

Parameters
groupAttribute group
attrAttribute ID within group
Returns
Attribute value

Definition at line 95 of file device.hh.

References gem5::ArmISA::attr, data, and setAttrPtr().

Referenced by gem5::KvmKernelGicV2::KvmKernelGicV2().

◆ setAttrPtr()

void gem5::KvmDevice::setAttrPtr ( uint32_t  group,
uint64_t  attr,
const void *  data 
) const

Definition at line 84 of file device.cc.

References gem5::ArmISA::attr, data, ioctl(), and panic.

Referenced by setAttr(), and gem5::KvmKernelGicV2::setGicReg().

Member Data Documentation

◆ fd

int gem5::KvmDevice::fd
private

Definition at line 124 of file device.hh.

Referenced by ioctl(), and ~KvmDevice().


The documentation for this class was generated from the following files:

Generated on Tue Sep 21 2021 12:27:44 for gem5 by doxygen 1.8.17