ESCC2
cover ESCC2
I've been working on improving Solaris 10 emulation for the SPARC64 Sun4u architecture with the goal of a working shell. Currently, Solaris 10 boots with a number of errors before displaying the prompt of an otherwise unresponsive installer shell. It's been mentioned that this problem may not be isolated to Solaris 10 but may affect derivatives of OpenSolaris including illumos.
From what I can tell, Solaris 10 never attempts to use the 16550A UART for the serial console. The kernel will probe registers to identify the device but will not use it for receiving or transmitting. The kernel only prints to the console using the prom interface that OpenBIOS provides. It's difficult to ascertain what the problem is because there is no visibility into the kernel. The 16550A UART on the Ultra 5 (Darwin), the machine that QEMU Sun4u is modelled against, is used for the keyboard/mouse (SuperIO) and is not traditionally used for the serial tty. Instead, the SAB 82532 ESCC2 is used to provide ttya and ttyb on this system. This patch exists to increment QEMU Sun4u towards being hardware faithful.
The SAB 82532 ESCC2 is complex because of the jungle of features that it provides. Linux and OpenBSD only use a small subset of features restricted to the ASYNC serial mode. The ASYNC serial mode is relatively simple to implement in isolation. I have made progress on a patch series that supports all serial modes, along with transitioning between them, but I have decided against submitting it. The serial controller appears to multiplex bit positions in registers across serial modes while preserving the bits themselves. This means that some 8-bit registers need to keep track of more than 8-bits of data and that the interpretation of the value the register holds depends on the selected serial mode. It's not ideal having a copy of each register for each serial mode because some bits are shared across some of the register modes. An added difficulty is that the manual doesn't document this behaviour well and its unclear what exactly happens when there is a transition in the selected serial mode. I've avoided depending on registers being uint8_t and have made use of macros so that the backend implementation of each register can be changed at a later date when supporting other serial modes. If I have the opportunity to test real hardware, or it becomes clear that HDLC/SDLC/BISYNC support is needed, I'll look at upstreaming the other changes that I have.
I have written a bare-bones patch for OpenBIOS that adds this device to the device tree. With that applied, Solaris identifies and attaches the device successfully but does not interact with it further - similar to the 16550A UART. I did notice, however, that Solaris 10 entered an interrupt routine for this device when the network card was being configured. I couldn't manage to provoke this behaviour for the 16550A so this might be some small success. I strongly suspect that the interrupt is a spurious interrupt caused by misconfiguration of the devices in the firmware but I have not investigated this further.
Solaris 10, judging from the OpenSolaris source code, determines stdin/stdout for the console by examining the stdin/stdout properties under /chosen in the device tree. Naturally, this is done with the prom interface. From what I can tell, to set these properties to the ESCC2 node it's necessary to change stdin/stdout for OpenBIOS completely. This requires a device driver. I have made some progress on an OpenBIOS device driver for the ESCC2 but it's taking longer than expected to completely replace the 16550A and it's unlikely that I will have this finished soon. It's possible that Solaris 10 emulation for this platform will improve once that work is finished but it's unclear.
This is my first patch series for QEMU so it's possible that I've made mistakes in the contribution process - sorry in advance.
Jasper Lowell (8):
hw/char/escc2: Add device
hw/char/escc2: Handle interrupt generation hw/char/escc2: Add character device backend hw/char/escc2: Add clock generation hw/char/escc2: Add Receiver Reset (RRES) command hw/char/escc2: Add RFRD command hw/char/escc2: Add Transmit Frame (XF) command hw/char/escc2: Add XRES command
hw/char/Kconfig | 8 + hw/char/Makefile.objs | 1 + hw/char/escc2.c | 1135 +++++++++++++++++++++++++++++++++++++++ hw/char/trace-events | 6 + include/hw/char/escc2.h | 17 + 5 files changed, 1167 insertions(+) create mode 100644 hw/char/escc2.c create mode 100644 include/hw/char/escc2.h
Signature · 1 line
2.26.2
PATCH 1/8 hw/char/escc2: Add device
The Ultra 5 (Darwin) machine that is emulated for the Sun4u architecture ships with a SAB 82532 ESCC2 device that is used for providing the default ttya/ttyb serial consoles. This device is introduced to increment Sun4u emulation towards being hardware faithful. ISA support is included so that the device can be attached to the Sun ebus.
Due to the complexity of the chip, the SAB 82532 ESCC2 is assumed to be configured and used in the ASYNC serial mode. This is the case for typical operating system drivers like those in Linux and OpenBSD.
While ASYNC serial mode is assumed, the implementation is designed with the assumption that the full set of serial modes may be added at a later date. Registers can not be represented as uint8_t when more than a single serial mode is correctly implemented and so, the design avoids assuming the data structure used for registers. Avoiding this assumption leads to loops, rather than memset, along with a verbose switch case. The verbose switch case also has the benefit of preemptively detangling the jungle of features that the device supports.
--- hw/char/Kconfig | 8 + hw/char/Makefile.objs | 1 + hw/char/escc2.c | 581 ++++++++++++++++++++++++++++++++++++++++ hw/char/trace-events | 4 + include/hw/char/escc2.h | 17 ++ 5 files changed, 611 insertions(+) create mode 100644 hw/char/escc2.c create mode 100644 include/hw/char/escc2.h
hw/char/Kconfig +8 -0
@@ -1,6 +1,14 @@ config ESCC bool +config ESCC2 + bool + +config ESCC2_ISA + bool + depends on ISA_BUS + select ESCC2 + config PARALLEL bool default y
hw/char/Makefile.objs +1 -0
@@ -1,5 +1,6 @@ common-obj-$(CONFIG_IPACK) += ipoctal232.o common-obj-$(CONFIG_ESCC) += escc.o +common-obj-$(CONFIG_ESCC2) += escc2.o common-obj-$(CONFIG_NRF51_SOC) += nrf51_uart.o common-obj-$(CONFIG_PARALLEL) += parallel.o common-obj-$(CONFIG_ISA_BUS) += parallel-isa.o
hw/char/escc2.c new file +581 -0
581 lines not on this page · raw message
hw/char/trace-events +4 -0
@@ -56,6 +56,10 @@ escc_sunkbd_event_out(int ch) "Translated keycode 0x%2.2x" escc_kbd_command(int val) "Command %d" escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=0x%01x" +# escc2.c +escc2_mem_read(char channel, uint32_t addr, uint8_t value) "channel %c addr 0x%x value 0x%x" +escc2_mem_write(char channel, uint32_t addr, uint8_t value) "channel %c addr 0x%x value 0x%x" + # pl011.c pl011_irq_state(int level) "irq state %d" pl011_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
include/hw/char/escc2.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* QEMU Enhanced Serial Communication Controller (ESCC2 v3.2). +* Modelled according to the user manual (version 07.96). +* +* Copyright (C) 2020 Jasper Lowell +*/ +#ifndef HW_ESCC2_H +#define HW_ESCC2_H + +#define TYPE_ESCC2 "ESCC2" +#define ESCC2 (obj) OBJECT_CHECK(ESCC2State, (obj), TYPE_ESCC2) + +#define TYPE_ESCC2_ISA "ESCC2_ISA" +#define ESCC2_ISA (obj) OBJECT_CHECK(ESCC2ISAState, (obj), TYPE_ESCC2_ISA) + +#endif /* HW_ESCC2_H */
Signature · 1 line
2.26.2
PATCH 2/8 hw/char/escc2: Handle interrupt generation
In reply to Jasper Lowell--- hw/char/escc2.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ hw/char/trace-events | 1 + 2 files changed, 89 insertions(+)
hw/char/escc2.c +88 -0
@@ -8,6 +8,7 @@#include "qemu/osdep.h" #include "hw/char/escc2.h" +#include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" #include "qapi/error.h"
@@ -55,6 +56,13 @@/* CCR0. */ #define REGISTER_CCR0_OFFSET 0x2c +#define REGISTER_CCR0_PU 0x80 +#define REGISTER_CCR0_MCE 0x40 +#define REGISTER_CCR0_SC2 0x10 +#define REGISTER_CCR0_SC1 0x8 +#define REGISTER_CCR0_SC0 0x4 +#define REGISTER_CCR0_SM1 0x2 +#define REGISTER_CCR0_SM0 0x1/* CCR1. */ #define REGISTER_CCR1_OFFSET 0x2d
@@ -94,12 +102,23 @@/* GIS. */ #define REGISTER_GIS_OFFSET 0x38 +#define REGISTER_GIS_PI 0x80 +#define REGISTER_GIS_ISA1 0x8 +#define REGISTER_GIS_ISA0 0x4 +#define REGISTER_GIS_ISB1 0x2 +#define REGISTER_GIS_ISB0 0x1/* IVA. */ #define REGISTER_IVA_OFFSET 0x38/* IPC. */ #define REGISTER_IPC_OFFSET 0x39 +#define REGISTER_IPC_VIS 0x80 +#define REGISTER_IPC_SLA1 0x10 +#define REGISTER_IPC_SLA0 0x8 +#define REGISTER_IPC_CASM 0x4 +#define REGISTER_IPC_IC1 0x2 +#define REGISTER_IPC_IC0 0x1/* ISR0. */ #define REGISTER_ISR0_OFFSET 0x3a
@@ -207,6 +226,7 @@ struct ESCC2State {DeviceState parent;MemoryRegion io; +qemu_irq irq;ESCC2ChannelState channel[CHANNEL_COUNT ]; };
@@ -218,9 +238,62 @@ struct ESCC2State {typedef struct ESCC2ISAState {ISADevice parent;uint32_t iobase; +uint32_t irq;struct ESCC2State controller; }ESCC2ISAState ; +static void escc2_irq_update (ESCC2State *controller) +{ +bool power; +uint8_t gis; +ESCC2ChannelState *a, *b; + + gis =0 ; + a =CONTROLLER_CHANNEL_A (controller); + b =CONTROLLER_CHANNEL_B (controller); + +/* +* Interrupts are not propagated to the CPU when in power-down mode. There +* is an exception for interrupts from the universal port. +*/ + power =REGISTER_READ (a,REGISTER_CCR0 ) ®ISTER_CCR0_PU ; + +if (REGISTER_READ (a,REGISTER_ISR0 ) & ~(REGISTER_READ (a,REGISTER_IMR0 ))) { + gis |=REGISTER_GIS_ISA0 ; + } +if (REGISTER_READ (a,REGISTER_ISR1 ) & ~(REGISTER_READ (a,REGISTER_IMR1 ))) { + gis |=REGISTER_GIS_ISA1 ; + } + +if (REGISTER_READ (b,REGISTER_ISR0 ) & ~(REGISTER_READ (b,REGISTER_IMR0 ))) { + gis |=REGISTER_GIS_ISB0 ; + } +if (REGISTER_READ (b,REGISTER_ISR1 ) & ~(REGISTER_READ (b,REGISTER_IMR1 ))) { + gis |=REGISTER_GIS_ISB1 ; + } + +if (REGISTER_READ (a,REGISTER_PIS ) & ~(REGISTER_READ (a,REGISTER_PIM ))) { + gis |=REGISTER_GIS_PI ; +/* +* Ensure that interrupts are propagated even if the controller is in +* power-down mode. +*/ + power = true; + } + +/* GIS is accessible from either channel and must be synchronised. */ +REGISTER_WRITE (a,REGISTER_GIS , gis); +REGISTER_WRITE (b,REGISTER_GIS , gis); + +if (gis && power) { +qemu_irq_raise (controller->irq); + }else { +qemu_irq_lower (controller->irq); + } + +trace_escc2_irq_update (gis); +} +static void escc2_channel_reset (ESCC2ChannelState *channel) {unsigned int i;
@@ -320,15 +393,22 @@ static uint64_t escc2_mem_read(void *opaque, hwaddr addr, unsigned size)break ;case REGISTER_ISR0_OFFSET : value =REGISTER_READ (channel,REGISTER_ISR0 ); +REGISTER_WRITE (channel,REGISTER_ISR0 ,0 ); +escc2_irq_update (controller);break ;case REGISTER_ISR1_OFFSET : value =REGISTER_READ (channel,REGISTER_ISR1 ); +REGISTER_WRITE (channel,REGISTER_ISR1 ,0 ); +escc2_irq_update (controller);break ;case REGISTER_PVR_OFFSET : value =REGISTER_READ (channel,REGISTER_PVR );break ;case REGISTER_PIS_OFFSET : value =REGISTER_READ (channel,REGISTER_PIS ); +REGISTER_WRITE (CONTROLLER_CHANNEL_A (controller),REGISTER_PIS ,0 ); +REGISTER_WRITE (CONTROLLER_CHANNEL_B (controller),REGISTER_PIS ,0 ); +escc2_irq_update (controller);break ;case REGISTER_PCR_OFFSET : value =REGISTER_READ (channel,REGISTER_PCR );
@@ -506,6 +586,13 @@ static void escc2_isa_realize(DeviceState *dev, Error **errp)return ; } +if (isa->irq ==-1 ) { +error_setg (errp,"IRQ must be provided." ); +return ; + } + +isa_init_irq (ISA_DEVICE (dev), &controller->irq, isa->irq); +object_property_set_bool (OBJECT (controller), true,"realized" , errp);if (*errp) {return ;
@@ -536,6 +623,7 @@ static Property escc2_properties[] = {static Property escc2_isa_properties[] = {DEFINE_PROP_UINT32 ("iobase" , ESCC2ISAState, iobase,-1 ), +DEFINE_PROP_UINT32 ("irq" , ESCC2ISAState, irq,-1 ),DEFINE_PROP_END_OF_LIST () };
hw/char/trace-events +1 -0
@@ -57,6 +57,7 @@ escc_kbd_command(int val) "Command %d" escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=0x%01x" # escc2.c +escc2_irq_update(uint8_t gis) "value 0x%x" escc2_mem_read(char channel, uint32_t addr, uint8_t value) "channel %c addr 0x%x value 0x%x" escc2_mem_write(char channel, uint32_t addr, uint8_t value) "channel %c addr 0x%x value 0x%x"
Signature · 1 line
2.26.2
PATCH 3/8 hw/char/escc2: Add character device backend
In reply to Jasper Lowell--- hw/char/escc2.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+)
hw/char/escc2.c +234 -0
@@ -7,6 +7,8 @@*/ #include "qemu/osdep.h" +#include "chardev/char-fe.h" +#include "chardev/char-serial.h" #include "hw/char/escc2.h" #include "hw/irq.h" #include "hw/isa/isa.h"
@@ -17,6 +19,13 @@/* STAR. */ #define REGISTER_STAR_OFFSET 0x20 +#define REGISTER_STAR_XDOV 0x80 +#define REGISTER_STAR_XFW 0x40 +#define REGISTER_STAR_RFNE 0x20 +#define REGISTER_STAR_FCS 0x10 +#define REGISTER_STAR_TEC 0x8 +#define REGISTER_STAR_CEC 0x4 +#define REGISTER_STAR_CTS 0x2/* CMDR. */ #define REGISTER_CMDR_OFFSET 0x20
@@ -38,9 +47,40 @@/* DAFO. */ #define REGISTER_DAFO_OFFSET 0x27 +#define REGISTER_DAFO_XBRK 0x40 +#define REGISTER_DAFO_STOP 0x20 +#define REGISTER_DAFO_PAR1 0x10 +#define REGISTER_DAFO_PAR0 0x8 +#define REGISTER_DAFO_PARE 0x4 +#define REGISTER_DAFO_CHL1 0x2 +#define REGISTER_DAFO_CHL0 0x1 + +#define REGISTER_DAFO_PAR_MASK \ + (REGISTER_DAFO_PAR1 | REGISTER_DAFO_PAR0) +#define REGISTER_DAFO_PAR_SPACE 0x0 +#define REGISTER_DAFO_PAR_ODD (REGISTER_DAFO_PAR0) +#define REGISTER_DAFO_PAR_EVEN (REGISTER_DAFO_PAR1) +#define REGISTER_DAFO_PAR_MARK \ + (REGISTER_DAFO_PAR1 | REGISTER_DAFO_PAR0) +#define REGISTER_DAFO_CHL_MASK \ + (REGISTER_DAFO_CHL1 | REGISTER_DAFO_CHL0) +#define REGISTER_DAFO_CHL_CS8 0x0 +#define REGISTER_DAFO_CHL_CS7 (REGISTER_DAFO_CHL0) +#define REGISTER_DAFO_CHL_CS6 (REGISTER_DAFO_CHL1) +#define REGISTER_DAFO_CHL_CS5 \ + (REGISTER_DAFO_CHL1 | REGISTER_DAFO_CHL0)/* RFC. */ #define REGISTER_RFC_OFFSET 0x28 +#define REGISTER_RFC_DPS 0x40 +#define REGISTER_RFC_DXS 0x20 +#define REGISTER_RFC_RFDF 0x10 +#define REGISTER_RFC_RFTH1 0x8 +#define REGISTER_RFC_RFTH0 0x4 +#define REGISTER_RFC_TCDE 0x1 + +#define REGISTER_RFC_RFTH_MASK \ + (REGISTER_RFC_RFTH1 | REGISTER_RFC_RFTH0)/* RBCL. */ #define REGISTER_RBCL_OFFSET 0x2a
@@ -122,6 +162,14 @@/* ISR0. */ #define REGISTER_ISR0_OFFSET 0x3a +#define REGISTER_ISR0_TCD 0x80 +#define REGISTER_ISR0_TIME 0x40 +#define REGISTER_ISR0_PERR 0x20 +#define REGISTER_ISR0_FERR 0x10 +#define REGISTER_ISR0_PLLA 0x8 +#define REGISTER_ISR0_CDSC 0x4 +#define REGISTER_ISR0_RFO 0x2 +#define REGISTER_ISR0_RPF 0x1/* IMR0. */ #define REGISTER_IMR0_OFFSET 0x3a
@@ -196,6 +244,8 @@ typedef struct ESCC2State ESCC2State; typedef struct ESCC2ChannelState { ESCC2State *controller; + CharBackend chardev; + /* * The SAB 82532 ships with 64 byte FIFO queues for transmitting and * receiving but only 32 bytes are addressable.
@@ -294,6 +344,102 @@ static void escc2_irq_update(ESCC2State *controller)trace_escc2_irq_update (gis); } +static void escc2_channel_irq_event (ESCC2ChannelState *channel, +uint8_t status_register,uint8_t event) +{ +/* +* Ensure that event does not have more than one bit set when calling this +* function. +*/ +uint8_t mask, tmp; + +switch (status_register) { +case REGISTER_ISR0 : + mask =REGISTER_READ (channel,REGISTER_IMR0 ); +break ; +case REGISTER_ISR1 : + mask =REGISTER_READ (channel,REGISTER_IMR1 ); +break ; +default : +g_assert_not_reached (); + } + +if ((event & ~(mask)) + || (REGISTER_READ (channel,REGISTER_IPC ) ®ISTER_IPC_VIS )) { + tmp =REGISTER_READ (channel, status_register); + tmp |= event; +REGISTER_WRITE (channel, status_register, tmp); + } + +if (event & ~(mask)) { +escc2_irq_update (channel->controller); + } +} + +static void escc2_channel_parameters_update (ESCC2ChannelState *channel) +{ +uint8_t dafo; +QEMUSerialSetParams ssp; + +if (!qemu_chr_fe_backend_connected (&channel->chardev)) { +return ; + } + +/* Check if parity is enabled. */ + dafo =REGISTER_READ (channel,REGISTER_DAFO ); +if (dafo ®ISTER_DAFO_PARE ) { +/* Determine the parity. */ +switch (dafo ®ISTER_DAFO_PAR_MASK ) { +case REGISTER_DAFO_PAR_SPACE : +case REGISTER_DAFO_PAR_MARK : +/* +* XXX: QEMU doesn't support stick parity yet. Silently fail and +* fall to the next case. +*/ +case REGISTER_DAFO_PAR_ODD : + ssp.parity ='O' ; +break ; +case REGISTER_DAFO_PAR_EVEN : + ssp.parity ='E' ; +break ; +default : +g_assert_not_reached (); + } + }else { + ssp.parity ='N' ; + } + +/* Determine the number of data bits. */ +switch (dafo ®ISTER_DAFO_CHL_MASK ) { +case REGISTER_DAFO_CHL_CS8 : + ssp.data_bits =8 ; +break ; +case REGISTER_DAFO_CHL_CS7 : + ssp.data_bits =7 ; +break ; +case REGISTER_DAFO_CHL_CS6 : + ssp.data_bits =6 ; +break ; +case REGISTER_DAFO_CHL_CS5 : + ssp.data_bits =5 ; +break ; +default : +g_assert_not_reached (); + } + +/* Determine the number of stop bits. */ +if (dafo ®ISTER_DAFO_STOP ) { + ssp.stop_bits =2 ; + }else { + ssp.stop_bits =1 ; + } + +/* XXX */ + ssp.speed =0 ; + +qemu_chr_fe_ioctl (&channel->chardev,CHR_IOCTL_SERIAL_SET_PARAMS , &ssp); +} +static void escc2_channel_reset (ESCC2ChannelState *channel) {unsigned int i;
@@ -469,6 +615,7 @@ static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,break ;case REGISTER_DAFO_OFFSET :REGISTER_WRITE (channel,REGISTER_DAFO , value); +escc2_channel_parameters_update (channel);break ;case REGISTER_RFC_OFFSET :REGISTER_WRITE (channel,REGISTER_RFC , value);
@@ -484,6 +631,7 @@ static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,break ;case REGISTER_CCR1_OFFSET :REGISTER_WRITE (channel,REGISTER_CCR1 , value); +escc2_channel_parameters_update (channel);break ;case REGISTER_CCR2_OFFSET :REGISTER_WRITE (channel,REGISTER_CCR2 , value);
@@ -505,9 +653,11 @@ static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,break ;case REGISTER_BGR_OFFSET :REGISTER_WRITE (channel,REGISTER_BGR , value); +escc2_channel_parameters_update (channel);break ;case REGISTER_TIC_OFFSET :REGISTER_WRITE (channel,REGISTER_TIC , value); +qemu_chr_fe_write_all (&channel->chardev, (uint8_t *)&value,1 );break ;case REGISTER_MXN_OFFSET :REGISTER_WRITE (channel,REGISTER_MXN , value);
@@ -542,6 +692,7 @@ static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,break ;case REGISTER_CCR4_OFFSET :REGISTER_WRITE (channel,REGISTER_CCR4 , value); +escc2_channel_parameters_update (channel);break ;default :/* Registers do not exhaustively cover the addressable region. */
@@ -551,6 +702,74 @@ static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,trace_escc2_mem_write (CHANNEL_CHAR (channel), offset, value); } +static unsigned int escc2_channel_rfifo_threshold (ESCC2ChannelState *channel) +{ +unsigned int threshold; + +switch (REGISTER_READ (channel,REGISTER_RFC ) ®ISTER_RFC_RFTH_MASK ) { +case 0 : + threshold =1 ; +break ; +case 1 : + threshold =4 ; +break ; +case 2 : + threshold =16 ; +break ; +case 3 : + threshold =32 ; +break ; +default : +g_assert_not_reached (); + } + +return threshold; +} + +static int escc2_channel_chardev_can_receive (void *opaque) +{ +uint8_t tmp; +ESCC2ChannelState *channel = opaque; +unsigned int threshold =escc2_channel_rfifo_threshold (channel); + + tmp =REGISTER_READ (channel,REGISTER_RBCL ); +if (threshold > tmp) { +return threshold - tmp; + }else { +return 0 ; + } +} + +static void escc2_channel_chardev_receive (void *opaque,const uint8_t *buf, +int size) +{ +uint8_t tmp, rbcl; +unsigned int i, nbytes; +ESCC2ChannelState *channel = opaque; + +/* Determine the number of characters that can be safely consumed. */ + rbcl =REGISTER_READ (channel,REGISTER_RBCL ); +if (rbcl + size >CHANNEL_FIFO_LENGTH ) { + nbytes =CHANNEL_FIFO_LENGTH - rbcl; + }else { + nbytes = size; + } + +/* Consume characters. */ +for (i =0 ; i < nbytes; i++) { + channel->fifo_receive[rbcl + i] = buf[i]; + } +REGISTER_WRITE (channel,REGISTER_RBCL , rbcl + nbytes); + + tmp =REGISTER_READ (channel,REGISTER_STAR ); + tmp |=REGISTER_STAR_RFNE ; +REGISTER_WRITE (channel,REGISTER_STAR , tmp); + +if (escc2_channel_chardev_can_receive (channel) ==0 ) { +escc2_channel_irq_event (channel,REGISTER_ISR0 ,REGISTER_ISR0_RPF ); + } +} +static void escc2_realize (DeviceState *dev,Error **errp) {unsigned int i;
@@ -560,6 +779,13 @@ static void escc2_realize(DeviceState *dev, Error **errp)for (i =0 ; i <CHANNEL_COUNT ; i++) { channel = &controller->channel[i]; channel->controller = controller; + +if (qemu_chr_fe_backend_connected (&channel->chardev)) { +qemu_chr_fe_set_handlers (&channel->chardev, + escc2_channel_chardev_can_receive, + escc2_channel_chardev_receive,NULL ,NULL , channel,NULL , + true); + } }qemu_register_reset (escc2_reset, controller);
@@ -605,7 +831,13 @@ static void escc2_isa_realize(DeviceState *dev, Error **errp)static void escc2_unrealize (DeviceState *dev) { +unsigned int i;ESCC2State *controller =ESCC2 (dev); + +for (i =0 ; i <CHANNEL_COUNT ; i++) { +qemu_chr_fe_deinit (&controller->channel[i].chardev, false); + } +qemu_unregister_reset (escc2_reset, controller); }
@@ -618,6 +850,8 @@ static void escc2_isa_instance_init(Object *o) }static Property escc2_properties[] = { +DEFINE_PROP_CHR ("chardevA" , ESCC2State, channel[CHANNEL_A ].chardev), +DEFINE_PROP_CHR ("chardevB" , ESCC2State, channel[CHANNEL_B ].chardev),DEFINE_PROP_END_OF_LIST () };
Signature · 1 line
2.26.2
PATCH 4/8 hw/char/escc2: Add clock generation
In reply to Jasper LowellEach channel on the controller has dedicated pins for providing receive and transmit clock sources, a baud rate generator, and a DPLL. Additionally, the controller has two pins, XTAL1 and XTAL2, that can be used with a crystal and oscillator for providing a clock source. Alternatively, XTAL1 can simply be used as a clock source. These components are used individually or together according to register configurations for generating the final receive and transmit clocks.
--- hw/char/escc2.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 2 deletions(-)
hw/char/escc2.c +177 -2
@@ -106,9 +106,31 @@/* CCR1. */ #define REGISTER_CCR1_OFFSET 0x2d +#define REGISTER_CCR1_ODS 0x10 +#define REGISTER_CCR1_BCR 0x8 +#define REGISTER_CCR1_CM2 0x4 +#define REGISTER_CCR1_CM1 0x2 +#define REGISTER_CCR1_CM0 0x1 + +#define REGISTER_CCR1_CM_MASK \ + (REGISTER_CCR1_CM2 | REGISTER_CCR1_CM1 | REGISTER_CCR1_CM0)/* CCR2. */ #define REGISTER_CCR2_OFFSET 0x2e +#define REGISTER_CCR2_SOC1 0x80 +#define REGISTER_CCR2_BR9 0x80 +#define REGISTER_CCR2_SOC0 0x40 +#define REGISTER_CCR2_BR8 0x40 +#define REGISTER_CCR2_BDF 0x20 +#define REGISTER_CCR2_XCS0 0x20 +#define REGISTER_CCR2_SSEL 0x10 +#define REGISTER_CCR2_RCS0 0x10 +#define REGISTER_CCR2_TOE 0x8 +#define REGISTER_CCR2_RWX 0x4 +#define REGISTER_CCR2_DIV 0x1 + +#define REGISTER_CCR2_BR_MASK \ + (REGISTER_CCR2_BR8 | REGISTER_CCR2_BR9)/* CCR3. */ #define REGISTER_CCR3_OFFSET 0x2f
@@ -131,6 +153,9 @@/* BGR. */ #define REGISTER_BGR_OFFSET 0x34 +#define REGISTER_BGR_EN_MASK 0x3f +#define REGISTER_BGR_EM_MASK 0xc0 +/* TIC. */ #define REGISTER_TIC_OFFSET 0x35
@@ -194,6 +219,10 @@/* CCR4. */ #define REGISTER_CCR4_OFFSET 0x3f +#define REGISTER_CCR4_MCK4 0x80 +#define REGISTER_CCR4_EBRG 0x40 +#define REGISTER_CCR4_TST1 0x20 +#define REGISTER_CCR4_ICD 0x10enum {REGISTER_STAR =0 ,
@@ -244,6 +273,14 @@ typedef struct ESCC2State ESCC2State; typedef struct ESCC2ChannelState { ESCC2State *controller; + /* + * Each channel has dedicated pins for providing receive and transmit clock + * sources. These dedicated pins are a subset of a larger set of selectable + * clock sources. + */ + unsigned int rxclock; + unsigned int txclock; + CharBackend chardev; /*
@@ -275,6 +312,14 @@ enum {struct ESCC2State {DeviceState parent; +/* +* The controller has two pins: XTAL1 and XTAL2. These pins can be used +* together with a crystal and oscillator to provide a clock source. +* Alternatively, XTAL1 can provide an externally generated clock source. +* These configurations are mutually exclusive. +*/ +unsigned int xtal; +MemoryRegion io;qemu_irq irq;ESCC2ChannelState channel[CHANNEL_COUNT ];
@@ -376,9 +421,130 @@ static void escc2_channel_irq_event(ESCC2ChannelState *channel, } } +static float escc2_channel_baud_rate_generate (ESCC2ChannelState *channel, +unsigned int clock) +{ +/* +* Each channel has an independent baud rate generator. This baud rate +* generator can act as a clock source for receiving, transmitting, and/or +* for the DPLL. +*/ +int k, n, m; +uint8_t ccr2 =REGISTER_READ (channel,REGISTER_CCR2 ); +uint8_t bgr =REGISTER_READ (channel,REGISTER_BGR ); + +if (REGISTER_READ (channel,REGISTER_CCR2 ) ®ISTER_CCR2_BDF ) { +/* The baud rate division factor k relies on BGR. */ +if (REGISTER_READ (channel,REGISTER_CCR4 ) ®ISTER_CCR4_EBRG ) { +/* Enhanced mode. */ + n = bgr ®ISTER_BGR_EN_MASK ; + m = ((ccr2 ®ISTER_CCR2_BR_MASK ) >>6 ) + | ((bgr ®ISTER_BGR_EM_MASK ) >>6 ); + k = (n +1 ) * (2 * m); + }else { +/* Standard mode. */ + n = ((ccr2 ®ISTER_CCR2_BR_MASK ) <<2 ) | bgr; + k = (n +1 ) *2 ; + } + }else { + k =1 ; + } + +return (float ) clock / (16 * k); +} + +static void escc2_channel_io_speed (ESCC2ChannelState *channel,float *input, +float *output) +{ +/* +* The receive and transmit speed can be configured to leverage dedicated +* receive and transmit clock source pins, the channel independent baud rate +* generator, the DPLL for handling clock synchronisation, the onboard +* oscillator, and a designated master clock. Different combinations of +* these are selected by specifying the clock mode and submode. +* +* Note: The DPLL, to function correctly, requires a clock source with a +* frequency 16 times the nominal bit rate so that the DPLL can synchronise +* the clock with the input stream. When the DPLL is used, the frequency +* must be divided by 16. +*/ +unsigned int mode =REGISTER_READ (channel,REGISTER_CCR1 ) + ®ISTER_CCR1_CM_MASK ; +unsigned int submode =REGISTER_READ (channel,REGISTER_CCR2 ) + ®ISTER_CCR2_SSEL ; + +/* Clock modes are numbered 0 through 7. */ +switch (mode) { +case 0 : + *input = channel->rxclock; +if (!submode) { +/* 0a. */ + *output = channel->txclock; + }else { +/* 0b. */ + *output =escc2_channel_baud_rate_generate (channel, + channel->controller->xtal); + } +break ; +case 1 : + *input = channel->rxclock; + *output = *input; +break ; +case 2 : + *input =escc2_channel_baud_rate_generate (channel, channel->rxclock) + /16 ; +if (!(REGISTER_READ (channel,REGISTER_CCR2 ) + ®ISTER_CCR2_SSEL )) { +/* 2a. */ + *output = channel->txclock; + }else { +/* 2b. */ + *output = *input; + } +break ; +case 3 : + *input =escc2_channel_baud_rate_generate (channel, channel->rxclock); +if (!(REGISTER_READ (channel,REGISTER_CCR2 ) ®ISTER_CCR2_SSEL )) { +/* 3a. */ + *input /=16 ; + } + *output = *input; +break ; +case 4 : + *input = channel->controller->xtal; + *output = *input; +case 5 : + *input = channel->rxclock; + *output = *input; +case 6 : + *input =escc2_channel_baud_rate_generate (channel, + channel->controller->xtal) /16 ; +if (!(REGISTER_READ (channel,REGISTER_CCR2 ) ®ISTER_CCR2_SSEL )) { +/* 6a. */ + *output = channel->txclock; + }else { +/* 6b. */ + *output = *input; + } +break ; +case 7 : + *input =escc2_channel_baud_rate_generate (channel, + channel->controller->xtal); +if (!(REGISTER_READ (channel,REGISTER_CCR2 ) ®ISTER_CCR2_SSEL )) { +/* 7a. */ + *input /=16 ; + } + *output = *input; +break ; +default : +g_assert_not_reached (); + } +} +static void escc2_channel_parameters_update (ESCC2ChannelState *channel) {uint8_t dafo; +float ispeed, ospeed;QEMUSerialSetParams ssp;if (!qemu_chr_fe_backend_connected (&channel->chardev)) {
@@ -434,8 +600,12 @@ static void escc2_channel_parameters_update(ESCC2ChannelState *channel) ssp.stop_bits =1 ; } -/* XXX */ - ssp.speed =0 ; +/* +* XXX: QEMU doesn't support configurations with different input/output +* speeds yet so the input speed is used for both. +*/ +escc2_channel_io_speed (channel, &ispeed, &ospeed); + ssp.speed = ispeed;qemu_chr_fe_ioctl (&channel->chardev,CHR_IOCTL_SERIAL_SET_PARAMS , &ssp); }
@@ -852,6 +1022,11 @@ static void escc2_isa_instance_init(Object *o)static Property escc2_properties[] = {DEFINE_PROP_CHR ("chardevA" , ESCC2State, channel[CHANNEL_A ].chardev),DEFINE_PROP_CHR ("chardevB" , ESCC2State, channel[CHANNEL_B ].chardev), +DEFINE_PROP_UINT32 ("xtal" , ESCC2State, xtal,0 ), +DEFINE_PROP_UINT32 ("rxclockA" , ESCC2State, channel[CHANNEL_A ].rxclock,0 ), +DEFINE_PROP_UINT32 ("txclockA" , ESCC2State, channel[CHANNEL_A ].txclock,0 ), +DEFINE_PROP_UINT32 ("rxclockB" , ESCC2State, channel[CHANNEL_B ].rxclock,0 ), +DEFINE_PROP_UINT32 ("txclockB" , ESCC2State, channel[CHANNEL_B ].txclock,0 ),DEFINE_PROP_END_OF_LIST () };
Signature · 1 line
2.26.2
PATCH 5/8 hw/char/escc2: Add Receiver Reset (RRES) command
In reply to Jasper LowellCommands are initiated by setting certain bits in the CMDR register. The Receiver Reset (RRES) command clears the receiver FIFO (RFIFO).
--- hw/char/escc2.c | 24 ++++++++++++++++++++++++ hw/char/trace-events | 1 + 2 files changed, 25 insertions(+)
hw/char/escc2.c +24 -0
@@ -29,6 +29,12 @@/* CMDR. */ #define REGISTER_CMDR_OFFSET 0x20 +#define REGISTER_CMDR_RMC 0x80 +#define REGISTER_CMDR_RRES 0x40 +#define REGISTER_CMDR_RFRD 0x20 +#define REGISTER_CMDR_STI 0x10 +#define REGISTER_CMDR_XF 0x8 +#define REGISTER_CMDR_XRES 0x1/* MODE. */ #define REGISTER_MODE_OFFSET 0x22
@@ -741,6 +747,23 @@ static uint64_t escc2_mem_read(void *opaque, hwaddr addr, unsigned size)return value; } +static void escc2_channel_command (ESCC2ChannelState *channel) +{ +uint8_t tmp, command; + + command =REGISTER_READ (channel,REGISTER_CMDR ); +trace_escc2_channel_command (CHANNEL_CHAR (channel), command); + +if (command ®ISTER_CMDR_RRES ) { +memset (channel->fifo_receive,0 ,sizeof (channel->fifo_receive)); +REGISTER_WRITE (channel,REGISTER_RBCL ,0 ); + + tmp =REGISTER_READ (channel,REGISTER_STAR ); + tmp &= ~(REGISTER_STAR_RFNE ); +REGISTER_WRITE (channel,REGISTER_STAR , tmp); + } +} +static void escc2_mem_write (void *opaque,hwaddr addr,uint64_t value,unsigned size) {
@@ -767,6 +790,7 @@ static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,break ;case REGISTER_CMDR_OFFSET :REGISTER_WRITE (channel,REGISTER_CMDR , value); +escc2_channel_command (channel);break ;case REGISTER_MODE_OFFSET :REGISTER_WRITE (channel,REGISTER_MODE , value);
hw/char/trace-events +1 -0
@@ -59,6 +59,7 @@ escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=0x%0 # escc2.c escc2_irq_update(uint8_t gis) "value 0x%x" escc2_mem_read(char channel, uint32_t addr, uint8_t value) "channel %c addr 0x%x value 0x%x" +escc2_channel_command(char channel, uint8_t command) "channel %c command 0x%x" escc2_mem_write(char channel, uint32_t addr, uint8_t value) "channel %c addr 0x%x value 0x%x" # pl011.c
Signature · 1 line
2.26.2
PATCH 6/8 hw/char/escc2: Add RFRD command
In reply to Jasper LowellThe Receive FIFO Read Enable command is used to request access to the receive FIFO. When the command is finished, the controller will issue a TCD interrupt and the number of available bytes will be available in tthe RBCL register. Given that the visible receive FIFO window is used to store characters as they come in, the only action that needs to be taken is to raise the TCD interrupt (if this interrupt is enabled).
--- hw/char/escc2.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/char/escc2.c +4 -0
@@ -762,6 +762,10 @@ static void escc2_channel_command(ESCC2ChannelState *channel) tmp &= ~(REGISTER_STAR_RFNE );REGISTER_WRITE (channel,REGISTER_STAR , tmp); } + +if (command ®ISTER_CMDR_RFRD ) { +escc2_channel_irq_event (channel,REGISTER_ISR0 ,REGISTER_ISR0_TCD ); + } } static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,
Signature · 1 line
2.26.2
PATCH 7/8 hw/char/escc2: Add Transmit Frame (XF) command
In reply to Jasper LowellThe Transmit Frame (XF) command is an alternative to using the TIC register for transmitting. This command allows the guest to transmit the contents of the transmit FIFO rather than a single character.
--- hw/char/escc2.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
hw/char/escc2.c +24 -0
@@ -207,6 +207,14 @@/* ISR1. */ #define REGISTER_ISR1_OFFSET 0x3b +#define REGISTER_ISR1_BRK 0x80 +#define REGISTER_ISR1_BRKT 0x40 +#define REGISTER_ISR1_ALLS 0x20 +#define REGISTER_ISR1_XOFF 0x10 +#define REGISTER_ISR1_TIN 0x8 +#define REGISTER_ISR1_CSC 0x4 +#define REGISTER_ISR1_XON 0x2 +#define REGISTER_ISR1_XPR 0x1/* IMR1. */ #define REGISTER_IMR1_OFFSET 0x3b
@@ -749,6 +757,7 @@ static uint64_t escc2_mem_read(void *opaque, hwaddr addr, unsigned size)static void escc2_channel_command (ESCC2ChannelState *channel) { +unsigned int i;uint8_t tmp, command; command =REGISTER_READ (channel,REGISTER_CMDR );
@@ -766,6 +775,21 @@ static void escc2_channel_command(ESCC2ChannelState *channel)if (command ®ISTER_CMDR_RFRD ) {escc2_channel_irq_event (channel,REGISTER_ISR0 ,REGISTER_ISR0_TCD ); } + +if (command ®ISTER_CMDR_XF ) { + i =0 ; +while (i <CHANNEL_FIFO_LENGTH && channel->fifo_transmit[i] !=0 ) { + i++; + } +qemu_chr_fe_write_all (&channel->chardev, channel->fifo_transmit, i); +escc2_channel_irq_event (channel,REGISTER_ISR1 ,REGISTER_ISR1_ALLS ); + +/* +* XFIFO is ready and ISR1_XPR should be generated. Fake the XRES +* command. +*/ + command &=REGISTER_CMDR_XRES ; + } } static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,
Signature · 1 line
2.26.2
PATCH 8/8 hw/char/escc2: Add XRES command
In reply to Jasper LowellThe Transmitter Reset (XRES) command is used for clearing the the transmit FIFO of any data. When the controller has completed the command, an XPR interrupt is generated (if this interrupt is enabled).
--- hw/char/escc2.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/char/escc2.c +5 -0
@@ -790,6 +790,11 @@ static void escc2_channel_command(ESCC2ChannelState *channel)*/ command &=REGISTER_CMDR_XRES ; } + +if (command ®ISTER_CMDR_XRES ) { +memset (channel->fifo_transmit,0 ,sizeof (channel->fifo_transmit)); +escc2_channel_irq_event (channel,REGISTER_ISR1 ,REGISTER_ISR1_XPR ); + } } static void escc2_mem_write(void *opaque, hwaddr addr, uint64_t value,
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
GEN docs/interop/qemu-qmp-ref.html GEN docs/interop/qemu-qmp-ref.txt GEN docs/interop/qemu-qmp-ref.7 /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) CC qga/commands.o CC qga/guest-agent-command-state.o CC qga/main.o --- AR libvhost-user.a GEN docs/interop/qemu-ga-ref.html GEN docs/interop/qemu-ga-ref.txt /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) GEN docs/interop/qemu-ga-ref.7 LINK qemu-ga LINK qemu-keymap
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK ivshmem-client/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK ivshmem-server/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-nbd
AS pc-bios/optionrom/multiboot.o/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
AS pc-bios/optionrom/linuxboot.o
CC pc-bios/optionrom/linuxboot_dma.o/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
AS pc-bios/optionrom/kvmvapic.o
AS pc-bios/optionrom/pvh.o
LINK qemu-storage-daemon
CC pc-bios/optionrom/pvh_main.o
LINK qemu-img
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
BUILD pc-bios/optionrom/multiboot.img
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
BUILD pc-bios/optionrom/linuxboot.img
BUILD pc-bios/optionrom/linuxboot_dma.img
LINK qemu-io
BUILD pc-bios/optionrom/kvmvapic.img
BUILD pc-bios/optionrom/multiboot.raw
BUILD pc-bios/optionrom/linuxboot.raw
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of ` BUILD pc-bios/optionrom/linuxboot_dma.raw
__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-edid
BUILD pc-bios/optionrom/kvmvapic.raw
SIGN pc-bios/optionrom/multiboot.bin
SIGN pc-bios/optionrom/linuxboot.bin
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
SIGN pc-bios/optionrom/linuxboot_dma.bin
LINK fsdev/virtfs-proxy-helper
SIGN pc-bios/optionrom/kvmvapic.bin
LINK scsi/qemu-pr-helper
LINK qemu-bridge-helper
LINK virtiofsd
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK vhost-user-input
BUILD pc-bios/optionrom/pvh.img
BUILD pc-bios/optionrom/pvh.raw
SIGN pc-bios/optionrom/pvh.bin
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
GEN x86_64-softmmu/hmp-commands.h
GEN x86_64-softmmu/hmp-commands-info.h
GEN x86_64-softmmu/config-devices.h
---
CC x86_64-softmmu/hw/scsi/virtio-scsi.o
CC x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
CC x86_64-softmmu/hw/scsi/vhost-scsi-common.o
/tmp/qemu-test/src/migration/ram.c:919:45: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
xbzrle_counters.encoding_rate = UINT64_MAX;
~ ^~~~~~~~~~/usr/include/stdint.h:130:23: note: expanded from macro 'UINT64_MAX'
---
18446744073709551615UL
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: migration/ram.o] Error 1
make[1]: *** Waiting for unfinished jobs..../tmp/qemu-test/src/fpu/softfloat.c:3365:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3423:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3483:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~(((uint64_t)(absZ1<<1) == 0) & roundNearestEven);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3606:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3760:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3987:21: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:4003:22: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:4273:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!8 errors generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: fpu/softfloat.o] Error 1
make: *** [Makefile:527: x86_64-softmmu/all] Error 2 Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>
sys.exit(main())
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=8d05dab6690f47fa9c4a223cb750d7b8', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-ijl9vbi1/src/docker-src.2020-06-17-04.49.55.30222:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=8d05dab6690f47fa9c4a223cb750d7b8
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-ijl9vbi1/src'
make: *** [docker-run-test-debug@fedora] Error 2
real 4m7.449s
user 0m8.702s
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Cc'ing chardev maintainers and Laurent.
Quoted 83 lines · Jasper Lowell
I've been working on improving Solaris 10 emulation for the SPARC64 Sun4u architecture with the goal of a working shell. Currently, Solaris 10 boots with a number of errors before displaying the prompt of an otherwise unresponsive installer shell. It's been mentioned that this problem may not be isolated to Solaris 10 but may affect derivatives of OpenSolaris including illumos.
From what I can tell, Solaris 10 never attempts to use the 16550A UART for the serial console. The kernel will probe registers to identify the device but will not use it for receiving or transmitting. The kernel only prints to the console using the prom interface that OpenBIOS provides. It's difficult to ascertain what the problem is because there is no visibility into the kernel. The 16550A UART on the Ultra 5 (Darwin), the machine that QEMU Sun4u is modelled against, is used for the keyboard/mouse (SuperIO) and is not traditionally used for the serial tty. Instead, the SAB 82532 ESCC2 is used to provide ttya and ttyb on this system. This patch exists to increment QEMU Sun4u towards being hardware faithful.
The SAB 82532 ESCC2 is complex because of the jungle of features that it provides. Linux and OpenBSD only use a small subset of features restricted to the ASYNC serial mode. The ASYNC serial mode is relatively simple to implement in isolation. I have made progress on a patch series that supports all serial modes, along with transitioning between them, but I have decided against submitting it. The serial controller appears to multiplex bit positions in registers across serial modes while preserving the bits themselves. This means that some 8-bit registers need to keep track of more than 8-bits of data and that the interpretation of the value the register holds depends on the selected serial mode. It's not ideal having a copy of each register for each serial mode because some bits are shared across some of the register modes. An added difficulty is that the manual doesn't document this behaviour well and its unclear what exactly happens when there is a transition in the selected serial mode. I've avoided depending on registers being
uint8_tand have made use of macros so that the backend implementation of each register can be changed at a later date when supporting other serial modes. If I have the opportunity to test real hardware, or it becomes clear that HDLC/SDLC/BISYNC support is needed, I'll look at upstreaming the other changes that I have.I have written a bare-bones patch for OpenBIOS that adds this device to the device tree. With that applied, Solaris identifies and attaches the device successfully but does not interact with it further - similar to the 16550A UART. I did notice, however, that Solaris 10 entered an interrupt routine for this device when the network card was being configured. I couldn't manage to provoke this behaviour for the 16550A so this might be some small success. I strongly suspect that the interrupt is a spurious interrupt caused by misconfiguration of the devices in the firmware but I have not investigated this further.
Solaris 10, judging from the OpenSolaris source code, determines stdin/stdout for the console by examining the stdin/stdout properties under /chosen in the device tree. Naturally, this is done with the prom interface. From what I can tell, to set these properties to the ESCC2 node it's necessary to change stdin/stdout for OpenBIOS completely. This requires a device driver. I have made some progress on an OpenBIOS device driver for the ESCC2 but it's taking longer than expected to completely replace the 16550A and it's unlikely that I will have this finished soon. It's possible that Solaris 10 emulation for this platform will improve once that work is finished but it's unclear.
This is my first patch series for QEMU so it's possible that I've made mistakes in the contribution process - sorry in advance.
Jasper Lowell (8):
hw/char/escc2: Add device
hw/char/escc2: Handle interrupt generation hw/char/escc2: Add character device backend hw/char/escc2: Add clock generation hw/char/escc2: Add Receiver Reset (RRES) command hw/char/escc2: Add RFRD command hw/char/escc2: Add Transmit Frame (XF) command hw/char/escc2: Add XRES commandhw/char/Kconfig | 8 + hw/char/Makefile.objs | 1 + hw/char/escc2.c | 1135 +++++++++++++++++++++++++++++++++++++++ hw/char/trace-events | 6 + include/hw/char/escc2.h | 17 + 5 files changed, 1167 insertions(+) create mode 100644 hw/char/escc2.c create mode 100644 include/hw/char/escc2.h
Quoted 8 lines · Jasper Lowell
I've been working on improving Solaris 10 emulation for the SPARC64 Sun4u architecture with the goal of a working shell. Currently, Solaris 10 boots with a number of errors before displaying the prompt of an otherwise unresponsive installer shell. It's been mentioned that this problem may not be isolated to Solaris 10 but may affect derivatives of OpenSolaris including illumos.
Quoted 11 lines
From what I can tell, Solaris 10 never attempts to use the 16550A UART for the serial console. The kernel will probe registers to identify the device but will not use it for receiving or transmitting. The kernel only prints to the console using the prom interface that OpenBIOS provides. It's difficult to ascertain what the problem is because there is no visibility into the kernel. The 16550A UART on the Ultra 5 (Darwin), the machine that QEMU Sun4u is modelled against, is used for the keyboard/mouse (SuperIO) and is not traditionally used for the serial tty. Instead, the SAB 82532 ESCC2 is used to provide ttya and ttyb on this system. This patch exists to increment QEMU Sun4u towards being hardware faithful.
Nice, thanks for sharing!
Quoted 31 lines
The SAB 82532 ESCC2 is complex because of the jungle of features that it provides. Linux and OpenBSD only use a small subset of features restricted to the ASYNC serial mode. The ASYNC serial mode is relatively simple to implement in isolation. I have made progress on a patch series that supports all serial modes, along with transitioning between them, but I have decided against submitting it. The serial controller appears to multiplex bit positions in registers across serial modes while preserving the bits themselves. This means that some 8-bit registers need to keep track of more than 8-bits of data and that the interpretation of the value the register holds depends on the selected serial mode. It's not ideal having a copy of each register for each serial mode because some bits are shared across some of the register modes. An added difficulty is that the manual doesn't document this behaviour well and its unclear what exactly happens when there is a transition in the selected serial mode. I've avoided depending on registers being
uint8_tand have made use of macros so that the backend implementation of each register can be changed at a later date when supporting other serial modes. If I have the opportunity to test real hardware, or it becomes clear that HDLC/SDLC/BISYNC support is needed, I'll look at upstreaming the other changes that I have.I have written a bare-bones patch for OpenBIOS that adds this device to the device tree. With that applied, Solaris identifies and attaches the device successfully but does not interact with it further - similar to the 16550A UART. I did notice, however, that Solaris 10 entered an interrupt routine for this device when the network card was being configured. I couldn't manage to provoke this behaviour for the 16550A so this might be some small success. I strongly suspect that the interrupt is a spurious interrupt caused by misconfiguration of the devices in the firmware but I have not investigated this further.
Quoted 10 lines
Solaris 10, judging from the OpenSolaris source code, determines stdin/stdout for the console by examining the stdin/stdout properties under /chosen in the device tree. Naturally, this is done with the prom interface. From what I can tell, to set these properties to the ESCC2 node it's necessary to change stdin/stdout for OpenBIOS completely. This requires a device driver. I have made some progress on an OpenBIOS device driver for the ESCC2 but it's taking longer than expected to completely replace the 16550A and it's unlikely that I will have this finished soon. It's possible that Solaris 10 emulation for this platform will improve once that work is finished but it's unclear.
Actually we may consider adding another sparc64 machine: "ultra5", and maybe deprecate "sun4u" machine once OpenBIOS supports escc2. (But maybe keep it as it's as long as it's used by NetBSD regression tests)
Quoted 2 lines
This is my first patch series for QEMU so it's possible that I've made mistakes in the contribution process - sorry in advance.
Congratulations on the first patch! It's a very good start.
Quoted 22 lines
Jasper Lowell (8):
hw/char/escc2: Add device
hw/char/escc2: Handle interrupt generation hw/char/escc2: Add character device backend hw/char/escc2: Add clock generation hw/char/escc2: Add Receiver Reset (RRES) command hw/char/escc2: Add RFRD command hw/char/escc2: Add Transmit Frame (XF) command hw/char/escc2: Add XRES commandhw/char/Kconfig | 8 + hw/char/Makefile.objs | 1 + hw/char/escc2.c | 1135 +++++++++++++++++++++++++++++++++++++++ hw/char/trace-events | 6 + include/hw/char/escc2.h | 17 + 5 files changed, 1167 insertions(+) create mode 100644 hw/char/escc2.c create mode 100644 include/hw/char/escc2.h--
2.26.2
Signature · 4 lines
Regards, Artyom Tarasenko SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu