From: 54weasels <54weasels@gmail.com>
To: qemu-devel@nongnu.org
Cc: laurent@vivier.eu, thuth@redhat.com, 54weasels <54weasels@gmail.com>
Subject: [PATCH 3/7] hw/char/escc: Expose diagnostic RS232 I/O routing
Date: Sat, 2 May 2026 18:57:52 -0700 [thread overview]
Message-ID: <20260503015756.99176-4-54weasels@gmail.com> (raw)
In-Reply-To: <20260503015756.99176-1-54weasels@gmail.com>
This adds proper initialization and routing hooks for the ESCC serial controller to support the specific diagnostic RS232 UART mappings expected by the Sun-3 Boot PROM.
Signed-off-by: 54weasels <54weasels@gmail.com>
---
hw/char/escc.c | 33 ++++++++++++++++++++++++---------
include/hw/char/escc.h | 3 +++
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/hw/char/escc.c b/hw/char/escc.c
index 3b46818ecc..d870806a35 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -313,7 +313,8 @@ static void escc_soft_reset_chn(ESCCChannelState *s)
s->rregs[R_STATUS] &= STATUS_DCD | STATUS_SYNC | STATUS_CTS | STATUS_BRK;
s->rregs[R_STATUS] |= STATUS_TXEMPTY | STATUS_TXUNDRN;
- if (s->disabled) {
+ if (s->disabled || s->parent->force_hw_ready) {
+ /* Force assert to satisfy Sun-3 PROM Flow Control */
s->rregs[R_STATUS] |= STATUS_DCD | STATUS_SYNC | STATUS_CTS;
}
s->rregs[R_SPEC] &= SPEC_ALLSENT;
@@ -653,7 +654,8 @@ static void escc_mem_write(void *opaque, hwaddr addr,
s->txint = 0;
escc_update_irq(s);
s->tx = val;
- if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) { /* tx enabled */
+ if (s->parent->force_hw_ready || (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN)) {
+ /* tx consistently forced enabled for Sun-3 boot PROM hooks */
if (s->wregs[W_MISC2] & MISC2_LCL_LOOP) {
serial_receive_byte(s, s->tx);
} else if (qemu_chr_fe_backend_connected(&s->chr)) {
@@ -691,6 +693,12 @@ static uint64_t escc_mem_read(void *opaque, hwaddr addr,
case SERIAL_CTRL:
trace_escc_mem_readb_ctrl(CHN_C(s), s->reg, s->rregs[s->reg]);
ret = s->rregs[s->reg];
+ if (s->reg == R_STATUS) {
+ if (serial->force_hw_ready) {
+ ret |= STATUS_DCD | STATUS_SYNC | STATUS_CTS;
+ /* Force Flow Control PINs */
+ }
+ }
s->reg = 0;
return ret;
case SERIAL_DATA:
@@ -715,6 +723,10 @@ static const MemoryRegionOps escc_mem_ops = {
.write = escc_mem_write,
.endianness = DEVICE_NATIVE_ENDIAN,
.valid = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
+ .impl = {
.min_access_size = 1,
.max_access_size = 1,
},
@@ -1067,16 +1079,17 @@ static void escc_realize(DeviceState *dev, Error **errp)
s->chn[0].disabled = s->disabled;
s->chn[1].disabled = s->disabled;
+ uint32_t escc_size = s->mmio_size ? s->mmio_size :\
+ (ESCC_SIZE << s->it_shift);
memory_region_init_io(&s->mmio, OBJECT(dev), &escc_mem_ops, s, "escc",
- ESCC_SIZE << s->it_shift);
+ escc_size);
for (i = 0; i < 2; i++) {
- if (qemu_chr_fe_backend_connected(&s->chn[i].chr)) {
- s->chn[i].clock = s->frequency / 2;
- qemu_chr_fe_set_handlers(&s->chn[i].chr, serial_can_receive,
- serial_receive1, serial_event, NULL,
- &s->chn[i], NULL, true);
- }
+ s->chn[i].parent = s;
+ s->chn[i].clock = s->frequency / 2;
+ qemu_chr_fe_set_handlers(&s->chn[i].chr, serial_can_receive,
+ serial_receive1, serial_event, NULL,
+ &s->chn[i], NULL, true);
}
if (s->chn[0].type == escc_mouse) {
@@ -1093,7 +1106,9 @@ static const Property escc_properties[] = {
DEFINE_PROP_UINT32("frequency", ESCCState, frequency, 0),
DEFINE_PROP_UINT32("it_shift", ESCCState, it_shift, 0),
DEFINE_PROP_BOOL("bit_swap", ESCCState, bit_swap, false),
+ DEFINE_PROP_BOOL("force-hw-ready", ESCCState, force_hw_ready, false),
DEFINE_PROP_UINT32("disabled", ESCCState, disabled, 0),
+ DEFINE_PROP_UINT32("mmio_size", ESCCState, mmio_size, 0),
DEFINE_PROP_UINT32("chnBtype", ESCCState, chn[0].type, 0),
DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0),
DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr),
diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h
index 9e60175b77..db4700d8e4 100644
--- a/include/hw/char/escc.h
+++ b/include/hw/char/escc.h
@@ -49,6 +49,7 @@ typedef struct ESCCChannelState {
int sunmouse_dx;
int sunmouse_dy;
int sunmouse_buttons;
+ ESCCState *parent;
} ESCCChannelState;
struct ESCCState {
@@ -57,9 +58,11 @@ struct ESCCState {
struct ESCCChannelState chn[2];
uint32_t it_shift;
bool bit_swap;
+ bool force_hw_ready;
MemoryRegion mmio;
uint32_t disabled;
uint32_t frequency;
+ uint32_t mmio_size;
};
#endif
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-05-03 6:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 1:57 [PATCH 0/7] m68k: Add Sun-3 Machine Emulation 54weasels
2026-05-03 1:57 ` [PATCH 1/7] target/m68k: Implement Physical Bus Error exception handling 54weasels
2026-05-10 5:40 ` Thomas Huth
2026-05-11 6:38 ` Purr Box
2026-05-03 1:57 ` [PATCH 2/7] hw/net/lance: Add Sun-3 Native DMA byte-swapping support 54weasels
2026-05-03 1:57 ` 54weasels [this message]
2026-05-03 1:57 ` [PATCH 4/7] hw/timer: Introduce Intersil 7170 RTC implementation 54weasels
2026-05-03 1:57 ` [PATCH 5/7] hw/m68k: Overhaul Sun-3 MMU and Boot PROM mapping 54weasels
2026-05-03 1:57 ` [PATCH 6/7] tests/qtest: Add Sun-3 hardware interaction tests 54weasels
2026-05-03 1:57 ` [PATCH 7/7] tests/functional: Add Sun-3 firmware boot and diagnostic test 54weasels
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260503015756.99176-4-54weasels@gmail.com \
--to=54weasels@gmail.com \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.