• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionb43047a20feba0ff1eaf6a49007e2d5402df3d46 (tree)
Time2019-09-07 15:32:12
AuthorLaurent Vivier <laurent@vivi...>
CommiterThomas Huth

Log Message

escc: introduce a selector for the register bit

On Sparc and PowerMac, the bit 0 of the address selects the register
type (control or data) and bit 1 selects the channel (B or A).

On m68k Macintosh and NeXTcube, the bit 0 selects the channel and
bit 1 the register type.

This patch introduces a new parameter (bit_swap) to the device interface
to indicate bits usage must be swapped between registers and channels.

For the moment all the machines use the bit 0, but this change will be
needed to emulate the Quadra 800 or NeXTcube machine.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
[thh: added NeXTcube to the patch description]
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190831074519.32613-5-huth@tuxfamily.org>
Signed-off-by: Thomas Huth <huth@tuxfamily.org>

Change Summary

Incremental Difference

--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -45,14 +45,21 @@
4545 * mouse and keyboard ports don't implement all functions and they are
4646 * only asynchronous. There is no DMA.
4747 *
48- * Z85C30 is also used on PowerMacs. There are some small differences
49- * between Sparc version (sunzilog) and PowerMac (pmac):
48+ * Z85C30 is also used on PowerMacs and m68k Macs.
49+ *
50+ * There are some small differences between Sparc version (sunzilog)
51+ * and PowerMac (pmac):
5052 * Offset between control and data registers
5153 * There is some kind of lockup bug, but we can ignore it
5254 * CTS is inverted
5355 * DMA on pmac using DBDMA chip
5456 * pmac can do IRDA and faster rates, sunzilog can only do 38400
5557 * pmac baud rate generator clock is 3.6864 MHz, sunzilog 4.9152 MHz
58+ *
59+ * Linux driver for m68k Macs is the same as for PowerMac (pmac_zilog),
60+ * but registers are grouped by type and not by channel:
61+ * channel is selected by bit 0 of the address (instead of bit 1)
62+ * and register is selected by bit 1 of the address (instead of bit 0).
5663 */
5764
5865 /*
@@ -172,6 +179,16 @@ static void handle_kbd_command(ESCCChannelState *s, int val);
172179 static int serial_can_receive(void *opaque);
173180 static void serial_receive_byte(ESCCChannelState *s, int ch);
174181
182+static int reg_shift(ESCCState *s)
183+{
184+ return s->bit_swap ? s->it_shift + 1 : s->it_shift;
185+}
186+
187+static int chn_shift(ESCCState *s)
188+{
189+ return s->bit_swap ? s->it_shift : s->it_shift + 1;
190+}
191+
175192 static void clear_queue(void *opaque)
176193 {
177194 ESCCChannelState *s = opaque;
@@ -436,8 +453,8 @@ static void escc_mem_write(void *opaque, hwaddr addr,
436453 int newreg, channel;
437454
438455 val &= 0xff;
439- saddr = (addr >> serial->it_shift) & 1;
440- channel = (addr >> (serial->it_shift + 1)) & 1;
456+ saddr = (addr >> reg_shift(serial)) & 1;
457+ channel = (addr >> chn_shift(serial)) & 1;
441458 s = &serial->chn[channel];
442459 switch (saddr) {
443460 case SERIAL_CTRL:
@@ -547,8 +564,8 @@ static uint64_t escc_mem_read(void *opaque, hwaddr addr,
547564 uint32_t ret;
548565 int channel;
549566
550- saddr = (addr >> serial->it_shift) & 1;
551- channel = (addr >> (serial->it_shift + 1)) & 1;
567+ saddr = (addr >> reg_shift(serial)) & 1;
568+ channel = (addr >> chn_shift(serial)) & 1;
552569 s = &serial->chn[channel];
553570 switch (saddr) {
554571 case SERIAL_CTRL:
@@ -832,6 +849,7 @@ static void escc_realize(DeviceState *dev, Error **errp)
832849 static Property escc_properties[] = {
833850 DEFINE_PROP_UINT32("frequency", ESCCState, frequency, 0),
834851 DEFINE_PROP_UINT32("it_shift", ESCCState, it_shift, 0),
852+ DEFINE_PROP_BOOL("bit_swap", ESCCState, bit_swap, false),
835853 DEFINE_PROP_UINT32("disabled", ESCCState, disabled, 0),
836854 DEFINE_PROP_UINT32("chnBtype", ESCCState, chn[0].type, 0),
837855 DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0),
--- a/include/hw/char/escc.h
+++ b/include/hw/char/escc.h
@@ -51,6 +51,7 @@ typedef struct ESCCState {
5151
5252 struct ESCCChannelState chn[2];
5353 uint32_t it_shift;
54+ bool bit_swap;
5455 MemoryRegion mmio;
5556 uint32_t disabled;
5657 uint32_t frequency;