L4Re Operating System Framework – Interface and Usage Documentation
|
Abstraction for L4-Virtio device config memory. More...
#include <l4virtio>
Inherited by L4virtio::Svr::Dev_config_t< l4virtio_block_config_t >, and L4virtio::Svr::Dev_config_t< PRIV_CONFIG >.
Public Member Functions | |
Dev_config (l4_uint32_t vendor, l4_uint32_t device, unsigned cfg_size, l4_uint32_t num_queues=0) | |
Create a L4-Virtio config data space. | |
Dev_config (Cfg_cap const &cfg, l4_addr_t cfg_offset, l4_uint32_t vendor, l4_uint32_t device, unsigned cfg_size, l4_uint32_t num_queues=0) | |
Setup an L4-Virtio config space in an existing data space. | |
l4_uint32_t | guest_features (unsigned idx) const |
Return a specific set of guest features. | |
l4_uint32_t | negotiated_features (unsigned idx) const |
Compute a specific set of negotiated features. | |
Status | status () const |
Get current device status (trusted). | |
l4_uint32_t | get_cmd () const |
Get the value from the cmd register. | |
void | reset_cmd () |
Reset the cmd register after execution of a command. | |
void | set_status (Status status) |
Set device status register. | |
void | set_device_needs_reset () |
Set DEVICE_NEEDS_RESET bit in device status register. | |
bool | change_queue_config (l4_uint32_t num_queues) |
Setup new queue configuration. | |
l4virtio_config_queue_t volatile const * | qconfig (unsigned index) const |
Get queue read-only config data for queue with the given index. | |
void | reset_hdr (bool inc_generation=false) const |
Reset the config header to the initial contents. | |
bool | reset_queue (unsigned index, unsigned num_max, bool inc_generation=false) const |
Reset queue config for the given queue. | |
l4virtio_config_hdr_t const volatile * | hdr () const |
Get a read-only pointer to the config header. | |
L4::Cap< L4Re::Dataspace > | ds () const |
Get data-space capability for the shared config data space. | |
l4_addr_t | ds_offset () const |
Return the offset into the config dataspace where the device configuration starts. | |
Abstraction for L4-Virtio device config memory.
Virtio defines a device configuration mechanism, L4-Virtio implements this mechanism based on shared memory a set_status() and a config_queue() call. This class provides an abstraction for L4-Virtio host implementations to establish such a shared memory data space and providing the necessary contents and access functions.
|
inline |
Create a L4-Virtio config data space.
vendor | The vendor ID to store in config header. |
device | The device ID to store in config header. |
cfg_size | The size of the device-specific config data in bytes. |
num_queues | The number of queues provided by the device. |
This constructor allocates a data space used for L4-virtio config attaches the data space to the local address space and writes the initial contents to the config header.
Definition at line 112 of file l4virtio.
References L4Re::chkcap(), L4Re::chksys(), L4Re::Env::env(), and L4_PAGESIZE.
|
inline |
Setup an L4-Virtio config space in an existing data space.
cfg | Dataspace that should hold the L4-Virtio configuration. |
cfg_offset | Offset into the dataspace where the configuration starts. |
vendor | The vendor ID to store in config header. |
device | The device ID to store in config header. |
cfg_size | The size of the device-specific config data in bytes. |
num_queues | The number of queues provided by the device. |
Definition at line 146 of file l4virtio.
References L4_PAGESIZE.
|
inline |
Setup new queue configuration.
num_queues | The number of queues provided by the device. |
Definition at line 269 of file l4virtio.
References L4_PAGESIZE, and reset_hdr().
|
inline |
|
inline |
Get the value from the cmd
register.
Note, the most significant eight bits are the command (0 is nothing to do). The upper eight bit are reset to zero after the command was handled.
Definition at line 224 of file l4virtio.
References l4virtio_config_hdr_t::cmd, and hdr().
Referenced by L4virtio::Svr::Device_t< DATA >::handle_mem_cmd_write().
|
inline |
Return a specific set of guest features.
idx | Index into the guest features array. |
The | selected set of guest features. |
This function returns a specific 32bit set of features enabled by the guest/driver. idx
is the index in the guest features array, resp. the 32 bit set to return.
|
inline |
Get a read-only pointer to the config header.
Definition at line 351 of file l4virtio.
References L4Re::Rm::Unique_region< T >::get().
Referenced by get_cmd(), reset_cmd(), set_device_needs_reset(), and set_status().
|
inline |
Compute a specific set of negotiated features.
idx | Index into the guest/host features array. |
The | selected set of negotiated features. |
This function returns a specific 32-bit set of features negotiated by the guest/driver and host/device. idx
is the index in the guest/host features array, resp. the 32-bit set to return.
|
inline |
Get queue read-only config data for queue with the given index.
index | The index of the queue. |
Definition at line 286 of file l4virtio.
References L4Re::Rm::Unique_region< T >::get(), and L4_UNLIKELY.
Referenced by reset_queue(), and L4virtio::Svr::Device_t< DATA >::setup_queue().
|
inline |
Reset the cmd
register after execution of a command.
This function resets the cmd
register in order for the client to detect that the command was executed by the device.
Definition at line 235 of file l4virtio.
References l4virtio_config_hdr_t::cmd, and hdr().
Referenced by L4virtio::Svr::Device_t< DATA >::handle_mem_cmd_write().
|
inline |
Reset queue config for the given queue.
index | The index of the queue to reset. |
num_max | The maximum number of descriptors supported by this queue. |
inc_generation | The config generation will be incremented when this is true. |
Definition at line 328 of file l4virtio.
References L4_UNLIKELY, l4virtio_config_queue_t::num, l4virtio_config_queue_t::num_max, qconfig(), and l4virtio_config_queue_t::ready.
Referenced by L4virtio::Svr::Device_t< DATA >::reset_queue_config().
|
inline |
Set DEVICE_NEEDS_RESET bit in device status register.
This function sets the internal status register and also the status register in the shared memory to DEVICE_NEEDS_RESET.
Definition at line 259 of file l4virtio.
References L4virtio::Svr::Dev_status::device_needs_reset(), hdr(), L4virtio::Svr::Dev_status::raw, and l4virtio_config_hdr_t::status.
Referenced by L4virtio::Svr::Device_t< DATA >::device_error().
|
inline |
Set device status register.
status | The new value for the device status register. |
This function sets the internal status register and also the status register in the shared memory to status.
Definition at line 247 of file l4virtio.
References hdr(), L4virtio::Svr::Dev_status::raw, status(), and l4virtio_config_hdr_t::status.
|
inline |
Get current device status (trusted).
The status returned by this function is value stored internally and cannot be written by the guest (i.e., the value can be taken as trusted.)
Definition at line 216 of file l4virtio.
Referenced by L4virtio::Svr::Device_t< DATA >::device_error(), and set_status().