L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
L4virtio::Svr::Console::Port Struct Reference

Representation of a Virtio console port. More...

#include <virtio-console>

+ Inheritance diagram for L4virtio::Svr::Console::Port:
+ Collaboration diagram for L4virtio::Svr::Console::Port:

Data Structures

struct  Transition
 State transition from last report state to current state. More...
 

Public Types

enum  Port_status {
  Port_disabled = 0 , Port_added , Port_ready , Port_open ,
  Port_failed , Port_num_states
}
 Possible states of a virtio console port. More...
 
enum  
 Size of control queues, also used as default size.
 

Public Member Functions

bool is_open () const
 Check that the port is open.
 
virtual void reset ()
 Reset the port to the initial state and disable its virtqueues.
 
bool queues_ready () const
 Check that both virtqueues are set up correctly.
 
bool rx_ready () const
 Check that device implementation may write to receive queues.
 
bool tx_ready () const
 Check that device implementation may read from transmit queues.
 

Data Fields

Virtqueue tx
 Receiveq of the port.
 
Virtqueue rx
 Transmitq of the port.
 
Port_status status
 State the port is in.
 
Port_status reported_status
 State the port was last reported.
 
unsigned vq_max
 Maximum queue sizes for this port.
 

Static Public Attributes

static constexpr Transition state_transitions [Port_num_states][Port_num_states]
 State transition table from last report state to current state.
 

Detailed Description

Representation of a Virtio console port.

Each port consists of a pair of queues for sending and receiving.

A port may be added and removed at runtime when the multi-port feature is enabled. The states are as follows:

+----------+ port_remove()
| DISABLED |<----------------------- [all]
+----------+
|
| port_add()
v
+----------+ process_port_ready(0)
| ADDED + --------------+
+----------+ | +--------+
| +------------>| |
| process_port_ready(1) | |
v | FAILED |
+----------+ process_port_ready(0) | |
| |---------------------------->| |
| READY | process_port_ready(1) | |
| |<----------------------------| |
+----------+<----------+ +--------+
| | ^
| port_open(true) | port_open(false) |
v | | process_port_ready(0)
+----------+ | |
| OPEN |-----------+ |
+----------+----------------------------------+

Definition at line 109 of file virtio-console.

Member Enumeration Documentation

◆ Port_status

Possible states of a virtio console port.

Enumerator
Port_disabled 

Reset state, waiting for port to be added.

Port_added 

Port has been added by device, waiting for ready message.

Port_ready 

Port is ready but still closed.

Port_open 

Port is in a working state.

Port_failed 

Device failure, port unusable.

Port_num_states 

Number of port states. Must be last.

Definition at line 114 of file virtio-console.

Field Documentation

◆ state_transitions

constexpr Transition L4virtio::Svr::Console::Port::state_transitions[Port_num_states][Port_num_states]
staticconstexpr

State transition table from last report state to current state.

Not all transitions can be made directly. For example, if the last reported state was Port_disabled and the current state is Port_open, the device has to send two messages: Control_message::Device_add and Control_message::Port_open. This is expressed by going through an intermediate state (Port_ready) on the reporting side.

For the purpose of the driver there are only three coarse states:

  1. The port does not exist (Port_disabled).
  2. The port exists but is closed on the device side (Port_added, Port_ready, Port_failed).
  3. The port exists and is open on the device side (Port_open).

The state transition table with Port_added, Port_ready and Port_failed as current state are thus identical.

Definition at line 195 of file virtio-console.


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