hw/m68k: add Apple Machintosh Quadra 800 machine
v7 cover hw/m68k: add Apple Machintosh Quadra 800 machine
I'm rebasing some of these patches for seven years now, too many years...
if you want to test the machine, I'm sorry, it doesn't boot a MacROM, but you can boot a linux kernel from the command line.
You can install your own disk using debian-installer, with:
...
-M q800 \
-serial none -serial mon:stdio \
-m 1000M \
-net nic,model=dp83932,addr=09:00:07:12:34:57 \
-append "console=ttyS0 vga=off" \
-kernel vmlinux-4.16.0-1-m68k \
-initrd initrd.gz \
-drive file=debian-10.0-m68k-NETINST-1.iso,media=cdrom \
-drive file=m68k.qcow2,format=qcow2 \
-nographicIf you use a graphic adapter instead of "-nographic", you can use "-g" to set the size of the display (I use "-g 1600x800x24").
You can get the ISO from:
https://cdimage.debian.org/cdimage/ports/10.0/m68k/iso-cd/debian-10.0-m68k-NETINST-1.iso
and extract the kernel and initrd.gz:
guestfish --add debian-10.0-m68k-NETINST-1.iso --ro \
--mount /dev/sda:/ <<_EOF_copy-out /install/cdrom/initrd.gz .
copy-out /install/kernels/vmlinux-4.16.0-1-m68k .
_EOF_
The mirror to use is: http://ftp.ports.debian.org/debian-ports/
when it fails, continue without boot loader.
In the same way, you can extract the kernel and the initramfs from the qcow2 image to use it with "-kernel" and "-initrd":
guestfish --add m68k.qcow2 --mount /dev/sda2:/ <<_EOF_ copy-out /boot/vmlinux-4.16.0-1-m68k . copy-out /boot/initrd.img-4.16.0-1-m68k . _EOF_
and boot with:
... -append "root=/dev/sda2 rw console=ttyS0 console=tty \ -kernel vmlinux-4.16.0-1-m68k \ -initrd initrd.img-4.16.0-1-m68k
v7: rebase and port to Kconfig
move IRQ controller back to q800.c (we don't need an object for this) update log message for ESP changes and add some g_assert() re-order patches: put esp, escc and dp8393x first
v6: Rebase onto git master (this now includes the m68k EXCP_ILLEGAL fix required
for this patchset to boot)
Add Hervé's R-B tags
Drop ASC (Apple Sound Chip) device since the Linux driver is broken and
it is not required for a successful boot
Remove extra esp_raise_irq() from ESP pseudo-DMA patch (Hervé) Remove "return" from unimplemented write functions and instead add a
"read only" comment (Hervé)
Rename MAX_FD to SWIM_MAX_FD in SWIM floppy controller patch to prevent
potential conflicts with other files (Hervé)
v5: Rebase onto git master
Add Philippe's R-B to patch 10
Include the command line to boot a Linux kernel under the q800 machine in the commit message for patch 11 (Philippe)
Fix up comments in hw/misc/mac_via.c (Thomas)
Add asserts to VIA ADB support to prevent potential buffer overflows (Thomas) Move macfb surface/resolution checks to realise and remove hw_error (Thomas) Move macfb draw_line functions inline and remove macfb-template.h (Mark) Use guest address rather than source pointer in draw_line functions - this brings
macfb in line with the VGA device and can prevent a potential buffer overflow
Use g_strdup_printf() for memory region names in NuBus devices instead of
hardcoded length char arrays (Thomas)
Move NuBus QOM types from patch 7 to patch 8 (spotted by Thomas) Move CONFIG_COLDFIRE sections together in hw/m68k/Makefile.objs (Thomas) Remove obsolete comment from q800.c in patch 11 (Thomas)
v4: Drop RFC from subject prefix as this is getting close to final
Rebased onto master (fixing ESP, rom_ptr() conflicts) Reworked q800.c based upon Thomas' comments about cpu_init() and
qemu_check_nic_model()
Address Thomas' comments on using error_report() instead of hw_error() Change the NuBus memory regions from DEVICE_NATIVE_ENDIAN to
DEVICE_BIG_ENDIAN
Split macfb Nubus support into separate commit
Change VMSTATE_BUFFER_UNSAFE() to VMSTATE_UINT8_ARRAY() in macfb.c as
suggested by David
Remove dummy Apple Sound Chip migration state as pointed out by David Keep VIA ADB state and buffers in the mac_via device rather than adding
to existing ADBState (this matches the pattern used in the PPC CUDA/PMU VIAs)
Remove blacklisting for q800 machine from "make check" as requested by
Thomas with the following fixes:
- Fix incorrect MemoryRegion owner in ASC device
- Add qtest_enabled() check in q800_init() to allow testing when no kernel is specified
- Move some Mac VIA initialisation from init to realize
Remove legacy drive properties from SWIM floppy controller and instead
expose separate floppy bus and drive devices as requested by Kevin
v3: fix subject prefix "C" -> "RFC"
v2: remove the dp8393x fixes, because one of the patch breaks something
Update "dp8393x: manage big endian bus" with idea from Thomas Mark has reworked most of the patches:
- use mos6522
- some code move, renamings and cleanup
Laurent Vivier (9):
escc: introduce a selector for the register bit
esp: add pseudo-DMA as used by Macintosh
dp8393x: manage big endian bus
hw/m68k: add via support
hw/m68k: implement ADB bus support for via
hw/m68k: add macfb video card
hw/m68k: add Nubus support
hw/m68k: add a dummy SWIM floppy controller
hw/m68k: define Macintosh Quadra 800
Mark Cave-Ayland (1):
hw/m68k: add Nubus support for macfb video card
MAINTAINERS | 14 + arch_init.c | 4 + default-configs/m68k-softmmu.mak | 1 + hw/Kconfig | 1 + hw/Makefile.objs | 1 + hw/block/Kconfig | 3 + hw/block/Makefile.objs | 1 + hw/block/swim.c | 415 ++++++++++++++ hw/char/escc.c | 30 +- hw/display/Kconfig | 4 + hw/display/Makefile.objs | 1 + hw/display/macfb.c | 475 +++++++++++++++ hw/m68k/Kconfig | 12 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 100 ++++ hw/m68k/q800.c | 369 ++++++++++++ hw/misc/Kconfig | 4 + hw/misc/Makefile.objs | 1 + hw/misc/mac_via.c | 856 ++++++++++++++++++++++++++++ hw/net/dp8393x.c | 88 ++- hw/nubus/Kconfig | 2 + hw/nubus/Makefile.objs | 4 + hw/nubus/mac-nubus-bridge.c | 45 ++ hw/nubus/nubus-bridge.c | 34 ++ hw/nubus/nubus-bus.c | 111 ++++ hw/nubus/nubus-device.c | 215 +++++++ hw/scsi/esp.c | 293 +++++++++- include/hw/block/swim.h | 76 +++ include/hw/char/escc.h | 1 + include/hw/display/macfb.h | 64 +++ include/hw/misc/mac_via.h | 114 ++++ include/hw/nubus/mac-nubus-bridge.h | 24 + include/hw/nubus/nubus.h | 69 +++ include/hw/scsi/esp.h | 7 + qemu-options.hx | 2 +- vl.c | 3 +- 36 files changed, 3377 insertions(+), 68 deletions(-) create mode 100644 hw/block/swim.c create mode 100644 hw/display/macfb.c create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.c create mode 100644 hw/misc/mac_via.c create mode 100644 hw/nubus/Kconfig create mode 100644 hw/nubus/Makefile.objs create mode 100644 hw/nubus/mac-nubus-bridge.c create mode 100644 hw/nubus/nubus-bridge.c create mode 100644 hw/nubus/nubus-bus.c create mode 100644 hw/nubus/nubus-device.c create mode 100644 include/hw/block/swim.h create mode 100644 include/hw/display/macfb.h create mode 100644 include/hw/misc/mac_via.h create mode 100644 include/hw/nubus/mac-nubus-bridge.h create mode 100644 include/hw/nubus/nubus.h
Signature · 1 line
2.20.1
PATCH v7 1/10 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, 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 Quadra 800.
--- hw/char/escc.c | 30 ++++++++++++++++++++++++------ include/hw/char/escc.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-)
hw/char/escc.c +24 -6
@@ -42,14 +42,21 @@* mouse and keyboard ports don't implement all functions and they are * only asynchronous. There is no DMA. * -* Z85C30 is also used on PowerMacs. There are some small differences -* between Sparc version (sunzilog) and PowerMac (pmac): +* Z85C30 is also used on PowerMacs and m68k Macs. +* +* There are some small differences between Sparc version (sunzilog) +* and PowerMac (pmac): * Offset between control and data registers * There is some kind of lockup bug, but we can ignore it * CTS is inverted * DMA on pmac using DBDMA chip * pmac can do IRDA and faster rates, sunzilog can only do 38400 * pmac baud rate generator clock is 3.6864 MHz, sunzilog 4.9152 MHz +* +* Linux driver for m68k Macs is the same as for PowerMac (pmac_zilog), +* but registers are grouped by type and not by channel: +* channel is selected by bit 0 of the address (instead of bit 1) +* and register is selected by bit 1 of the address (instead of bit 0). */ /*
@@ -169,6 +176,16 @@ static void handle_kbd_command(ESCCChannelState *s, int val);static int serial_can_receive (void *opaque);static void serial_receive_byte (ESCCChannelState *s,int ch); +static int reg_shift (ESCCState *s) +{ +return s->bit_swap ? s->it_shift +1 : s->it_shift; +} + +static int chn_shift (ESCCState *s) +{ +return s->bit_swap ? s->it_shift : s->it_shift +1 ; +} +static void clear_queue (void *opaque) {ESCCChannelState *s = opaque;
@@ -433,8 +450,8 @@ static void escc_mem_write(void *opaque, hwaddr addr,int newreg, channel; val &=0xff ; - saddr = (addr >> serial->it_shift) &1 ; - channel = (addr >> (serial->it_shift +1 )) &1 ; + saddr = (addr >>reg_shift (serial)) &1 ; + channel = (addr >>chn_shift (serial)) &1 ; s = &serial->chn[channel];switch (saddr) {case SERIAL_CTRL :
@@ -544,8 +561,8 @@ static uint64_t escc_mem_read(void *opaque, hwaddr addr,uint32_t ret;int channel; - saddr = (addr >> serial->it_shift) &1 ; - channel = (addr >> (serial->it_shift +1 )) &1 ; + saddr = (addr >>reg_shift (serial)) &1 ; + channel = (addr >>chn_shift (serial)) &1 ; s = &serial->chn[channel];switch (saddr) {case SERIAL_CTRL :
@@ -829,6 +846,7 @@ static void escc_realize(DeviceState *dev, Error **errp)static 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_UINT32 ("disabled" , ESCCState, disabled,0 ),DEFINE_PROP_UINT32 ("chnBtype" , ESCCState, chn[0 ].type,0 ),DEFINE_PROP_UINT32 ("chnAtype" , ESCCState, chn[1 ].type,0 ),
include/hw/char/escc.h +1 -0
@@ -50,6 +50,7 @@ typedef struct ESCCState {struct ESCCChannelState chn[2 ];uint32_t it_shift; +bool bit_swap;MemoryRegion mmio;uint32_t disabled;uint32_t frequency;
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v7 01/10] escc: introduce a selector for the register bit
Am Sun, 26 May 2019 00:50:04 +0200
schrieb Laurent Vivier <[email protected]>:
Quoted 14 lines
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, 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 Quadra 800.
Quoted 6 lines
Signed-off-by Laurent Vivier <[email protected]>Reviewed-by Hervé Poussineau <[email protected]>--- hw/char/escc.c | 30 ++++++++++++++++++++++++------ include/hw/char/escc.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-)
PATCH v7 2/10 esp: add pseudo-DMA as used by Macintosh
In reply to Laurent VivierThere is no DMA in Quadra 800, so the CPU reads/writes the data from the PDMA register (offset 0x100, ESP_PDMA in hw/m68k/q800.c) and copies them to/from the memory.
There is a nice assembly loop in the kernel to do that, see linux/drivers/scsi/mac_esp.c:MAC_ESP_PDMA_LOOP().
The start of the transfer is triggered by the DREQ interrupt (see linux mac_esp_send_pdma_cmd()), the CPU polls on the IRQ flag to start the transfer after a SCSI command has been sent (in Quadra 800 it goes through the VIA2, the via2-irq line and the vIFR register)
The Macintosh hardware includes hardware handshaking to prevent the CPU from reading invalid data or writing data faster than the peripheral device can accept it.
This is the "blind mode", and from the doc:
"Approximate maximum SCSI transfer rates within a blocks are 1.4 MB per second for blind transfers in the Macintosh II"
Some references can be found in:
Apple Macintosh Family Hardware Reference, ISBN 0-201-19255-1 Guide to the Macintosh Family Hardware, ISBN-0-201-52405-8
--- hw/scsi/esp.c | 293 +++++++++++++++++++++++++++++++++++++----- include/hw/scsi/esp.h | 7 + 2 files changed, 271 insertions(+), 29 deletions(-)
hw/scsi/esp.c +264 -29
@@ -35,6 +35,8 @@* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C100.txt * and * http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR53C9X.txt +* +* On Macintosh Quadra it is a NCR53C96. */ static void esp_raise_irq (ESPState *s)
@@ -55,6 +57,16 @@ static void esp_lower_irq(ESPState *s) } } +static void esp_raise_drq (ESPState *s) +{ +qemu_irq_raise (s->irq_data); +} + +static void esp_lower_drq (ESPState *s) +{ +qemu_irq_lower (s->irq_data); +} +void esp_dma_enable (ESPState *s,int irq,int level) {if (level) {
@@ -81,29 +93,11 @@ void esp_request_cancelled(SCSIRequest *req) } } -static uint32_t get_cmd (ESPState *s,uint8_t *buf,uint8_t buflen) +static int get_cmd_cb (ESPState *s) { -uint32_t dmalen;int target; target = s->wregs[ESP_WBUSID ] &BUSID_DID ; -if (s->dma) { - dmalen = s->rregs[ESP_TCLO ]; - dmalen |= s->rregs[ESP_TCMID ] <<8 ; - dmalen |= s->rregs[ESP_TCHI ] <<16 ; -if (dmalen > buflen) { -return 0 ; - } - s->dma_memory_read (s->dma_opaque, buf, dmalen); - }else { - dmalen = s->ti_size; -if (dmalen >TI_BUFSZ ) { -return 0 ; - } -memcpy (buf, s->ti_buf, dmalen); - buf[0 ] = buf[2 ] >>5 ; - } -trace_esp_get_cmd (dmalen, target); s->ti_size =0 ; s->ti_rptr =0 ;
@@ -122,8 +116,48 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf, uint8_t buflen) s->rregs[ESP_RINTR ] =INTR_DC ; s->rregs[ESP_RSEQ ] =SEQ_0 ;esp_raise_irq (s); +return -1 ; + } +return 0 ; +} + +static uint32_t get_cmd (ESPState *s,uint8_t *buf,uint8_t buflen) +{ +int target; +uint32_t dmalen; + + target = s->wregs[ESP_WBUSID ] &BUSID_DID ; +if (s->dma) { + dmalen = s->rregs[ESP_TCLO ]; + dmalen |= s->rregs[ESP_TCMID ] <<8 ; + dmalen |= s->rregs[ESP_TCHI ] <<16 ; +if (dmalen > buflen) { +return 0 ; + } +if (s->dma_memory_read) { + s->dma_memory_read (s->dma_opaque, buf, dmalen); + }else { +memcpy (s->pdma_buf, buf, dmalen); + s->pdma_len = dmalen; + s->pdma_start = s->pdma_buf; + s->pdma_cur = s->pdma_buf; +esp_raise_drq (s); +return 0 ; + } + }else { + dmalen = s->ti_size; +if (dmalen >TI_BUFSZ ) { +return 0 ; + } +memcpy (buf, s->ti_buf, dmalen); + buf[0 ] = buf[2 ] >>5 ; + } +trace_esp_get_cmd (dmalen, target); + +if (get_cmd_cb (s) <0 ) {return 0 ; } +return dmalen; }
@@ -162,6 +196,15 @@ static void do_cmd(ESPState *s, uint8_t *buf)do_busid_cmd (s, &buf[1 ], busid); } +static void satn_pdma_cb (ESPState *s) +{ +if (get_cmd_cb (s) <0 ) { +return ; + } +if (s->pdma_cur != s->pdma_start) +do_cmd (s, s->pdma_start); +} +static void handle_satn (ESPState *s) {uint8_t buf[32 ];
@@ -171,11 +214,21 @@ static void handle_satn(ESPState *s) s->dma_cb = handle_satn;return ; } + s->pdma_cb = satn_pdma_cb; len =get_cmd (s, buf,sizeof (buf));if (len)do_cmd (s, buf); } +static void s_without_satn_pdma_cb (ESPState *s) +{ +if (get_cmd_cb (s) <0 ) { +return ; + } +if (s->pdma_cur != s->pdma_start) +do_busid_cmd (s, s->pdma_start,0 ); +} +static void handle_s_without_atn (ESPState *s) {uint8_t buf[32 ];
@@ -185,18 +238,36 @@ static void handle_s_without_atn(ESPState *s) s->dma_cb = handle_s_without_atn;return ; } + s->pdma_cb = s_without_satn_pdma_cb; len =get_cmd (s, buf,sizeof (buf));if (len) {do_busid_cmd (s, buf,0 ); } } +static void satn_stop_pdma_cb (ESPState *s) +{ +if (get_cmd_cb (s) <0 ) { +return ; + } + s->cmdlen = s->pdma_cur - s->pdma_start; +if (s->cmdlen) { +trace_esp_handle_satn_stop (s->cmdlen); + s->do_cmd =1 ; + s->rregs[ESP_RSTAT ] =STAT_TC |STAT_CD ; + s->rregs[ESP_RINTR ] =INTR_BS |INTR_FC ; + s->rregs[ESP_RSEQ ] =SEQ_CD ; +esp_raise_irq (s); + } +} +static void handle_satn_stop (ESPState *s) {if (s->dma && !s->dma_enabled) { s->dma_cb = handle_satn_stop;return ; } + s->pdma_cb = satn_stop_pdma_cb;; s->cmdlen =get_cmd (s, s->cmdbuf,sizeof (s->cmdbuf));if (s->cmdlen) {trace_esp_handle_satn_stop (s->cmdlen);
@@ -208,16 +279,33 @@ static void handle_satn_stop(ESPState *s) } } +static void write_response_pdma_cb (ESPState *s) +{ + s->rregs[ESP_RSTAT ] =STAT_TC |STAT_ST ; + s->rregs[ESP_RINTR ] =INTR_BS |INTR_FC ; + s->rregs[ESP_RSEQ ] =SEQ_CD ; +esp_raise_irq (s); +} +static void write_response (ESPState *s) {trace_esp_write_response (s->status); s->ti_buf[0 ] = s->status; s->ti_buf[1 ] =0 ;if (s->dma) { - s->dma_memory_write (s->dma_opaque, s->ti_buf,2 ); - s->rregs[ESP_RSTAT ] =STAT_TC |STAT_ST ; - s->rregs[ESP_RINTR ] =INTR_BS |INTR_FC ; - s->rregs[ESP_RSEQ ] =SEQ_CD ; +if (s->dma_memory_write) { + s->dma_memory_write (s->dma_opaque, s->ti_buf,2 ); + s->rregs[ESP_RSTAT ] =STAT_TC |STAT_ST ; + s->rregs[ESP_RINTR ] =INTR_BS |INTR_FC ; + s->rregs[ESP_RSEQ ] =SEQ_CD ; + }else { + s->pdma_len =2 ; + s->pdma_start = s->ti_buf; + s->pdma_cur = s->ti_buf; + s->pdma_cb = write_response_pdma_cb; +esp_raise_drq (s); +return ; + } }else { s->ti_size =2 ; s->ti_rptr =0 ;
@@ -239,6 +327,39 @@ static void esp_dma_done(ESPState *s)esp_raise_irq (s); } +static void do_dma_pdma_cb (ESPState *s) +{ +int to_device = (s->ti_size <0 ); +int len = s->pdma_cur - s->pdma_start; +if (s->do_cmd) { + s->ti_size =0 ; + s->cmdlen =0 ; + s->do_cmd =0 ; +do_cmd (s, s->cmdbuf); +return ; + } + s->dma_left -= len; + s->async_buf += len; + s->async_len -= len; +if (to_device) { + s->ti_size += len; + }else { + s->ti_size -= len; + } +if (s->async_len ==0 ) { +scsi_req_continue (s->current_req); +/* If there is still data to be read from the device then +complete the DMA operation immediately. Otherwise defer +until the scsi layer has completed. */ +if (to_device || s->dma_left !=0 || s->ti_size ==0 ) { +return ; + } + } + +/* Partially filled a scsi buffer. Complete immediately. */ +esp_dma_done (s); +} +static void esp_do_dma (ESPState *s) {uint32_t len;
@@ -249,10 +370,27 @@ static void esp_do_dma(ESPState *s)trace_esp_do_dma (s->cmdlen, len);assert (s->cmdlen <=sizeof (s->cmdbuf) && len <=sizeof (s->cmdbuf) - s->cmdlen); - s->dma_memory_read (s->dma_opaque, &s->cmdbuf[s->cmdlen], len); +if (s->dma_memory_read) { + s->dma_memory_read (s->dma_opaque, &s->cmdbuf[s->cmdlen], len); + }else { + s->pdma_len = len; + s->pdma_start = &s->cmdbuf[s->cmdlen]; + s->pdma_cur = &s->cmdbuf[s->cmdlen]; + s->pdma_cb = do_dma_pdma_cb; +esp_raise_drq (s); +return ; + } +trace_esp_handle_ti_cmd (s->cmdlen); + s->ti_size =0 ; + s->cmdlen =0 ; + s->do_cmd =0 ; +do_cmd (s, s->cmdbuf);return ; }if (s->async_len ==0 ) { +if (s->dma_left ==0 ) { +esp_dma_done (s); + }/* Defer until data is available. */ return ; }
@@ -261,9 +399,27 @@ static void esp_do_dma(ESPState *s) } to_device = (s->ti_size <0 );if (to_device) { - s->dma_memory_read (s->dma_opaque, s->async_buf, len); +if (s->dma_memory_read) { + s->dma_memory_read (s->dma_opaque, s->async_buf, len); + }else { + s->pdma_len = len; + s->pdma_start = s->async_buf; + s->pdma_cur = s->async_buf; + s->pdma_cb = do_dma_pdma_cb; +esp_raise_drq (s); +return ; + } }else { - s->dma_memory_write (s->dma_opaque, s->async_buf, len); +if (s->dma_memory_write) { + s->dma_memory_write (s->dma_opaque, s->async_buf, len); + }else { + s->pdma_len = len; + s->pdma_start = s->async_buf; + s->pdma_cur = s->async_buf; + s->pdma_cb = do_dma_pdma_cb; +esp_raise_drq (s); +return ; + } } s->dma_left -= len; s->async_buf += len;
@@ -370,14 +526,14 @@ static void handle_ti(ESPState *s) s->dma_left = minlen; s->rregs[ESP_RSTAT ] &= ~STAT_TC ;esp_do_dma (s); - } -if (s->do_cmd) { + }else if (s->do_cmd) {trace_esp_handle_ti_cmd (s->cmdlen); s->ti_size =0 ; s->cmdlen =0 ; s->do_cmd =0 ;do_cmd (s, s->cmdbuf); } + }void esp_hard_reset (ESPState *s)
@@ -398,6 +554,7 @@ void esp_hard_reset(ESPState *s)static void esp_soft_reset (ESPState *s) {qemu_irq_lower (s->irq); +qemu_irq_lower (s->irq_data);esp_hard_reset (s); }
@@ -638,6 +795,80 @@ static const MemoryRegionOps sysbus_esp_mem_ops = { .valid.accepts = esp_mem_accepts, }; +static void sysbus_esp_pdma_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +SysBusESPState *sysbus = opaque; +ESPState *s = &sysbus->esp; +uint32_t dmalen; + + dmalen = s->rregs[ESP_TCLO ]; + dmalen |= s->rregs[ESP_TCMID ] <<8 ; + dmalen |= s->rregs[ESP_TCHI ] <<16 ; +if (dmalen ==0 || s->pdma_len ==0 ) { +return ; + } +switch (size) { +case 1 : + *s->pdma_cur++ = val; + s->pdma_len--; + dmalen--; +break ; +case 2 : + *s->pdma_cur++ = val >>8 ; + *s->pdma_cur++ = val; + s->pdma_len -=2 ; + dmalen -=2 ; +break ; + } + s->rregs[ESP_TCLO ] = dmalen &0xff ; + s->rregs[ESP_TCMID ] = dmalen >>8 ; + s->rregs[ESP_TCHI ] = dmalen >>16 ; +if (s->pdma_len ==0 && s->pdma_cb) { +esp_lower_drq (s); + s->pdma_cb (s); + s->pdma_cb =NULL ; + } +} + +static uint64_t sysbus_esp_pdma_read (void *opaque,hwaddr addr, +unsigned int size) +{ +SysBusESPState *sysbus = opaque; +ESPState *s = &sysbus->esp; +uint64_t val =0 ; + +if (s->pdma_len ==0 ) { +return 0 ; + } +switch (size) { +case 1 : + val = *s->pdma_cur++; + s->pdma_len--; +break ; +case 2 : + val = *s->pdma_cur++; + val = (val <<8 ) | *s->pdma_cur++; + s->pdma_len -=2 ; +break ; + } + +if (s->pdma_len ==0 && s->pdma_cb) { +esp_lower_drq (s); + s->pdma_cb (s); + s->pdma_cb =NULL ; + } +return val; +} + +static const MemoryRegionOps sysbus_esp_pdma_ops = { + .read = sysbus_esp_pdma_read, + .write = sysbus_esp_pdma_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid.min_access_size =1 , + .valid.max_access_size =2 , +}; +static const struct SCSIBusInfo esp_scsi_info = { .tcq = false, .max_target =ESP_MAX_DEVS ,
@@ -670,12 +901,16 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp)ESPState *s = &sysbus->esp;sysbus_init_irq (sbd, &s->irq); +sysbus_init_irq (sbd, &s->irq_data);assert (sysbus->it_shift !=-1 ); s->chip_id =TCHI_FAS100A ;memory_region_init_io (&sysbus->iomem,OBJECT (sysbus), &sysbus_esp_mem_ops, - sysbus,"esp" ,ESP_REGS << sysbus->it_shift); + sysbus,"esp-regs" ,ESP_REGS << sysbus->it_shift);sysbus_init_mmio (sbd, &sysbus->iomem); +memory_region_init_io (&sysbus->pdma,OBJECT (sysbus), &sysbus_esp_pdma_ops, + sysbus,"esp-pdma" ,2 ); +sysbus_init_mmio (sbd, &sysbus->pdma);qdev_init_gpio_in (dev, sysbus_esp_gpio_demux,2 );
include/hw/scsi/esp.h +7 -0
@@ -18,6 +18,7 @@ struct ESPState {uint8_t rregs[ESP_REGS ];uint8_t wregs[ESP_REGS ];qemu_irq irq; +qemu_irq irq_data;uint8_t chip_id;bool tchi_written;int32_t ti_size;
@@ -48,6 +49,11 @@ struct ESPState {ESPDMAMemoryReadWriteFunc dma_memory_write;void *dma_opaque;void (*dma_cb)(ESPState *s); +uint8_t pdma_buf[32 ]; +uint32_t pdma_len; +uint8_t *pdma_start; +uint8_t *pdma_cur; +void (*pdma_cb)(ESPState *s); };#define TYPE_ESP "esp"
@@ -59,6 +65,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +MemoryRegion pdma;uint32_t it_shift;ESPState esp; } SysBusESPState;
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v7 02/10] esp: add pseudo-DMA as used by Macintosh
Am Sun, 26 May 2019 00:50:05 +0200
schrieb Laurent Vivier <[email protected]>:
Quoted 31 lines
There is no DMA in Quadra 800, so the CPU reads/writes the data from the PDMA register (offset
0x100,ESP_PDMAinhw/m68k/q800.c) and copies them to/from the memory.There is a nice assembly loop in the kernel to do that, see linux/drivers/scsi/mac_esp.c:MAC_ESP_PDMA_LOOP().
The start of the transfer is triggered by the DREQ interrupt (see linux
mac_esp_send_pdma_cmd()), the CPU polls on the IRQ flag to start the transfer after a SCSI command has been sent (in Quadra 800 it goes through the VIA2, the via2-irq line and the vIFR register)The Macintosh hardware includes hardware handshaking to prevent the CPU from reading invalid data or writing data faster than the peripheral device can accept it.
This is the "blind mode", and from the doc:
"Approximate maximum SCSI transfer rates within a blocks are 1.4 MB per second for blind transfers in the Macintosh II"Some references can be found in:
Apple Macintosh Family Hardware Reference, ISBN 0-201-19255-1 Guide to the Macintosh Family Hardware, ISBN-0-201-52405-8Co-developed-by Mark Cave-Ayland <[email protected]>Signed-off-by Mark Cave-Ayland <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- hw/scsi/esp.c | 293+++++++++++++++++++++++++++++++++++++-----
include/hw/scsi/esp.h| 7 + 2 files changed, 271 insertions(+), 29 deletions(-)
[...]
hw/scsi/esp.c static void do_cmd(ESPState *s, uint8_t *buf) · line 205
Quoted 11 lines
hw/scsi/esp.c +7
-0@@ -162,6 +196,15 @@ static void do_cmd(ESPState *s, uint8_t *buf)do_busid_cmd (s, &buf[1 ], busid); } +static void satn_pdma_cb (ESPState *s) +{ +if (get_cmd_cb (s) <0 ) { +return ; + } +if (s->pdma_cur != s->pdma_start) +do_cmd (s, s->pdma_start);
Curly braces, please.
Quoted 12 lines
hw/scsi/esp.c +3
-0+} +static void handle_satn (ESPState *s) {uint8_t buf[32 ];@@ -171,11 +214,21 @@ static void handle_satn(ESPState *s) s->dma_cb = handle_satn;return ; } + s->pdma_cb = satn_pdma_cb; len =get_cmd (s, buf,sizeof (buf));if (len)
hw/scsi/esp.c static void handle_satn(ESPState *s) · line 229
Quoted 10 lines
hw/scsi/esp.c +7
-0do_cmd (s, buf); } +static void s_without_satn_pdma_cb (ESPState *s) +{ +if (get_cmd_cb (s) <0 ) { +return ; + } +if (s->pdma_cur != s->pdma_start) +do_busid_cmd (s, s->pdma_start,0 );
dito.
Quoted 5 lines
hw/scsi/esp.c +2
-0+} +static void handle_s_without_atn (ESPState *s) {uint8_t buf[32 ];
[...]
Quoted 5 lines
hw/scsi/esp.c +0
-1@@ -370,14 +526,14 @@ static void handle_ti(ESPState *s) s->dma_left = minlen; s->rregs[ESP_RSTAT ] &= ~STAT_TC ;esp_do_dma (s); - }
hw/scsi/esp.c static void handle_ti(ESPState *s) · line 537
Quoted 10 lines
hw/scsi/esp.c +2
-1-if (s->do_cmd) { + }else if (s->do_cmd) {trace_esp_handle_ti_cmd (s->cmdlen); s->ti_size =0 ; s->cmdlen =0 ; s->do_cmd =0 ;do_cmd (s, s->cmdbuf); } + }
Superfluous empty line.
Apart from those nits (which can be fixed when you apply the patches), the patch looks fine to me.
Thomas
PATCH v7 3/10 dp8393x: manage big endian bus
In reply to Laurent VivierThis is needed by Quadra 800, this card can run on little-endian or big-endian bus.
--- hw/net/dp8393x.c | 88 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-)
hw/net/dp8393x.c +57 -31
@@ -149,6 +149,7 @@ typedef struct dp8393xState {/* Hardware */ uint8_t it_shift; +bool big_endian;qemu_irq irq;#ifdef DEBUG_SONIC int irq_level;
@@ -219,6 +220,29 @@ static uint32_t dp8393x_wt(dp8393xState *s)return s->regs[SONIC_WT1 ] <<16 | s->regs[SONIC_WT0 ]; } +static uint16_t dp8393x_get (dp8393xState *s,int width,uint16_t *base, +int offset) +{ +uint16_t val; + +if (s->big_endian) { + val =be16_to_cpu (base[offset * width + width -1 ]); + }else { + val =le16_to_cpu (base[offset * width]); + } +return val; +} + +static void dp8393x_put (dp8393xState *s,int width,uint16_t *base,int offset, +uint16_t val) +{ +if (s->big_endian) { + base[offset * width + width -1 ] =cpu_to_be16 (val); + }else { + base[offset * width] =cpu_to_le16 (val); + } +} +static void dp8393x_update_irq (dp8393xState *s) {int level = (s->regs[SONIC_IMR ] & s->regs[SONIC_ISR ]) ?1 :0 ;
@@ -250,12 +274,12 @@ static void dp8393x_do_load_cam(dp8393xState *s)/* Fill current entry */ address_space_rw (&s->as,dp8393x_cdp (s),MEMTXATTRS_UNSPECIFIED , (uint8_t *)data, size,0 ); - s->cam[index][0 ] = data[1 * width] &0xff ; - s->cam[index][1 ] = data[1 * width] >>8 ; - s->cam[index][2 ] = data[2 * width] &0xff ; - s->cam[index][3 ] = data[2 * width] >>8 ; - s->cam[index][4 ] = data[3 * width] &0xff ; - s->cam[index][5 ] = data[3 * width] >>8 ; + s->cam[index][0 ] =dp8393x_get (s, width, data,1 ) &0xff ; + s->cam[index][1 ] =dp8393x_get (s, width, data,1 ) >>8 ; + s->cam[index][2 ] =dp8393x_get (s, width, data,2 ) &0xff ; + s->cam[index][3 ] =dp8393x_get (s, width, data,2 ) >>8 ; + s->cam[index][4 ] =dp8393x_get (s, width, data,3 ) &0xff ; + s->cam[index][5 ] =dp8393x_get (s, width, data,3 ) >>8 ;DPRINTF ("load cam[%d] with %02x%02x%02x%02x%02x%02x\n" , index, s->cam[index][0 ], s->cam[index][1 ], s->cam[index][2 ], s->cam[index][3 ], s->cam[index][4 ], s->cam[index][5 ]);
@@ -268,7 +292,7 @@ static void dp8393x_do_load_cam(dp8393xState *s)/* Read CAM enable */ address_space_rw (&s->as,dp8393x_cdp (s),MEMTXATTRS_UNSPECIFIED , (uint8_t *)data, size,0 ); - s->regs[SONIC_CE ] = data[0 * width]; + s->regs[SONIC_CE ] =dp8393x_get (s, width, data,0 );DPRINTF ("load cam done. cam enable mask 0x%04x\n" , s->regs[SONIC_CE ]);/* Done */
@@ -289,10 +313,10 @@ static void dp8393x_do_read_rra(dp8393xState *s) MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 0);/* Update SONIC registers */ - s->regs[SONIC_CRBA0 ] = data[0 * width]; - s->regs[SONIC_CRBA1 ] = data[1 * width]; - s->regs[SONIC_RBWC0 ] = data[2 * width]; - s->regs[SONIC_RBWC1 ] = data[3 * width]; + s->regs[SONIC_CRBA0 ] =dp8393x_get (s, width, data,0 ); + s->regs[SONIC_CRBA1 ] =dp8393x_get (s, width, data,1 ); + s->regs[SONIC_RBWC0 ] =dp8393x_get (s, width, data,2 ); + s->regs[SONIC_RBWC1 ] =dp8393x_get (s, width, data,3 );DPRINTF ("CRBA0/1: 0x%04x/0x%04x, RBWC0/1: 0x%04x/0x%04x\n" , s->regs[SONIC_CRBA0 ], s->regs[SONIC_CRBA1 ], s->regs[SONIC_RBWC0 ], s->regs[SONIC_RBWC1 ]);
@@ -407,12 +431,12 @@ static void dp8393x_do_transmit_packets(dp8393xState *s) tx_len =0 ;/* Update registers */ - s->regs[SONIC_TCR ] = data[0 * width] &0xf000 ; - s->regs[SONIC_TPS ] = data[1 * width]; - s->regs[SONIC_TFC ] = data[2 * width]; - s->regs[SONIC_TSA0 ] = data[3 * width]; - s->regs[SONIC_TSA1 ] = data[4 * width]; - s->regs[SONIC_TFS ] = data[5 * width]; + s->regs[SONIC_TCR ] =dp8393x_get (s, width, data,0 ) &0xf000 ; + s->regs[SONIC_TPS ] =dp8393x_get (s, width, data,1 ); + s->regs[SONIC_TFC ] =dp8393x_get (s, width, data,2 ); + s->regs[SONIC_TSA0 ] =dp8393x_get (s, width, data,3 ); + s->regs[SONIC_TSA1 ] =dp8393x_get (s, width, data,4 ); + s->regs[SONIC_TFS ] =dp8393x_get (s, width, data,5 );/* Handle programmable interrupt */ if (s->regs[SONIC_TCR ] &SONIC_TCR_PINT ) {
@@ -438,9 +462,9 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)address_space_rw (&s->as,dp8393x_ttda (s) +sizeof (uint16_t ) * (4 +3 * i) * width,MEMTXATTRS_UNSPECIFIED , (uint8_t *)data, size,0 ); - s->regs[SONIC_TSA0 ] = data[0 * width]; - s->regs[SONIC_TSA1 ] = data[1 * width]; - s->regs[SONIC_TFS ] = data[2 * width]; + s->regs[SONIC_TSA0 ] =dp8393x_get (s, width, data,0 ); + s->regs[SONIC_TSA1 ] =dp8393x_get (s, width, data,1 ); + s->regs[SONIC_TFS ] =dp8393x_get (s, width, data,2 ); } }
@@ -467,7 +491,8 @@ static void dp8393x_do_transmit_packets(dp8393xState *s) s->regs[SONIC_TCR ] |=SONIC_TCR_PTX ;/* Write status */ - data[0 * width] = s->regs[SONIC_TCR ] &0x0fff ;/* status */ +dp8393x_put (s, width, data,0 , + s->regs[SONIC_TCR ] &0x0fff );/* status */ size =sizeof (uint16_t ) * width; address_space_rw(&s->as, dp8393x_ttda(s),
@@ -481,8 +506,8 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)sizeof (uint16_t ) * (4 +3 * s->regs[SONIC_TFC ]) * width, MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 0); - s->regs[SONIC_CTDA ] = data[0 * width] & ~0x1 ; -if (data[0 * width] &0x1 ) { + s->regs[SONIC_CTDA ] =dp8393x_get (s, width, data,0 ) & ~0x1 ; +if (dp8393x_get (s, width, data,0 ) &0x1 ) {/* EOL detected */ break ; }
@@ -745,7 +770,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, address =dp8393x_crda (s) +sizeof (uint16_t ) *5 * width;address_space_rw (&s->as, address,MEMTXATTRS_UNSPECIFIED , (uint8_t *)data, size,0 ); -if (data[0 * width] &0x1 ) { +if (dp8393x_get (s, width, data,0 ) &0x1 ) {/* Still EOL ; stop reception */ return -1 ; }else {
@@ -789,11 +814,11 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,/* Write status to memory */ DPRINTF ("Write status at %08x\n" ,dp8393x_crda (s)); - data[0 * width] = s->regs[SONIC_RCR ];/* status */ - data[1 * width] = rx_len;/* byte count */ - data[2 * width] = s->regs[SONIC_TRBA0 ];/* pkt_ptr0 */ - data[3 * width] = s->regs[SONIC_TRBA1 ];/* pkt_ptr1 */ - data[4 * width] = s->regs[SONIC_RSC ];/* seq_no */ +dp8393x_put (s, width, data,0 , s->regs[SONIC_RCR ]);/* status */ +dp8393x_put (s, width, data,1 , rx_len);/* byte count */ +dp8393x_put (s, width, data,2 , s->regs[SONIC_TRBA0 ]);/* pkt_ptr0 */ +dp8393x_put (s, width, data,3 , s->regs[SONIC_TRBA1 ]);/* pkt_ptr1 */ +dp8393x_put (s, width, data,4 , s->regs[SONIC_RSC ]);/* seq_no */ size =sizeof (uint16_t ) *5 * width;address_space_rw (&s->as,dp8393x_crda (s),MEMTXATTRS_UNSPECIFIED , (uint8_t *)data, size,1 );
@@ -802,12 +827,12 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, size =sizeof (uint16_t ) * width;address_space_rw (&s->as,dp8393x_crda (s) +sizeof (uint16_t ) *5 * width,MEMTXATTRS_UNSPECIFIED , (uint8_t *)data, size,0 ); - s->regs[SONIC_LLFA ] = data[0 * width]; + s->regs[SONIC_LLFA ] =dp8393x_get (s, width, data,0 );if (s->regs[SONIC_LLFA ] &0x1 ) {/* EOL detected */ s->regs[SONIC_ISR ] |=SONIC_ISR_RDE ; }else { - data[0 * width] =0 ;/* in_use */ +dp8393x_put (s, width, data,0 ,0 );/* in_use */ address_space_rw (&s->as,dp8393x_crda (s) +sizeof (uint16_t ) *6 * width,MEMTXATTRS_UNSPECIFIED , (uint8_t *)data,sizeof (uint16_t ),1 ); s->regs[SONIC_CRDA ] = s->regs[SONIC_LLFA ];
@@ -920,6 +945,7 @@ static Property dp8393x_properties[] = {DEFINE_NIC_PROPERTIES (dp8393xState, conf),DEFINE_PROP_PTR ("dma_mr" , dp8393xState, dma_mr),DEFINE_PROP_UINT8 ("it_shift" , dp8393xState, it_shift,0 ), +DEFINE_PROP_BOOL ("big_endian" , dp8393xState, big_endian, false), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.20.1
PATCH v7 4/10 hw/m68k: add via support
In reply to Laurent Vivier--- hw/misc/Kconfig | 4 + hw/misc/Makefile.objs | 1 + hw/misc/mac_via.c | 666 ++++++++++++++++++++++++++++++++++++++ include/hw/misc/mac_via.h | 107 ++++++ 4 files changed, 778 insertions(+) create mode 100644 hw/misc/mac_via.c create mode 100644 include/hw/misc/mac_via.h
hw/misc/Kconfig +4 -0
@@ -117,4 +117,8 @@ config AUX bool select I2C +config MAC_VIA + bool + select MOS6522 + source macio/Kconfig
hw/misc/Makefile.objs +1 -0
@@ -75,6 +75,7 @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_AUX) += auxbus.o obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o +obj-$(CONFIG_MAC_VIA) += mac_via.o obj-$(CONFIG_MSF2) += msf2-sysreg.o obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o
hw/misc/mac_via.c new file +666 -0
666 lines not on this page · raw message
include/hw/misc/mac_via.h new file +107 -0
107 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v7 5/10 hw/m68k: implement ADB bus support for via
In reply to Laurent Vivier--- hw/misc/mac_via.c | 190 ++++++++++++++++++++++++++++++++++++++ include/hw/misc/mac_via.h | 7 ++ 2 files changed, 197 insertions(+)
hw/misc/mac_via.c +190 -0
@@ -237,10 +237,16 @@* Table 19-10 ADB transaction states */ +#define ADB_STATE_NEW 0 +#define ADB_STATE_EVEN 1 +#define ADB_STATE_ODD 2 +#define ADB_STATE_IDLE 3 +#define VIA1B_vADB_StateMask (VIA1B_vADBS1 | VIA1B_vADBS2)#define VIA1B_vADB_StateShift 4#define VIA_TIMER_FREQ (783360) +#define VIA_ADB_POLL_FREQ 50/* XXX: not real */ /* VIA returns time offset from Jan 1, 1904, not 1970 */ #define RTC_OFFSET 2082844800
@@ -422,6 +428,181 @@ static void via1_rtc_update(MacVIAState *m) } } +static int adb_via_poll (MacVIAState *s,int state,uint8_t *data) +{ +if (state !=ADB_STATE_IDLE ) { +return 0 ; + } + +if (s->adb_data_in_size < s->adb_data_in_index) { +return 0 ; + } + +if (s->adb_data_out_index !=0 ) { +return 0 ; + } + + s->adb_data_in_index =0 ; + s->adb_data_out_index =0 ; + s->adb_data_in_size =adb_poll (&s->adb_bus, s->adb_data_in,0xffff ); + +if (s->adb_data_in_size) { + *data = s->adb_data_in[s->adb_data_in_index++]; +qemu_irq_raise (s->adb_data_ready); + } + +return s->adb_data_in_size; +} + +static int adb_via_send (MacVIAState *s,int state,uint8_t data) +{ +switch (state) { +case ADB_STATE_NEW : + s->adb_data_out_index =0 ; +break ; +case ADB_STATE_EVEN : +if ((s->adb_data_out_index &1 ) ==0 ) { +return 0 ; + } +break ; +case ADB_STATE_ODD : +if (s->adb_data_out_index &1 ) { +return 0 ; + } +break ; +case ADB_STATE_IDLE : +return 0 ; + } + +assert (s->adb_data_out_index <sizeof (s->adb_data_out) -1 ); + + s->adb_data_out[s->adb_data_out_index++] = data; +qemu_irq_raise (s->adb_data_ready); +return 1 ; +} + +static int adb_via_receive (MacVIAState *s,int state,uint8_t *data) +{ +switch (state) { +case ADB_STATE_NEW : +return 0 ; + +case ADB_STATE_EVEN : +if (s->adb_data_in_size <=0 ) { +qemu_irq_raise (s->adb_data_ready); +return 0 ; + } + +if (s->adb_data_in_index >= s->adb_data_in_size) { + *data =0 ; +qemu_irq_raise (s->adb_data_ready); +return 1 ; + } + +if ((s->adb_data_in_index &1 ) ==0 ) { +return 0 ; + } + +break ; + +case ADB_STATE_ODD : +if (s->adb_data_in_size <=0 ) { +qemu_irq_raise (s->adb_data_ready); +return 0 ; + } + +if (s->adb_data_in_index >= s->adb_data_in_size) { + *data =0 ; +qemu_irq_raise (s->adb_data_ready); +return 1 ; + } + +if (s->adb_data_in_index &1 ) { +return 0 ; + } + +break ; + +case ADB_STATE_IDLE : +if (s->adb_data_out_index ==0 ) { +return 0 ; + } + + s->adb_data_in_size =adb_request (&s->adb_bus, s->adb_data_in, + s->adb_data_out, + s->adb_data_out_index); + s->adb_data_out_index =0 ; + s->adb_data_in_index =0 ; +if (s->adb_data_in_size <0 ) { + *data =0xff ; +qemu_irq_raise (s->adb_data_ready); +return -1 ; + } + +if (s->adb_data_in_size ==0 ) { +return 0 ; + } + +break ; + } + +assert (s->adb_data_in_index <sizeof (s->adb_data_in) -1 ); + + *data = s->adb_data_in[s->adb_data_in_index++]; +qemu_irq_raise (s->adb_data_ready); +if (*data ==0xff || *data ==0 ) { +return 0 ; + } +return 1 ; +} + +static void via1_adb_update (MacVIAState *m) +{ +MOS6522Q800VIA1State *v1s =MOS6522_Q800_VIA1 (&m->mos6522_via1); +MOS6522State *s =MOS6522 (v1s); +int state; +int ret; + + state = (s->b & VIA1B_vADB_StateMask) >> VIA1B_vADB_StateShift; + +if (s->acr & VIA1ACR_vShiftOut) { +/* output mode */ + ret =adb_via_send (m, state, s->sr); +if (ret >0 ) { + s->b &= ~VIA1B_vADBInt; + }else { + s->b |= VIA1B_vADBInt; + } + }else { +/* input mode */ + ret =adb_via_receive (m, state, &s->sr); +if (ret >0 && s->sr !=0xff ) { + s->b &= ~VIA1B_vADBInt; + }else { + s->b |= VIA1B_vADBInt; + } + } +} + +static void via_adb_poll (void *opaque) +{ +MacVIAState *m = opaque; +MOS6522Q800VIA1State *v1s =MOS6522_Q800_VIA1 (&m->mos6522_via1); +MOS6522State *s =MOS6522 (v1s); +int state; + +if (s->b & VIA1B_vADBInt) { + state = (s->b & VIA1B_vADB_StateMask) >> VIA1B_vADB_StateShift; +if (adb_via_poll (m, state, &s->sr)) { + s->b &= ~VIA1B_vADBInt; + } + } + +timer_mod (m->adb_poll_timer, +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + + (NANOSECONDS_PER_SECOND /VIA_ADB_POLL_FREQ )); +} +static uint64_t mos6522_q800_via1_read (void *opaque,hwaddr addr,unsigned size) {MOS6522Q800VIA1State *s =MOS6522_Q800_VIA1 (opaque);
@@ -484,6 +665,10 @@ static void mac_via_reset(DeviceState *dev) {MacVIAState *m =MAC_VIA (dev); +timer_mod (m->adb_poll_timer, +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + + (NANOSECONDS_PER_SECOND /VIA_ADB_POLL_FREQ )); +timer_mod (m->VBL_timer, (qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) +16630 ) /16630 *16630 );
@@ -522,6 +707,10 @@ static void mac_via_realize(DeviceState *dev, Error **errp)qemu_get_timedate (&tm,0 ); m->tick_offset = (uint32_t )mktimegm (&tm) +RTC_OFFSET ; + + m->adb_poll_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , via_adb_poll, m); + m->adb_data_ready =qdev_get_gpio_in_named (dev,"via1-irq" , +VIA1_IRQ_ADB_READY_BIT ); }static void mac_via_init (Object *obj)
@@ -570,6 +759,7 @@ static void mos6522_q800_via1_portB_write(MOS6522State *s)MacVIAState *m =container_of (v1s, MacVIAState, mos6522_via1);via1_rtc_update (m); +via1_adb_update (m); v1s->last_b = s->b; }
include/hw/misc/mac_via.h +7 -0
@@ -97,6 +97,13 @@ typedef struct MacVIAState {/* ADB */ ADBBusState adb_bus; +QEMUTimer *adb_poll_timer; +qemu_irq adb_data_ready; +int adb_data_in_size; +int adb_data_in_index; +int adb_data_out_index; +uint8_t adb_data_in[128 ]; +uint8_t adb_data_out[16 ];/* external timers */ QEMUTimer *one_second_timer;
Signature · 1 line
2.20.1
PATCH v7 6/10 hw/m68k: add macfb video card
In reply to Laurent Vivier--- arch_init.c | 4 + hw/display/Kconfig | 3 + hw/display/Makefile.objs | 1 + hw/display/macfb.c | 419 +++++++++++++++++++++++++++++++++++++ include/hw/display/macfb.h | 43 ++++ qemu-options.hx | 2 +- vl.c | 3 +- 7 files changed, 473 insertions(+), 2 deletions(-) create mode 100644 hw/display/macfb.c create mode 100644 include/hw/display/macfb.h
arch_init.c +4 -0
@@ -39,6 +39,10 @@int graphic_width =1024 ;int graphic_height =768 ;int graphic_depth =8 ; +#elif defined(TARGET_M68K ) +int graphic_width =800 ; +int graphic_height =600 ; +int graphic_depth =8 ;#else int graphic_width =800 ;int graphic_height =600 ;
hw/display/Kconfig +3 -0
@@ -120,3 +120,6 @@ config ATI_VGA default y if PCI_DEVICES depends on PCI select VGA + +config MACFB + bool
hw/display/Makefile.objs +1 -0
@@ -26,6 +26,7 @@ common-obj-$(CONFIG_EXYNOS4) += exynos4210_fimd.o common-obj-$(CONFIG_FRAMEBUFFER) += framebuffer.o obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o common-obj-$(CONFIG_ZAURUS) += tc6393xb.o +common-obj-$(CONFIG_MACFB) += macfb.o obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o milkymist-tmu2.o-cflags := $(X11_CFLAGS) $(OPENGL_CFLAGS)
hw/display/macfb.c new file +419 -0
419 lines not on this page · raw message
include/hw/display/macfb.h new file +43 -0
43 lines not on this page · raw message
qemu-options.hx +1 -1
@@ -1794,7 +1794,7 @@ ETEXI DEF("g", 1, QEMU_OPTION_g , "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n", - QEMU_ARCH_PPC | QEMU_ARCH_SPARC) + QEMU_ARCH_PPC | QEMU_ARCH_SPARC | QEMU_ARCH_M68K) STEXI @item -g @var{width}x@var{height}[x@var{depth}] @findex -g
vl.c +2 -1
@@ -3403,7 +3403,8 @@ int main(int argc, char **argv, char **envp)if (*p =='x' ) { p++; depth =strtol (p, (char **)&p,10 ); -if (depth !=8 && depth !=15 && depth !=16 && +if (depth !=1 && depth !=2 && depth !=4 && + depth !=8 && depth !=15 && depth !=16 && depth !=24 && depth !=32 ) goto graphic_error; }else if (*p =='\0' ) {
Signature · 1 line
2.20.1
PATCH v7 7/10 hw/m68k: add Nubus support
In reply to Laurent Vivier--- hw/Kconfig | 1 + hw/Makefile.objs | 1 + hw/nubus/Kconfig | 2 + hw/nubus/Makefile.objs | 4 + hw/nubus/mac-nubus-bridge.c | 45 ++++++ hw/nubus/nubus-bridge.c | 34 +++++ hw/nubus/nubus-bus.c | 111 ++++++++++++++ hw/nubus/nubus-device.c | 215 ++++++++++++++++++++++++++++ include/hw/nubus/mac-nubus-bridge.h | 24 ++++ include/hw/nubus/nubus.h | 69 +++++++++ 10 files changed, 506 insertions(+) create mode 100644 hw/nubus/Kconfig create mode 100644 hw/nubus/Makefile.objs create mode 100644 hw/nubus/mac-nubus-bridge.c create mode 100644 hw/nubus/nubus-bridge.c create mode 100644 hw/nubus/nubus-bus.c create mode 100644 hw/nubus/nubus-device.c create mode 100644 include/hw/nubus/mac-nubus-bridge.h create mode 100644 include/hw/nubus/nubus.h
hw/Kconfig +1 -0
@@ -21,6 +21,7 @@ source isa/Kconfig source mem/Kconfig source misc/Kconfig source net/Kconfig +source nubus/Kconfig source nvram/Kconfig source pci-bridge/Kconfig source pci-host/Kconfig
hw/Makefile.objs +1 -0
@@ -36,6 +36,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += watchdog/ devices-dirs-$(CONFIG_SOFTMMU) += xen/ devices-dirs-$(CONFIG_MEM_DEVICE) += mem/ devices-dirs-$(CONFIG_SOFTMMU) += smbios/ +devices-dirs-$(CONFIG_NUBUS) += nubus/ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y)
hw/nubus/Kconfig new file +2 -0
@@ -0,0 +1,2 @@ +config NUBUS + bool
hw/nubus/Makefile.objs new file +4 -0
@@ -0,0 +1,4 @@ +common-obj-y += nubus-device.o +common-obj-y += nubus-bus.o +common-obj-y += nubus-bridge.o +common-obj-$(CONFIG_Q800) += mac-nubus-bridge.o
hw/nubus/mac-nubus-bridge.c new file +45 -0
45 lines not on this page · raw message
hw/nubus/nubus-bridge.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QEMU Macintosh Nubus +* +* Copyright (c) 2013-2018 Laurent Vivier <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "hw/nubus/nubus.h" + +static void nubus_bridge_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->fw_name ="nubus" ; +} + +static const TypeInfo nubus_bridge_info = { + .name =TYPE_NUBUS_BRIDGE , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SysBusDevice), + .class_init = nubus_bridge_class_init, +}; + +static void nubus_register_types (void ) +{ +type_register_static (&nubus_bridge_info); +} + +type_init (nubus_register_types)
hw/nubus/nubus-bus.c new file +111 -0
111 lines not on this page · raw message
hw/nubus/nubus-device.c new file +215 -0
215 lines not on this page · raw message
include/hw/nubus/mac-nubus-bridge.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (c) 2013-2018 Laurent Vivier <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#ifndef HW_NUBUS_MAC_H +#define HW_NUBUS_MAC_H + +#include "hw/nubus/nubus.h" + +#define TYPE_MAC_NUBUS_BRIDGE "mac-nubus-bridge" +#define MAC_NUBUS_BRIDGE (obj) OBJECT_CHECK(MacNubusState, (obj), \ + TYPE_MAC_NUBUS_BRIDGE) + +typedef struct MacNubusState { +SysBusDevice sysbus_dev; + +NubusBus *bus; +}MacNubusState ; + +#endif
include/hw/nubus/nubus.h new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v7 8/10 hw/m68k: add Nubus support for macfb video card
In reply to Laurent VivierFrom: Mark Cave-Ayland <[email protected]>
--- hw/display/Kconfig | 1 + hw/display/macfb.c | 56 ++++++++++++++++++++++++++++++++++++++ include/hw/display/macfb.h | 21 ++++++++++++++ 3 files changed, 78 insertions(+)
hw/display/Kconfig +1 -0
@@ -123,3 +123,4 @@ config ATI_VGA config MACFB bool + depends on NUBUS
hw/display/macfb.c +56 -0
95 lines not on this page · raw message
include/hw/display/macfb.h +21 -0
@@ -40,4 +40,25 @@ typedef struct { MacfbState macfb; } MacfbSysBusState; +#define MACFB_NUBUS_DEVICE_CLASS (class) \ + OBJECT_CLASS_CHECK(MacfbNubusDeviceClass, (class), TYPE_NUBUS_MACFB) +#define MACFB_NUBUS_GET_CLASS (obj) \ + OBJECT_GET_CLASS(MacfbNubusDeviceClass, (obj), TYPE_NUBUS_MACFB) + +typedef struct MacfbNubusDeviceClass { +DeviceClass parent_class; + +DeviceRealize parent_realize; +}MacfbNubusDeviceClass ; + +#define TYPE_NUBUS_MACFB "nubus-macfb" +#define NUBUS_MACFB (obj) \ + OBJECT_CHECK(MacfbNubusState, (obj), TYPE_NUBUS_MACFB) + +typedef struct { +NubusDevice busdev; + +MacfbState macfb; +}MacfbNubusState ; +#endif
Signature · 1 line
2.20.1
PATCH v7 9/10 hw/m68k: add a dummy SWIM floppy controller
In reply to Laurent Vivier--- hw/block/Kconfig | 3 + hw/block/Makefile.objs | 1 + hw/block/swim.c | 415 ++++++++++++++++++++++++++++++++++++++++ include/hw/block/swim.h | 76 ++++++++ 4 files changed, 495 insertions(+) create mode 100644 hw/block/swim.c create mode 100644 include/hw/block/swim.h
hw/block/Kconfig +3 -0
@@ -37,3 +37,6 @@ config VHOST_USER_BLK # Only PCI devices are provided for now default y if VIRTIO_PCI depends on VIRTIO && VHOST_USER && LINUX + +config SWIM + bool
hw/block/Makefile.objs +1 -0
@@ -8,6 +8,7 @@ common-obj-$(CONFIG_XEN) += xen-block.o common-obj-$(CONFIG_ECC) += ecc.o common-obj-$(CONFIG_ONENAND) += onenand.o common-obj-$(CONFIG_NVME_PCI) += nvme.o +common-obj-$(CONFIG_SWIM) += swim.o obj-$(CONFIG_SH4) += tc58128.o
hw/block/swim.c new file +415 -0
415 lines not on this page · raw message
include/hw/block/swim.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v7 10/10 hw/m68k: define Macintosh Quadra 800
In reply to Laurent VivierIf you want to test the machine, it doesn't yet boot a MacROM, but you can boot a linux kernel from the command line.
You can install your own disk using debian-installer with:
./qemu-system-m68k \
-M q800 \
-serial none -serial mon:stdio \
-m 1000M -drive file=m68k.qcow2,format=qcow2 \
-net nic,model=dp83932,addr=09:00:07:12:34:57 \
-append "console=ttyS0 vga=off" \
-kernel vmlinux-4.15.0-2-m68k \
-initrd initrd.gz \
-drive file=debian-9.0-m68k-NETINST-1.iso \
-drive file=m68k.qcow2,format=qcow2 \
-nographicIf you use a graphic adapter instead of "-nographic", you can use "-g" to set the size of the display (I use "-g 1600x800x24").
--- MAINTAINERS | 14 ++ default-configs/m68k-softmmu.mak | 1 + hw/m68k/Kconfig | 12 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 100 +++++++++ hw/m68k/q800.c | 369 +++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+) create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.c
MAINTAINERS +14 -0
@@ -906,6 +906,20 @@ F: hw/char/mcf_uart.c F: hw/net/mcf_fec.c F: include/hw/m68k/mcf*.h +q800 +M: Laurent Vivier <[email protected]> +S: Maintained +F: hw/block/swim.c +F: hw/m68k/bootinfo.h +F: hw/display/macfb.c +F: hw/m68k/q800.c +F: hw/misc/mac_via.c +F: hw/nubus/* +F: include/hw/block/swim.h +F: include/hw/display/macfb.h +F: include/hw/misc/mac_via.h +F: include/hw/nubus/* + MicroBlaze Machines ------------------- petalogix_s3adsp1800
default-configs/m68k-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ # CONFIG_AN5206=y CONFIG_MCF5208=y +CONFIG_Q800=y
hw/m68k/Kconfig +12 -0
@@ -7,3 +7,15 @@ config MCF5208 bool select COLDFIRE select PTIMER + +config Q800 + bool + select FRAMEBUFFER + select ADB + select MAC_VIA + select ESCC + select ESP + select MACFB + select NUBUS + select DP8393X + select SWIM
hw/m68k/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_AN5206) += an5206.o mcf5206.o obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o +obj-$(CONFIG_Q800) += q800.o
hw/m68k/bootinfo.h new file +100 -0
100 lines not on this page · raw message
hw/m68k/q800.c new file +369 -0
369 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v7 10/10] hw/m68k: define Macintosh Quadra 800
Am Sun, 26 May 2019 00:50:13 +0200
schrieb Laurent Vivier <[email protected]>:
Quoted 33 lines
If you want to test the machine, it doesn't yet boot a MacROM, but you can boot a linux kernel from the command line.
You can install your own disk using debian-installer with:
./qemu-system-m68k \ -M q800 \ -serial none -serial mon:stdio \ -m 1000M -drive file=m68k.qcow2,format=qcow2 \ -net nic,model=dp83932,addr=09:00:07:12:34:57 \ -append "console=ttyS0 vga=off" \ -kernel vmlinux-4.15.0-2-m68k \ -initrd initrd.gz \ -drive file=debian-9.0-m68k-NETINST-1.iso \ -drive file=m68k.qcow2,format=qcow2 \ -nographicIf you use a graphic adapter instead of "-nographic", you can use "-g" to set the size of the display (I use "-g 1600x800x24").
Co-developed-by Mark Cave-Ayland <[email protected]>Signed-off-by Mark Cave-Ayland <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- MAINTAINERS | 14 ++ default-configs/m68k-softmmu.mak | 1 + hw/m68k/Kconfig | 12 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 100 +++++++++ hw/m68k/q800.c | 369 +++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+) create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.c
[...]
hw/m68k/bootinfo.h line 5
Quoted 11 lines
hw/m68k/bootinfo.h new file +5
-0@@ -0,0 +1,100 @@ +struct bi_record { +uint16_t tag;/* tag ID */ +uint16_t size;/* size of record */ +uint32_t data[0 ];/* data */ +};
Maybe add a short description, license information and header guards at the top of the file?
Apart from that, the patch looks sane to me.
Thomas
Re: [Qemu-devel] [PATCH v7 10/10] hw/m68k: define Macintosh Quadra 800
In reply to Laurent VivierQuoted 298 lines · Laurent Vivier
If you want to test the machine, it doesn't yet boot a MacROM, but you can boot a linux kernel from the command line.
You can install your own disk using debian-installer with:
./qemu-system-m68k \ -M q800 \ -serial none -serial mon:stdio \ -m 1000M -drive file=m68k.qcow2,format=qcow2 \ -net nic,model=dp83932,addr=09:00:07:12:34:57 \ -append "console=ttyS0 vga=off" \ -kernel vmlinux-4.15.0-2-m68k \ -initrd initrd.gz \ -drive file=debian-9.0-m68k-NETINST-1.iso \ -drive file=m68k.qcow2,format=qcow2 \ -nographicIf you use a graphic adapter instead of "-nographic", you can use "-g" to set the size of the display (I use "-g 1600x800x24").
Co-developed-by Mark Cave-Ayland <[email protected]>Signed-off-by Mark Cave-Ayland <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- MAINTAINERS | 14 ++ default-configs/m68k-softmmu.mak | 1 + hw/m68k/Kconfig | 12 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 100 +++++++++ hw/m68k/q800.c | 369 +++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+) create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.cMAINTAINERS +14
-0@@ -906,6 +906,20 @@ F: hw/char/mcf_uart.c F: hw/net/mcf_fec.c F: include/hw/m68k/mcf*.h +q800 +M: Laurent Vivier <[email protected]> +S: Maintained +F: hw/block/swim.c +F: hw/m68k/bootinfo.h +F: hw/display/macfb.c +F: hw/m68k/q800.c +F: hw/misc/mac_via.c +F: hw/nubus/* +F: include/hw/block/swim.h +F: include/hw/display/macfb.h +F: include/hw/misc/mac_via.h +F: include/hw/nubus/* + MicroBlaze Machines ------------------- petalogix_s3adsp1800default-configs/m68k-softmmu.mak +1
-0@@ -4,3 +4,4 @@ # CONFIG_AN5206=y CONFIG_MCF5208=y +CONFIG_Q800=yhw/m68k/Kconfig +12
-0@@ -7,3 +7,15 @@ config MCF5208 bool select COLDFIRE select PTIMER + +config Q800 + bool + select FRAMEBUFFER + select ADB + select MAC_VIA + select ESCC + select ESP + select MACFB + select NUBUS + select DP8393X + select SWIMhw/m68k/Makefile.objs +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_AN5206) += an5206.o mcf5206.o obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o +obj-$(CONFIG_Q800) += q800.ohw/m68k/bootinfo.h new file +100
-0@@ -0,0 +1,100 @@ +struct bi_record { +uint16_t tag;/* tag ID */ +uint16_t size;/* size of record */ +uint32_t data[0 ];/* data */ +}; + +/* machine independent tags */ + +#define BI_LAST 0x0000/* last record */ +#define BI_MACHTYPE 0x0001/* machine type (u_long) */ +#define BI_CPUTYPE 0x0002/* cpu type (u_long) */ +#define BI_FPUTYPE 0x0003/* fpu type (u_long) */ +#define BI_MMUTYPE 0x0004/* mmu type (u_long) */ +#define BI_MEMCHUNK 0x0005/* memory chunk address and size */ +/* (struct mem_info) */ +#define BI_RAMDISK 0x0006/* ramdisk address and size */ +/* (struct mem_info) */ +#define BI_COMMAND_LINE 0x0007/* kernel command line parameters */ +/* (string) */ + +/* Macintosh-specific tags (all u_long) */ + +#define BI_MAC_MODEL 0x8000/* Mac Gestalt ID (model type) */ +#define BI_MAC_VADDR 0x8001/* Mac video base address */ +#define BI_MAC_VDEPTH 0x8002/* Mac video depth */ +#define BI_MAC_VROW 0x8003/* Mac video rowbytes */ +#define BI_MAC_VDIM 0x8004/* Mac video dimensions */ +#define BI_MAC_VLOGICAL 0x8005/* Mac video logical base */ +#define BI_MAC_SCCBASE 0x8006/* Mac SCC base address */ +#define BI_MAC_BTIME 0x8007/* Mac boot time */ +#define BI_MAC_GMTBIAS 0x8008/* Mac GMT timezone offset */ +#define BI_MAC_MEMSIZE 0x8009/* Mac RAM size (sanity check) */ +#define BI_MAC_CPUID 0x800a/* Mac CPU type (sanity check) */ +#define BI_MAC_ROMBASE 0x800b/* Mac system ROM base address */ + +/* Macintosh hardware profile data */ + +#define BI_MAC_VIA1BASE 0x8010/* Mac VIA1 base address (always present) */ +#define BI_MAC_VIA2BASE 0x8011/* Mac VIA2 base address (type varies) */ +#define BI_MAC_VIA2TYPE 0x8012/* Mac VIA2 type (VIA, RBV, OSS) */ +#define BI_MAC_ADBTYPE 0x8013/* Mac ADB interface type */ +#define BI_MAC_ASCBASE 0x8014/* Mac Apple Sound Chip base address */ +#define BI_MAC_SCSI5380 0x8015/* Mac NCR 5380 SCSI (base address, multi) */ +#define BI_MAC_SCSIDMA 0x8016/* Mac SCSI DMA (base address) */ +#define BI_MAC_SCSI5396 0x8017/* Mac NCR 53C96 SCSI (base address, multi) */ +#define BI_MAC_IDETYPE 0x8018/* Mac IDE interface type */ +#define BI_MAC_IDEBASE 0x8019/* Mac IDE interface base address */ +#define BI_MAC_NUBUS 0x801a/* Mac Nubus type (none, regular, pseudo) */ +#define BI_MAC_SLOTMASK 0x801b/* Mac Nubus slots present */ +#define BI_MAC_SCCTYPE 0x801c/* Mac SCC serial type (normal, IOP) */ +#define BI_MAC_ETHTYPE 0x801d/* Mac builtin ethernet type (Sonic, MACE */ +#define BI_MAC_ETHBASE 0x801e/* Mac builtin ethernet base address */ +#define BI_MAC_PMU 0x801f/* Mac power management / poweroff hardware */ +#define BI_MAC_IOP_SWIM 0x8020/* Mac SWIM floppy IOP */ +#define BI_MAC_IOP_ADB 0x8021/* Mac ADB IOP */ + +#define BOOTINFO0 (as, base, id) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record)); \ + base += 2; \ + } while (0) + +#define BOOTINFO1 (as, base, id, value) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record) + 4); \ + base += 2; \ + stl_phys(as, base, value); \ + base += 4; \ + } while (0) + +#define BOOTINFO2 (as, base, id, value1, value2) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record) + 8); \ + base += 2; \ + stl_phys(as, base, value1); \ + base += 4; \ + stl_phys(as, base, value2); \ + base += 4; \ + } while (0) + +#define BOOTINFOSTR (as, base, id, string) \ + do { \ + int i; \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, \ + (sizeof(struct bi_record) + strlen(string) + 2) & ~1); \ + base += 2; \ + for (i = 0; string[i]; i++) { \ + stb_phys(as, base++, string[i]); \ + } \ + stb_phys(as, base++, 0); \ + base = (parameters_base + 1) & ~1; \ + } while (0)hw/m68k/q800.c new file +90
-0@@ -0,0 +1,369 @@ +/* +* QEMU Motorla 680x0 Macintosh hardware System Emulator +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" +#include "cpu.h" +#include "hw/hw.h" +#include "hw/boards.h" +#include "elf.h" +#include "hw/loader.h" +#include "ui/console.h" +#include "exec/address-spaces.h" +#include "hw/char/escc.h" +#include "hw/sysbus.h" +#include "hw/scsi/esp.h" +#include "bootinfo.h" +#include "hw/misc/mac_via.h" +#include "hw/input/adb.h" +#include "hw/nubus/mac-nubus-bridge.h" +#include "hw/display/macfb.h" +#include "hw/block/swim.h" +#include "net/net.h" +#include "qapi/error.h" +#include "sysemu/qtest.h" + +#define MACROM_ADDR 0x40000000 +#define MACROM_SIZE 0x00100000 + +#define MACROM_FILENAME "MacROM.bin" + +#define Q800_MACHINE_ID 35 +#define Q800_CPU_ID (1 << 2) +#define Q800_FPU_ID (1 << 2) +#define Q800_MMU_ID (1 << 2) + +#define MACH_MAC 3 +#define Q800_MAC_CPU_ID 2 + +#define VIA_BASE 0x50f00000 +#define SONIC_PROM_BASE 0x50f08000 +#define SONIC_BASE 0x50f0a000 +#define SCC_BASE 0x50f0c020 +#define ESP_BASE 0x50f10000 +#define ESP_PDMA 0x50f10100 +#define ASC_BASE 0x50F14000 +#define SWIM_BASE 0x50F1E000 +#define NUBUS_SUPER_SLOT_BASE 0x60000000 +#define NUBUS_SLOT_BASE 0xf0000000 + +/* the video base, whereas it a Nubus address, +* is needed by the kernel to have early display and +* thus provided by the bootloader +*/ +#define VIDEO_BASE 0xf9001000 + +#define MAC_CLOCK 3686418 + +typedef struct { +M68kCPU *cpu; +uint8_t ipr; +}Q800IRQState ; + +static void q800_set_irq (void *opaque,int irq,int level) +{ +Q800IRQState *s = opaque; +int i; + +if (level) { + s->ipr |=1 << irq; + }else { + s->ipr &= ~(1 << irq);
hw/m68k/q800.c line 100
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+ } + +for (i =7 ; i >=0 ; i--) { +if ((s->ipr >> i) &1 ) { +m68k_set_irq_level (s->cpu, i +1 , i +25 ); +return ; + } + } +m68k_set_irq_level (s->cpu,0 ,0 ); +}
FWIW I think that even if you decide to keep the q800 IRQ routines in this file, rather than a separate file in hw/intc/ as per the previous revision, in my eyes it is still worth keeping the QOM conversion part for the IRQ controller, and wire up the IRQs using qdev.
By doing it this way it just keeps everything a bit more consistent since anyone familiar with QOM/qdev can easily see how everything is wired up without requiring any q800-specific knowledge, it potentially allows for future device tests to be written, plus the eventual dream is that one day devices can be wired together via external configuration to create a machine...
Quoted 258 lines
hw/m68k/q800.c new file +258
-0+ +static void main_cpu_reset (void *opaque) +{ +M68kCPU *cpu = opaque; +CPUState *cs =CPU (cpu); + +cpu_reset (cs); + cpu->env.aregs[7 ] =ldl_phys (cs->as,0 ); + cpu->env.pc =ldl_phys (cs->as,4 ); +} + +static void q800_init (MachineState *machine) +{ +M68kCPU *cpu =NULL ; +int linux_boot; +int32_t kernel_size; +uint64_t elf_entry; +char *filename; +int bios_size; +ram_addr_t initrd_base; +int32_t initrd_size; +MemoryRegion *rom; +MemoryRegion *ram; +ram_addr_t ram_size = machine->ram_size; +const char *kernel_filename = machine->kernel_filename; +const char *initrd_filename = machine->initrd_filename; +const char *kernel_cmdline = machine->kernel_cmdline; +hwaddr parameters_base; +CPUState *cs; +DeviceState *dev; +DeviceState *via_dev; +SysBusESPState *sysbus_esp; +ESPState *esp; +SysBusDevice *sysbus; +BusState *adb_bus; +NubusBus *nubus; +Q800IRQState *irq; +qemu_irq *pic; + + linux_boot = (kernel_filename !=NULL ); + +/* init CPUs */ + cpu =M68K_CPU (cpu_create (machine->cpu_type)); +qemu_register_reset (main_cpu_reset, cpu); + + ram =g_malloc (sizeof (*ram)); +memory_region_init_ram (ram,NULL ,"m68k_mac.ram" , ram_size, &error_abort); +memory_region_add_subregion (get_system_memory (),0 , ram); + +/* IRQ Glue */ + + irq =g_new0 (Q800IRQState,1 ); + irq->cpu = cpu; + pic =qemu_allocate_irqs (q800_set_irq, irq,8 ); + +/* VIA */ + + via_dev =qdev_create (NULL ,TYPE_MAC_VIA ); +qdev_init_nofail (via_dev); + sysbus =SYS_BUS_DEVICE (via_dev); +sysbus_mmio_map (sysbus,0 ,VIA_BASE ); +qdev_connect_gpio_out_named (DEVICE (sysbus),"irq" ,0 , pic[0 ]); +qdev_connect_gpio_out_named (DEVICE (sysbus),"irq" ,1 , pic[1 ]); + + + adb_bus =qdev_get_child_bus (via_dev,"adb.0" ); + dev =qdev_create (adb_bus,TYPE_ADB_KEYBOARD ); +qdev_init_nofail (dev); + dev =qdev_create (adb_bus,TYPE_ADB_MOUSE ); +qdev_init_nofail (dev); + +/* MACSONIC */ + +if (nb_nics >1 ) { +error_report ("q800 can only have one ethernet interface" ); +exit (1 ); + } + +qemu_check_nic_model (&nd_table[0 ],"dp83932" ); + +/* MacSonic driver needs an Apple MAC address +* Valid prefix are: +* 00:05:02 Apple +* 00:80:19 Dayna Communications, Inc. +* 00:A0:40 Apple +* 08:00:07 Apple +* (Q800 use the last one) +*/ + nd_table[0 ].macaddr.a[0 ] =0x08 ; + nd_table[0 ].macaddr.a[1 ] =0x00 ; + nd_table[0 ].macaddr.a[2 ] =0x07 ; + + dev =qdev_create (NULL ,"dp8393x" ); +qdev_set_nic_properties (dev, &nd_table[0 ]); +qdev_prop_set_uint8 (dev,"it_shift" ,2 ); +qdev_prop_set_bit (dev,"big_endian" , true); +qdev_prop_set_ptr (dev,"dma_mr" ,get_system_memory ()); +qdev_init_nofail (dev); + sysbus =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (sysbus,0 ,SONIC_BASE ); +sysbus_mmio_map (sysbus,1 ,SONIC_PROM_BASE ); +sysbus_connect_irq (sysbus,0 , pic[2 ]); + +/* SCC */ + + dev =qdev_create (NULL ,TYPE_ESCC ); +qdev_prop_set_uint32 (dev,"disabled" ,0 ); +qdev_prop_set_uint32 (dev,"frequency" ,MAC_CLOCK ); +qdev_prop_set_uint32 (dev,"it_shift" ,1 ); +qdev_prop_set_bit (dev,"bit_swap" , true); +qdev_prop_set_chr (dev,"chrA" ,serial_hd (0 )); +qdev_prop_set_chr (dev,"chrB" ,serial_hd (1 )); +qdev_prop_set_uint32 (dev,"chnBtype" ,0 ); +qdev_prop_set_uint32 (dev,"chnAtype" ,0 ); +qdev_init_nofail (dev); + sysbus =SYS_BUS_DEVICE (dev); +sysbus_connect_irq (sysbus,0 , pic[3 ]); +sysbus_connect_irq (sysbus,1 , pic[3 ]); +sysbus_mmio_map (sysbus,0 ,SCC_BASE ); + +/* SCSI */ + + dev =qdev_create (NULL ,TYPE_ESP ); + sysbus_esp =ESP_STATE (dev); + esp = &sysbus_esp->esp; + esp->dma_memory_read =NULL ; + esp->dma_memory_write =NULL ; + esp->dma_opaque =NULL ; + sysbus_esp->it_shift =4 ; + esp->dma_enabled =1 ; +qdev_init_nofail (dev); + + sysbus =SYS_BUS_DEVICE (dev); +sysbus_connect_irq (sysbus,0 ,qdev_get_gpio_in_named (via_dev, +"via2-irq" , +VIA2_IRQ_SCSI_BIT )); +sysbus_connect_irq (sysbus,1 , +qdev_get_gpio_in_named (via_dev,"via2-irq" , +VIA2_IRQ_SCSI_DATA_BIT )); +sysbus_mmio_map (sysbus,0 ,ESP_BASE ); +sysbus_mmio_map (sysbus,1 ,ESP_PDMA ); + +scsi_bus_legacy_handle_cmdline (&esp->bus); + +/* SWIM floppy controller */ + + dev =qdev_create (NULL ,TYPE_SWIM ); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,SWIM_BASE ); + +/* NuBus */ + + dev =qdev_create (NULL ,TYPE_MAC_NUBUS_BRIDGE ); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,NUBUS_SUPER_SLOT_BASE ); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),1 ,NUBUS_SLOT_BASE ); + + nubus =MAC_NUBUS_BRIDGE (dev)->bus; + +/* framebuffer in nubus slot #9 */ + + dev =qdev_create (BUS (nubus),TYPE_NUBUS_MACFB ); +qdev_prop_set_uint32 (dev,"width" , graphic_width); +qdev_prop_set_uint32 (dev,"height" , graphic_height); +qdev_prop_set_uint8 (dev,"depth" , graphic_depth); +qdev_init_nofail (dev); + + cs =CPU (cpu); +if (linux_boot) { +uint64_t high; + kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , + &elf_entry,NULL , &high,1 , +EM_68K ,0 ,0 ); +if (kernel_size <0 ) { +error_report ("could not load kernel '%s'" , kernel_filename); +exit (1 ); + } +stl_phys (cs->as,4 , elf_entry);/* reset initial PC */ + parameters_base = (high +1 ) & ~1 ; + +BOOTINFO1 (cs->as, parameters_base,BI_MACHTYPE ,MACH_MAC ); +BOOTINFO1 (cs->as, parameters_base,BI_FPUTYPE ,Q800_FPU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_MMUTYPE ,Q800_MMU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_CPUTYPE ,Q800_CPU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_CPUID ,Q800_MAC_CPU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_MODEL ,Q800_MACHINE_ID ); +BOOTINFO1 (cs->as, parameters_base, +BI_MAC_MEMSIZE , ram_size >>20 );/* in MB */ +BOOTINFO2 (cs->as, parameters_base,BI_MEMCHUNK ,0 , ram_size); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VADDR ,VIDEO_BASE ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VDEPTH , graphic_depth); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VDIM , + (graphic_height <<16 ) | graphic_width); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VROW , + (graphic_width * graphic_depth +7 ) /8 ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_SCCBASE ,SCC_BASE ); + +if (kernel_cmdline) { +BOOTINFOSTR (cs->as, parameters_base,BI_COMMAND_LINE , + kernel_cmdline); + } + +/* load initrd */ +if (initrd_filename) { + initrd_size =get_image_size (initrd_filename); +if (initrd_size <0 ) { +error_report ("could not load initial ram disk '%s'" , + initrd_filename); +exit (1 ); + } + + initrd_base = (ram_size - initrd_size) &TARGET_PAGE_MASK ; +load_image_targphys (initrd_filename, initrd_base, + ram_size - initrd_base); +BOOTINFO2 (cs->as, parameters_base,BI_RAMDISK , initrd_base, + initrd_size); + }else { + initrd_base =0 ; + initrd_size =0 ; + } +BOOTINFO0 (cs->as, parameters_base,BI_LAST ); + }else { +uint8_t *ptr; +/* allocate and load BIOS */ + rom =g_malloc (sizeof (*rom)); +memory_region_init_ram (rom,NULL ,"m68k_mac.rom" ,MACROM_SIZE , + &error_abort); +if (bios_name ==NULL ) { + bios_name =MACROM_FILENAME ; + } + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +memory_region_set_readonly (rom, true); +memory_region_add_subregion (get_system_memory (),MACROM_ADDR , rom); + +/* Load MacROM binary */ +if (filename) { + bios_size =load_image_targphys (filename,MACROM_ADDR ,MACROM_SIZE ); +g_free (filename); + }else { + bios_size =-1 ; + } + +/* Remove qtest_enabled() check once firmware files are in the tree */ +if (!qtest_enabled ()) { +if (bios_size <0 || bios_size >MACROM_SIZE ) { +error_report ("could not load MacROM '%s'" , bios_name); +exit (1 ); + } + + ptr =rom_ptr (MACROM_ADDR ,MACROM_SIZE ); +stl_phys (cs->as,0 ,ldl_p (ptr));/* reset initial SP */ +stl_phys (cs->as,4 , +MACROM_ADDR +ldl_p (ptr +4 ));/* reset initial PC */ + } + } +} + +static void q800_machine_init (MachineClass *mc)
hw/m68k/q800.c line 369
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+{ + mc->desc ="Macintosh Quadra 800" ; + mc->init = q800_init; + mc->default_cpu_type =M68K_CPU_TYPE_NAME ("m68040" ); + mc->max_cpus =1 ; + mc->is_default =0 ; + mc->block_default_type =IF_SCSI ; +} + +DEFINE_MACHINE ("q800" , q800_machine_init)
ATB,
Mark.
Re: [Qemu-devel] [PATCH v7 10/10] hw/m68k: define Macintosh Quadra 800
In reply to Laurent VivierQuoted 6 lines · Laurent Vivier
If you want to test the machine, it doesn't yet boot a MacROM, but you can boot a linux kernel from the command line.
You can install your own disk using debian-installer with:
Quoted 12 lines
./qemu-system-m68k \
-M q800 \
-serial none -serial mon:stdio \
-m 1000M -drive file=m68k.qcow2,format=qcow2 \
-net nic,model=dp83932,addr=09:00:07:12:34:57 \
-append "console=ttyS0 vga=off" \
-kernel vmlinux-4.15.0-2-m68k \
-initrd initrd.gz \
-drive file=debian-9.0-m68k-NETINST-1.iso \
-drive file=m68k.qcow2,format=qcow2 \
-nographicHello Laurent,
How does one obtain vmlinux-4.15.0-2-m68 and init.rd?
Greetings, Aleksandar
Quoted 1 line
If you use a graphic adapter instead of "-nographic", you can use "-g" to
set the
Review
Quoted 42 lines
size of the display (I use "-g 1600x800x24").
Co-developed-by Mark Cave-Ayland <[email protected]>Signed-off-by Mark Cave-Ayland <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- MAINTAINERS | 14 ++ default-configs/m68k-softmmu.mak | 1 + hw/m68k/Kconfig | 12 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 100 +++++++++ hw/m68k/q800.c | 369 +++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+) create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.cMAINTAINERS +14
-0@@ -906,6 +906,20 @@ F: hw/char/mcf_uart.c F: hw/net/mcf_fec.c F: include/hw/m68k/mcf*.h +q800 +M: Laurent Vivier <[email protected]> +S: Maintained +F: hw/block/swim.c +F: hw/m68k/bootinfo.h +F: hw/display/macfb.c +F: hw/m68k/q800.c +F: hw/misc/mac_via.c +F: hw/nubus/* +F: include/hw/block/swim.h +F: include/hw/display/macfb.h +F: include/hw/misc/mac_via.h +F: include/hw/nubus/* + MicroBlaze Machines ------------------- petalogix_s3adsp1800(quoted diff) +0
-0
b/default-configs/m68k-softmmu.mak
Quoted 70 lines
index
e17495e2a0..7e3649c1b8100644default-configs/m68k-softmmu.mak +1
-0@@ -4,3 +4,4 @@ # CONFIG_AN5206=y CONFIG_MCF5208=y +CONFIG_Q800=yhw/m68k/Kconfig +12
-0@@ -7,3 +7,15 @@ config MCF5208 bool select COLDFIRE select PTIMER + +config Q800 + bool + select FRAMEBUFFER + select ADB + select MAC_VIA + select ESCC + select ESP + select MACFB + select NUBUS + select DP8393X + select SWIMhw/m68k/Makefile.objs +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_AN5206) += an5206.o mcf5206.o obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o +obj-$(CONFIG_Q800) += q800.ohw/m68k/bootinfo.h new file +28
-0@@ -0,0 +1,100 @@ +struct bi_record { +uint16_t tag;/* tag ID */ +uint16_t size;/* size of record */ +uint32_t data[0 ];/* data */ +}; + +/* machine independent tags */ + +#define BI_LAST 0x0000/* last record */ +#define BI_MACHTYPE 0x0001/* machine type (u_long) */ +#define BI_CPUTYPE 0x0002/* cpu type (u_long) */ +#define BI_FPUTYPE 0x0003/* fpu type (u_long) */ +#define BI_MMUTYPE 0x0004/* mmu type (u_long) */ +#define BI_MEMCHUNK 0x0005/* memory chunk address and size */ +/* (struct mem_info) */ +#define BI_RAMDISK 0x0006/* ramdisk address and size */ +/* (struct mem_info) */ +#define BI_COMMAND_LINE 0x0007/* kernel command line parameters */ +/* (string) */ + +/* Macintosh-specific tags (all u_long) */ + +#define BI_MAC_MODEL 0x8000/* Mac Gestalt ID (model type) */ +#define BI_MAC_VADDR 0x8001/* Mac video base address */ +#define BI_MAC_VDEPTH 0x8002/* Mac video depth */ +#define BI_MAC_VROW 0x8003/* Mac video rowbytes */ +#define BI_MAC_VDIM 0x8004/* Mac video dimensions */ +#define BI_MAC_VLOGICAL 0x8005/* Mac video logical base */
hw/m68k/bootinfo.h line 38
Quoted 10 lines
hw/m68k/bootinfo.h new file +10
-0+#define BI_MAC_SCCBASE 0x8006/* Mac SCC base address */ +#define BI_MAC_BTIME 0x8007/* Mac boot time */ +#define BI_MAC_GMTBIAS 0x8008/* Mac GMT timezone offset */ +#define BI_MAC_MEMSIZE 0x8009/* Mac RAM size (sanity check) */ +#define BI_MAC_CPUID 0x800a/* Mac CPU type (sanity check) */ +#define BI_MAC_ROMBASE 0x800b/* Mac system ROM base address */ + +/* Macintosh hardware profile data */ + +#define BI_MAC_VIA1BASE 0x8010/* Mac VIA1 base address (always
present) */
hw/m68k/bootinfo.h
Quoted 5 lines
hw/m68k/bootinfo.h new file +5
-0+#define BI_MAC_VIA2BASE 0x8011/* Mac VIA2 base address (type varies) */ +#define BI_MAC_VIA2TYPE 0x8012/* Mac VIA2 type (VIA, RBV, OSS) */ +#define BI_MAC_ADBTYPE 0x8013/* Mac ADB interface type */ +#define BI_MAC_ASCBASE 0x8014/* Mac Apple Sound Chip base address */ +#define BI_MAC_SCSI5380 0x8015/* Mac NCR 5380 SCSI (base address,
multi) */
hw/m68k/bootinfo.h line 45
Quoted 2 lines
hw/m68k/bootinfo.h new file +2
-0+#define BI_MAC_SCSIDMA 0x8016/* Mac SCSI DMA (base address) */ +#define BI_MAC_SCSI5396 0x8017/* Mac NCR 53C96 SCSI (base address,
multi) */
hw/m68k/bootinfo.h
Quoted 3 lines
hw/m68k/bootinfo.h new file +3
-0+#define BI_MAC_IDETYPE 0x8018/* Mac IDE interface type */ +#define BI_MAC_IDEBASE 0x8019/* Mac IDE interface base address */ +#define BI_MAC_NUBUS 0x801a/* Mac Nubus type (none, regular,
pseudo) */
hw/m68k/bootinfo.h
Quoted 3 lines
hw/m68k/bootinfo.h new file +3
-0+#define BI_MAC_SLOTMASK 0x801b/* Mac Nubus slots present */ +#define BI_MAC_SCCTYPE 0x801c/* Mac SCC serial type (normal, IOP) */ +#define BI_MAC_ETHTYPE 0x801d/* Mac builtin ethernet type (Sonic,
MACE */
hw/m68k/bootinfo.h line 53
Quoted 2 lines
hw/m68k/bootinfo.h new file +2
-0+#define BI_MAC_ETHBASE 0x801e/* Mac builtin ethernet base address */ +#define BI_MAC_PMU 0x801f/* Mac power management / poweroff
hardware */
Quoted 53 lines
hw/m68k/bootinfo.h new file +47
-0+#define BI_MAC_IOP_SWIM 0x8020/* Mac SWIM floppy IOP */ +#define BI_MAC_IOP_ADB 0x8021/* Mac ADB IOP */ + +#define BOOTINFO0 (as, base, id) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record)); \ + base += 2; \ + } while (0) + +#define BOOTINFO1 (as, base, id, value) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record) + 4); \ + base += 2; \ + stl_phys(as, base, value); \ + base += 4; \ + } while (0) + +#define BOOTINFO2 (as, base, id, value1, value2) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record) + 8); \ + base += 2; \ + stl_phys(as, base, value1); \ + base += 4; \ + stl_phys(as, base, value2); \ + base += 4; \ + } while (0) + +#define BOOTINFOSTR (as, base, id, string) \ + do { \ + int i; \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, \ + (sizeof(struct bi_record) + strlen(string) + 2) & ~1); \ + base += 2; \ + for (i = 0; string[i]; i++) { \ + stb_phys(as, base++, string[i]); \ + } \ + stb_phys(as, base++, 0); \ + base = (parameters_base + 1) & ~1; \ + } while (0)hw/m68k/q800.c new file +0
-0
hw/m68k/q800.c line 4
Quoted 4 lines
hw/m68k/q800.c new file +4
-0@@ -0,0 +1,369 @@ +/* +* QEMU Motorla 680x0 Macintosh hardware System Emulator +* +* Permission is hereby granted, free of charge, to any person obtaining
a copy
hw/m68k/q800.c line 5
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* of this software and associated documentation files (the "Software"),
to deal
hw/m68k/q800.c line 6
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* in the Software without restriction, including without limitation the
rights
hw/m68k/q800.c line 7
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell
hw/m68k/q800.c
Quoted 4 lines
hw/m68k/q800.c new file +4
-0+* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be
included in
hw/m68k/q800.c
Quoted 3 lines
hw/m68k/q800.c new file +3
-0+* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
hw/m68k/q800.c line 15
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
hw/m68k/q800.c line 16
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL
hw/m68k/q800.c line 17
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
hw/m68k/q800.c line 18
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
hw/m68k/q800.c line 19
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
Quoted 119 lines
hw/m68k/q800.c new file +119
-0+* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" +#include "cpu.h" +#include "hw/hw.h" +#include "hw/boards.h" +#include "elf.h" +#include "hw/loader.h" +#include "ui/console.h" +#include "exec/address-spaces.h" +#include "hw/char/escc.h" +#include "hw/sysbus.h" +#include "hw/scsi/esp.h" +#include "bootinfo.h" +#include "hw/misc/mac_via.h" +#include "hw/input/adb.h" +#include "hw/nubus/mac-nubus-bridge.h" +#include "hw/display/macfb.h" +#include "hw/block/swim.h" +#include "net/net.h" +#include "qapi/error.h" +#include "sysemu/qtest.h" + +#define MACROM_ADDR 0x40000000 +#define MACROM_SIZE 0x00100000 + +#define MACROM_FILENAME "MacROM.bin" + +#define Q800_MACHINE_ID 35 +#define Q800_CPU_ID (1 << 2) +#define Q800_FPU_ID (1 << 2) +#define Q800_MMU_ID (1 << 2) + +#define MACH_MAC 3 +#define Q800_MAC_CPU_ID 2 + +#define VIA_BASE 0x50f00000 +#define SONIC_PROM_BASE 0x50f08000 +#define SONIC_BASE 0x50f0a000 +#define SCC_BASE 0x50f0c020 +#define ESP_BASE 0x50f10000 +#define ESP_PDMA 0x50f10100 +#define ASC_BASE 0x50F14000 +#define SWIM_BASE 0x50F1E000 +#define NUBUS_SUPER_SLOT_BASE 0x60000000 +#define NUBUS_SLOT_BASE 0xf0000000 + +/* the video base, whereas it a Nubus address, +* is needed by the kernel to have early display and +* thus provided by the bootloader +*/ +#define VIDEO_BASE 0xf9001000 + +#define MAC_CLOCK 3686418 + +typedef struct { +M68kCPU *cpu; +uint8_t ipr; +}Q800IRQState ; + +static void q800_set_irq (void *opaque,int irq,int level) +{ +Q800IRQState *s = opaque; +int i; + +if (level) { + s->ipr |=1 << irq; + }else { + s->ipr &= ~(1 << irq); + } + +for (i =7 ; i >=0 ; i--) { +if ((s->ipr >> i) &1 ) { +m68k_set_irq_level (s->cpu, i +1 , i +25 ); +return ; + } + } +m68k_set_irq_level (s->cpu,0 ,0 ); +} + + +static void main_cpu_reset (void *opaque) +{ +M68kCPU *cpu = opaque; +CPUState *cs =CPU (cpu); + +cpu_reset (cs); + cpu->env.aregs[7 ] =ldl_phys (cs->as,0 ); + cpu->env.pc =ldl_phys (cs->as,4 ); +} + +static void q800_init (MachineState *machine) +{ +M68kCPU *cpu =NULL ; +int linux_boot; +int32_t kernel_size; +uint64_t elf_entry; +char *filename; +int bios_size; +ram_addr_t initrd_base; +int32_t initrd_size; +MemoryRegion *rom; +MemoryRegion *ram; +ram_addr_t ram_size = machine->ram_size; +const char *kernel_filename = machine->kernel_filename; +const char *initrd_filename = machine->initrd_filename; +const char *kernel_cmdline = machine->kernel_cmdline; +hwaddr parameters_base; +CPUState *cs; +DeviceState *dev; +DeviceState *via_dev; +SysBusESPState *sysbus_esp; +ESPState *esp; +SysBusDevice *sysbus; +BusState *adb_bus; +NubusBus *nubus; +Q800IRQState *irq;
hw/m68k/q800.c
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+qemu_irq *pic; + + linux_boot = (kernel_filename !=NULL ); + +/* init CPUs */ + cpu =M68K_CPU (cpu_create (machine->cpu_type)); +qemu_register_reset (main_cpu_reset, cpu); + + ram =g_malloc (sizeof (*ram)); + memory_region_init_ram(ram, NULL, "m68k_mac.ram", ram_size,
&error_abort);
Quoted 79 lines
hw/m68k/q800.c new file +79
-0+memory_region_add_subregion (get_system_memory (),0 , ram); + +/* IRQ Glue */ + + irq =g_new0 (Q800IRQState,1 ); + irq->cpu = cpu; + pic =qemu_allocate_irqs (q800_set_irq, irq,8 ); + +/* VIA */ + + via_dev =qdev_create (NULL ,TYPE_MAC_VIA ); +qdev_init_nofail (via_dev); + sysbus =SYS_BUS_DEVICE (via_dev); +sysbus_mmio_map (sysbus,0 ,VIA_BASE ); +qdev_connect_gpio_out_named (DEVICE (sysbus),"irq" ,0 , pic[0 ]); +qdev_connect_gpio_out_named (DEVICE (sysbus),"irq" ,1 , pic[1 ]); + + + adb_bus =qdev_get_child_bus (via_dev,"adb.0" ); + dev =qdev_create (adb_bus,TYPE_ADB_KEYBOARD ); +qdev_init_nofail (dev); + dev =qdev_create (adb_bus,TYPE_ADB_MOUSE ); +qdev_init_nofail (dev); + +/* MACSONIC */ + +if (nb_nics >1 ) { +error_report ("q800 can only have one ethernet interface" ); +exit (1 ); + } + +qemu_check_nic_model (&nd_table[0 ],"dp83932" ); + +/* MacSonic driver needs an Apple MAC address +* Valid prefix are: +* 00:05:02 Apple +* 00:80:19 Dayna Communications, Inc. +* 00:A0:40 Apple +* 08:00:07 Apple +* (Q800 use the last one) +*/ + nd_table[0 ].macaddr.a[0 ] =0x08 ; + nd_table[0 ].macaddr.a[1 ] =0x00 ; + nd_table[0 ].macaddr.a[2 ] =0x07 ; + + dev =qdev_create (NULL ,"dp8393x" ); +qdev_set_nic_properties (dev, &nd_table[0 ]); +qdev_prop_set_uint8 (dev,"it_shift" ,2 ); +qdev_prop_set_bit (dev,"big_endian" , true); +qdev_prop_set_ptr (dev,"dma_mr" ,get_system_memory ()); +qdev_init_nofail (dev); + sysbus =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (sysbus,0 ,SONIC_BASE ); +sysbus_mmio_map (sysbus,1 ,SONIC_PROM_BASE ); +sysbus_connect_irq (sysbus,0 , pic[2 ]); + +/* SCC */ + + dev =qdev_create (NULL ,TYPE_ESCC ); +qdev_prop_set_uint32 (dev,"disabled" ,0 ); +qdev_prop_set_uint32 (dev,"frequency" ,MAC_CLOCK ); +qdev_prop_set_uint32 (dev,"it_shift" ,1 ); +qdev_prop_set_bit (dev,"bit_swap" , true); +qdev_prop_set_chr (dev,"chrA" ,serial_hd (0 )); +qdev_prop_set_chr (dev,"chrB" ,serial_hd (1 )); +qdev_prop_set_uint32 (dev,"chnBtype" ,0 ); +qdev_prop_set_uint32 (dev,"chnAtype" ,0 ); +qdev_init_nofail (dev); + sysbus =SYS_BUS_DEVICE (dev); +sysbus_connect_irq (sysbus,0 , pic[3 ]); +sysbus_connect_irq (sysbus,1 , pic[3 ]); +sysbus_mmio_map (sysbus,0 ,SCC_BASE ); + +/* SCSI */ + + dev =qdev_create (NULL ,TYPE_ESP ); + sysbus_esp =ESP_STATE (dev); + esp = &sysbus_esp->esp; + esp->dma_memory_read =NULL ;
hw/m68k/q800.c line 243
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+ esp->dma_memory_write =NULL ; + esp->dma_opaque =NULL ; + sysbus_esp->it_shift =4 ; + esp->dma_enabled =1 ; +qdev_init_nofail (dev); + + sysbus =SYS_BUS_DEVICE (dev); + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via_dev, + "via2-irq", +
VIA2_IRQ_SCSI_BIT));
Quoted 39 lines
hw/m68k/q800.c new file +39
-0+sysbus_connect_irq (sysbus,1 , +qdev_get_gpio_in_named (via_dev,"via2-irq" , +VIA2_IRQ_SCSI_DATA_BIT )); +sysbus_mmio_map (sysbus,0 ,ESP_BASE ); +sysbus_mmio_map (sysbus,1 ,ESP_PDMA ); + +scsi_bus_legacy_handle_cmdline (&esp->bus); + +/* SWIM floppy controller */ + + dev =qdev_create (NULL ,TYPE_SWIM ); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,SWIM_BASE ); + +/* NuBus */ + + dev =qdev_create (NULL ,TYPE_MAC_NUBUS_BRIDGE ); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,NUBUS_SUPER_SLOT_BASE ); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),1 ,NUBUS_SLOT_BASE ); + + nubus =MAC_NUBUS_BRIDGE (dev)->bus; + +/* framebuffer in nubus slot #9 */ + + dev =qdev_create (BUS (nubus),TYPE_NUBUS_MACFB ); +qdev_prop_set_uint32 (dev,"width" , graphic_width); +qdev_prop_set_uint32 (dev,"height" , graphic_height); +qdev_prop_set_uint8 (dev,"depth" , graphic_depth); +qdev_init_nofail (dev); + + cs =CPU (cpu); +if (linux_boot) { +uint64_t high; + kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , + &elf_entry,NULL , &high,1 , +EM_68K ,0 ,0 ); +if (kernel_size <0 ) { +error_report ("could not load kernel '%s'" , kernel_filename);
hw/m68k/q800.c
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+exit (1 ); + } +stl_phys (cs->as,4 , elf_entry);/* reset initial PC */ + parameters_base = (high +1 ) & ~1 ; + +BOOTINFO1 (cs->as, parameters_base,BI_MACHTYPE ,MACH_MAC ); +BOOTINFO1 (cs->as, parameters_base,BI_FPUTYPE ,Q800_FPU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_MMUTYPE ,Q800_MMU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_CPUTYPE ,Q800_CPU_ID ); + BOOTINFO1(cs->as, parameters_base, BI_MAC_CPUID,
Q800_MAC_CPU_ID);
hw/m68k/q800.c line 287
Quoted 1 line
hw/m68k/q800.c new file +1
-0+ BOOTINFO1(cs->as, parameters_base, BI_MAC_MODEL,
Q800_MACHINE_ID);
Quoted 37 lines
hw/m68k/q800.c new file +37
-0+BOOTINFO1 (cs->as, parameters_base, +BI_MAC_MEMSIZE , ram_size >>20 );/* in MB */ +BOOTINFO2 (cs->as, parameters_base,BI_MEMCHUNK ,0 , ram_size); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VADDR ,VIDEO_BASE ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VDEPTH , graphic_depth); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VDIM , + (graphic_height <<16 ) | graphic_width); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VROW , + (graphic_width * graphic_depth +7 ) /8 ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_SCCBASE ,SCC_BASE ); + +if (kernel_cmdline) { +BOOTINFOSTR (cs->as, parameters_base,BI_COMMAND_LINE , + kernel_cmdline); + } + +/* load initrd */ +if (initrd_filename) { + initrd_size =get_image_size (initrd_filename); +if (initrd_size <0 ) { +error_report ("could not load initial ram disk '%s'" , + initrd_filename); +exit (1 ); + } + + initrd_base = (ram_size - initrd_size) &TARGET_PAGE_MASK ; +load_image_targphys (initrd_filename, initrd_base, + ram_size - initrd_base); +BOOTINFO2 (cs->as, parameters_base,BI_RAMDISK , initrd_base, + initrd_size); + }else { + initrd_base =0 ; + initrd_size =0 ; + } +BOOTINFO0 (cs->as, parameters_base,BI_LAST ); + }else { +uint8_t *ptr;
hw/m68k/q800.c
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+/* allocate and load BIOS */ + rom =g_malloc (sizeof (*rom)); +memory_region_init_ram (rom,NULL ,"m68k_mac.rom" ,MACROM_SIZE , + &error_abort); +if (bios_name ==NULL ) { + bios_name =MACROM_FILENAME ; + } + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +memory_region_set_readonly (rom, true); + memory_region_add_subregion(get_system_memory(), MACROM_ADDR,
rom);
hw/m68k/q800.c
Quoted 4 lines
hw/m68k/q800.c new file +4
-0+ +/* Load MacROM binary */ +if (filename) { + bios_size = load_image_targphys(filename, MACROM_ADDR,
MACROM_SIZE);
hw/m68k/q800.c
Quoted 6 lines
hw/m68k/q800.c new file +6
-0+g_free (filename); + }else { + bios_size =-1 ; + } + +/* Remove qtest_enabled() check once firmware files are in the
tree */
hw/m68k/q800.c
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+if (!qtest_enabled ()) { +if (bios_size <0 || bios_size >MACROM_SIZE ) { +error_report ("could not load MacROM '%s'" , bios_name); +exit (1 ); + } + + ptr =rom_ptr (MACROM_ADDR ,MACROM_SIZE ); +stl_phys (cs->as,0 ,ldl_p (ptr));/* reset initial SP */ +stl_phys (cs->as,4 , +MACROM_ADDR +ldl_p (ptr +4 ));/* reset initial PC
*/
Quoted 19 lines
hw/m68k/q800.c new file +15
-1+ } + } +} + +static void q800_machine_init (MachineClass *mc) +{ + mc->desc ="Macintosh Quadra 800" ; + mc->init = q800_init; + mc->default_cpu_type =M68K_CPU_TYPE_NAME ("m68040" ); + mc->max_cpus =1 ; + mc->is_default =0 ; + mc->block_default_type =IF_SCSI ; +} + +DEFINE_MACHINE ("q800" , q800_machine_init) --2.20.1
Re: [Qemu-devel] [PATCH v7 10/10] hw/m68k: define Macintosh Quadra 800
Quoted 23 lines · Aleksandar Markovic
Quoted 2 lines · On May 26, 2019 1:07 AM, "Laurent Vivier" <[email protected]…
If you want to test the machine, it doesn't yet boot a MacROM, but
you can
Quoted 4 lines
boot a linux kernel from the command line.
You can install your own disk using debian-installer with:
Quoted 12 lines
./qemu-system-m68k \
-M q800 \
-serial none -serial mon:stdio \
-m 1000M -drive file=m68k.qcow2,format=qcow2 \
-net nic,model=dp83932,addr=09:00:07:12:34:57 \
-append "console=ttyS0 vga=off" \
-kernel vmlinux-4.15.0-2-m68k \
-initrd initrd.gz \
-drive file=debian-9.0-m68k-NETINST-1.iso \
-drive file=m68k.qcow2,format=qcow2 \
-nographic
Quoted 1 line
Hello Laurent,
Hello Aleksandar,
Quoted 2 lines
How does one obtain vmlinux-4.15.0-2-m68 and init.rd?
you can find more details in the cover letter:
You can get the ISO from:
https://cdimage.debian.org/cdimage/ports/10.0/m68k/iso-cd/debian-10.0-m68k-NETINST-1.iso
and extract the kernel and initrd.gz:
guestfish --add debian-10.0-m68k-NETINST-1.iso --ro \
--mount /dev/sda:/ <<_EOF_
copy-out /install/cdrom/initrd.gz .
copy-out /install/kernels/vmlinux-4.16.0-1-m68k .
_EOF_ The mirror to use is: http://ftp.ports.debian.org/debian-ports/
when it fails, continue without boot loader.
In the same way, you can extract the kernel and the initramfs from the qcow2 image to use it with "-kernel" and "-initrd":
guestfish --add m68k.qcow2 --mount /dev/sda2:/ <<_EOF_
copy-out /boot/vmlinux-4.16.0-1-m68k .
copy-out /boot/initrd.img-4.16.0-1-m68k .
_EOF_Thanks,
Laurent
Re: [Qemu-devel] [PATCH v7 10/10] hw/m68k: define Macintosh Quadra 800
In reply to Aleksandar MarkovicQuoted 5 lines · Aleksandar Markovic
Quoted 2 lines · Laurent Vivier
If you want to test the machine, it doesn't yet boot a MacROM, but you
can
Quoted 17 lines
Quoted 4 lines
boot a linux kernel from the command line.
You can install your own disk using debian-installer with:
Quoted 12 lines
./qemu-system-m68k \ -M q800 \ -serial none -serial mon:stdio \ -m 1000M -drive file=m68k.qcow2,format=qcow2 \ -net nic,model=dp83932,addr=09:00:07:12:34:57 \ -append "console=ttyS0 vga=off" \ -kernel vmlinux-4.15.0-2-m68k \ -initrd initrd.gz \ -drive file=debian-9.0-m68k-NETINST-1.iso \ -drive file=m68k.qcow2,format=qcow2 \ -nographic
Quoted 6 lines
Hello Laurent,
How does one obtain vmlinux-4.15.0-2-m68 and init.rd?
Greetings, Aleksandar
And the same for Debian iso.
Thanks in advance, Aleksandar
Quoted 1 line
Quoted 1 line
If you use a graphic adapter instead of "-nographic", you can use "-g"
to set the
Quoted 34 lines
Quoted 34 lines
size of the display (I use "-g 1600x800x24").
Co-developed-by Mark Cave-Ayland <[email protected]>Signed-off-by Mark Cave-Ayland <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- MAINTAINERS | 14 ++ default-configs/m68k-softmmu.mak | 1 + hw/m68k/Kconfig | 12 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 100 +++++++++ hw/m68k/q800.c | 369 +++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+) create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.cMAINTAINERS +10
-0@@ -906,6 +906,20 @@ F: hw/char/mcf_uart.c F: hw/net/mcf_fec.c F: include/hw/m68k/mcf*.h +q800 +M: Laurent Vivier <[email protected]> +S: Maintained +F: hw/block/swim.c +F: hw/m68k/bootinfo.h +F: hw/display/macfb.c +F: hw/m68k/q800.c +F: hw/misc/mac_via.c +F: hw/nubus/* +F: include/hw/block/swim.h
Quoted 8 lines
Review
Quoted 8 lines
MAINTAINERS +4
-0+F: include/hw/display/macfb.h +F: include/hw/misc/mac_via.h +F: include/hw/nubus/* + MicroBlaze Machines ------------------- petalogix_s3adsp1800(quoted diff) +0
-0
b/default-configs/m68k-softmmu.mak
Quoted 72 lines
Quoted 72 lines
index
e17495e2a0..7e3649c1b8100644default-configs/m68k-softmmu.mak +1
-0@@ -4,3 +4,4 @@ # CONFIG_AN5206=y CONFIG_MCF5208=y +CONFIG_Q800=yhw/m68k/Kconfig +12
-0@@ -7,3 +7,15 @@ config MCF5208 bool select COLDFIRE select PTIMER + +config Q800 + bool + select FRAMEBUFFER + select ADB + select MAC_VIA + select ESCC + select ESP + select MACFB + select NUBUS + select DP8393X + select SWIMhw/m68k/Makefile.objs +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_AN5206) += an5206.o mcf5206.o obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o +obj-$(CONFIG_Q800) += q800.ohw/m68k/bootinfo.h new file +30
-0@@ -0,0 +1,100 @@ +struct bi_record { +uint16_t tag;/* tag ID */ +uint16_t size;/* size of record */ +uint32_t data[0 ];/* data */ +}; + +/* machine independent tags */ + +#define BI_LAST 0x0000/* last record */ +#define BI_MACHTYPE 0x0001/* machine type (u_long) */ +#define BI_CPUTYPE 0x0002/* cpu type (u_long) */ +#define BI_FPUTYPE 0x0003/* fpu type (u_long) */ +#define BI_MMUTYPE 0x0004/* mmu type (u_long) */ +#define BI_MEMCHUNK 0x0005/* memory chunk address and size */ +/* (struct mem_info) */ +#define BI_RAMDISK 0x0006/* ramdisk address and size */ +/* (struct mem_info) */ +#define BI_COMMAND_LINE 0x0007/* kernel command line parameters */ +/* (string) */ + +/* Macintosh-specific tags (all u_long) */ + +#define BI_MAC_MODEL 0x8000/* Mac Gestalt ID (model type) */ +#define BI_MAC_VADDR 0x8001/* Mac video base address */ +#define BI_MAC_VDEPTH 0x8002/* Mac video depth */ +#define BI_MAC_VROW 0x8003/* Mac video rowbytes */ +#define BI_MAC_VDIM 0x8004/* Mac video dimensions */ +#define BI_MAC_VLOGICAL 0x8005/* Mac video logical base */ +#define BI_MAC_SCCBASE 0x8006/* Mac SCC base address */ +#define BI_MAC_BTIME 0x8007/* Mac boot time */
Quoted 8 lines
hw/m68k/bootinfo.h
Quoted 8 lines
hw/m68k/bootinfo.h new file +8
-0+#define BI_MAC_GMTBIAS 0x8008/* Mac GMT timezone offset */ +#define BI_MAC_MEMSIZE 0x8009/* Mac RAM size (sanity check) */ +#define BI_MAC_CPUID 0x800a/* Mac CPU type (sanity check) */ +#define BI_MAC_ROMBASE 0x800b/* Mac system ROM base address */ + +/* Macintosh hardware profile data */ + +#define BI_MAC_VIA1BASE 0x8010/* Mac VIA1 base address (always
present) */
Quoted 1 line
hw/m68k/bootinfo.h line 39
Quoted 1 line
hw/m68k/bootinfo.h new file +1
-0+#define BI_MAC_VIA2BASE 0x8011/* Mac VIA2 base address (type varies)
*/
Quoted 4 lines
hw/m68k/bootinfo.h
Quoted 4 lines
hw/m68k/bootinfo.h new file +4
-0+#define BI_MAC_VIA2TYPE 0x8012/* Mac VIA2 type (VIA, RBV, OSS) */ +#define BI_MAC_ADBTYPE 0x8013/* Mac ADB interface type */ +#define BI_MAC_ASCBASE 0x8014/* Mac Apple Sound Chip base address */ +#define BI_MAC_SCSI5380 0x8015/* Mac NCR 5380 SCSI (base address,
multi) */
Quoted 2 lines
hw/m68k/bootinfo.h line 45
Quoted 2 lines
hw/m68k/bootinfo.h new file +2
-0+#define BI_MAC_SCSIDMA 0x8016/* Mac SCSI DMA (base address) */ +#define BI_MAC_SCSI5396 0x8017/* Mac NCR 53C96 SCSI (base address,
multi) */
Quoted 3 lines
hw/m68k/bootinfo.h
Quoted 3 lines
hw/m68k/bootinfo.h new file +3
-0+#define BI_MAC_IDETYPE 0x8018/* Mac IDE interface type */ +#define BI_MAC_IDEBASE 0x8019/* Mac IDE interface base address */ +#define BI_MAC_NUBUS 0x801a/* Mac Nubus type (none, regular,
pseudo) */
Quoted 3 lines
hw/m68k/bootinfo.h
Quoted 3 lines
hw/m68k/bootinfo.h new file +3
-0+#define BI_MAC_SLOTMASK 0x801b/* Mac Nubus slots present */ +#define BI_MAC_SCCTYPE 0x801c/* Mac SCC serial type (normal, IOP) */ +#define BI_MAC_ETHTYPE 0x801d/* Mac builtin ethernet type (Sonic,
MACE */
Quoted 2 lines
hw/m68k/bootinfo.h line 53
Quoted 2 lines
hw/m68k/bootinfo.h new file +2
-0+#define BI_MAC_ETHBASE 0x801e/* Mac builtin ethernet base address */ +#define BI_MAC_PMU 0x801f/* Mac power management / poweroff
hardware */
Quoted 32 lines
Quoted 32 lines
hw/m68k/bootinfo.h new file +32
-0+#define BI_MAC_IOP_SWIM 0x8020/* Mac SWIM floppy IOP */ +#define BI_MAC_IOP_ADB 0x8021/* Mac ADB IOP */ + +#define BOOTINFO0 (as, base, id) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record)); \ + base += 2; \ + } while (0) + +#define BOOTINFO1 (as, base, id, value) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record) + 4); \ + base += 2; \ + stl_phys(as, base, value); \ + base += 4; \ + } while (0) + +#define BOOTINFO2 (as, base, id, value1, value2) \ + do { \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, sizeof(struct bi_record) + 8); \ + base += 2; \ + stl_phys(as, base, value1); \ + base += 4; \ + stl_phys(as, base, value2); \ + base += 4; \ + } while (0)
Quoted 8 lines
hw/m68k/bootinfo.h
Quoted 8 lines
hw/m68k/bootinfo.h new file +8
-0+ +#define BOOTINFOSTR (as, base, id, string) \ + do { \ + int i; \ + stw_phys(as, base, id); \ + base += 2; \ + stw_phys(as, base, \ + (sizeof(struct bi_record) + strlen(string) + 2) &
~1); \
Quoted 9 lines
Quoted 9 lines
hw/m68k/bootinfo.h new file +7
-0+ base +=2 ; \ +for (i =0 ; string[i]; i++) { \ +stb_phys (as, base++, string[i]); \ + } \ +stb_phys (as, base++,0 ); \ + base = (parameters_base +1 ) & ~1 ; \ + }while (0 )hw/m68k/q800.c new file +0
-0
Quoted 8 lines
hw/m68k/q800.c line 4
Quoted 8 lines
index 0000000000..66f4fc827d
hw/m68k/q800.c new file +4
-0@@ -0,0 +1,369 @@ +/* +* QEMU Motorla 680x0 Macintosh hardware System Emulator +* +* Permission is hereby granted, free of charge, to any person
obtaining a copy
Quoted 1 line
hw/m68k/q800.c line 5
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* of this software and associated documentation files (the
"Software"), to deal
Quoted 1 line
hw/m68k/q800.c line 6
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* in the Software without restriction, including without limitation
the rights
Quoted 1 line
hw/m68k/q800.c line 7
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell
Quoted 1 line
hw/m68k/q800.c line 8
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* copies of the Software, and to permit persons to whom the Software
is
Quoted 3 lines
hw/m68k/q800.c
Quoted 3 lines
hw/m68k/q800.c new file +3
-0+* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be
included in
Quoted 3 lines
hw/m68k/q800.c
Quoted 3 lines
hw/m68k/q800.c new file +3
-0+* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
Quoted 1 line
hw/m68k/q800.c line 15
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
Quoted 1 line
hw/m68k/q800.c line 16
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL
Quoted 1 line
hw/m68k/q800.c line 17
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER
Quoted 1 line
hw/m68k/q800.c line 18
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
Quoted 1 line
hw/m68k/q800.c line 19
Quoted 1 line
hw/m68k/q800.c new file +1
-0+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
Quoted 121 lines
Quoted 121 lines
hw/m68k/q800.c new file +121
-0+* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" +#include "cpu.h" +#include "hw/hw.h" +#include "hw/boards.h" +#include "elf.h" +#include "hw/loader.h" +#include "ui/console.h" +#include "exec/address-spaces.h" +#include "hw/char/escc.h" +#include "hw/sysbus.h" +#include "hw/scsi/esp.h" +#include "bootinfo.h" +#include "hw/misc/mac_via.h" +#include "hw/input/adb.h" +#include "hw/nubus/mac-nubus-bridge.h" +#include "hw/display/macfb.h" +#include "hw/block/swim.h" +#include "net/net.h" +#include "qapi/error.h" +#include "sysemu/qtest.h" + +#define MACROM_ADDR 0x40000000 +#define MACROM_SIZE 0x00100000 + +#define MACROM_FILENAME "MacROM.bin" + +#define Q800_MACHINE_ID 35 +#define Q800_CPU_ID (1 << 2) +#define Q800_FPU_ID (1 << 2) +#define Q800_MMU_ID (1 << 2) + +#define MACH_MAC 3 +#define Q800_MAC_CPU_ID 2 + +#define VIA_BASE 0x50f00000 +#define SONIC_PROM_BASE 0x50f08000 +#define SONIC_BASE 0x50f0a000 +#define SCC_BASE 0x50f0c020 +#define ESP_BASE 0x50f10000 +#define ESP_PDMA 0x50f10100 +#define ASC_BASE 0x50F14000 +#define SWIM_BASE 0x50F1E000 +#define NUBUS_SUPER_SLOT_BASE 0x60000000 +#define NUBUS_SLOT_BASE 0xf0000000 + +/* the video base, whereas it a Nubus address, +* is needed by the kernel to have early display and +* thus provided by the bootloader +*/ +#define VIDEO_BASE 0xf9001000 + +#define MAC_CLOCK 3686418 + +typedef struct { +M68kCPU *cpu; +uint8_t ipr; +}Q800IRQState ; + +static void q800_set_irq (void *opaque,int irq,int level) +{ +Q800IRQState *s = opaque; +int i; + +if (level) { + s->ipr |=1 << irq; + }else { + s->ipr &= ~(1 << irq); + } + +for (i =7 ; i >=0 ; i--) { +if ((s->ipr >> i) &1 ) { +m68k_set_irq_level (s->cpu, i +1 , i +25 ); +return ; + } + } +m68k_set_irq_level (s->cpu,0 ,0 ); +} + + +static void main_cpu_reset (void *opaque) +{ +M68kCPU *cpu = opaque; +CPUState *cs =CPU (cpu); + +cpu_reset (cs); + cpu->env.aregs[7 ] =ldl_phys (cs->as,0 ); + cpu->env.pc =ldl_phys (cs->as,4 ); +} + +static void q800_init (MachineState *machine) +{ +M68kCPU *cpu =NULL ; +int linux_boot; +int32_t kernel_size; +uint64_t elf_entry; +char *filename; +int bios_size; +ram_addr_t initrd_base; +int32_t initrd_size; +MemoryRegion *rom; +MemoryRegion *ram; +ram_addr_t ram_size = machine->ram_size; +const char *kernel_filename = machine->kernel_filename; +const char *initrd_filename = machine->initrd_filename; +const char *kernel_cmdline = machine->kernel_cmdline; +hwaddr parameters_base; +CPUState *cs; +DeviceState *dev; +DeviceState *via_dev; +SysBusESPState *sysbus_esp; +ESPState *esp; +SysBusDevice *sysbus; +BusState *adb_bus; +NubusBus *nubus; +Q800IRQState *irq; +qemu_irq *pic; +
Quoted 8 lines
hw/m68k/q800.c
Quoted 8 lines
hw/m68k/q800.c new file +8
-0+ linux_boot = (kernel_filename !=NULL ); + +/* init CPUs */ + cpu =M68K_CPU (cpu_create (machine->cpu_type)); +qemu_register_reset (main_cpu_reset, cpu); + + ram =g_malloc (sizeof (*ram)); + memory_region_init_ram(ram, NULL, "m68k_mac.ram", ram_size,
&error_abort);
Quoted 81 lines
Quoted 81 lines
hw/m68k/q800.c new file +81
-0+memory_region_add_subregion (get_system_memory (),0 , ram); + +/* IRQ Glue */ + + irq =g_new0 (Q800IRQState,1 ); + irq->cpu = cpu; + pic =qemu_allocate_irqs (q800_set_irq, irq,8 ); + +/* VIA */ + + via_dev =qdev_create (NULL ,TYPE_MAC_VIA ); +qdev_init_nofail (via_dev); + sysbus =SYS_BUS_DEVICE (via_dev); +sysbus_mmio_map (sysbus,0 ,VIA_BASE ); +qdev_connect_gpio_out_named (DEVICE (sysbus),"irq" ,0 , pic[0 ]); +qdev_connect_gpio_out_named (DEVICE (sysbus),"irq" ,1 , pic[1 ]); + + + adb_bus =qdev_get_child_bus (via_dev,"adb.0" ); + dev =qdev_create (adb_bus,TYPE_ADB_KEYBOARD ); +qdev_init_nofail (dev); + dev =qdev_create (adb_bus,TYPE_ADB_MOUSE ); +qdev_init_nofail (dev); + +/* MACSONIC */ + +if (nb_nics >1 ) { +error_report ("q800 can only have one ethernet interface" ); +exit (1 ); + } + +qemu_check_nic_model (&nd_table[0 ],"dp83932" ); + +/* MacSonic driver needs an Apple MAC address +* Valid prefix are: +* 00:05:02 Apple +* 00:80:19 Dayna Communications, Inc. +* 00:A0:40 Apple +* 08:00:07 Apple +* (Q800 use the last one) +*/ + nd_table[0 ].macaddr.a[0 ] =0x08 ; + nd_table[0 ].macaddr.a[1 ] =0x00 ; + nd_table[0 ].macaddr.a[2 ] =0x07 ; + + dev =qdev_create (NULL ,"dp8393x" ); +qdev_set_nic_properties (dev, &nd_table[0 ]); +qdev_prop_set_uint8 (dev,"it_shift" ,2 ); +qdev_prop_set_bit (dev,"big_endian" , true); +qdev_prop_set_ptr (dev,"dma_mr" ,get_system_memory ()); +qdev_init_nofail (dev); + sysbus =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (sysbus,0 ,SONIC_BASE ); +sysbus_mmio_map (sysbus,1 ,SONIC_PROM_BASE ); +sysbus_connect_irq (sysbus,0 , pic[2 ]); + +/* SCC */ + + dev =qdev_create (NULL ,TYPE_ESCC ); +qdev_prop_set_uint32 (dev,"disabled" ,0 ); +qdev_prop_set_uint32 (dev,"frequency" ,MAC_CLOCK ); +qdev_prop_set_uint32 (dev,"it_shift" ,1 ); +qdev_prop_set_bit (dev,"bit_swap" , true); +qdev_prop_set_chr (dev,"chrA" ,serial_hd (0 )); +qdev_prop_set_chr (dev,"chrB" ,serial_hd (1 )); +qdev_prop_set_uint32 (dev,"chnBtype" ,0 ); +qdev_prop_set_uint32 (dev,"chnAtype" ,0 ); +qdev_init_nofail (dev); + sysbus =SYS_BUS_DEVICE (dev); +sysbus_connect_irq (sysbus,0 , pic[3 ]); +sysbus_connect_irq (sysbus,1 , pic[3 ]); +sysbus_mmio_map (sysbus,0 ,SCC_BASE ); + +/* SCSI */ + + dev =qdev_create (NULL ,TYPE_ESP ); + sysbus_esp =ESP_STATE (dev); + esp = &sysbus_esp->esp; + esp->dma_memory_read =NULL ; + esp->dma_memory_write =NULL ; + esp->dma_opaque =NULL ;
Quoted 8 lines
hw/m68k/q800.c line 243
Quoted 8 lines
hw/m68k/q800.c new file +8
-0+ sysbus_esp->it_shift =4 ; + esp->dma_enabled =1 ; +qdev_init_nofail (dev); + + sysbus =SYS_BUS_DEVICE (dev); + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via_dev, + "via2-irq", +
VIA2_IRQ_SCSI_BIT));
Quoted 31 lines
Quoted 31 lines
hw/m68k/q800.c new file +31
-0+sysbus_connect_irq (sysbus,1 , +qdev_get_gpio_in_named (via_dev,"via2-irq" , +VIA2_IRQ_SCSI_DATA_BIT )); +sysbus_mmio_map (sysbus,0 ,ESP_BASE ); +sysbus_mmio_map (sysbus,1 ,ESP_PDMA ); + +scsi_bus_legacy_handle_cmdline (&esp->bus); + +/* SWIM floppy controller */ + + dev =qdev_create (NULL ,TYPE_SWIM ); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,SWIM_BASE ); + +/* NuBus */ + + dev =qdev_create (NULL ,TYPE_MAC_NUBUS_BRIDGE ); +qdev_init_nofail (dev); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,NUBUS_SUPER_SLOT_BASE ); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),1 ,NUBUS_SLOT_BASE ); + + nubus =MAC_NUBUS_BRIDGE (dev)->bus; + +/* framebuffer in nubus slot #9 */ + + dev =qdev_create (BUS (nubus),TYPE_NUBUS_MACFB ); +qdev_prop_set_uint32 (dev,"width" , graphic_width); +qdev_prop_set_uint32 (dev,"height" , graphic_height); +qdev_prop_set_uint8 (dev,"depth" , graphic_depth); +qdev_init_nofail (dev); +
Quoted 8 lines
hw/m68k/q800.c
Quoted 8 lines
hw/m68k/q800.c new file +8
-0+ cs =CPU (cpu); +if (linux_boot) { +uint64_t high; + kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , + &elf_entry,NULL , &high,1 , +EM_68K ,0 ,0 ); +if (kernel_size <0 ) { + error_report("could not load kernel '%s'",
kernel_filename);
Quoted 10 lines
hw/m68k/q800.c
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+exit (1 ); + } +stl_phys (cs->as,4 , elf_entry);/* reset initial PC */ + parameters_base = (high +1 ) & ~1 ; + +BOOTINFO1 (cs->as, parameters_base,BI_MACHTYPE ,MACH_MAC ); +BOOTINFO1 (cs->as, parameters_base,BI_FPUTYPE ,Q800_FPU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_MMUTYPE ,Q800_MMU_ID ); +BOOTINFO1 (cs->as, parameters_base,BI_CPUTYPE ,Q800_CPU_ID ); + BOOTINFO1(cs->as, parameters_base, BI_MAC_CPUID,
Q800_MAC_CPU_ID);
Quoted 1 line
hw/m68k/q800.c line 287
Quoted 1 line
hw/m68k/q800.c new file +1
-0+ BOOTINFO1(cs->as, parameters_base, BI_MAC_MODEL,
Q800_MACHINE_ID);
Quoted 5 lines
hw/m68k/q800.c
Quoted 5 lines
hw/m68k/q800.c new file +5
-0+BOOTINFO1 (cs->as, parameters_base, +BI_MAC_MEMSIZE , ram_size >>20 );/* in MB */ +BOOTINFO2 (cs->as, parameters_base,BI_MEMCHUNK ,0 , ram_size); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VADDR ,VIDEO_BASE ); + BOOTINFO1(cs->as, parameters_base, BI_MAC_VDEPTH,
graphic_depth);
Quoted 34 lines
Quoted 34 lines
hw/m68k/q800.c new file +34
-0+BOOTINFO1 (cs->as, parameters_base,BI_MAC_VDIM , + (graphic_height <<16 ) | graphic_width); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_VROW , + (graphic_width * graphic_depth +7 ) /8 ); +BOOTINFO1 (cs->as, parameters_base,BI_MAC_SCCBASE ,SCC_BASE ); + +if (kernel_cmdline) { +BOOTINFOSTR (cs->as, parameters_base,BI_COMMAND_LINE , + kernel_cmdline); + } + +/* load initrd */ +if (initrd_filename) { + initrd_size =get_image_size (initrd_filename); +if (initrd_size <0 ) { +error_report ("could not load initial ram disk '%s'" , + initrd_filename); +exit (1 ); + } + + initrd_base = (ram_size - initrd_size) &TARGET_PAGE_MASK ; +load_image_targphys (initrd_filename, initrd_base, + ram_size - initrd_base); +BOOTINFO2 (cs->as, parameters_base,BI_RAMDISK , initrd_base, + initrd_size); + }else { + initrd_base =0 ; + initrd_size =0 ; + } +BOOTINFO0 (cs->as, parameters_base,BI_LAST ); + }else { +uint8_t *ptr; +/* allocate and load BIOS */ + rom =g_malloc (sizeof (*rom));
Quoted 8 lines
hw/m68k/q800.c
Quoted 8 lines
hw/m68k/q800.c new file +8
-0+memory_region_init_ram (rom,NULL ,"m68k_mac.rom" ,MACROM_SIZE , + &error_abort); +if (bios_name ==NULL ) { + bios_name =MACROM_FILENAME ; + } + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +memory_region_set_readonly (rom, true); + memory_region_add_subregion(get_system_memory(), MACROM_ADDR,
rom);
Quoted 4 lines
hw/m68k/q800.c
Quoted 4 lines
hw/m68k/q800.c new file +4
-0+ +/* Load MacROM binary */ +if (filename) { + bios_size = load_image_targphys(filename, MACROM_ADDR,
MACROM_SIZE);
Quoted 6 lines
hw/m68k/q800.c
Quoted 6 lines
hw/m68k/q800.c new file +6
-0+g_free (filename); + }else { + bios_size =-1 ; + } + +/* Remove qtest_enabled() check once firmware files are in the
tree */
Quoted 10 lines
hw/m68k/q800.c
Quoted 10 lines
hw/m68k/q800.c new file +10
-0+if (!qtest_enabled ()) { +if (bios_size <0 || bios_size >MACROM_SIZE ) { +error_report ("could not load MacROM '%s'" , bios_name); +exit (1 ); + } + + ptr =rom_ptr (MACROM_ADDR ,MACROM_SIZE ); +stl_phys (cs->as,0 ,ldl_p (ptr));/* reset initial SP */ +stl_phys (cs->as,4 , +MACROM_ADDR +ldl_p (ptr +4 ));/* reset initial
PC */
Quoted 19 lines
Quoted 19 lines
hw/m68k/q800.c new file +15
-1+ } + } +} + +static void q800_machine_init (MachineClass *mc) +{ + mc->desc ="Macintosh Quadra 800" ; + mc->init = q800_init; + mc->default_cpu_type =M68K_CPU_TYPE_NAME ("m68040" ); + mc->max_cpus =1 ; + mc->is_default =0 ; + mc->block_default_type =IF_SCSI ; +} + +DEFINE_MACHINE ("q800" , q800_machine_init) --2.20.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v7 00/10] hw/m68k: add Apple Machintosh Quadra 800 machine
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'f556bdda0b hw/m68k: define Macintosh Quadra 800 937de47b17 hw/m68k: add a dummy SWIM floppy controller 6c6978f083 hw/m68k: add Nubus support for macfb video card e20d403316 hw/m68k: add Nubus support3e9f2296f1 hw/m68k: add macfb video card d1247477c0 hw/m68k: implement ADB bus support for via beee051e0f hw/m68k: add via support48c6f3a154 dp8393x: manage big endian bus 700fe1c320 esp: add pseudo-DMA as used by Macintosh 46fe7b4c2a escc: introduce a selector for the register bit
=== OUTPUT BEGIN ===
1/10 Checking commit 46fe7b4c2a99 (escc: introduce a selector for the register bit) 2/10 Checking commit 700fe1c32069 (esp: add pseudo-DMA as used by Macintosh)
WARNING: Block comments use a leading /* on a separate line
#284: FILE: hw/scsi/esp.c:351:
+ /* If there is still data to be read from the device then
WARNING: Block comments use * on subsequent lines
#285: FILE: hw/scsi/esp.c:352:
+ /* If there is still data to be read from the device then
+ complete the DMA operation immediately. Otherwise defer
WARNING: Block comments use a trailing */ on a separate line #286: FILE: hw/scsi/esp.c:353:
+ until the scsi layer has completed. */
total: 0 errors, 3 warnings, 452 lines checked
Patch 2/10 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/10 Checking commit 48c6f3a1541d (dp8393x: manage big endian bus) 4/10 Checking commit beee051e0f54 (hw/m68k: add via support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #39:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #91: FILE: hw/misc/mac_via.c:48:
+#define VIA1A_vSccWrReq 0x80 /* SCC write. (input)
WARNING: Block comments use a leading /* on a separate line #98: FILE: hw/misc/mac_via.c:55:
+#define VIA1A_vRev8 0x40 /* Revision 8 board ???
WARNING: Block comments use a leading /* on a separate line #108: FILE: hw/misc/mac_via.c:65:
+#define VIA1A_vHeadSel 0x20 /* Head select for IWM.
WARNING: Block comments use a leading /* on a separate line #113: FILE: hw/misc/mac_via.c:70:
+#define VIA1A_vOverlay 0x10 /* [Macintosh Family] On SE/30,II,IIx,IIcx
WARNING: Block comments use a leading /* on a separate line #127: FILE: hw/misc/mac_via.c:84:
+#define VIA1A_vSync 0x08 /* [CHRP] Sync Modem: modem clock select:
WARNING: Block comments use a leading /* on a separate line #135: FILE: hw/misc/mac_via.c:92:
+/* Macintosh Family Hardware sez: bits 0-2 of VIA1A are volume control
WARNING: Block comments use a leading /* on a separate line #150: FILE: hw/misc/mac_via.c:107:
+/* Info on VIA1B is from Macintosh Family Hardware & MkLinux.
WARNING: Block comments use a trailing */ on a separate line #151: FILE: hw/misc/mac_via.c:108:
+ * CHRP offers no info. */
WARNING: Block comments use a leading /* on a separate line #152: FILE: hw/misc/mac_via.c:109:
+#define VIA1B_vSound 0x80 /* Sound enable (for compatibility with
WARNING: Block comments use a trailing */ on a separate line #155: FILE: hw/misc/mac_via.c:112:
+ * 0=error, 1=OK. */
WARNING: Block comments use a leading /* on a separate line #156: FILE: hw/misc/mac_via.c:113:
+#define VIA1B_vMystery 0x40 /* On IIci, parity enable. 0=enabled,1=disabled
WARNING: Block comments use a trailing */ on a separate line #159: FILE: hw/misc/mac_via.c:116:
+ * as a slot $E interrupt. */
WARNING: Block comments use a leading /* on a separate line #186: FILE: hw/misc/mac_via.c:143:
+/* RAM size bits decoded as follows:
WARNING: Block comments use a leading /* on a separate line #198: FILE: hw/misc/mac_via.c:155:
+#define VIA2B_vVBL 0x80 /* VBL output to VIA1 (60.15Hz) driven by
WARNING: Block comments use a trailing */ on a separate line #201: FILE: hw/misc/mac_via.c:158:
+ * [MkLinux] RBV_PARODD: 1=odd,0=even. */
WARNING: Block comments use a leading /* on a separate line #202: FILE: hw/misc/mac_via.c:159:
+#define VIA2B_vSndJck 0x40 /* External sound jack status.
WARNING: Block comments use a trailing */ on a separate line #203: FILE: hw/misc/mac_via.c:160:
+ * 0=plug is inserted. On SE/30, always 0 */
WARNING: Block comments use a leading /* on a separate line #206: FILE: hw/misc/mac_via.c:163:
+#define VIA2B_vMode32 0x08 /* 24/32bit switch - doubles as cache flush
WARNING: Block comments use a leading /* on a separate line #214: FILE: hw/misc/mac_via.c:171:
+#define VIA2B_vPower 0x04 /* Power off, 0=shut off power.
WARNING: Block comments use a leading /* on a separate line #217: FILE: hw/misc/mac_via.c:174:
+#define VIA2B_vBusLk 0x02 /* Lock NuBus transactions, 0=locked.
WARNING: Block comments use a leading /* on a separate line #220: FILE: hw/misc/mac_via.c:177:
+#define VIA2B_vCDis 0x01 /* Cache control. On IIci, 1=disable cache card
WARNING: Block comments use a leading /* on a separate line #234: FILE: hw/misc/mac_via.c:191:
+/* Apple sez: http://developer.apple.com/technotes/ov/ov_04.html
WARNING: Block comments use a leading /* on a separate line #263: FILE: hw/misc/mac_via.c:220:
+ /* CHRP sez never ever to *write* this.
WARNING: Block comments use a leading /* on a separate line #279: FILE: hw/misc/mac_via.c:236:
+/* Apple Macintosh Family Hardware Refenece
ERROR: space prohibited after that '&&' (ctx:WxW)
#361: FILE: hw/misc/mac_via.c:318:
+ if (!(v1s->last_b & VIA1B_vRTCClk) && (s->b & VIA1B_vRTCClk)) {
^total: 1 errors, 25 warnings, 788 lines checked
Patch 4/10 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/10 Checking commit d1247477c045 (hw/m68k: implement ADB bus support for via) 6/10 Checking commit 3e9f2296f16e (hw/m68k: add macfb video card)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #53:
new file mode 100644
total: 0 errors, 1 warnings, 502 lines checked
Patch 6/10 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
7/10 Checking commit e20d40331612 (hw/m68k: add Nubus support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #38:
new file mode 100644
total: 0 errors, 1 warnings, 518 lines checked
Patch 7/10 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
8/10 Checking commit 6c6978f083af (hw/m68k: add Nubus support for macfb video card) 9/10 Checking commit 937de47b17b1 (hw/m68k: add a dummy SWIM floppy controller)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #37:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #233: FILE: hw/block/swim.c:192:
+ /* rerror/werror aren't supported by fdc and therefore not even registered
WARNING: Block comments use a trailing */ on a separate line #235: FILE: hw/block/swim.c:194:
+ * blkconf_apply_backend_options(). */
WARNING: Block comments use a leading /* on a separate line #245: FILE: hw/block/swim.c:204:
+ /* 'enospc' is the default for -drive, 'report' is what blk_new() gives us
WARNING: Block comments use a trailing */ on a separate line #246: FILE: hw/block/swim.c:205:
+ * for empty drives. */
total: 0 errors, 5 warnings, 504 lines checked
Patch 9/10 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
10/10 Checking commit f556bdda0b87 (hw/m68k: define Macintosh Quadra 800)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #95:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #274: FILE: hw/m68k/q800.c:69:
+/* the video base, whereas it a Nubus address,
WARNING: Block comments use a leading /* on a separate line #387: FILE: hw/m68k/q800.c:182:
+ /* MacSonic driver needs an Apple MAC address
total: 0 errors, 3 warnings, 511 lines checked
Patch 10/10 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]