hw/char/cadence_uart: Add BXRS register definition
PATCH v5 2/13 hw/char/cadence_uart: Add BXRS register definition
The RXBS (RX FIFO Byte Status) register at 0x48 is only exposed to the guest when the brk_support property is set, so the accessible size should be CADENCE_UART_R_MAX_BRK in that case and CADENCE_UART_R_MAX otherwise.
Signed-off-by Kuan-Jui Chiu <[email protected]>
--- hw/char/cadence_uart.c | 15 ++++++++++++--- include/hw/char/cadence_uart.h | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-)
hw/char/cadence_uart.c +12 -3
@@ -120,6 +120,13 @@#define R_PMIN (0x3C/4)#define R_PWID (0x40/4)#define R_TTRIG (0x44/4) +#define R_RXBS (0x48/4) + +/* Number of registers reachable by the guest, depending on brk_support */ +static inline unsigned int uart_r_max (const CadenceUARTState *s) +{ +return s->brk_support ?CADENCE_UART_R_MAX_BRK :CADENCE_UART_R_MAX ; +}static void uart_update_status (CadenceUARTState *s)
@@ -424,7 +431,7 @@ static MemTxResult uart_write(void *opaque, hwaddr offset,DB_PRINT (" offset:%x data:%08x\n" , (unsigned )offset, (unsigned )value); offset >>=2 ; -if (offset >=CADENCE_UART_R_MAX ) { +if (offset >=uart_r_max (s)) {return MEMTX_DECODE_ERROR ; }switch (offset) {
@@ -492,7 +499,7 @@ static MemTxResult uart_read(void *opaque, hwaddr offset, } offset >>=2 ; -if (offset >=CADENCE_UART_R_MAX ) { +if (offset >=uart_r_max (s)) {return MEMTX_DECODE_ERROR ; }if (offset ==R_TX_RX ) {
@@ -523,6 +530,7 @@ static void cadence_uart_reset_init(Object *obj, ResetType type) s->r[R_BRGR ] =0x0000028B ; s->r[R_BDIV ] =0x0000000F ; s->r[R_TTRIG ] =0x00000020 ; + s->r[R_RXBS ] =0 ; }static void cadence_uart_reset_hold (Object *obj,ResetType type)
@@ -603,7 +611,7 @@ static const VMStateDescription vmstate_cadence_uart = { .pre_load = cadence_uart_pre_load, .post_load = cadence_uart_post_load, .fields = (const VMStateField []) { -VMSTATE_UINT32_ARRAY (r, CadenceUARTState,CADENCE_UART_R_MAX ), +VMSTATE_UINT32_ARRAY (r, CadenceUARTState,CADENCE_UART_R_MAX_BRK ),VMSTATE_UINT8_ARRAY (rx_fifo, CadenceUARTState,CADENCE_UART_RX_FIFO_SIZE ), VMSTATE_UINT8_ARRAY(tx_fifo, CadenceUARTState,
@@ -619,6 +627,7 @@ static const VMStateDescription vmstate_cadence_uart = {static const Property cadence_uart_properties[] = {DEFINE_PROP_CHR ("chardev" , CadenceUARTState, chr), +DEFINE_PROP_BOOL ("brk-support" , CadenceUARTState, brk_support, false), };static void cadence_uart_class_init (ObjectClass *klass,const void *data)
include/hw/char/cadence_uart.h +3 -1
@@ -30,6 +30,7 @@#define CADENCE_UART_TX_FIFO_SIZE 16#define CADENCE_UART_R_MAX (0x48/4) +#define CADENCE_UART_R_MAX_BRK (0x4C/4)#define TYPE_CADENCE_UART "cadence_uart"OBJECT_DECLARE_SIMPLE_TYPE (CadenceUARTState,CADENCE_UART )
@@ -40,7 +41,7 @@ struct CadenceUARTState {/*< public >*/ MemoryRegion iomem; -uint32_t r[CADENCE_UART_R_MAX ]; +uint32_t r[CADENCE_UART_R_MAX_BRK ];uint8_t rx_fifo[CADENCE_UART_RX_FIFO_SIZE ];uint8_t tx_fifo[CADENCE_UART_TX_FIFO_SIZE ];uint32_t rx_wpos;
@@ -51,6 +52,7 @@ struct CadenceUARTState {qemu_irq irq;QEMUTimer *fifo_trigger_handle;Clock *refclk; + bool brk_support; };#endif
Signature · 1 line
2.34.1