12#ifndef TENSTORRENT_UART_TT_VIRT_H_
13#define TENSTORRENT_UART_TT_VIRT_H_
21#ifdef CONFIG_UART_TT_VIRT_TX_BLOCK
166 volatile atomic_uint *headp;
170 headp = (
volatile atomic_uint *)&vuart->
rx_head;
176 headp = (
volatile atomic_uint *)&vuart->
tx_head;
194 atomic_thread_fence(memory_order_acquire);
195 unsigned char ch = vuart->
buf[offs + (head % cap)];
197 if (atomic_compare_exchange_strong(headp, &head, head + 1)) {
232 volatile atomic_uint *tailp;
234#ifdef CONFIG_UART_TT_VIRT_TX_BLOCK
241 tailp = (
volatile atomic_uint *)&vuart->
tx_tail;
247 tailp = (
volatile atomic_uint *)&vuart->
rx_tail;
258#ifdef CONFIG_UART_TT_VIRT_TX_BLOCK
274 vuart->
buf[offs + (tail % cap)] = out_char;
275 atomic_store_explicit(tailp, tail + 1, memory_order_release);
static uint32_t k_uptime_get_32(void)
tt_vuart_role
Role of the virtual UART in the context of the shared memory buffer.
Definition uart_tt_virt.h:46
static bool tt_vuart_buf_empty(uint32_t head, uint32_t tail)
Determine if the given buffer is empty.
Definition uart_tt_virt.h:130
static uint32_t tt_vuart_buf_size(uint32_t head, uint32_t tail)
Determine the size of the given buffer.
Definition uart_tt_virt.h:105
static bool tt_vuart_buf_full(uint32_t head, uint32_t tail, uint32_t cap)
Determine if the given buffer is full.
Definition uart_tt_virt.h:143
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.
Definition uart_tt_virt.h:118
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.
Definition uart_tt_virt.h:159
static size_t tt_vuart_inst(volatile const struct tt_vuart *vuart)
Determine the instance number of a virtual UART buffer descriptor.
Definition uart_tt_virt.h:93
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.
Definition uart_tt_virt.h:225
@ TT_VUART_ROLE_DEVICE
Definition uart_tt_virt.h:47
@ TT_VUART_ROLE_HOST
Definition uart_tt_virt.h:48
In-memory ring buffer descriptor for Tenstorrent virtual UART.
Definition uart_tt_virt.h:73
uint32_t tx_head
Definition uart_tt_virt.h:79
uint32_t magic
Definition uart_tt_virt.h:74
uint32_t rx_cap
Definition uart_tt_virt.h:75
uint32_t tx_oflow
Definition uart_tt_virt.h:80
uint32_t rx_tail
Definition uart_tt_virt.h:77
uint32_t version
Definition uart_tt_virt.h:82
uint32_t tx_tail
Definition uart_tt_virt.h:81
uint32_t tx_cap
Definition uart_tt_virt.h:78
uint32_t rx_head
Definition uart_tt_virt.h:76
uint8_t buf[]
Definition uart_tt_virt.h:83
__weak volatile struct tt_vuart * uart_tt_virt_lookup_callback(size_t inst)
Definition uart_tt_virt.c:367
__weak void uart_tt_virt_init_callback(const struct device *dev, size_t inst)
Definition uart_tt_virt.c:361
volatile struct tt_vuart * uart_tt_virt_get(const struct device *dev)
Definition uart_tt_virt.c:374