gem5  v20.1.0.0
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
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 57 of file device.hh.

Constructor & Destructor Documentation

◆ KvmDevice()

KvmDevice::KvmDevice ( int  fd)

Definition at line 49 of file device.cc.

◆ ~KvmDevice()

KvmDevice::~KvmDevice ( )
virtual

Definition at line 54 of file device.cc.

References fd.

Member Function Documentation

◆ getAttr()

template<typename T >
T 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 75 of file device.hh.

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

◆ getAttrPtr()

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

Definition at line 60 of file device.cc.

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

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

◆ hasAttr()

bool 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 100 of file device.cc.

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

◆ ioctl() [1/3]

int KvmDevice::ioctl ( int  request) const
inlineprotected

Definition at line 116 of file device.hh.

References ioctl(), and X86ISA::L.

◆ ioctl() [2/3]

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

Definition at line 117 of file device.cc.

References fd.

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

◆ ioctl() [3/3]

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

Definition at line 113 of file device.hh.

References ioctl().

◆ setAttr()

template<typename T >
void 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 92 of file device.hh.

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

Referenced by KvmKernelGicV2::KvmKernelGicV2().

◆ setAttrPtr()

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

Definition at line 80 of file device.cc.

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

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

Member Data Documentation

◆ fd

int KvmDevice::fd
private

Definition at line 121 of file device.hh.

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


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

Generated on Wed Sep 30 2020 14:02:26 for gem5 by doxygen 1.8.17