TT Zephyr Platforms 18.11.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
Tenstorrent virtual UART APIs

Data Structures

struct  tt_vuart
 In-memory ring buffer descriptor for Tenstorrent virtual UART. More...

Enumerations

enum  tt_vuart_role {
  TT_VUART_ROLE_DEVICE ,
  TT_VUART_ROLE_HOST
}
 Role of the virtual UART in the context of the shared memory buffer. More...

Functions

static size_t tt_vuart_inst (volatile const struct tt_vuart *vuart)
 Determine the instance number of a virtual UART buffer descriptor.
static uint32_t tt_vuart_buf_size (uint32_t head, uint32_t tail)
 Determine the size of the given buffer.
static uint32_t tt_vuart_buf_space (uint32_t head, uint32_t tail, uint32_t cap)
 Determine the free space available in the given buffer.
static bool tt_vuart_buf_empty (uint32_t head, uint32_t tail)
 Determine if the given buffer is empty.
static bool tt_vuart_buf_full (uint32_t head, uint32_t tail, uint32_t cap)
 Determine if the given buffer is full.
static int tt_vuart_poll_in (volatile struct tt_vuart *vuart, unsigned char *p_char, enum tt_vuart_role role)
 Poll the virtual UART buffer for incoming data.
static void tt_vuart_poll_out (volatile struct tt_vuart *vuart, unsigned char out_char, enum tt_vuart_role role)
 Poll the virtual UART buffer with outgoing data.

Detailed Description

Enumeration Type Documentation

◆ tt_vuart_role

Role of the virtual UART in the context of the shared memory buffer.

The virtual UART is a shared memory buffer that is used to communicate between a device and a host. The device and host have different perspectives on the buffer, so the role of the virtual UART is used to clarify the direction of communication.

From the perspective of the device, the transmit buffer is used to send data to the host, and the receive buffer is used to receive data from the host. Conversely, from the perspective of the host, the transmit buffer is used to send data to the device, and the receive buffer is used to receive data from the device.

Enumerator
TT_VUART_ROLE_DEVICE 

Device perspective of tt_vuart

TT_VUART_ROLE_HOST 

Host perspective of tt_vuart

Function Documentation

◆ tt_vuart_buf_empty()

bool tt_vuart_buf_empty ( uint32_t head,
uint32_t tail )
inlinestatic

Determine if the given buffer is empty.

Parameters
headHead index of the buffer
tailTail index of the buffer
Returns
true if the buffer is empty, false otherwise

◆ tt_vuart_buf_full()

bool tt_vuart_buf_full ( uint32_t head,
uint32_t tail,
uint32_t cap )
inlinestatic

Determine if the given buffer is full.

Parameters
headHead index of the buffer
tailTail index of the buffer
capCapacity of the buffer
Returns
true if the buffer is full, false otherwise

◆ tt_vuart_buf_size()

uint32_t tt_vuart_buf_size ( uint32_t head,
uint32_t tail )
inlinestatic

Determine the size of the given buffer.

Parameters
headHead index of the buffer
tailTail index of the buffer
Returns
Size of the buffer

◆ tt_vuart_buf_space()

uint32_t tt_vuart_buf_space ( uint32_t head,
uint32_t tail,
uint32_t cap )
inlinestatic

Determine the free space available in the given buffer.

Parameters
headHead index of the buffer
tailTail index of the buffer
capCapacity of the buffer
Returns
Free space available in the buffer

◆ tt_vuart_inst()

size_t tt_vuart_inst ( volatile const struct tt_vuart * vuart)
inlinestatic

Determine the instance number of a virtual UART buffer descriptor.

Parameters
vuartPointer to the virtual UART buffer descriptor
Returns
The instance number

◆ tt_vuart_poll_in()

int tt_vuart_poll_in ( volatile struct tt_vuart * vuart,
unsigned char * p_char,
enum tt_vuart_role role )
inlinestatic

Poll the virtual UART buffer for incoming data.

This method returns one byte of data from the virtual UART buffer, if available. If the buffer is empty, this method returns -1 (EOF).

Parameters
vuartPointer to the virtual UART buffer descriptor
p_charPointer to the location to store the incoming byte
roleRole with respect to the virtual UART buffer
Returns
The incoming byte, or -1 (EOF) if the buffer is empty

◆ tt_vuart_poll_out()

void tt_vuart_poll_out ( volatile struct tt_vuart * vuart,
unsigned char out_char,
enum tt_vuart_role role )
inlinestatic

Poll the virtual UART buffer with outgoing data.

This method transmits one byte of data from the virtual UART buffer, if possible. If the buffer is empty, this method simply returns.

If writing to the virtual UART results in buffer overflow, the overflow counter is incremented and the data is discarded.

Parameters
vuartPointer to the virtual UART buffer descriptor
out_charThe byte to transmit
roleRole with respect to the virtual UART buffer