hw/m68k: add Apple Machintosh Quadra 800 machine
v13 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
NOTE: DHCP doesn't work but you can assign a static IP address.
We need some patches for dp8393x that are not ready to be merged.
See http://patchwork.ozlabs.org/patch/927020/
http://patchwork.ozlabs.org/patch/927030/
http://patchwork.ozlabs.org/patch/927026/v13: rebase
Stop 1-second and VBL timers when the interrupt is disabled (fix some performance regressions on PowerMac G5, and 100% CPU
usage on x86_64)
v12: Merge macfb and nubus macfb patches
Add some commit messages
replace DEFINE_MACHINE() by type_init()
Add BootLinuxConsoleTest from Philippe
rebase
v11: Add VMState to migrate ESP PDMA
The new VMState structures cannot be tested because m68k is not migratable and then Q800 is not either.
I've tested the ESP VMState is not broken by the change with 'migrate "exec:cat > mig"' with qemu-system-sparc and I have compared the result with/without the patch with scripts/analyze-migrate.py: files desc.json are identical.
v10: Add SWIM VMState and reset function
Add MacVIA VMState
rework Kconfig
v9: Fix comments format
rebase on top of NeXTcube
v8: rebase (new blk_new(), add "qemu-common.h")
update bootinfo information and license
add some braces
Rename Q800IRQState to GLUEState:
it's more like a Logic Unit than an IRQ controller, and Apple calls it "GLUE" (Mark: I prefer to keep it like this for the moment, in the future this part need to be reworked, we have to review the IRQ levels and to wire NUBUS IRQ. The implementation is really trivial for the moment and we will move it to QOM in the future)
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 (8):
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 Nubus support
hw/m68k: add Nubus macfb video card
hw/m68k: add a dummy SWIM floppy controller
hw/m68k: define Macintosh Quadra 800
Philippe Mathieu-Daudé (1):
BootLinuxConsoleTest: Test the Quadra 800
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 | 487 +++++++++++++ hw/display/Kconfig | 5 + hw/display/Makefile.objs | 1 + hw/display/macfb.c | 477 +++++++++++++ hw/m68k/Kconfig | 10 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 114 +++ hw/m68k/q800.c | 394 +++++++++++ hw/misc/Kconfig | 5 + hw/misc/Makefile.objs | 1 + hw/misc/mac_via.c | 939 +++++++++++++++++++++++++ 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 | 338 ++++++++- include/hw/block/swim.h | 76 ++ include/hw/display/macfb.h | 64 ++ include/hw/misc/mac_via.h | 113 +++ include/hw/nubus/mac-nubus-bridge.h | 24 + include/hw/nubus/nubus.h | 69 ++ include/hw/scsi/esp.h | 15 + qemu-options.hx | 2 +- tests/acceptance/boot_linux_console.py | 24 + vl.c | 3 +- 35 files changed, 3624 insertions(+), 62 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.21.0
PATCH v13 1/9 esp: add pseudo-DMA as used by Macintosh
There 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 | 338 ++++++++++++++++++++++++++++++++++++++---- include/hw/scsi/esp.h | 15 ++ 2 files changed, 324 insertions(+), 29 deletions(-)
hw/scsi/esp.c +309 -29
@@ -38,6 +38,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)
@@ -58,6 +60,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) {
@@ -84,29 +96,35 @@ void esp_request_cancelled(SCSIRequest *req) } } -static uint32_t get_cmd (ESPState *s,uint8_t *buf,uint8_t buflen) +static void set_pdma (ESPState *s,enum pdma_origin_id origin, +uint32_t index,uint32_t len) +{ + s->pdma_origin = origin; + s->pdma_start = index; + s->pdma_cur = index; + s->pdma_len = len; +} + +static uint8_t *get_pdma_buf (ESPState *s) +{ +switch (s->pdma_origin) { +case PDMA : +return s->pdma_buf; +case TI : +return s->ti_buf; +case CMD : +return s->cmdbuf; +case ASYNC : +return s->async_buf; + } +return NULL ; +} + +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 ;
@@ -125,8 +143,46 @@ 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); +set_pdma (s,PDMA ,0 , dmalen); +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; }
@@ -165,6 +221,16 @@ 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,get_pdma_buf (s) + s->pdma_start); + } +} +static void handle_satn (ESPState *s) {uint8_t buf[32 ];
@@ -174,11 +240,22 @@ 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,get_pdma_buf (s) + s->pdma_start,0 ); + } +} +static void handle_s_without_atn (ESPState *s) {uint8_t buf[32 ];
@@ -188,18 +265,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);
@@ -211,16 +306,31 @@ 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 { +set_pdma (s,TI ,0 ,2 ); + s->pdma_cb = write_response_pdma_cb; +esp_raise_drq (s); +return ; + } }else { s->ti_size =2 ; s->ti_rptr =0 ;
@@ -242,6 +352,41 @@ 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;
@@ -252,10 +397,25 @@ 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 { +set_pdma (s,CMD , s->cmdlen, len); + 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 ; }
@@ -264,9 +424,23 @@ 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 { +set_pdma (s,ASYNC ,0 , len); + 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 { +set_pdma (s,ASYNC ,0 , len); + s->pdma_cb = do_dma_pdma_cb; +esp_raise_drq (s); +return ; + } } s->dma_left -= len; s->async_buf += len;
@@ -373,8 +547,7 @@ 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 ;
@@ -401,6 +574,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); }
@@ -590,6 +764,28 @@ static bool esp_mem_accepts(void *opaque, hwaddr addr,return (size ==1 ) || (is_write && size ==4 ); } +static bool esp_pdma_needed (void *opaque) +{ +ESPState *s = opaque; +return s->dma_memory_read ==NULL && s->dma_memory_write ==NULL && + s->dma_enabled; +} + +static const VMStateDescription vmstate_esp_pdma = { + .name ="esp/pdma" , + .version_id =1 , + .minimum_version_id =1 , + .needed = esp_pdma_needed, + .fields = (VMStateField []) { +VMSTATE_BUFFER (pdma_buf, ESPState), +VMSTATE_INT32 (pdma_origin, ESPState), +VMSTATE_UINT32 (pdma_len, ESPState), +VMSTATE_UINT32 (pdma_start, ESPState), +VMSTATE_UINT32 (pdma_cur, ESPState), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_esp = { .name ="esp" , .version_id =4 ,
@@ -611,6 +807,10 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT32(do_cmd, ESPState), VMSTATE_UINT32(dma_left, ESPState),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription * []) { + &vmstate_esp_pdma, +NULL } };
@@ -641,6 +841,82 @@ 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; +uint8_t *buf =get_pdma_buf (s); + + 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 : + buf[s->pdma_cur++] = val; + s->pdma_len--; + dmalen--; +break ; +case 2 : + buf[s->pdma_cur++] = val >>8 ; + buf[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; +uint8_t *buf =get_pdma_buf (s); +uint64_t val =0 ; + +if (s->pdma_len ==0 ) { +return 0 ; + } +switch (size) { +case 1 : + val = buf[s->pdma_cur++]; + s->pdma_len--; +break ; +case 2 : + val = buf[s->pdma_cur++]; + val = (val <<8 ) | buf[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 ,
@@ -673,12 +949,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 +15 -0
@@ -14,10 +14,18 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, uint8_t *buf, int len);typedef struct ESPState ESPState ; +enum pdma_origin_id { +PDMA , +TI , +CMD , +ASYNC , +}; +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 +56,12 @@ struct ESPState {ESPDMAMemoryReadWriteFunc dma_memory_write;void *dma_opaque;void (*dma_cb)(ESPState *s); +uint8_t pdma_buf[32 ]; +int pdma_origin; +uint32_t pdma_len; +uint32_t pdma_start; +uint32_t pdma_cur; +void (*pdma_cb)(ESPState *s); };#define TYPE_ESP "esp"
@@ -59,6 +73,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +MemoryRegion pdma;uint32_t it_shift;ESPState esp; } SysBusESPState;
Signature · 1 line
2.21.0
Re: [PATCH v13 1/9] esp: add pseudo-DMA as used by Macintosh
Paolo,
this patch is the only that is not specific to Q800 and has not been "acked" or reviewed by the maintainer.
If you ack it I will be ready to send a PR for the Q800 series.
Thanks,
Laurent
Le 27/09/2019 à 11:04, Laurent Vivier a écrit :
Quoted 577 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 | 338 ++++++++++++++++++++++++++++++++++++++---- include/hw/scsi/esp.h | 15 ++ 2 files changed, 324 insertions(+), 29 deletions(-)hw/scsi/esp.c +309
-29@@ -38,6 +38,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)@@ -58,6 +60,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) {@@ -84,29 +96,35 @@ void esp_request_cancelled(SCSIRequest *req) } } -static uint32_t get_cmd (ESPState *s,uint8_t *buf,uint8_t buflen) +static void set_pdma (ESPState *s,enum pdma_origin_id origin, +uint32_t index,uint32_t len) +{ + s->pdma_origin = origin; + s->pdma_start = index; + s->pdma_cur = index; + s->pdma_len = len; +} + +static uint8_t *get_pdma_buf (ESPState *s) +{ +switch (s->pdma_origin) { +case PDMA : +return s->pdma_buf; +case TI : +return s->ti_buf; +case CMD : +return s->cmdbuf; +case ASYNC : +return s->async_buf; + } +return NULL ; +} + +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 ;@@ -125,8 +143,46 @@ 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); +set_pdma (s,PDMA ,0 , dmalen); +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; }@@ -165,6 +221,16 @@ 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,get_pdma_buf (s) + s->pdma_start); + } +} +static void handle_satn (ESPState *s) {uint8_t buf[32 ];@@ -174,11 +240,22 @@ 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,get_pdma_buf (s) + s->pdma_start,0 ); + } +} +static void handle_s_without_atn (ESPState *s) {uint8_t buf[32 ];@@ -188,18 +265,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);@@ -211,16 +306,31 @@ 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 { +set_pdma (s,TI ,0 ,2 ); + s->pdma_cb = write_response_pdma_cb; +esp_raise_drq (s); +return ; + } }else { s->ti_size =2 ; s->ti_rptr =0 ;@@ -242,6 +352,41 @@ 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;@@ -252,10 +397,25 @@ 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 { +set_pdma (s,CMD , s->cmdlen, len); + 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 ; }@@ -264,9 +424,23 @@ 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 { +set_pdma (s,ASYNC ,0 , len); + 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 { +set_pdma (s,ASYNC ,0 , len); + s->pdma_cb = do_dma_pdma_cb; +esp_raise_drq (s); +return ; + } } s->dma_left -= len; s->async_buf += len;@@ -373,8 +547,7 @@ 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 ;@@ -401,6 +574,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); }@@ -590,6 +764,28 @@ static bool esp_mem_accepts(void *opaque, hwaddr addr,return (size ==1 ) || (is_write && size ==4 ); } +static bool esp_pdma_needed (void *opaque) +{ +ESPState *s = opaque; +return s->dma_memory_read ==NULL && s->dma_memory_write ==NULL && + s->dma_enabled; +} + +static const VMStateDescription vmstate_esp_pdma = { + .name ="esp/pdma" , + .version_id =1 , + .minimum_version_id =1 , + .needed = esp_pdma_needed, + .fields = (VMStateField []) { +VMSTATE_BUFFER (pdma_buf, ESPState), +VMSTATE_INT32 (pdma_origin, ESPState), +VMSTATE_UINT32 (pdma_len, ESPState), +VMSTATE_UINT32 (pdma_start, ESPState), +VMSTATE_UINT32 (pdma_cur, ESPState), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_esp = { .name ="esp" , .version_id =4 ,@@ -611,6 +807,10 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT32(do_cmd, ESPState), VMSTATE_UINT32(dma_left, ESPState),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription * []) { + &vmstate_esp_pdma, +NULL } };@@ -641,6 +841,82 @@ 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; +uint8_t *buf =get_pdma_buf (s); + + 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 : + buf[s->pdma_cur++] = val; + s->pdma_len--; + dmalen--; +break ; +case 2 : + buf[s->pdma_cur++] = val >>8 ; + buf[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; +uint8_t *buf =get_pdma_buf (s); +uint64_t val =0 ; + +if (s->pdma_len ==0 ) { +return 0 ; + } +switch (size) { +case 1 : + val = buf[s->pdma_cur++]; + s->pdma_len--; +break ; +case 2 : + val = buf[s->pdma_cur++]; + val = (val <<8 ) | buf[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 ,@@ -673,12 +949,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 +15
-0@@ -14,10 +14,18 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, uint8_t *buf, int len);typedef struct ESPState ESPState ; +enum pdma_origin_id { +PDMA , +TI , +CMD , +ASYNC , +}; +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 +56,12 @@ struct ESPState {ESPDMAMemoryReadWriteFunc dma_memory_write;void *dma_opaque;void (*dma_cb)(ESPState *s); +uint8_t pdma_buf[32 ]; +int pdma_origin; +uint32_t pdma_len; +uint32_t pdma_start; +uint32_t pdma_cur; +void (*pdma_cb)(ESPState *s); };#define TYPE_ESP "esp"@@ -59,6 +73,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +MemoryRegion pdma;uint32_t it_shift;ESPState esp; } SysBusESPState;
Re: [PATCH v13 1/9] esp: add pseudo-DMA as used by Macintosh
In reply to Laurent VivierQuoted 24 lines · Laurent Vivier
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-8
Quoted 7 lines
Co-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 | 338 ++++++++++++++++++++++++++++++++++++++---- include/hw/scsi/esp.h | 15 ++
I recommend you to install the scripts/git.orderfile file.
Quoted 525 lines
2 files changed, 324 insertions(+), 29 deletions(-)hw/scsi/esp.c +309
-29@@ -38,6 +38,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)@@ -58,6 +60,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) {@@ -84,29 +96,35 @@ void esp_request_cancelled(SCSIRequest *req) } } -static uint32_t get_cmd (ESPState *s,uint8_t *buf,uint8_t buflen) +static void set_pdma (ESPState *s,enum pdma_origin_id origin, +uint32_t index,uint32_t len) +{ + s->pdma_origin = origin; + s->pdma_start = index; + s->pdma_cur = index; + s->pdma_len = len; +} + +static uint8_t *get_pdma_buf (ESPState *s) +{ +switch (s->pdma_origin) { +case PDMA : +return s->pdma_buf; +case TI : +return s->ti_buf; +case CMD : +return s->cmdbuf; +case ASYNC : +return s->async_buf; + } +return NULL ; +} + +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 ;@@ -125,8 +143,46 @@ 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); +set_pdma (s,PDMA ,0 , dmalen); +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; }@@ -165,6 +221,16 @@ 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,get_pdma_buf (s) + s->pdma_start); + } +} +static void handle_satn (ESPState *s) {uint8_t buf[32 ];@@ -174,11 +240,22 @@ 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,get_pdma_buf (s) + s->pdma_start,0 ); + } +} +static void handle_s_without_atn (ESPState *s) {uint8_t buf[32 ];@@ -188,18 +265,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);@@ -211,16 +306,31 @@ 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 { +set_pdma (s,TI ,0 ,2 ); + s->pdma_cb = write_response_pdma_cb; +esp_raise_drq (s); +return ; + } }else { s->ti_size =2 ; s->ti_rptr =0 ;@@ -242,6 +352,41 @@ 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;@@ -252,10 +397,25 @@ 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 { +set_pdma (s,CMD , s->cmdlen, len); + 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 ; }@@ -264,9 +424,23 @@ 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 { +set_pdma (s,ASYNC ,0 , len); + 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 { +set_pdma (s,ASYNC ,0 , len); + s->pdma_cb = do_dma_pdma_cb; +esp_raise_drq (s); +return ; + } } s->dma_left -= len; s->async_buf += len;@@ -373,8 +547,7 @@ 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 ;@@ -401,6 +574,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); }@@ -590,6 +764,28 @@ static bool esp_mem_accepts(void *opaque, hwaddr addr,return (size ==1 ) || (is_write && size ==4 ); } +static bool esp_pdma_needed (void *opaque) +{ +ESPState *s = opaque; +return s->dma_memory_read ==NULL && s->dma_memory_write ==NULL && + s->dma_enabled; +} + +static const VMStateDescription vmstate_esp_pdma = { + .name ="esp/pdma" , + .version_id =1 , + .minimum_version_id =1 , + .needed = esp_pdma_needed, + .fields = (VMStateField []) { +VMSTATE_BUFFER (pdma_buf, ESPState), +VMSTATE_INT32 (pdma_origin, ESPState), +VMSTATE_UINT32 (pdma_len, ESPState), +VMSTATE_UINT32 (pdma_start, ESPState), +VMSTATE_UINT32 (pdma_cur, ESPState), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_esp = { .name ="esp" , .version_id =4 ,@@ -611,6 +807,10 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT32(do_cmd, ESPState), VMSTATE_UINT32(dma_left, ESPState),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription * []) { + &vmstate_esp_pdma, +NULL } };@@ -641,6 +841,82 @@ 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; +uint8_t *buf =get_pdma_buf (s); + + 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 : + buf[s->pdma_cur++] = val; + s->pdma_len--; + dmalen--; +break ; +case 2 : + buf[s->pdma_cur++] = val >>8 ; + buf[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; +uint8_t *buf =get_pdma_buf (s); +uint64_t val =0 ; + +if (s->pdma_len ==0 ) { +return 0 ; + } +switch (size) { +case 1 : + val = buf[s->pdma_cur++]; + s->pdma_len--; +break ; +case 2 : + val = buf[s->pdma_cur++]; + val = (val <<8 ) | buf[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 ,@@ -673,12 +949,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 +8
-0@@ -14,10 +14,18 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, uint8_t *buf, int len);typedef struct ESPState ESPState ; +enum pdma_origin_id { +PDMA , +TI , +CMD , +ASYNC , +}; +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;
include/hw/scsi/esp.h struct ESPState { · line 60
Quoted 5 lines
include/hw/scsi/esp.h +2
-0@@ -48,6 +56,12 @@ struct ESPState {ESPDMAMemoryReadWriteFunc dma_memory_write;void *dma_opaque;void (*dma_cb)(ESPState *s); +uint8_t pdma_buf[32 ]; +int pdma_origin;
'int' -> 'enum pdma_origin_id'
You can also declare the enum in place:
enum pdma_origin_id {
PDMA,
TI,
CMD,
ASYNC,
} pdma_origin;Quoted 16 lines
include/hw/scsi/esp.h +5
-0+uint32_t pdma_len; +uint32_t pdma_start; +uint32_t pdma_cur; +void (*pdma_cb)(ESPState *s); };#define TYPE_ESP "esp"@@ -59,6 +73,7 @@ typedef struct {/*< public >*/ MemoryRegion iomem; +MemoryRegion pdma;uint32_t it_shift;ESPState esp; } SysBusESPState;
Re: [PATCH v13 1/9] esp: add pseudo-DMA as used by Macintosh
Le 02/10/2019 à 13:10, Philippe Mathieu-Daudé a écrit :
Quoted 33 lines · Laurent Vivier
Quoted 24 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-8Quoted 7 lines
Co-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 | 338 ++++++++++++++++++++++++++++++++++++++----include/hw/scsi/esp.h| 15 ++
Quoted 1 line
I recommend you to install the
scripts/git.orderfilefile.
done
Quoted 3 lines
Quoted 3 lines
2 files changed, 324 insertions(+), 29 deletions(-)
...
Quoted 29 lines
Quoted 21 lines
include/hw/scsi/esp.h +7
-0@@ -14,10 +14,18 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, uint8_t *buf, int len); typedef struct ESPState ESPState; +enum pdma_origin_id { + PDMA, + TI, + CMD, + ASYNC, +}; + 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;include/hw/scsi/esp.h struct ESPState { · line 60
Quoted 5 lines
include/hw/scsi/esp.h +2
-0@@ -48,6 +56,12 @@ struct ESPState { ESPDMAMemoryReadWriteFunc dma_memory_write; void *dma_opaque; void (*dma_cb)(ESPState *s); + uint8_t pdma_buf[32]; + int pdma_origin;'int' -> 'enum
pdma_origin_id'
Quoted 8 lines
You can also declare the enum in place:
enum
pdma_origin_id{
PDMA,
TI,
CMD,
ASYNC,
}pdma_origin;
If I remember correctly I put an "int" here because I didn't find the VMSTATE_XXX() to use and VMSTATE_INT32() doesn't like the enum type (which should be treated as an int).
Thanks,
Laurent
Re: [PATCH v13 1/9] esp: add pseudo-DMA as used by Macintosh
Quoted 80 lines · Laurent Vivier
Le 02/10/2019 à 13:10, Philippe Mathieu-Daudé a écrit :
Quoted 33 lines · Laurent Vivier
Quoted 24 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-8Quoted 7 lines
Co-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 | 338 ++++++++++++++++++++++++++++++++++++++---- include/hw/scsi/esp.h | 15 ++Quoted 1 line
I recommend you to install the
scripts/git.orderfilefile.done
Quoted 3 lines
Quoted 3 lines
2 files changed, 324 insertions(+), 29 deletions(-)...
Quoted 29 lines
Quoted 21 lines
include/hw/scsi/esp.h +7
-0@@ -14,10 +14,18 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, uint8_t *buf, int len); typedef struct ESPState ESPState; +enum pdma_origin_id { + PDMA, + TI, + CMD, + ASYNC, +}; + 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;include/hw/scsi/esp.h struct ESPState { · line 60
Quoted 5 lines
include/hw/scsi/esp.h +2
-0@@ -48,6 +56,12 @@ struct ESPState { ESPDMAMemoryReadWriteFunc dma_memory_write; void *dma_opaque; void (*dma_cb)(ESPState *s); + uint8_t pdma_buf[32]; + int pdma_origin;'int' -> 'enum
pdma_origin_id'Quoted 8 lines
You can also declare the enum in place:
enum
pdma_origin_id{
PDMA,
TI,
CMD,
ASYNC,
}pdma_origin;
Quoted 3 lines
If I remember correctly I put an "int" here because I didn't find the
VMSTATE_XXX()to use andVMSTATE_INT32()doesn't like the enum type (which should be treated as an int).
Yes you are correct, I didn't check this was a migrated enum.
Regards,
Phil.
PATCH v13 2/9 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
@@ -153,6 +153,7 @@ typedef struct dp8393xState {/* Hardware */ uint8_t it_shift; +bool big_endian;qemu_irq irq;#ifdef DEBUG_SONIC int irq_level;
@@ -223,6 +224,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 ;
@@ -254,12 +278,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 ]);
@@ -272,7 +296,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 */
@@ -293,10 +317,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 ]);
@@ -411,12 +435,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 ) {
@@ -442,9 +466,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 ); } }
@@ -471,7 +495,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),
@@ -485,8 +510,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 ; }
@@ -749,7 +774,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 {
@@ -793,11 +818,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 );
@@ -806,12 +831,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 ];
@@ -924,6 +949,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.21.0
PATCH v13 3/9 hw/m68k: add VIA support
In reply to Laurent VivierInside the 680x0 Macintosh, VIA (Versatile Interface Adapter) is used to interface the keyboard, Mouse, and real-time clock. It also provides control line for the floppy disk driver, video interface, sound circuitry and serial interface.
This implementation is based on the MOS6522 object.
--- MAINTAINERS | 6 + default-configs/m68k-softmmu.mak | 1 + hw/m68k/Kconfig | 4 + hw/misc/Kconfig | 4 + hw/misc/Makefile.objs | 1 + hw/misc/mac_via.c | 742 +++++++++++++++++++++++++++++++ include/hw/misc/mac_via.h | 106 +++++ 7 files changed, 864 insertions(+) create mode 100644 hw/misc/mac_via.c create mode 100644 include/hw/misc/mac_via.h
MAINTAINERS +6 -0
@@ -917,6 +917,12 @@ F: hw/m68k/next-*.c F: hw/display/next-fb.c F: include/hw/m68k/next-cube.h +q800 +M: Laurent Vivier <[email protected]> +S: Maintained +F: hw/misc/mac_via.c +F: include/hw/misc/mac_via.h + MicroBlaze Machines ------------------- petalogix_s3adsp1800
default-configs/m68k-softmmu.mak +1 -0
@@ -7,3 +7,4 @@ CONFIG_SEMIHOSTING=y CONFIG_AN5206=y CONFIG_MCF5208=y CONFIG_NEXTCUBE=y +CONFIG_Q800=y
hw/m68k/Kconfig +4 -0
@@ -12,3 +12,7 @@ config NEXTCUBE bool select FRAMEBUFFER select ESCC + +config Q800 + bool + select MAC_VIA
hw/misc/Kconfig +4 -0
@@ -120,4 +120,8 @@ config AUX config UNIMP bool +config MAC_VIA + bool + select MOS6522 + source macio/Kconfig
hw/misc/Makefile.objs +1 -0
@@ -78,5 +78,6 @@ common-obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o common-obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o common-obj-$(CONFIG_MSF2) += msf2-sysreg.o common-obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o +obj-$(CONFIG_MAC_VIA) += mac_via.o common-obj-$(CONFIG_GRLIB) += grlib_ahb_apb_pnp.o
hw/misc/mac_via.c new file +742 -0
742 lines not on this page · raw message
include/hw/misc/mac_via.h new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v13 4/9 hw/m68k: implement ADB bus support for via
In reply to Laurent VivierVIA needs to be able to poll the ADB interface and to read/write data from/to the bus.
This patch adds functions allowing that.
--- hw/misc/Kconfig | 1 + hw/misc/mac_via.c | 197 ++++++++++++++++++++++++++++++++++++++ include/hw/misc/mac_via.h | 7 ++ 3 files changed, 205 insertions(+)
hw/misc/Kconfig +1 -0
@@ -123,5 +123,6 @@ config UNIMP config MAC_VIA bool select MOS6522 + select ADB source macio/Kconfig
hw/misc/mac_via.c +197 -0
237 lines not on this page · raw message
include/hw/misc/mac_via.h +7 -0
@@ -101,6 +101,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]; } MacVIAState;#endif
Signature · 1 line
2.21.0
PATCH v13 5/9 hw/m68k: add Nubus support
In reply to Laurent VivierThis patch adds basic support for the NuBus bus. This is used by 680x0 Macintosh.
--- MAINTAINERS | 2 + hw/Kconfig | 1 + hw/Makefile.objs | 1 + hw/m68k/Kconfig | 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 +++++++++ 12 files changed, 509 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
MAINTAINERS +2 -0
@@ -921,7 +921,9 @@ q800 M: Laurent Vivier <[email protected]> S: Maintained F: hw/misc/mac_via.c +F: hw/nubus/* F: include/hw/misc/mac_via.h +F: include/hw/nubus/* MicroBlaze Machines -------------------
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
@@ -37,6 +37,7 @@ devices-dirs-y += virtio/ devices-dirs-y += watchdog/ devices-dirs-y += xen/ devices-dirs-$(CONFIG_MEM_DEVICE) += mem/ +devices-dirs-$(CONFIG_NUBUS) += nubus/ devices-dirs-y += semihosting/ devices-dirs-y += smbios/ endif
hw/m68k/Kconfig +1 -0
@@ -16,3 +16,4 @@ config NEXTCUBE config Q800 bool select MAC_VIA + select NUBUS
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.21.0
PATCH v13 6/9 hw/m68k: add Nubus macfb video card
In reply to Laurent VivierThis patch adds support for a graphic framebuffer device. This device can be added as a sysbus device or as a NuBus device.
It is accessed as a framebuffer but the color palette can be set.
--- MAINTAINERS | 2 + arch_init.c | 4 + hw/display/Kconfig | 5 + hw/display/Makefile.objs | 1 + hw/display/macfb.c | 477 +++++++++++++++++++++++++++++++++++++ hw/m68k/Kconfig | 1 + include/hw/display/macfb.h | 64 +++++ qemu-options.hx | 2 +- vl.c | 3 +- 9 files changed, 557 insertions(+), 2 deletions(-) create mode 100644 hw/display/macfb.c create mode 100644 include/hw/display/macfb.h
MAINTAINERS +2 -0
@@ -922,8 +922,10 @@ M: Laurent Vivier <[email protected]> S: Maintained F: hw/misc/mac_via.c F: hw/nubus/* +F: hw/display/macfb.c F: include/hw/misc/mac_via.h F: include/hw/nubus/* +F: include/hw/display/macfb.h MicroBlaze Machines -------------------
arch_init.c +4 -0
@@ -38,6 +38,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 +5 -0
@@ -132,3 +132,8 @@ config ATI_VGA select VGA select BITBANG_I2C select DDC + +config MACFB + bool + select FRAMEBUFFER + depends on NUBUS
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 +477 -0
477 lines not on this page · raw message
hw/m68k/Kconfig +1 -0
@@ -17,3 +17,4 @@ config Q800 bool select MAC_VIA select NUBUS + select MACFB
include/hw/display/macfb.h new file +64 -0
64 lines not on this page · raw message
qemu-options.hx +1 -1
@@ -1802,7 +1802,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
@@ -3270,7 +3270,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.21.0
PATCH v13 7/9 hw/m68k: add a dummy SWIM floppy controller
In reply to Laurent VivierSWIM (Sander-Wozniak Integrated Machine) is the floppy controller of the 680x0 Macintosh.
This patch introduces only the basic support: it allows to switch from IWM (Integrated WOZ Machine) mode to the SWIM mode and makes the linux driver happy.
It cannot read any floppy image.
--- MAINTAINERS | 2 + hw/block/Kconfig | 3 + hw/block/Makefile.objs | 1 + hw/block/swim.c | 487 ++++++++++++++++++++++++++++++++++++++++ hw/m68k/Kconfig | 1 + include/hw/block/swim.h | 76 +++++++ 6 files changed, 570 insertions(+) create mode 100644 hw/block/swim.c create mode 100644 include/hw/block/swim.h
MAINTAINERS +2 -0
@@ -923,9 +923,11 @@ S: Maintained F: hw/misc/mac_via.c F: hw/nubus/* F: hw/display/macfb.c +F: hw/block/swim.c F: include/hw/misc/mac_via.h F: include/hw/nubus/* F: include/hw/display/macfb.h +F: include/hw/block/swim.h MicroBlaze Machines -------------------
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 +487 -0
487 lines not on this page · raw message
hw/m68k/Kconfig +1 -0
@@ -18,3 +18,4 @@ config Q800 select MAC_VIA select NUBUS select MACFB + select SWIM
include/hw/block/swim.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH v13 7/9] hw/m68k: add a dummy SWIM floppy controller
Quoted 4 lines · Laurent Vivier
SWIM (Sander-Wozniak Integrated Machine) is the floppy controller of the 680x0 Macintosh.
This patch introduces
This information ...
Quoted 5 lines
only the basic support: it allows to switch from
IWM (Integrated WOZ Machine) mode to the SWIM mode and makes the linux driver happy.It cannot read any floppy image.
... is worth to add in swim.c header IMHO.
Quoted 640 lines
Co-developed-by Mark Cave-Ayland <[email protected]>Signed-off-by Mark Cave-Ayland <[email protected]>Signed-off-by Laurent Vivier <[email protected]>Reviewed-by Hervé Poussineau <[email protected]>--- MAINTAINERS | 2 + hw/block/Kconfig | 3 + hw/block/Makefile.objs | 1 + hw/block/swim.c | 487 ++++++++++++++++++++++++++++++++++++++++ hw/m68k/Kconfig | 1 + include/hw/block/swim.h | 76 +++++++ 6 files changed, 570 insertions(+) create mode 100644 hw/block/swim.c create mode 100644 include/hw/block/swim.hMAINTAINERS +2
-0@@ -923,9 +923,11 @@ S: Maintained F: hw/misc/mac_via.c F: hw/nubus/* F: hw/display/macfb.c +F: hw/block/swim.c F: include/hw/misc/mac_via.h F: include/hw/nubus/* F: include/hw/display/macfb.h +F: include/hw/block/swim.h MicroBlaze Machines -------------------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 + boolhw/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.ohw/block/swim.c new file +487
-0@@ -0,0 +1,487 @@ +/* +* QEMU Macintosh floppy disk controller emulator (SWIM) +* +* Copyright (c) 2014-2018 Laurent Vivier <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "qapi/error.h" +#include "sysemu/block-backend.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "hw/block/block.h" +#include "hw/block/swim.h" +#include "hw/qdev-properties.h" + +/* IWM registers */ + +#define IWM_PH0L 0 +#define IWM_PH0H 1 +#define IWM_PH1L 2 +#define IWM_PH1H 3 +#define IWM_PH2L 4 +#define IWM_PH2H 5 +#define IWM_PH3L 6 +#define IWM_PH3H 7 +#define IWM_MTROFF 8 +#define IWM_MTRON 9 +#define IWM_INTDRIVE 10 +#define IWM_EXTDRIVE 11 +#define IWM_Q6L 12 +#define IWM_Q6H 13 +#define IWM_Q7L 14 +#define IWM_Q7H 15 + +/* SWIM registers */ + +#define SWIM_WRITE_DATA 0 +#define SWIM_WRITE_MARK 1 +#define SWIM_WRITE_CRC 2 +#define SWIM_WRITE_PARAMETER 3 +#define SWIM_WRITE_PHASE 4 +#define SWIM_WRITE_SETUP 5 +#define SWIM_WRITE_MODE0 6 +#define SWIM_WRITE_MODE1 7 + +#define SWIM_READ_DATA 8 +#define SWIM_READ_MARK 9 +#define SWIM_READ_ERROR 10 +#define SWIM_READ_PARAMETER 11 +#define SWIM_READ_PHASE 12 +#define SWIM_READ_SETUP 13 +#define SWIM_READ_STATUS 14 +#define SWIM_READ_HANDSHAKE 15 + +#define REG_SHIFT 9 + +#define SWIM_MODE_IWM 0 +#define SWIM_MODE_SWIM 1 + +/* bits in phase register */ + +#define SWIM_SEEK_NEGATIVE 0x074 +#define SWIM_STEP 0x071 +#define SWIM_MOTOR_ON 0x072 +#define SWIM_MOTOR_OFF 0x076 +#define SWIM_INDEX 0x073 +#define SWIM_EJECT 0x077 +#define SWIM_SETMFM 0x171 +#define SWIM_SETGCR 0x175 +#define SWIM_RELAX 0x033 +#define SWIM_LSTRB 0x008 +#define SWIM_CA_MASK 0x077 + +/* Select values for swim_select and swim_readbit */ + +#define SWIM_READ_DATA_0 0x074 +#define SWIM_TWOMEG_DRIVE 0x075 +#define SWIM_SINGLE_SIDED 0x076 +#define SWIM_DRIVE_PRESENT 0x077 +#define SWIM_DISK_IN 0x170 +#define SWIM_WRITE_PROT 0x171 +#define SWIM_TRACK_ZERO 0x172 +#define SWIM_TACHO 0x173 +#define SWIM_READ_DATA_1 0x174 +#define SWIM_MFM_MODE 0x175 +#define SWIM_SEEK_COMPLETE 0x176 +#define SWIM_ONEMEG_MEDIA 0x177 + +/* Bits in handshake register */ + +#define SWIM_MARK_BYTE 0x01 +#define SWIM_CRC_ZERO 0x02 +#define SWIM_RDDATA 0x04 +#define SWIM_SENSE 0x08 +#define SWIM_MOTEN 0x10 +#define SWIM_ERROR 0x20 +#define SWIM_DAT2BYTE 0x40 +#define SWIM_DAT1BYTE 0x80 + +/* bits in setup register */ + +#define SWIM_S_INV_WDATA 0x01 +#define SWIM_S_3_5_SELECT 0x02 +#define SWIM_S_GCR 0x04 +#define SWIM_S_FCLK_DIV2 0x08 +#define SWIM_S_ERROR_CORR 0x10 +#define SWIM_S_IBM_DRIVE 0x20 +#define SWIM_S_GCR_WRITE 0x40 +#define SWIM_S_TIMEOUT 0x80 + +/* bits in mode register */ + +#define SWIM_CLFIFO 0x01 +#define SWIM_ENBL1 0x02 +#define SWIM_ENBL2 0x04 +#define SWIM_ACTION 0x08 +#define SWIM_WRITE_MODE 0x10 +#define SWIM_HEDSEL 0x20 +#define SWIM_MOTON 0x80 + +static void fd_recalibrate (FDrive *drive) +{ +} + +static void swim_change_cb (void *opaque,bool load,Error **errp) +{ +FDrive *drive = opaque; + +if (!load) { +blk_set_perm (drive->blk,0 ,BLK_PERM_ALL , &error_abort); + }else { +if (!blkconf_apply_backend_options (drive->conf, +blk_is_read_only (drive->blk), false, + errp)) { +return ; + } + } +} + +static const BlockDevOps swim_block_ops = { + .change_media_cb = swim_change_cb, +}; + +static Property swim_drive_properties[] = { +DEFINE_PROP_INT32 ("unit" , SWIMDrive, unit,-1 ), +DEFINE_BLOCK_PROPERTIES (SWIMDrive, conf), +DEFINE_PROP_END_OF_LIST (), +}; + +static void swim_drive_realize (DeviceState *qdev,Error **errp) +{ +SWIMDrive *dev =SWIM_DRIVE (qdev); +SWIMBus *bus =SWIM_BUS (qdev->parent_bus); +FDrive *drive; +int ret; + +if (dev->unit ==-1 ) { +for (dev->unit =0 ; dev->unit <SWIM_MAX_FD ; dev->unit++) { + drive = &bus->ctrl->drives[dev->unit]; +if (!drive->blk) { +break ; + } + } + } + +if (dev->unit >=SWIM_MAX_FD ) { +error_setg (errp,"Can't create floppy unit %d, bus supports " +"only %d units" , dev->unit,SWIM_MAX_FD ); +return ; + } + + drive = &bus->ctrl->drives[dev->unit]; +if (drive->blk) { +error_setg (errp,"Floppy unit %d is in use" , dev->unit); +return ; + } + +if (!dev->conf.blk) { +/* Anonymous BlockBackend for an empty drive */ + dev->conf.blk =blk_new (qemu_get_aio_context (),0 ,BLK_PERM_ALL ); + ret =blk_attach_dev (dev->conf.blk, qdev); +assert (ret ==0 ); + } + +blkconf_blocksizes (&dev->conf); +if (dev->conf.logical_block_size !=512 || + dev->conf.physical_block_size !=512 ) + { +error_setg (errp,"Physical and logical block size must " +"be 512 for floppy" ); +return ; + } + +/* +* rerror/werror aren't supported by fdc and therefore not even registered +* with qdev. So set the defaults manually before they are used in +* blkconf_apply_backend_options(). +*/ + dev->conf.rerror =BLOCKDEV_ON_ERROR_AUTO ; + dev->conf.werror =BLOCKDEV_ON_ERROR_AUTO ; + +if (!blkconf_apply_backend_options (&dev->conf, +blk_is_read_only (dev->conf.blk), + false, errp)) { +return ; + } + +/* +* 'enospc' is the default for -drive, 'report' is what blk_new() gives us +* for empty drives. +*/ +if (blk_get_on_error (dev->conf.blk,0 ) !=BLOCKDEV_ON_ERROR_ENOSPC && +blk_get_on_error (dev->conf.blk,0 ) !=BLOCKDEV_ON_ERROR_REPORT ) { +error_setg (errp,"fdc doesn't support drive option werror" ); +return ; + } +if (blk_get_on_error (dev->conf.blk,1 ) !=BLOCKDEV_ON_ERROR_REPORT ) { +error_setg (errp,"fdc doesn't support drive option rerror" ); +return ; + } + + drive->conf = &dev->conf; + drive->blk = dev->conf.blk; + drive->swimctrl = bus->ctrl; + +blk_set_dev_ops (drive->blk, &swim_block_ops, drive); +} + +static void swim_drive_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *k =DEVICE_CLASS (klass); + k->realize = swim_drive_realize; +set_bit (DEVICE_CATEGORY_STORAGE , k->categories); + k->bus_type =TYPE_SWIM_BUS ; + k->props = swim_drive_properties; + k->desc ="virtual SWIM drive" ; +} + +static const TypeInfo swim_drive_info = { + .name =TYPE_SWIM_DRIVE , + .parent =TYPE_DEVICE , + .instance_size =sizeof (SWIMDrive), + .class_init = swim_drive_class_init, +}; + +static const TypeInfo swim_bus_info = { + .name =TYPE_SWIM_BUS , + .parent =TYPE_BUS , + .instance_size =sizeof (SWIMBus), +}; + +static void iwmctrl_write (void *opaque,hwaddr reg,uint64_t value, +unsigned size) +{ +SWIMCtrl *swimctrl = opaque; + + reg >>=REG_SHIFT ; + + swimctrl->regs[reg >>1 ] = reg &1 ; + +if (swimctrl->regs[IWM_Q6 ] && + swimctrl->regs[IWM_Q7 ]) { +if (swimctrl->regs[IWM_MTR ]) { +/* data register */ + swimctrl->iwm_data = value; + }else { +/* mode register */ + swimctrl->iwm_mode = value; +/* detect sequence to switch from IWM mode to SWIM mode */ +switch (swimctrl->iwm_switch) { +case 0 : +if (value ==0x57 ) { + swimctrl->iwm_switch++; + } +break ; +case 1 : +if (value ==0x17 ) { + swimctrl->iwm_switch++; + } +break ; +case 2 : +if (value ==0x57 ) { + swimctrl->iwm_switch++; + } +break ; +case 3 : +if (value ==0x57 ) { + swimctrl->mode =SWIM_MODE_SWIM ; + swimctrl->iwm_switch =0 ; + } +break ; + } + } + } +} + +static uint64_t iwmctrl_read (void *opaque,hwaddr reg,unsigned size) +{ +SWIMCtrl *swimctrl = opaque; + + reg >>=REG_SHIFT ; + + swimctrl->regs[reg >>1 ] = reg &1 ; + +return 0 ; +} + +static void swimctrl_write (void *opaque,hwaddr reg,uint64_t value, +unsigned size) +{ +SWIMCtrl *swimctrl = opaque; + +if (swimctrl->mode ==SWIM_MODE_IWM ) { +iwmctrl_write (opaque, reg, value, size); +return ; + } + + reg >>=REG_SHIFT ; + +switch (reg) { +case SWIM_WRITE_PHASE : + swimctrl->swim_phase = value; +break ; +case SWIM_WRITE_MODE0 : + swimctrl->swim_mode &= ~value; +break ; +case SWIM_WRITE_MODE1 : + swimctrl->swim_mode |= value; +break ; +case SWIM_WRITE_DATA : +case SWIM_WRITE_MARK : +case SWIM_WRITE_CRC : +case SWIM_WRITE_PARAMETER : +case SWIM_WRITE_SETUP : +break ; + } +} + +static uint64_t swimctrl_read (void *opaque,hwaddr reg,unsigned size) +{ +SWIMCtrl *swimctrl = opaque; +uint32_t value =0 ; + +if (swimctrl->mode ==SWIM_MODE_IWM ) { +return iwmctrl_read (opaque, reg, size); + } + + reg >>=REG_SHIFT ; + +switch (reg) { +case SWIM_READ_PHASE : + value = swimctrl->swim_phase; +break ; +case SWIM_READ_HANDSHAKE : +if (swimctrl->swim_phase ==SWIM_DRIVE_PRESENT ) { +/* always answer "no drive present" */ + value =SWIM_SENSE ; + } +break ; +case SWIM_READ_DATA : +case SWIM_READ_MARK : +case SWIM_READ_ERROR : +case SWIM_READ_PARAMETER : +case SWIM_READ_SETUP : +case SWIM_READ_STATUS : +break ; + } + +return value; +} + +static const MemoryRegionOps swimctrl_mem_ops = { + .write = swimctrl_write, + .read = swimctrl_read, + .endianness =DEVICE_NATIVE_ENDIAN , +}; + +static void sysbus_swim_reset (DeviceState *d) +{ +SWIM *sys =SWIM (d); +SWIMCtrl *ctrl = &sys->ctrl; +int i; + + ctrl->mode =0 ; + ctrl->iwm_switch =0 ; +for (i =0 ; i <8 ; i++) { + ctrl->regs[i] =0 ; + } + ctrl->iwm_data =0 ; + ctrl->iwm_mode =0 ; + ctrl->swim_phase =0 ; + ctrl->swim_mode =0 ; +for (i =0 ; i <SWIM_MAX_FD ; i++) { +fd_recalibrate (&ctrl->drives[i]); + } +} + +static void sysbus_swim_init (Object *obj) +{ +SysBusDevice *sbd =SYS_BUS_DEVICE (obj); +SWIM *sbs =SWIM (obj); +SWIMCtrl *swimctrl = &sbs->ctrl; + +memory_region_init_io (&swimctrl->iomem, obj, &swimctrl_mem_ops, swimctrl, +"swim" ,0x2000 ); +sysbus_init_mmio (sbd, &swimctrl->iomem); +} + +static void sysbus_swim_realize (DeviceState *dev,Error **errp) +{ +SWIM *sys =SWIM (dev); +SWIMCtrl *swimctrl = &sys->ctrl; + +qbus_create_inplace (&swimctrl->bus,sizeof (SWIMBus),TYPE_SWIM_BUS , dev, +NULL ); + swimctrl->bus.ctrl = swimctrl; +} + +static const VMStateDescription vmstate_fdrive = { + .name ="fdrive" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_swim = { + .name ="swim" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (mode, SWIMCtrl), +/* IWM mode */ +VMSTATE_INT32 (iwm_switch, SWIMCtrl), +VMSTATE_UINT16_ARRAY (regs, SWIMCtrl,8 ), +VMSTATE_UINT8 (iwm_data, SWIMCtrl), +VMSTATE_UINT8 (iwm_mode, SWIMCtrl), +/* SWIM mode */ +VMSTATE_UINT8 (swim_phase, SWIMCtrl), +VMSTATE_UINT8 (swim_mode, SWIMCtrl), +/* Drives */ +VMSTATE_STRUCT_ARRAY (drives, SWIMCtrl,SWIM_MAX_FD ,1 , + vmstate_fdrive, FDrive), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_sysbus_swim = { + .name ="SWIM" , + .version_id =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (ctrl,SWIM ,0 , vmstate_swim, SWIMCtrl), +VMSTATE_END_OF_LIST () + } +}; + +static void sysbus_swim_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = sysbus_swim_realize; + dc->reset = sysbus_swim_reset; + dc->vmsd = &vmstate_sysbus_swim; +} + +static const TypeInfo sysbus_swim_info = { + .name =TYPE_SWIM , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SWIM ), + .instance_init = sysbus_swim_init, + .class_init = sysbus_swim_class_init, +}; + +static void swim_register_types (void ) +{ +type_register_static (&sysbus_swim_info); +type_register_static (&swim_bus_info); +type_register_static (&swim_drive_info); +} + +type_init (swim_register_types)hw/m68k/Kconfig +1
-0@@ -18,3 +18,4 @@ config Q800 select MAC_VIA select NUBUS select MACFB + select SWIMinclude/hw/block/swim.h new file +76
-0@@ -0,0 +1,76 @@ +/* +* QEMU Macintosh floppy disk controller emulator (SWIM) +* +* Copyright (c) 2014-2018 Laurent Vivier <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +* +*/ + +#ifndef SWIM_H +#define SWIM_H + +#include "qemu/osdep.h" +#include "hw/sysbus.h" + +#define SWIM_MAX_FD 2 + +typedef struct SWIMDrive SWIMDrive ; +typedef struct SWIMBus SWIMBus ; +typedef struct SWIMCtrl SWIMCtrl ; + +#define TYPE_SWIM_DRIVE "swim-drive" +#define SWIM_DRIVE (obj) OBJECT_CHECK(SWIMDrive, (obj), TYPE_SWIM_DRIVE) + +struct SWIMDrive { +DeviceState qdev; +int32_t unit; +BlockConf conf; +}; + +#define TYPE_SWIM_BUS "swim-bus" +#define SWIM_BUS (obj) OBJECT_CHECK(SWIMBus, (obj), TYPE_SWIM_BUS) + +struct SWIMBus { +BusState bus; +struct SWIMCtrl *ctrl; +}; + +typedef struct FDrive { +SWIMCtrl *swimctrl; +BlockBackend *blk; +BlockConf *conf; +}FDrive ; + +struct SWIMCtrl { +MemoryRegion iomem; +FDrive drives[SWIM_MAX_FD ]; +int mode; +/* IWM mode */ +int iwm_switch; +uint16_t regs[8 ]; +#define IWM_PH0 0 +#define IWM_PH1 1 +#define IWM_PH2 2 +#define IWM_PH3 3 +#define IWM_MTR 4 +#define IWM_DRIVE 5 +#define IWM_Q6 6 +#define IWM_Q7 7 +uint8_t iwm_data; +uint8_t iwm_mode; +/* SWIM mode */ +uint8_t swim_phase; +uint8_t swim_mode; +SWIMBus bus; +}; + +#define TYPE_SWIM "swim" +#define SWIM (obj) OBJECT_CHECK(SWIM, (obj), TYPE_SWIM) + +typedef struct SWIM { +SysBusDevice parent_obj; +SWIMCtrl ctrl; +}SWIM ; +#endif
PATCH v13 8/9 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 | 2 + hw/m68k/Kconfig | 3 + hw/m68k/Makefile.objs | 1 + hw/m68k/bootinfo.h | 114 ++++++++++++ hw/m68k/q800.c | 394 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 514 insertions(+) create mode 100644 hw/m68k/bootinfo.h create mode 100644 hw/m68k/q800.c
MAINTAINERS +2 -0
@@ -920,10 +920,12 @@ F: include/hw/m68k/next-cube.h q800 M: Laurent Vivier <[email protected]> S: Maintained +F: hw/m68k/q800.c F: hw/misc/mac_via.c F: hw/nubus/* F: hw/display/macfb.c F: hw/block/swim.c +F: hw/m68k/bootinfo.h F: include/hw/misc/mac_via.h F: include/hw/nubus/* F: include/hw/display/macfb.h
hw/m68k/Kconfig +3 -0
@@ -19,3 +19,6 @@ config Q800 select NUBUS select MACFB select SWIM + select ESCC + select ESP + select DP8393X
hw/m68k/Makefile.objs +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_AN5206) += an5206.o mcf5206.o obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o obj-$(CONFIG_NEXTCUBE) += next-kbd.o next-cube.o +obj-$(CONFIG_Q800) += q800.o
hw/m68k/bootinfo.h new file +114 -0
114 lines not on this page · raw message
hw/m68k/q800.c new file +394 -0
394 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v13 9/9 BootLinuxConsoleTest: Test the Quadra 800
In reply to Laurent VivierFrom: Philippe Mathieu-Daudé <[email protected]>
This test boots a Linux kernel on a Quadra 800 board and verify the serial is working.
Example:
$ avocado --show=app,console run -t machine:q800 tests/acceptance/boot_linux_console.py console: ABCFGHIJK console: Linux version 5.2.0-2-m68k ([email protected]) (gcc version 8.3.0 (Debian 8.3.0-21)) #1 Debian 5.2.9-2 (2019-08-21) console: Detected Macintosh model: 35 console: Apple Macintosh Quadra 800 console: Built 1 zonelists, mobility grouping on. Total pages: 32448 console: Kernel command line: printk.time=0 console=ttyS0 vga=off [...] console: Calibrating delay loop... 1236.99 BogoMIPS (lpj=6184960) [...] console: NuBus: Scanning NuBus slots. console: Slot 9: Board resource not found! console: SCSI subsystem initialized console: clocksource: Switched to clocksource via1 [...] console: macfb: framebuffer at 0xf9001000, mapped to 0x(ptrval), size 468k console: macfb: mode is 800x600x8, linelength=800 console: Console: switching to colour frame buffer device 100x37 console: fb0: DAFB frame buffer device console: pmac_zilog: 0.6 (Benjamin Herrenschmidt <[email protected]>) console: scc.0: ttyS0 at MMIO 0x50f0c022 (irq = 4, base_baud = 230400) is a Z85c30 ESCC - Serial port console: scc.1: ttyS1 at MMIO 0x50f0c020 (irq = 4, base_baud = 230400) is a Z85c30 ESCC - Serial port console: Non-volatile memory driver v1.3 console: adb: Mac II ADB Driver v1.0 for Unified ADB console: mousedev: PS/2 mouse device common for all mice console: random: fast init done console: Detected ADB keyboard, type <unknown>. console: input: ADB keyboard as /devices/virtual/input/input0 console: input: ADB mouse as /devices/virtual/input/input1 console: rtc-generic rtc-generic: registered as rtc0 console: ledtrig-cpu: registered to indicate activity on CPUs [...] console: rtc-generic rtc-generic: setting system clock to 2019-09-10T16:20:25 UTC (1568132425) console: List of all partitions: console: No filesystem could mount root, tried: JOB TIME : 2.91 s
Message-Id: <[email protected]>
--- tests/acceptance/boot_linux_console.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tests/acceptance/boot_linux_console.py +24 -0
@@ -378,3 +378,27 @@ class BootLinuxConsole(Test): self.vm.launch() console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + + def test_m68k_q800(self): + """ + :avocado: tags=arch:m68k + :avocado: tags=machine:q800 + """ + deb_url = ('http://ftp.ports.debian.org/debian-ports/pool-m68k/main' + '/l/linux/kernel-image-5.2.0-2-m68k-di_5.2.9-2_m68k.udeb') + deb_hash = '0797e05129595f22f3c0142db5e199769a723bf9' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinux-5.2.0-2-m68k') + + self.vm.set_machine('q800') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 vga=off') + self.vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line) + self.vm.launch() + console_pattern = 'Kernel command line: %s' % kernel_command_line + self.wait_for_console_pattern(console_pattern) + console_pattern = 'No filesystem could mount root' + self.wait_for_console_pattern(console_pattern)
Signature · 1 line
2.21.0
Quoted 46 lines · Laurent Vivier
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_
Quoted 8 lines
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-m68kNOTE: DHCP doesn't work but you can assign a static IP address.
Series:
(on x86 host)
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:
Type: series
Message-id: [email protected]
Subject: [PATCH v13 0/9] 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 ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
922e2f1 BootLinuxConsoleTest: Test the Quadra 800 e3bd2d5 hw/m68k: define Macintosh Quadra 800 5f04265 hw/m68k: add a dummy SWIM floppy controller c38a597 hw/m68k: add Nubus macfb video card ada0ee1 hw/m68k: add Nubus support
96c965a hw/m68k: implement ADB bus support for via 5182aca hw/m68k: add VIA support
77f0533 dp8393x: manage big endian bus aea47c6 esp: add pseudo-DMA as used by Macintosh
=== OUTPUT BEGIN ===
1/9 Checking commit aea47c6bfc48 (esp: add pseudo-DMA as used by Macintosh) 2/9 Checking commit 77f053352d12 (dp8393x: manage big endian bus) 3/9 Checking commit 5182acaded8e (hw/m68k: add VIA support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #84:
new file mode 100644
ERROR: code indent should never use tabs
#368: FILE: hw/misc/mac_via.c:280:
+^I^I 16630) / 16630 * 16630);$
ERROR: space prohibited after that '&&' (ctx:WxW)
#450: FILE: hw/misc/mac_via.c:362:
+ if (!(v1s->last_b & VIA1B_vRTCClk) && (s->b & VIA1B_vRTCClk)) {
^total: 2 errors, 1 warnings, 885 lines checked
Patch 3/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/9 Checking commit 96c965aa05fb (hw/m68k: implement ADB bus support for via) 5/9 Checking commit ada0ee13074b (hw/m68k: add Nubus support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #65:
new file mode 100644
total: 0 errors, 1 warnings, 531 lines checked
Patch 5/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/9 Checking commit c38a5975734d (hw/m68k: add Nubus macfb video card)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #76:
new file mode 100644
total: 0 errors, 1 warnings, 597 lines checked
Patch 6/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/9 Checking commit 5f0426584a10 (hw/m68k: add a dummy SWIM floppy controller)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #63:
new file mode 100644
total: 0 errors, 1 warnings, 591 lines checked
Patch 7/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
8/9 Checking commit e3bd2d5737f9 (hw/m68k: define Macintosh Quadra 800)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #71:
new file mode 100644
total: 0 errors, 1 warnings, 530 lines checked
Patch 8/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
9/9 Checking commit 922e2f108ba1 (BootLinuxConsoleTest: Test the Quadra 800) === 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]