Loading...
Searching...
No Matches
L4virtio::Svr::Dev_config Class Reference

Abstraction for L4-Virtio device config memory. More...

`#include <l4virtio>`

Collaboration diagram for L4virtio::Svr::Dev_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 | num_queues () const
| Return the number of queues currently usable.
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 | add_irq_status (l4_uint32_t status)
| Adds irq status bit.
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.

## Detailed Description

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.

Definition at line 52 of file l4virtio.

## Constructor & Destructor Documentation

## Dev_config() [1/2]

L4virtio::Svr::Dev_config::Dev_config | ( | l4_uint32_t | vendor,
|  | l4_uint32_t | device,
|  | unsigned | cfg_size,
|  | l4_uint32_t | num_queues = 0 )

inline

Create a L4-Virtio config data space.

Parameters

  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(), L4_PAGESIZE, L4Re::Util::make_shared_cap(), and num_queues().

Here is the call graph for this function:

## Dev_config() [2/2]

L4virtio::Svr::Dev_config::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 )

inline

Setup an L4-Virtio config space in an existing data space.

Parameters

  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, and num_queues().

Here is the call graph for this function:

## Member Function Documentation

## add_irq_status()

void L4virtio::Svr::Dev_config::add_irq_status | ( | l4_uint32_t | status | ) |

inline

Adds irq status bit.

Parameters

  status | The value to add to the irq status register.

This function adds the status bit to the irq status register.

Definition at line 265 of file l4virtio.

References hdr(), and status().

Here is the call graph for this function:

## change_queue_config()

bool L4virtio::Svr::Dev_config::change_queue_config | ( | l4_uint32_t | num_queues | ) |

inline

Setup new queue configuration.

Parameters

  num_queues | The number of queues provided by the device.

Definition at line 286 of file l4virtio.

References L4_PAGESIZE, num_queues(), and reset_hdr().

Here is the call graph for this function:

## ds()

L4::Cap< L4Re::Dataspace > L4virtio::Svr::Dev_config::ds | ( |  | ) | const

inline

Get data-space capability for the shared config data space.

Returns
  Capability for the shared config data space.

Definition at line 375 of file l4virtio.

## get_cmd()

l4_uint32_t L4virtio::Svr::Dev_config::get_cmd | ( |  | ) | const

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 230 of file l4virtio.

References hdr().

Here is the call graph for this function:

## guest_features()

l4_uint32_t L4virtio::Svr::Dev_config::guest_features | ( | unsigned | idx | ) | const

inline

Return a specific set of guest features.

Parameters

  idx | Index into the guest features array.

Return values

  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.

Definition at line 198 of file l4virtio.

## hdr()

l4virtio_config_hdr_t const volatile * L4virtio::Svr::Dev_config::hdr | ( |  | ) | const

inline

Get a read-only pointer to the config header.

Returns
  Read-only pointer to the shared config header.

Definition at line 368 of file l4virtio.

Referenced by add_irq_status(), get_cmd(), reset_cmd(), set_device_needs_reset(), and set_status().

Here is the caller graph for this function:

## negotiated_features()

l4_uint32_t L4virtio::Svr::Dev_config::negotiated_features | ( | unsigned | idx | ) | const

inline

Compute a specific set of negotiated features.

Parameters

  idx | Index into the guest/host features array.

Return values

  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.

Definition at line 212 of file l4virtio.

## qconfig()

l4virtio_config_queue_t volatile const * L4virtio::Svr::Dev_config::qconfig | ( | unsigned | index | ) | const

inline

Get queue read-only config data for queue with the given index.

Parameters

  index | The index of the queue.

Returns
  Read-only pointer to the config of the queue with the given index, or NULL if index is out of range.

Definition at line 303 of file l4virtio.

References L4_UNLIKELY.

Referenced by reset_queue().

Here is the caller graph for this function:

## reset_cmd()

void L4virtio::Svr::Dev_config::reset_cmd | ( |  | ) |

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 241 of file l4virtio.

References hdr().

Here is the call graph for this function:

## reset_queue()

bool L4virtio::Svr::Dev_config::reset_queue | ( | unsigned | index,
|  | unsigned | num_max,
|  | bool | inc_generation = false ) const

inline

Reset queue config for the given queue.

Parameters

  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.

Returns
  true on success, or false when index is out of range.

Definition at line 345 of file l4virtio.

References L4_UNLIKELY, l4virtio_config_queue_t::num, l4virtio_config_queue_t::num_max, qconfig(), and l4virtio_config_queue_t::ready.

Here is the call graph for this function:

## set_device_needs_reset()

void L4virtio::Svr::Dev_config::set_device_needs_reset | ( |  | ) |

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 276 of file l4virtio.

References hdr().

Here is the call graph for this function:

## set_status()

void L4virtio::Svr::Dev_config::set_status | ( | Status | status | ) |

inline

Set device status register.

Parameters

  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 253 of file l4virtio.

References hdr(), and status().

Here is the call graph for this function:

## status()

Status L4virtio::Svr::Dev_config::status | ( |  | ) | const

inline

Get current device status (trusted).

Returns
  Current device status register (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 222 of file l4virtio.

Referenced by add_irq_status(), and set_status().

Here is the caller graph for this function:

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

- l4/l4virtio/server/l4virtio