From 647d78e4c2d1934774ec76fd1f88ceec1582c985 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 2 Oct 2018 22:54:28 +0200 Subject: [PATCH] Removed a lot of useless #include's from a lot of files and reworked the SCSI #include's a bit to resolve the problem of scsi.h being a mess. --- src/86box.h | 6 +- src/cdrom/cdrom.c | 4 +- src/cdrom/cdrom_image.cc | 4 +- src/cdrom/cdrom_null.c | 4 +- src/config.c | 3 +- src/cpu/cpu.h | 4 +- src/device.c | 3 +- src/disk/hdc_ide.c | 4 +- src/disk/zip.c | 4 +- src/floppy/fdd.c | 6 +- src/floppy/fdd_86f.c | 4 +- src/intel_flash.c | 3 +- src/intel_piix.c | 4 +- src/intel_sio.c | 3 +- src/isamem.c | 18 +- src/machine/m_at_neat.c | 5 +- src/machine/m_at_sis_85c496.c | 3 +- src/mcr.c | 1 - src/memregs.c | 4 +- src/mouse_bus.c | 3 +- src/mouse_ps2.c | 3 +- src/mouse_serial.c | 3 +- src/network/net_3c503.c | 4 +- src/network/net_ne2000.c | 8 +- src/network/net_pcap.c | 3 +- src/network/net_slirp.c | 3 +- src/network/net_wd8003.c | 7 +- src/nvr.c | 7 +- src/nvr_ps2.c | 3 +- src/pc.c | 3 +- src/pci.c | 7 - src/pic.c | 9 +- src/random.c | 7 +- src/rom.c | 4 +- src/scsi/scsi.c | 53 +---- src/scsi/scsi.h | 354 +--------------------------------- src/scsi/scsi_aha154x.c | 5 +- src/scsi/scsi_device.h | 279 ++++++++++++++++++++++++++- src/scsi/scsi_disk.c | 4 +- src/scsi/scsi_ncr5380.c | 27 ++- src/scsi/scsi_x54x.c | 3 +- src/scsi/scsi_x54x.h | 37 +++- src/sio_pc87306.c | 3 +- src/sio_w83877f.c | 3 +- src/sound/snd_adlibgold.c | 3 - src/sound/sound.c | 4 +- src/video/vid_ati18800.c | 3 +- src/video/vid_ati28800.c | 11 +- src/video/vid_ati_mach64.c | 24 ++- src/video/vid_cga.h | 4 +- src/video/vid_cga_comp.c | 7 +- src/video/vid_cl54xx.c | 2 +- src/video/vid_et4000w32.c | 3 +- src/video/vid_icd2061.c | 5 +- src/video/vid_icd2061.h | 3 +- src/video/vid_oak_oti.c | 19 +- src/video/vid_table.c | 6 +- src/video/vid_ti_cf62011.c | 3 +- src/video/video.c | 3 +- src/win/win_cdrom.c | 4 +- src/win/win_new_floppy.c | 4 +- src/win/win_settings.c | 3 +- src/win/win_stbar.c | 3 +- 63 files changed, 444 insertions(+), 599 deletions(-) diff --git a/src/86box.h b/src/86box.h index 7846be212..4c60598bc 100644 --- a/src/86box.h +++ b/src/86box.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)86box.h 1.0.24 2018/08/04 + * Version: @(#)86box.h 1.0.25 2018/10/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -112,6 +112,10 @@ extern int network_card; /* (C) net interface num */ extern char network_host[512]; /* (C) host network intf */ +extern int is_pentium; /* TODO: Move back to cpu/cpu.h when it's figured out, + how to remove that hack from the ET4000/W32p. */ + + #ifdef ENABLE_LOG_TOGGLES extern int buslogic_do_log; extern int cdrom_do_log; diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index c24f92aa0..41b6b0954 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.49 2018/09/22 + * Version: @(#)cdrom.c 1.0.50 2018/10/02 * * Author: Miran Grca, * @@ -28,7 +28,7 @@ #include "../timer.h" #include "../device.h" #include "../piix.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../nvr.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" diff --git a/src/cdrom/cdrom_image.cc b/src/cdrom/cdrom_image.cc index c1a301ba6..230fd6e4a 100644 --- a/src/cdrom/cdrom_image.cc +++ b/src/cdrom/cdrom_image.cc @@ -8,7 +8,7 @@ * * CD-ROM image support. * - * Version: @(#)cdrom_image.cc 1.0.0 2018/03/29 + * Version: @(#)cdrom_image.cc 1.0.1 2018/10/02 * * Author: RichardG867, * Miran Grca, @@ -29,7 +29,7 @@ #include #include "../config.h" #include "../plat.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "cdrom_dosbox.h" #include "cdrom.h" #include "cdrom_image.h" diff --git a/src/cdrom/cdrom_null.c b/src/cdrom/cdrom_null.c index 15b2c937f..da5e0db5e 100644 --- a/src/cdrom/cdrom_null.c +++ b/src/cdrom/cdrom_null.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM null interface for unmounted * guest CD-ROM drives. * - * Version: @(#)cdrom_null.c 1.0.7 2018/03/26 + * Version: @(#)cdrom_null.c 1.0.8 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,7 @@ #include #include #include "../86box.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "cdrom.h" diff --git a/src/config.c b/src/config.c index 78929e1dc..6cf46f62e 100644 --- a/src/config.c +++ b/src/config.c @@ -8,7 +8,7 @@ * * Configuration file handler. * - * Version: @(#)config.c 1.0.54 2018/09/19 + * Version: @(#)config.c 1.0.55 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -51,6 +51,7 @@ #include "mouse.h" #include "network/network.h" #include "scsi/scsi.h" +#include "scsi/scsi_device.h" #include "cdrom/cdrom.h" #include "disk/zip.h" #include "sound/sound.h" diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index b4efb8a3c..a5845889b 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -8,7 +8,7 @@ * * CPU type handler. * - * Version: @(#)cpu.h 1.0.11 2018/03/28 + * Version: @(#)cpu.h 1.0.12 2018/10/02 * * Authors: Sarah Walker, * leilei, @@ -316,7 +316,7 @@ extern int cpu_cyrix_alignment; /*Cyrix 5x86/6x86 only has data misalignment penalties when crossing 8-byte boundaries*/ extern int is8086, is286, is386, is486; -extern int is_rapidcad, is_pentium; +extern int is_rapidcad; extern int hasfpu; extern int cpu_hasrdtsc; extern int cpu_hasMSR; diff --git a/src/device.c b/src/device.c index 86ac96336..c2b508399 100644 --- a/src/device.c +++ b/src/device.c @@ -9,7 +9,7 @@ * Implementation of the generic device interface to handle * all devices attached to the emulator. * - * Version: @(#)device.c 1.0.16 2018/09/06 + * Version: @(#)device.c 1.0.17 2018/10/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,7 +45,6 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "cpu/cpu.h" #include "config.h" #include "device.h" #include "machine/machine.h" diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index dee6395aa..2ba635c31 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -9,7 +9,7 @@ * Implementation of the IDE emulation for hard disks and ATAPI * CD-ROM devices. * - * Version: @(#)hdc_ide.c 1.0.48 2018/09/15 + * Version: @(#)hdc_ide.c 1.0.49 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -38,7 +38,7 @@ #include "../rom.h" #include "../timer.h" #include "../device.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../cdrom/cdrom.h" #include "../plat.h" #include "../ui.h" diff --git a/src/disk/zip.c b/src/disk/zip.c index f2ec8497f..aabd79634 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -9,7 +9,7 @@ * Implementation of the Iomega ZIP drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)zip.c 1.0.23 2018/09/13 + * Version: @(#)zip.c 1.0.24 2018/10/02 * * Author: Miran Grca, * @@ -27,7 +27,7 @@ #include "../timer.h" #include "../device.h" #include "../piix.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../nvr.h" #include "../plat.h" #include "../ui.h" diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index f72deda33..4d8846662 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -8,7 +8,7 @@ * * Implementation of the floppy drive emulation. * - * Version: @(#)fdd.c 1.0.10 2018/08/12 + * Version: @(#)fdd.c 1.0.11 2018/10/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,10 +43,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../machine/machine.h" -#include "../mem.h" -#include "../rom.h" -#include "../config.h" #include "../timer.h" #include "../plat.h" #include "../ui.h" diff --git a/src/floppy/fdd_86f.c b/src/floppy/fdd_86f.c index fc8c969ca..4822cc912 100644 --- a/src/floppy/fdd_86f.c +++ b/src/floppy/fdd_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)fdd_86f.c 1.0.14 2018/09/15 + * Version: @(#)fdd_86f.c 1.0.15 2018/10/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,8 +45,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../config.h" -#include "../device.h" #include "../dma.h" #include "../nvr.h" #include "../random.h" diff --git a/src/intel_flash.c b/src/intel_flash.c index a619212ac..371d91ed8 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 1 Mbit 8-bit flash devices. * - * Version: @(#)intel_flash.c 1.0.16 2018/04/29 + * Version: @(#)intel_flash.c 1.0.17 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "86box.h" -#include "cpu/cpu.h" #include "device.h" #include "mem.h" #include "machine/machine.h" diff --git a/src/intel_piix.c b/src/intel_piix.c index 43f8dd17b..41f44b029 100644 --- a/src/intel_piix.c +++ b/src/intel_piix.c @@ -10,7 +10,7 @@ * word 0 - base address * word 1 - bits 1-15 = byte count, bit 31 = end of transfer * - * Version: @(#)intel_piix.c 1.0.17 2018/06/02 + * Version: @(#)intel_piix.c 1.0.18 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -26,7 +26,7 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "scsi/scsi.h" +#include "scsi/scsi_device.h" #include "cdrom/cdrom.h" #include "dma.h" #include "io.h" diff --git a/src/intel_sio.c b/src/intel_sio.c index 69c35fa78..5c098d296 100644 --- a/src/intel_sio.c +++ b/src/intel_sio.c @@ -6,7 +6,7 @@ * * Emulation of Intel System I/O PCI chip. * - * Version: @(#)intel_sio.c 1.0.8 2018/04/26 + * Version: @(#)intel_sio.c 1.0.9 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -20,7 +20,6 @@ #include #include #include "device.h" -#include "cpu/cpu.h" #include "io.h" #include "dma.h" #include "mem.h" diff --git a/src/isamem.c b/src/isamem.c index 3139cb199..50a4c1e49 100644 --- a/src/isamem.c +++ b/src/isamem.c @@ -32,7 +32,7 @@ * TODO: The EV159 is supposed to support 16b EMS transfers, but the * EMM.sys driver for it doesn't seem to want to do that.. * - * Version: @(#)isamem.c 1.0.5 2018/09/06 + * Version: @(#)isamem.c 1.0.6 2018/10/02 * * Author: Fred N. van Kempen, * @@ -74,7 +74,6 @@ #include #include #include "86box.h" -#include "cpu/cpu.h" #include "machine/machine.h" #include "io.h" #include "mem.h" @@ -484,18 +483,9 @@ dev->frame_addr = 0xE0000; isamem_log(")\n"); /* Force (back to) 8-bit bus if needed. */ - if (dev->flags & FLAG_WIDE) { - if (AT) { - if (! cpu_16bitbus) - isamem_log("ISAMEM: *WARNING* this board will slow down your PC!\n"); - } else { - isamem_log("ISAMEM: not AT+ system, forcing 8-bit mode!\n"); - dev->flags &= ~FLAG_WIDE; - } - } else { - if (AT) { - isamem_log("ISAMEM: *WARNING* this board will slow down your PC!\n"); - } + if ((!AT) && (dev->flags & FLAG_WIDE)) { + isamem_log("ISAMEM: not AT+ system, forcing 8-bit mode!\n"); + dev->flags &= ~FLAG_WIDE; } /* Allocate and initialize our RAM. */ diff --git a/src/machine/m_at_neat.c b/src/machine/m_at_neat.c index 0de13c233..88b354c95 100644 --- a/src/machine/m_at_neat.c +++ b/src/machine/m_at_neat.c @@ -13,7 +13,7 @@ * 8MB of DRAM chips', because it works fine with bus-based * memory expansion. * - * Version: @(#)m_at_neat.c 1.0.3 2018/09/12 + * Version: @(#)m_at_neat.c 1.0.4 2018/10/02 * * Author: Fred N. van Kempen, * @@ -57,15 +57,12 @@ #include #include "../86box.h" #include "../device.h" -#include "../cpu/cpu.h" -#include "../cpu/x86.h" #include "../floppy/fdd.h" #include "../floppy/fdc.h" #include "../keyboard.h" #include "../io.h" #include "../mem.h" #include "../nmi.h" -#include "../rom.h" #include "machine.h" #define NEAT_DEBUG 0 diff --git a/src/machine/m_at_sis_85c496.c b/src/machine/m_at_sis_85c496.c index ca8ffd732..be457d328 100644 --- a/src/machine/m_at_sis_85c496.c +++ b/src/machine/m_at_sis_85c496.c @@ -8,7 +8,7 @@ * * Implementation of the SiS 85c496/85c497 chip. * - * Version: @(#)m_at_sis_85c496.c 1.0.1 2018/04/26 + * Version: @(#)m_at_sis_85c496.c 1.0.2 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../cpu/cpu.h" #include "../device.h" #include "../keyboard.h" #include "../io.h" diff --git a/src/mcr.c b/src/mcr.c index ddd2dd784..86bddcbaf 100644 --- a/src/mcr.c +++ b/src/mcr.c @@ -6,7 +6,6 @@ #include #include #include "86box.h" -#include "cpu/cpu.h" #include "mem.h" diff --git a/src/memregs.c b/src/memregs.c index f1aae4ac8..52cd8b702 100644 --- a/src/memregs.c +++ b/src/memregs.c @@ -9,18 +9,16 @@ * Emulation of the memory I/O scratch registers on ports 0xE1 * and 0xE2, used by just about any emulated machine. * - * Version: @(#)memregs.c 1.0.6 2018/04/29 + * Version: @(#)memregs.c 1.0.7 2018/10/02 * * Author: Miran Grca, * * Copyright 2016-2018 Miran Grca. */ -#include #include #include #include #include -#define HAVE_STDARG_H #include "86box.h" #include "io.h" #include "memregs.h" diff --git a/src/mouse_bus.c b/src/mouse_bus.c index e60a7063b..3975a0f58 100644 --- a/src/mouse_bus.c +++ b/src/mouse_bus.c @@ -51,7 +51,7 @@ * Microsoft Windows NT 3.1 * Microsoft Windows 98 SE * - * Version: @(#)mouse_bus.c 1.0.0 2018/05/23 + * Version: @(#)mouse_bus.c 1.0.1 2018/10/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -69,7 +69,6 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "config.h" #include "io.h" #include "pic.h" #include "timer.h" diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index 9775a2cc6..42bdf7194 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -8,7 +8,7 @@ * * Implementation of PS/2 series Mouse devices. * - * Version: @(#)mouse_ps2.c 1.0.10 2018/09/13 + * Version: @(#)mouse_ps2.c 1.0.11 2018/10/02 * * Authors: Fred N. van Kempen, */ @@ -20,7 +20,6 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "config.h" #include "device.h" #include "keyboard.h" #include "mouse.h" diff --git a/src/mouse_serial.c b/src/mouse_serial.c index cb338a0c5..f58b834cf 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -10,7 +10,7 @@ * * TODO: Add the Genius Serial Mouse. * - * Version: @(#)mouse_serial.c 1.0.23 2018/04/29 + * Version: @(#)mouse_serial.c 1.0.24 2018/10/02 * * Author: Fred N. van Kempen, */ @@ -22,7 +22,6 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "config.h" #include "device.h" #include "timer.h" #include "serial.h" diff --git a/src/network/net_3c503.c b/src/network/net_3c503.c index 65bea5af7..61fd1f96c 100644 --- a/src/network/net_3c503.c +++ b/src/network/net_3c503.c @@ -8,7 +8,7 @@ * Implementation of the following network controllers: * - 3Com Etherlink II 3c503 (ISA 8-bit). * - * Version: @(#)net_3c503.c 1.0.0 2018/06/08 + * Version: @(#)net_3c503.c 1.0.1 2018/10/02 * * Based on @(#)3c503.cpp Carl (MAME) * @@ -49,8 +49,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../config.h" -#include "../machine/machine.h" #include "../io.h" #include "../dma.h" #include "../pic.h" diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index 1f60d45ad..c5c049443 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -13,7 +13,7 @@ * - Realtek RTL8019AS (ISA 16-bit, PnP); * - Realtek RTL8029AS (PCI). * - * Version: @(#)net_ne2000.c 1.0.8 2018/08/11 + * Version: @(#)net_ne2000.c 1.0.9 2018/10/02 * * Based on @(#)ne2k.cc v1.56.2.1 2004/02/02 22:37:22 cbothamy * @@ -53,8 +53,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../config.h" -#include "../machine/machine.h" #include "../io.h" #include "../mem.h" #include "../rom.h" @@ -166,7 +164,7 @@ nelog(int lvl, const char *fmt, ...) static void nic_interrupt(nic_t *dev, int set) { - if (PCI && dev->is_pci) { + if (dev->is_pci) { if (set) pci_set_irq(dev->card, PCI_INTA); else @@ -1775,7 +1773,7 @@ nic_update_bios(nic_t *dev) if (! dev->has_bios) return; - if (PCI && dev->is_pci) + if (dev->is_pci) reg_bios_enable = dev->pci_bar[1].addr_regs[0] & 0x01; /* PCI BIOS stuff, just enable_disable. */ diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 78cf72f91..ea19e97a1 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -8,7 +8,7 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.4 2018/04/29 + * Version: @(#)net_pcap.c 1.0.5 2018/10/02 * * Author: Fred N. van Kempen, * @@ -52,7 +52,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../config.h" #include "../device.h" #include "../plat.h" #include "../plat_dynld.h" diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index 3285702f4..41ca07b70 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -8,7 +8,7 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.3 2018/04/29 + * Version: @(#)net_slirp.c 1.0.4 2018/10/02 * * Author: Fred N. van Kempen, * @@ -54,7 +54,6 @@ #include "slirp/slirp.h" #include "slirp/queue.h" #include "../86box.h" -#include "../config.h" #include "../device.h" #include "../plat.h" #include "network.h" diff --git a/src/network/net_wd8003.c b/src/network/net_wd8003.c index 8bccbd78d..0cc0ae533 100644 --- a/src/network/net_wd8003.c +++ b/src/network/net_wd8003.c @@ -11,7 +11,7 @@ * - SMC/WD 8013EBT (ISA 16-bit); * - SMC/WD 8013EP/A (MCA). * - * Version: @(#)net_wd8003.c 1.0.0 2018/07/19 + * Version: @(#)net_wd8003.c 1.0.1 2018/10/02 * * Authors: Fred N. van Kempen, * TheCollector1995, @@ -49,9 +49,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../cpu/cpu.h" -#include "../config.h" -#include "../machine/machine.h" #include "../io.h" #include "../mem.h" #include "../rom.h" @@ -1008,7 +1005,7 @@ read_cr(wd_t *dev) static void write_cr(wd_t *dev, uint8_t val) { - wdlog(3, "%s: wrote 0x%02x to CR, CS=%08x, PC=%08x\n", dev->name, val, CS, cpu_state.pc); + wdlog(3, "%s: wrote 0x%02x to CR\n", dev->name, val); /* Validate remote-DMA */ if ((val & 0x38) == 0x00) { diff --git a/src/nvr.c b/src/nvr.c index e76a255e0..42a9affe1 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -8,7 +8,7 @@ * * Implement a generic NVRAM/CMOS/RTC device. * - * Version: @(#)nvr.c 1.0.13 2018/09/15 + * Version: @(#)nvr.c 1.0.14 2018/10/02 * * Authors: Fred N. van Kempen, , * David Hrdlička, @@ -55,13 +55,8 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "device.h" #include "machine/machine.h" -#include "machine/m_xt_t1000.h" #include "mem.h" -#include "pic.h" -#include "pit.h" -#include "rom.h" #include "timer.h" #include "plat.h" #include "nvr.h" diff --git a/src/nvr_ps2.c b/src/nvr_ps2.c index df1a05430..e9823ac0b 100644 --- a/src/nvr_ps2.c +++ b/src/nvr_ps2.c @@ -8,7 +8,7 @@ * * Handling of the PS/2 series CMOS devices. * - * Version: @(#)nvr_ps2.c 1.0.9 2018/09/15 + * Version: @(#)nvr_ps2.c 1.0.10 2018/10/02 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -40,7 +40,6 @@ #include #include #include "86box.h" -#include "cpu/cpu.h" #include "machine/machine.h" #include "device.h" #include "io.h" diff --git a/src/pc.c b/src/pc.c index 3fe00755e..90ff5177e 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.79 2018/09/21 + * Version: @(#)pc.c 1.0.80 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -60,6 +60,7 @@ #include "disk/hdc.h" #include "disk/hdc_ide.h" #include "scsi/scsi.h" +#include "scsi/scsi_device.h" #include "cdrom/cdrom.h" #include "disk/zip.h" #include "scsi/scsi_disk.h" diff --git a/src/pci.c b/src/pci.c index f3b7a9ce1..223dd2107 100644 --- a/src/pci.c +++ b/src/pci.c @@ -14,13 +14,6 @@ #include "pci.h" #include "piix.h" #include "keyboard.h" -#if 0 -#include "scsi/scsi.h" -#include "cdrom/cdrom.h" -#include "disk/hdc.h" -#include "disk/hdc_ide.h" -#include "disk/zip.h" -#endif static uint64_t pci_irq_hold[16]; diff --git a/src/pic.c b/src/pic.c index fb107da8b..b7149d898 100644 --- a/src/pic.c +++ b/src/pic.c @@ -8,7 +8,7 @@ * * Implementation of the Intel PIC chip emulation. * - * Version: @(#)pic.c 1.0.0 2018/04/29 + * Version: @(#)pic.c 1.0.1 2018/10/02 * * Author: Miran Grca, * @@ -21,7 +21,6 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "cpu/cpu.h" #include "machine/machine.h" #include "io.h" #include "pci.h" @@ -351,14 +350,14 @@ uint8_t pic2_read(uint16_t addr, void *priv) { if (addr&1) { - pic_log("Read PIC2 mask %02X %04X:%08X\n", pic2.mask, CS, cpu_state.pc); + pic_log("Read PIC2 mask %02X\n", pic2.mask); return pic2.mask; } if (pic2.read) { - pic_log("Read PIC2 ins %02X %04X:%08X\n", pic2.ins, CS, cpu_state.pc); + pic_log("Read PIC2 ins %02X\n", pic2.ins); return pic2.ins; } - pic_log("Read PIC2 pend %02X %04X:%08X\n", pic2.pend, CS, cpu_state.pc); + pic_log("Read PIC2 pend %02X\n", pic2.pend); return pic2.pend; } diff --git a/src/random.c b/src/random.c index 9d7f1b229..3d1d229a2 100644 --- a/src/random.c +++ b/src/random.c @@ -9,16 +9,13 @@ * A better random number generation, used for floppy weak bits * and network MAC address generation. * - * Version: @(#)random.c 1.0.3 2017/09/24 + * Version: @(#)random.c 1.0.4 2018/10/02 * * Author: Miran Grca, - * Copyright 2016,2017 Miran Grca. + * Copyright 2016-2018 Miran Grca. */ -#include #include #include -#include -#include #include "random.h" diff --git a/src/rom.c b/src/rom.c index 1f31b8bf9..a4db53873 100644 --- a/src/rom.c +++ b/src/rom.c @@ -13,7 +13,7 @@ * - c386sx16 BIOS fails checksum * - the loadfont() calls should be done elsewhere * - * Version: @(#)rom.c 1.0.39 2018/09/12 + * Version: @(#)rom.c 1.0.40 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -31,8 +31,6 @@ #include #define HAVE_STDARG_H #include "86box.h" -#include "config.h" -#include "cpu/cpu.h" #include "mem.h" #include "rom.h" #include "video/video.h" /* for loadfont() */ diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index 8fc535dc3..d0dcd34f3 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -8,7 +8,7 @@ * * Handling of the SCSI controllers. * - * Version: @(#)scsi.c 1.0.20 2018/06/02 + * Version: @(#)scsi.c 1.0.21 2018/10/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -25,18 +25,15 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../mem.h" -#include "../rom.h" -#include "../timer.h" #include "../device.h" #include "../disk/hdc.h" #include "../disk/hdd.h" #include "../plat.h" #include "scsi.h" +#include "scsi_device.h" #include "../cdrom/cdrom.h" #include "../disk/zip.h" #include "scsi_disk.h" -#include "scsi_device.h" #include "scsi_aha154x.h" #include "scsi_buslogic.h" #include "scsi_ncr5380.h" @@ -44,7 +41,6 @@ #ifdef WALTJE # include "scsi_wd33c93.h" #endif -#include "scsi_x54x.h" scsi_device_t SCSIDevices[SCSI_ID_MAX]; @@ -55,8 +51,6 @@ int scsi_card_current = 0; int scsi_card_last = 0; uint32_t SCSI_BufferLength; -static volatile -mutex_t *scsiMutex; typedef const struct { @@ -158,15 +152,6 @@ int scsi_card_get_from_internal_name(char *s) } -void scsi_mutex(uint8_t start) -{ - if (start) - scsiMutex = thread_create_mutex(L"86Box.SCSIMutex"); - else - thread_close_mutex((mutex_t *) scsiMutex); -} - - void scsi_card_init(void) { int i; @@ -199,37 +184,3 @@ void scsi_card_init(void) scsi_card_last = scsi_card_current; } - - -/* Initialization function for the SCSI layer */ -void SCSIReset(uint8_t id) -{ - uint8_t cdrom_id = scsi_cdrom_drives[id]; - uint8_t zip_id = scsi_zip_drives[id]; - uint8_t hdc_id = scsi_disks[id]; - - if (hdc_id != 0xff) - SCSIDevices[id].LunType = SCSI_DISK; - else if (cdrom_id != 0xff) - SCSIDevices[id].LunType = SCSI_CDROM; - else if (zip_id != 0xff) - SCSIDevices[id].LunType = SCSI_ZIP; - else - SCSIDevices[id].LunType = SCSI_NONE; - - scsi_device_reset(id); - - if (SCSIDevices[id].CmdBuffer) - free(SCSIDevices[id].CmdBuffer); - SCSIDevices[id].CmdBuffer = NULL; -} - - -void -scsi_mutex_wait(uint8_t wait) -{ - if (wait) - thread_wait_mutex((mutex_t *) scsiMutex); - else - thread_release_mutex((mutex_t *) scsiMutex); -} diff --git a/src/scsi/scsi.h b/src/scsi/scsi.h index e45209538..011d2569a 100644 --- a/src/scsi/scsi.h +++ b/src/scsi/scsi.h @@ -8,7 +8,7 @@ * * SCSI controller handler header. * - * Version: @(#)scsi_h 1.0.18 2018/09/12 + * Version: @(#)scsi_h 1.0.19 2018/10/02 * * Authors: TheCollector1995, * Miran Grca, @@ -21,354 +21,16 @@ #ifndef EMU_SCSI_H #define EMU_SCSI_H - -#ifdef WALTJE -#define SCSI_TIME (50 * (1 << TIMER_SHIFT)) -#else -#define SCSI_TIME (5 * 100 * (1 << TIMER_SHIFT)) -#endif - - -/* Configuration. */ -#define SCSI_ID_MAX 16 /* 16 on wide buses */ -#define SCSI_LUN_MAX 8 /* always 8 */ - - -/* SCSI commands. */ -#define GPCMD_TEST_UNIT_READY 0x00 -#define GPCMD_REZERO_UNIT 0x01 -#define GPCMD_REQUEST_SENSE 0x03 -#define GPCMD_FORMAT_UNIT 0x04 -#define GPCMD_IOMEGA_SENSE 0x06 -#define GPCMD_READ_6 0x08 -#define GPCMD_WRITE_6 0x0a -#define GPCMD_SEEK_6 0x0b -#define GPCMD_IOMEGA_SET_PROTECTION_MODE 0x0c -#define GPCMD_IOMEGA_EJECT 0x0d /* ATAPI only? */ -#define GPCMD_INQUIRY 0x12 -#define GPCMD_VERIFY_6 0x13 -#define GPCMD_MODE_SELECT_6 0x15 -#define GPCMD_SCSI_RESERVE 0x16 -#define GPCMD_SCSI_RELEASE 0x17 -#define GPCMD_MODE_SENSE_6 0x1a -#define GPCMD_START_STOP_UNIT 0x1b -#define GPCMD_SEND_DIAGNOSTIC 0x1d -#define GPCMD_PREVENT_REMOVAL 0x1e -#define GPCMD_READ_FORMAT_CAPACITIES 0x23 -#define GPCMD_READ_CDROM_CAPACITY 0x25 -#define GPCMD_READ_10 0x28 -#define GPCMD_WRITE_10 0x2a -#define GPCMD_SEEK_10 0x2b -#define GPCMD_WRITE_AND_VERIFY_10 0x2e -#define GPCMD_VERIFY_10 0x2f -#define GPCMD_READ_BUFFER 0x3c -#define GPCMD_WRITE_SAME_10 0x41 -#define GPCMD_READ_SUBCHANNEL 0x42 -#define GPCMD_READ_TOC_PMA_ATIP 0x43 -#define GPCMD_READ_HEADER 0x44 -#define GPCMD_PLAY_AUDIO_10 0x45 -#define GPCMD_GET_CONFIGURATION 0x46 -#define GPCMD_PLAY_AUDIO_MSF 0x47 -#define GPCMD_PLAY_AUDIO_TRACK_INDEX 0x48 -#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a -#define GPCMD_PAUSE_RESUME 0x4b -#define GPCMD_STOP_PLAY_SCAN 0x4e -#define GPCMD_READ_DISC_INFORMATION 0x51 -#define GPCMD_READ_TRACK_INFORMATION 0x52 -#define GPCMD_MODE_SELECT_10 0x55 -#define GPCMD_MODE_SENSE_10 0x5a -#define GPCMD_PLAY_AUDIO_12 0xa5 -#define GPCMD_READ_12 0xa8 -#define GPCMD_WRITE_12 0xaa -#define GPCMD_READ_DVD_STRUCTURE 0xad /* For reading. */ -#define GPCMD_WRITE_AND_VERIFY_12 0xae -#define GPCMD_VERIFY_12 0xaf -#define GPCMD_PLAY_CD_OLD 0xb4 -#define GPCMD_READ_CD_OLD 0xb8 -#define GPCMD_READ_CD_MSF 0xb9 -#define GPCMD_SCAN 0xba -#define GPCMD_SET_SPEED 0xbb -#define GPCMD_PLAY_CD 0xbc -#define GPCMD_MECHANISM_STATUS 0xbd -#define GPCMD_READ_CD 0xbe -#define GPCMD_SEND_DVD_STRUCTURE 0xbf /* This is for writing only, irrelevant to PCem. */ -#define GPCMD_PAUSE_RESUME_ALT 0xc2 -#define GPCMD_SCAN_ALT 0xcd /* Should be equivalent to 0xba */ -#define GPCMD_SET_SPEED_ALT 0xda /* Should be equivalent to 0xbb */ - -/* Mode page codes for mode sense/set */ -#define GPMODE_R_W_ERROR_PAGE 0x01 -#define GPMODE_CDROM_PAGE 0x0d -#define GPMODE_CDROM_AUDIO_PAGE 0x0e -#define GPMODE_CAPABILITIES_PAGE 0x2a -#define GPMODE_ALL_PAGES 0x3f - -/* Mode page codes for presence */ -#define GPMODEP_R_W_ERROR_PAGE 0x0000000000000002LL -#define GPMODEP_UNK_PAGE_02 0x0000000000000004LL -#define GPMODEP_UNK_PAGE_03 0x0000000000000008LL -#define GPMODEP_UNK_PAGE_04 0x0000000000000010LL -#define GPMODEP_UNK_PAGE_05 0x0000000000000020LL -#define GPMODEP_UNK_PAGE_08 0x0000000000000100LL -#define GPMODEP_CDROM_PAGE 0x0000000000002000LL -#define GPMODEP_CDROM_AUDIO_PAGE 0x0000000000004000LL -#define GPMODEP_CAPABILITIES_PAGE 0x0000040000000000LL -#define GPMODEP_UNK_PAGE_2F 0x0000800000000000LL -#define GPMODEP_UNK_PAGE_30 0x0001000000000000LL -#define GPMODEP_ALL_PAGES 0x8000000000000000LL - -/* SCSI Status Codes */ -#define SCSI_STATUS_OK 0 -#define SCSI_STATUS_CHECK_CONDITION 2 - -/* SCSI Sense Keys */ -#define SENSE_NONE 0 -#define SENSE_NOT_READY 2 -#define SENSE_ILLEGAL_REQUEST 5 -#define SENSE_UNIT_ATTENTION 6 - -/* SCSI Additional Sense Codes */ -#define ASC_AUDIO_PLAY_OPERATION 0x00 -#define ASC_NOT_READY 0x04 -#define ASC_ILLEGAL_OPCODE 0x20 -#define ASC_LBA_OUT_OF_RANGE 0x21 -#define ASC_INV_FIELD_IN_CMD_PACKET 0x24 -#define ASC_INV_LUN 0x25 -#define ASC_INV_FIELD_IN_PARAMETER_LIST 0x26 -#define ASC_WRITE_PROTECTED 0x27 -#define ASC_MEDIUM_MAY_HAVE_CHANGED 0x28 -#define ASC_CAPACITY_DATA_CHANGED 0x2A -#define ASC_INCOMPATIBLE_FORMAT 0x30 -#define ASC_MEDIUM_NOT_PRESENT 0x3a -#define ASC_DATA_PHASE_ERROR 0x4b -#define ASC_ILLEGAL_MODE_FOR_THIS_TRACK 0x64 - -#define ASCQ_UNIT_IN_PROCESS_OF_BECOMING_READY 0x01 -#define ASCQ_INITIALIZING_COMMAND_REQUIRED 0x02 -#define ASCQ_CAPACITY_DATA_CHANGED 0x09 -#define ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS 0x11 -#define ASCQ_AUDIO_PLAY_OPERATION_PAUSED 0x12 -#define ASCQ_AUDIO_PLAY_OPERATION_COMPLETED 0x13 - -/* Tell RISC OS that we have a 4x CD-ROM drive (600kb/sec data, 706kb/sec raw). - Not that it means anything */ -#define CDROM_SPEED 706 /* 0x2C2 */ - -#define BUFFER_SIZE (256*1024) - -#define RW_DELAY (TIMER_USEC * 500) - -/* Some generally useful CD-ROM information */ -#define CD_MINS 75 /* max. minutes per CD */ -#define CD_SECS 60 /* seconds per minute */ -#define CD_FRAMES 75 /* frames per second */ -#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ -#define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE) -#define CD_MAX_SECTORS (CD_MAX_BYTES / 512) - -/* Event notification classes for GET EVENT STATUS NOTIFICATION */ -#define GESN_NO_EVENTS 0 -#define GESN_OPERATIONAL_CHANGE 1 -#define GESN_POWER_MANAGEMENT 2 -#define GESN_EXTERNAL_REQUEST 3 -#define GESN_MEDIA 4 -#define GESN_MULTIPLE_HOSTS 5 -#define GESN_DEVICE_BUSY 6 - -/* Event codes for MEDIA event status notification */ -#define MEC_NO_CHANGE 0 -#define MEC_EJECT_REQUESTED 1 -#define MEC_NEW_MEDIA 2 -#define MEC_MEDIA_REMOVAL 3 /* only for media changers */ -#define MEC_MEDIA_CHANGED 4 /* only for media changers */ -#define MEC_BG_FORMAT_COMPLETED 5 /* MRW or DVD+RW b/g format completed */ -#define MEC_BG_FORMAT_RESTARTED 6 /* MRW or DVD+RW b/g format restarted */ -#define MS_TRAY_OPEN 1 -#define MS_MEDIA_PRESENT 2 - -/* - * The MMC values are not IDE specific and might need to be moved - * to a common header if they are also needed for the SCSI emulation - */ - -/* Profile list from MMC-6 revision 1 table 91 */ -#define MMC_PROFILE_NONE 0x0000 -#define MMC_PROFILE_CD_ROM 0x0008 -#define MMC_PROFILE_CD_R 0x0009 -#define MMC_PROFILE_CD_RW 0x000A -#define MMC_PROFILE_DVD_ROM 0x0010 -#define MMC_PROFILE_DVD_R_SR 0x0011 -#define MMC_PROFILE_DVD_RAM 0x0012 -#define MMC_PROFILE_DVD_RW_RO 0x0013 -#define MMC_PROFILE_DVD_RW_SR 0x0014 -#define MMC_PROFILE_DVD_R_DL_SR 0x0015 -#define MMC_PROFILE_DVD_R_DL_JR 0x0016 -#define MMC_PROFILE_DVD_RW_DL 0x0017 -#define MMC_PROFILE_DVD_DDR 0x0018 -#define MMC_PROFILE_DVD_PLUS_RW 0x001A -#define MMC_PROFILE_DVD_PLUS_R 0x001B -#define MMC_PROFILE_DVD_PLUS_RW_DL 0x002A -#define MMC_PROFILE_DVD_PLUS_R_DL 0x002B -#define MMC_PROFILE_BD_ROM 0x0040 -#define MMC_PROFILE_BD_R_SRM 0x0041 -#define MMC_PROFILE_BD_R_RRM 0x0042 -#define MMC_PROFILE_BD_RE 0x0043 -#define MMC_PROFILE_HDDVD_ROM 0x0050 -#define MMC_PROFILE_HDDVD_R 0x0051 -#define MMC_PROFILE_HDDVD_RAM 0x0052 -#define MMC_PROFILE_HDDVD_RW 0x0053 -#define MMC_PROFILE_HDDVD_R_DL 0x0058 -#define MMC_PROFILE_HDDVD_RW_DL 0x005A -#define MMC_PROFILE_INVALID 0xFFFF - -#define SCSI_ONLY 32 -#define ATAPI_ONLY 16 -#define IMPLEMENTED 8 -#define NONDATA 4 -#define CHECK_READY 2 -#define ALLOW_UA 1 - - -extern uint8_t SCSICommandTable[0x100]; -extern uint8_t mode_sense_pages[0x40]; -extern int readcdmode; - -/* Mode sense/select stuff. */ -extern uint8_t mode_pages_in[256][256]; -extern uint8_t page_flags[256]; -extern uint8_t prefix_len; -extern uint8_t page_current; -#define PAGE_CHANGEABLE 1 -#define PAGE_CHANGED 2 - -struct _scsisense_ { - uint8_t SenseBuffer[18]; - uint8_t SenseLength; - uint8_t UnitAttention; - uint8_t SenseKey; - uint8_t Asc; - uint8_t Ascq; -} SCSISense; - -extern int cd_status; -extern int prev_status; - -enum { - SCSI_NONE = 0, - SCSI_DISK, - SCSI_CDROM, - SCSI_ZIP -}; - -#define MSFtoLBA(m,s,f) ((((m*60)+s)*75)+f) - -#define MSG_COMMAND_COMPLETE 0x00 - -#define BUS_DBP 0x01 -#define BUS_SEL 0x02 -#define BUS_IO 0x04 -#define BUS_CD 0x08 -#define BUS_MSG 0x10 -#define BUS_REQ 0x20 -#define BUS_BSY 0x40 -#define BUS_RST 0x80 -#define BUS_ACK 0x200 -#define BUS_ATN 0x200 -#define BUS_ARB 0x8000 -#define BUS_SETDATA(val) ((uint32_t)val << 16) -#define BUS_GETDATA(val) ((val >> 16) & 0xff) -#define BUS_DATAMASK 0xff0000 - -#define BUS_IDLE (1 << 31) - -#define SCSI_PHASE_DATA_OUT 0 -#define SCSI_PHASE_DATA_IN BUS_IO -#define SCSI_PHASE_COMMAND BUS_CD -#define SCSI_PHASE_STATUS (BUS_CD | BUS_IO) -#define SCSI_PHASE_MESSAGE_OUT (BUS_MSG | BUS_CD) -#define SCSI_PHASE_MESSAGE_IN (BUS_MSG | BUS_CD | BUS_IO) - -typedef struct { - uint8_t *CmdBuffer; - int LunType; - int32_t BufferLength; - uint8_t Status; - uint8_t Phase; -} scsi_device_t; - - -extern scsi_device_t SCSIDevices[SCSI_ID_MAX]; - -extern void SCSIReset(uint8_t id); - -extern int cdrom_add_error_and_subchannel(uint8_t *b, int real_sector_type); -extern int cdrom_LBAtoMSF_accurate(void); - -extern int mode_select_init(uint8_t command, uint16_t pl_length, uint8_t do_save); -extern int mode_select_terminate(int force); -extern int mode_select_write(uint8_t val); - extern int scsi_card_current; -extern int scsi_card_available(int card); -extern char *scsi_card_getname(int card); +extern int scsi_card_available(int card); +extern char *scsi_card_getname(int card); #ifdef EMU_DEVICE_H -extern const device_t *scsi_card_getdevice(int card); +extern const device_t *scsi_card_getdevice(int card); #endif -extern int scsi_card_has_config(int card); -extern char *scsi_card_get_internal_name(int card); -extern int scsi_card_get_from_internal_name(char *s); -extern void scsi_mutex(uint8_t start); -extern void scsi_card_init(void); - - -#pragma pack(push,1) -typedef struct { - uint8_t hi; - uint8_t mid; - uint8_t lo; -} addr24; -#pragma pack(pop) - -#define ADDR_TO_U32(x) (((x).hi<<16)|((x).mid<<8)|((x).lo&0xFF)) -#define U32_TO_ADDR(a,x) do {(a).hi=(x)>>16;(a).mid=(x)>>8;(a).lo=(x)&0xFF;}while(0) - - -/* - * - * Scatter/Gather Segment List Definitions - * - * Adapter limits - */ -#define MAX_SG_DESCRIPTORS 32 /* Always make the array 32 elements long, if less are used, that's not an issue. */ - -#pragma pack(push,1) -typedef struct { - uint32_t Segment; - uint32_t SegmentPointer; -} SGE32; -#pragma pack(pop) - -#pragma pack(push,1) -typedef struct { - addr24 Segment; - addr24 SegmentPointer; -} SGE; -#pragma pack(pop) - -#pragma pack(push,1) -typedef struct { - uint8_t pages[0x40][0x40]; -} mode_sense_pages_t; -#pragma pack(pop) - - -#define MODE_SELECT_PHASE_IDLE 0 -#define MODE_SELECT_PHASE_HEADER 1 -#define MODE_SELECT_PHASE_BLOCK_DESC 2 -#define MODE_SELECT_PHASE_PAGE_HEADER 3 -#define MODE_SELECT_PHASE_PAGE 4 +extern int scsi_card_has_config(int card); +extern char *scsi_card_get_internal_name(int card); +extern int scsi_card_get_from_internal_name(char *s); +extern void scsi_card_init(void); #endif /*EMU_SCSI_H*/ - -extern void scsi_mutex_wait(uint8_t wait); diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index 59e48129c..a314d4672 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -10,7 +10,7 @@ * made by Adaptec, Inc. These controllers were designed for * the ISA bus. * - * Version: @(#)scsi_aha154x.c 1.0.42 2018/06/12 + * Version: @(#)scsi_aha154x.c 1.0.43 2018/10/02 * * Authors: Fred N. van Kempen, * Original Buslogic version by SA1988 and Miran Grca. @@ -36,7 +36,7 @@ #include "../pic.h" #include "../timer.h" #include "../plat.h" -#include "../cpu/cpu.h" +// #include "../cpu/cpu.h" #include "scsi.h" #include "scsi_aha154x.h" #include "scsi_x54x.h" @@ -92,7 +92,6 @@ aha_log(const char *fmt, ...) va_list ap; if (aha_do_log) { - pclog("In %s mode: ",(msw&1)?((eflags&VM_FLAG)?"V86":"protected"):"real"); va_start(ap, fmt); pclog_ex(fmt, ap); va_end(ap); diff --git a/src/scsi/scsi_device.h b/src/scsi/scsi_device.h index d0da9a19b..88401cda1 100644 --- a/src/scsi/scsi_device.h +++ b/src/scsi/scsi_device.h @@ -8,7 +8,7 @@ * * Definitions for the generic SCSI device command handler. * - * Version: @(#)scsi_device.h 1.0.8 2018/06/12 + * Version: @(#)scsi_device.h 1.0.9 2018/10/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -16,6 +16,247 @@ #ifndef SCSI_DEVICE_H # define SCSI_DEVICE_H + +/* Configuration. */ +#define SCSI_ID_MAX 16 /* 16 on wide buses */ +#define SCSI_LUN_MAX 8 /* always 8 */ + +#ifdef WALTJE +#define SCSI_TIME (50 * (1 << TIMER_SHIFT)) +#else +#define SCSI_TIME (5 * 100 * (1 << TIMER_SHIFT)) +#endif + + +/* SCSI commands. */ +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_REZERO_UNIT 0x01 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_IOMEGA_SENSE 0x06 +#define GPCMD_READ_6 0x08 +#define GPCMD_WRITE_6 0x0a +#define GPCMD_SEEK_6 0x0b +#define GPCMD_IOMEGA_SET_PROTECTION_MODE 0x0c +#define GPCMD_IOMEGA_EJECT 0x0d /* ATAPI only? */ +#define GPCMD_INQUIRY 0x12 +#define GPCMD_VERIFY_6 0x13 +#define GPCMD_MODE_SELECT_6 0x15 +#define GPCMD_SCSI_RESERVE 0x16 +#define GPCMD_SCSI_RELEASE 0x17 +#define GPCMD_MODE_SENSE_6 0x1a +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_SEND_DIAGNOSTIC 0x1d +#define GPCMD_PREVENT_REMOVAL 0x1e +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_CDROM_CAPACITY 0x25 +#define GPCMD_READ_10 0x28 +#define GPCMD_WRITE_10 0x2a +#define GPCMD_SEEK_10 0x2b +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_READ_BUFFER 0x3c +#define GPCMD_WRITE_SAME_10 0x41 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TRACK_INDEX 0x48 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_READ_DISC_INFORMATION 0x51 +#define GPCMD_READ_TRACK_INFORMATION 0x52 +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PLAY_AUDIO_12 0xa5 +#define GPCMD_READ_12 0xa8 +#define GPCMD_WRITE_12 0xaa +#define GPCMD_READ_DVD_STRUCTURE 0xad /* For reading. */ +#define GPCMD_WRITE_AND_VERIFY_12 0xae +#define GPCMD_VERIFY_12 0xaf +#define GPCMD_PLAY_CD_OLD 0xb4 +#define GPCMD_READ_CD_OLD 0xb8 +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_SCAN 0xba +#define GPCMD_SET_SPEED 0xbb +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_READ_CD 0xbe +#define GPCMD_SEND_DVD_STRUCTURE 0xbf /* This is for writing only, irrelevant to PCem. */ +#define GPCMD_PAUSE_RESUME_ALT 0xc2 +#define GPCMD_SCAN_ALT 0xcd /* Should be equivalent to 0xba */ +#define GPCMD_SET_SPEED_ALT 0xda /* Should be equivalent to 0xbb */ + +/* Mode page codes for mode sense/set */ +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_CDROM_PAGE 0x0d +#define GPMODE_CDROM_AUDIO_PAGE 0x0e +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f + +/* Mode page codes for presence */ +#define GPMODEP_R_W_ERROR_PAGE 0x0000000000000002LL +#define GPMODEP_UNK_PAGE_02 0x0000000000000004LL +#define GPMODEP_UNK_PAGE_03 0x0000000000000008LL +#define GPMODEP_UNK_PAGE_04 0x0000000000000010LL +#define GPMODEP_UNK_PAGE_05 0x0000000000000020LL +#define GPMODEP_UNK_PAGE_08 0x0000000000000100LL +#define GPMODEP_CDROM_PAGE 0x0000000000002000LL +#define GPMODEP_CDROM_AUDIO_PAGE 0x0000000000004000LL +#define GPMODEP_CAPABILITIES_PAGE 0x0000040000000000LL +#define GPMODEP_UNK_PAGE_2F 0x0000800000000000LL +#define GPMODEP_UNK_PAGE_30 0x0001000000000000LL +#define GPMODEP_ALL_PAGES 0x8000000000000000LL + +/* SCSI Status Codes */ +#define SCSI_STATUS_OK 0 +#define SCSI_STATUS_CHECK_CONDITION 2 + +/* SCSI Sense Keys */ +#define SENSE_NONE 0 +#define SENSE_NOT_READY 2 +#define SENSE_ILLEGAL_REQUEST 5 +#define SENSE_UNIT_ATTENTION 6 + +/* SCSI Additional Sense Codes */ +#define ASC_AUDIO_PLAY_OPERATION 0x00 +#define ASC_NOT_READY 0x04 +#define ASC_ILLEGAL_OPCODE 0x20 +#define ASC_LBA_OUT_OF_RANGE 0x21 +#define ASC_INV_FIELD_IN_CMD_PACKET 0x24 +#define ASC_INV_LUN 0x25 +#define ASC_INV_FIELD_IN_PARAMETER_LIST 0x26 +#define ASC_WRITE_PROTECTED 0x27 +#define ASC_MEDIUM_MAY_HAVE_CHANGED 0x28 +#define ASC_CAPACITY_DATA_CHANGED 0x2A +#define ASC_INCOMPATIBLE_FORMAT 0x30 +#define ASC_MEDIUM_NOT_PRESENT 0x3a +#define ASC_DATA_PHASE_ERROR 0x4b +#define ASC_ILLEGAL_MODE_FOR_THIS_TRACK 0x64 + +#define ASCQ_UNIT_IN_PROCESS_OF_BECOMING_READY 0x01 +#define ASCQ_INITIALIZING_COMMAND_REQUIRED 0x02 +#define ASCQ_CAPACITY_DATA_CHANGED 0x09 +#define ASCQ_AUDIO_PLAY_OPERATION_IN_PROGRESS 0x11 +#define ASCQ_AUDIO_PLAY_OPERATION_PAUSED 0x12 +#define ASCQ_AUDIO_PLAY_OPERATION_COMPLETED 0x13 + +/* Tell RISC OS that we have a 4x CD-ROM drive (600kb/sec data, 706kb/sec raw). + Not that it means anything */ +#define CDROM_SPEED 706 /* 0x2C2 */ + +#define BUFFER_SIZE (256*1024) + +#define RW_DELAY (TIMER_USEC * 500) + +/* Some generally useful CD-ROM information */ +#define CD_MINS 75 /* max. minutes per CD */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ +#define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE) +#define CD_MAX_SECTORS (CD_MAX_BYTES / 512) + +/* Event notification classes for GET EVENT STATUS NOTIFICATION */ +#define GESN_NO_EVENTS 0 +#define GESN_OPERATIONAL_CHANGE 1 +#define GESN_POWER_MANAGEMENT 2 +#define GESN_EXTERNAL_REQUEST 3 +#define GESN_MEDIA 4 +#define GESN_MULTIPLE_HOSTS 5 +#define GESN_DEVICE_BUSY 6 + +/* Event codes for MEDIA event status notification */ +#define MEC_NO_CHANGE 0 +#define MEC_EJECT_REQUESTED 1 +#define MEC_NEW_MEDIA 2 +#define MEC_MEDIA_REMOVAL 3 /* only for media changers */ +#define MEC_MEDIA_CHANGED 4 /* only for media changers */ +#define MEC_BG_FORMAT_COMPLETED 5 /* MRW or DVD+RW b/g format completed */ +#define MEC_BG_FORMAT_RESTARTED 6 /* MRW or DVD+RW b/g format restarted */ +#define MS_TRAY_OPEN 1 +#define MS_MEDIA_PRESENT 2 + +/* + * The MMC values are not IDE specific and might need to be moved + * to a common header if they are also needed for the SCSI emulation + */ + +/* Profile list from MMC-6 revision 1 table 91 */ +#define MMC_PROFILE_NONE 0x0000 +#define MMC_PROFILE_CD_ROM 0x0008 +#define MMC_PROFILE_CD_R 0x0009 +#define MMC_PROFILE_CD_RW 0x000A +#define MMC_PROFILE_DVD_ROM 0x0010 +#define MMC_PROFILE_DVD_R_SR 0x0011 +#define MMC_PROFILE_DVD_RAM 0x0012 +#define MMC_PROFILE_DVD_RW_RO 0x0013 +#define MMC_PROFILE_DVD_RW_SR 0x0014 +#define MMC_PROFILE_DVD_R_DL_SR 0x0015 +#define MMC_PROFILE_DVD_R_DL_JR 0x0016 +#define MMC_PROFILE_DVD_RW_DL 0x0017 +#define MMC_PROFILE_DVD_DDR 0x0018 +#define MMC_PROFILE_DVD_PLUS_RW 0x001A +#define MMC_PROFILE_DVD_PLUS_R 0x001B +#define MMC_PROFILE_DVD_PLUS_RW_DL 0x002A +#define MMC_PROFILE_DVD_PLUS_R_DL 0x002B +#define MMC_PROFILE_BD_ROM 0x0040 +#define MMC_PROFILE_BD_R_SRM 0x0041 +#define MMC_PROFILE_BD_R_RRM 0x0042 +#define MMC_PROFILE_BD_RE 0x0043 +#define MMC_PROFILE_HDDVD_ROM 0x0050 +#define MMC_PROFILE_HDDVD_R 0x0051 +#define MMC_PROFILE_HDDVD_RAM 0x0052 +#define MMC_PROFILE_HDDVD_RW 0x0053 +#define MMC_PROFILE_HDDVD_R_DL 0x0058 +#define MMC_PROFILE_HDDVD_RW_DL 0x005A +#define MMC_PROFILE_INVALID 0xFFFF + +#define SCSI_ONLY 32 +#define ATAPI_ONLY 16 +#define IMPLEMENTED 8 +#define NONDATA 4 +#define CHECK_READY 2 +#define ALLOW_UA 1 + +#define MSFtoLBA(m,s,f) ((((m*60)+s)*75)+f) + +#define MSG_COMMAND_COMPLETE 0x00 + +#define BUS_DBP 0x01 +#define BUS_SEL 0x02 +#define BUS_IO 0x04 +#define BUS_CD 0x08 +#define BUS_MSG 0x10 +#define BUS_REQ 0x20 +#define BUS_BSY 0x40 +#define BUS_RST 0x80 +#define BUS_ACK 0x200 +#define BUS_ATN 0x200 +#define BUS_ARB 0x8000 +#define BUS_SETDATA(val) ((uint32_t)val << 16) +#define BUS_GETDATA(val) ((val >> 16) & 0xff) +#define BUS_DATAMASK 0xff0000 + +#define BUS_IDLE (1 << 31) + +#define SCSI_PHASE_DATA_OUT 0 +#define SCSI_PHASE_DATA_IN BUS_IO +#define SCSI_PHASE_COMMAND BUS_CD +#define SCSI_PHASE_STATUS (BUS_CD | BUS_IO) +#define SCSI_PHASE_MESSAGE_OUT (BUS_MSG | BUS_CD) +#define SCSI_PHASE_MESSAGE_IN (BUS_MSG | BUS_CD | BUS_IO) + +#define MODE_SELECT_PHASE_IDLE 0 +#define MODE_SELECT_PHASE_HEADER 1 +#define MODE_SELECT_PHASE_BLOCK_DESC 2 +#define MODE_SELECT_PHASE_PAGE_HEADER 3 +#define MODE_SELECT_PHASE_PAGE 4 + + typedef struct { int state; @@ -32,6 +273,38 @@ typedef struct int new_req_delay; } scsi_bus_t; +typedef struct { + uint8_t *CmdBuffer; + int LunType; + int32_t BufferLength; + uint8_t Status; + uint8_t Phase; +} scsi_device_t; + +#pragma pack(push,1) +typedef struct { + uint8_t pages[0x40][0x40]; +} mode_sense_pages_t; +#pragma pack(pop) + +enum { + SCSI_NONE = 0, + SCSI_DISK, + SCSI_CDROM, + SCSI_ZIP +}; + + +extern scsi_device_t SCSIDevices[SCSI_ID_MAX]; + + +extern int cdrom_add_error_and_subchannel(uint8_t *b, int real_sector_type); +extern int cdrom_LBAtoMSF_accurate(void); + +extern int mode_select_init(uint8_t command, uint16_t pl_length, uint8_t do_save); +extern int mode_select_terminate(int force); +extern int mode_select_write(uint8_t val); + extern uint8_t *scsi_device_sense(uint8_t id); extern void scsi_device_type_data(uint8_t id, uint8_t *type, uint8_t *rmb); extern int64_t scsi_device_get_callback(uint8_t scsi_id); @@ -48,8 +321,4 @@ extern void scsi_device_command_phase0(uint8_t scsi_id, uint8_t *cdb); extern void scsi_device_command_phase1(uint8_t scsi_id); extern int32_t *scsi_device_get_buf_len(uint8_t scsi_id); -extern int scsi_bus_update(scsi_bus_t *bus, int bus_assert); -extern int scsi_bus_read(scsi_bus_t *bus); -extern int scsi_bus_match(scsi_bus_t *bus, int bus_assert); - #endif /*SCSI_DEVICE_H*/ diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 31afaecf2..e59e705d0 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -6,7 +6,7 @@ * * Emulation of SCSI fixed disks. * - * Version: @(#)scsi_disk.c 1.0.21 2018/09/12 + * Version: @(#)scsi_disk.c 1.0.22 2018/10/02 * * Author: Miran Grca, * @@ -29,7 +29,7 @@ #include "../disk/hdc_ide.h" #include "../plat.h" #include "../ui.h" -#include "scsi.h" +#include "scsi_device.h" #include "../cdrom/cdrom.h" #include "scsi_disk.h" diff --git a/src/scsi/scsi_ncr5380.c b/src/scsi/scsi_ncr5380.c index a5107bfb6..e7f721008 100644 --- a/src/scsi/scsi_ncr5380.c +++ b/src/scsi/scsi_ncr5380.c @@ -9,7 +9,7 @@ * Implementation of the NCR 5380 series of SCSI Host Adapters * made by NCR. These controllers were designed for the ISA bus. * - * Version: @(#)scsi_ncr5380.c 1.0.16 2018/07/19 + * Version: @(#)scsi_ncr5380.c 1.0.17 2018/10/02 * * Authors: Sarah Walker, * TheCollector1995, @@ -28,7 +28,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../cpu/cpu.h" #include "../io.h" #include "../dma.h" #include "../pic.h" @@ -368,7 +367,7 @@ ncr_write(uint16_t port, uint8_t val, void *priv) ncr5380_t *ncr_dev = (ncr5380_t *)priv; ncr_t *ncr = &ncr_dev->ncr; - ncr_log("NCR5380 write(%04x,%02x) @%04X:%04X\n",port & 7,val,CS,cpu_state.pc); + ncr_log("NCR5380 write(%04x,%02x)\n",port & 7,val); switch (port & 7) { case 0: /* Output data register */ @@ -536,7 +535,7 @@ ncr_read(uint16_t port, void *priv) break; } - ncr_log("NCR5380 read(%04x)=%02x @%04X:%04X\n", port & 7, ret, CS,cpu_state.pc); + ncr_log("NCR5380 read(%04x)=%02x\n", port & 7, ret); return(ret); } @@ -636,7 +635,7 @@ memio_write(uint32_t addr, uint8_t val, void *priv) addr &= 0x3fff; - ncr_log("memio_write(%08x,%02x) @%04X:%04X %i %02x\n", addr, val, CS,cpu_state.pc, ncr_dev->buffer_host_pos, ncr_dev->status_ctrl); + ncr_log("memio_write(%08x,%02x) %i %02x\n", addr, val, ncr_dev->buffer_host_pos, ncr_dev->status_ctrl); if (addr >= 0x3a00) ncr_dev->ext_ram[addr - 0x3a00] = val; @@ -670,7 +669,7 @@ memio_write(uint32_t addr, uint8_t val, void *priv) case 0x3980: switch (addr) { case 0x3980: /* Control */ - ncr_log("Write 0x3980: val=%02x CS=%04x, pc=%04x\n", val, CS,cpu_state.pc); + ncr_log("Write 0x3980: val=%02x\n", val); if (val & 0x80) { ncr_log("Resetting the 53c400\n"); @@ -828,7 +827,7 @@ scsiat_in(uint16_t port, void *priv) break; } - pclog("SCSI AT read=0x%03x, ret=%02x, CS:%08x, PC:%08x\n", port, ret, CS,cpu_state.pc); + ncr_log("SCSI AT read=0x%03x, ret=%02x\n", port, ret); return(ret); } @@ -841,7 +840,7 @@ scsiat_out(uint16_t port, uint8_t val, void *priv) ncr_t *ncr = &ncr_dev->ncr; scsi_device_t *dev = &SCSIDevices[ncr->target_id]; - pclog("SCSI AT write=0x%03x, val=%02x, CS:%08x, PC:%08x\n", port, val, CS,cpu_state.pc); + ncr_log("SCSI AT write=0x%03x, val=%02x\n", port, val); switch (port & 0x0f) { case 0x08: ncr->unk_08 = val; @@ -856,7 +855,7 @@ scsiat_out(uint16_t port, uint8_t val, void *priv) temp = ncr_dev->buffer[ncr_dev->buffer_host_pos++]; - pclog("Read Buffer host=%d\n", ncr_dev->buffer_host_pos); + ncr_log("Read Buffer host=%d\n", ncr_dev->buffer_host_pos); ncr->bus_host = get_bus_host(ncr) & ~BUS_DATAMASK; ncr->bus_host |= BUS_SETDATA(temp); @@ -878,7 +877,7 @@ scsiat_out(uint16_t port, uint8_t val, void *priv) ncr_dev->buffer[ncr_dev->buffer_host_pos++] = temp; - pclog("Write Buffer host=%d\n", ncr_dev->buffer_host_pos); + ncr_log("Write Buffer host=%d\n", ncr_dev->buffer_host_pos); if (ncr_dev->buffer_host_pos == 128) { @@ -1338,7 +1337,7 @@ ncr_callback(void *priv) } ncr_dev->buffer[ncr_dev->buffer_pos++] = temp; - pclog("Buffer pos for reading=%d\n", ncr_dev->buffer_pos); + ncr_log("Buffer pos for reading=%d\n", ncr_dev->buffer_pos); c++; @@ -1347,7 +1346,7 @@ ncr_callback(void *priv) ncr_dev->buffer_pos = 0; ncr_dev->buffer_host_pos = 0; ncr_dev->block_count = (ncr_dev->block_count - 1) & 255; - pclog("Remaining blocks to be read=%d\n", ncr_dev->block_count); + ncr_log("Remaining blocks to be read=%d\n", ncr_dev->block_count); if (!ncr_dev->block_count) { ncr_dev->block_count_loaded = 0; ncr_log("IO End of read transfer\n"); @@ -1407,7 +1406,7 @@ ncr_callback(void *priv) ncr_dev->buffer_pos = 0; ncr_dev->buffer_host_pos = 0; ncr_dev->block_count = (ncr_dev->block_count - 1) & 255; - pclog("Remaining blocks to be written=%d\n", ncr_dev->block_count); + ncr_log("Remaining blocks to be written=%d\n", ncr_dev->block_count); if (!ncr_dev->block_count) { ncr_dev->block_count_loaded = 0; ncr_log("IO End of write transfer\n"); @@ -1429,7 +1428,7 @@ ncr_callback(void *priv) ncr_wait_process(ncr_dev); if (!(ncr->bus_host & BUS_BSY) && (ncr->mode & MODE_MONITOR_BUSY)) { - pclog("Updating DMA\n"); + ncr_log("Updating DMA\n"); ncr->mode &= ~MODE_DMA; ncr->dma_mode = DMA_IDLE; } diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index e8c334eab..6be8820b1 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -11,7 +11,7 @@ * series of SCSI Host Adapters made by Mylex. * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.c 1.0.21 2018/06/12 + * Version: @(#)scsi_x54x.c 1.0.22 2018/10/02 * * Authors: TheCollector1995, * Miran Grca, @@ -40,7 +40,6 @@ #include "../nvr.h" #include "../timer.h" #include "../plat.h" -#include "../cpu/cpu.h" #include "scsi.h" #include "scsi_device.h" #include "scsi_aha154x.h" diff --git a/src/scsi/scsi_x54x.h b/src/scsi/scsi_x54x.h index 13699a181..306279a71 100644 --- a/src/scsi/scsi_x54x.h +++ b/src/scsi/scsi_x54x.h @@ -11,7 +11,7 @@ * of SCSI Host Adapters made by Mylex. * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.h 1.0.7 2018/04/06 + * Version: @(#)scsi_x54x.h 1.0.8 2018/10/02 * * Authors: TheCollector1995, * Miran Grca, @@ -118,6 +118,18 @@ #define INTR_MBIF 0x01 /* MBI full */ +#pragma pack(push,1) +typedef struct { + uint8_t hi; + uint8_t mid; + uint8_t lo; +} addr24; +#pragma pack(pop) + +#define ADDR_TO_U32(x) (((x).hi<<16)|((x).mid<<8)|((x).lo&0xFF)) +#define U32_TO_ADDR(a,x) do {(a).hi=(x)>>16;(a).mid=(x)>>8;(a).lo=(x)&0xFF;}while(0) + + /* Structure for the INQUIRE_SETUP_INFORMATION reply. */ #pragma pack(push,1) typedef struct { @@ -491,6 +503,29 @@ typedef struct (p->u.lba.lba2<<8) | p->u.lba.lba3) +/* + * + * Scatter/Gather Segment List Definitions + * + * Adapter limits + */ +#define MAX_SG_DESCRIPTORS 32 /* Always make the array 32 elements long, if less are used, that's not an issue. */ + +#pragma pack(push,1) +typedef struct { + uint32_t Segment; + uint32_t SegmentPointer; +} SGE32; +#pragma pack(pop) + +#pragma pack(push,1) +typedef struct { + addr24 Segment; + addr24 SegmentPointer; +} SGE; +#pragma pack(pop) + + extern void x54x_reset_ctrl(x54x_t *dev, uint8_t Reset); extern void x54x_buf_alloc(uint8_t id, int length); extern void x54x_buf_free(uint8_t id); diff --git a/src/sio_pc87306.c b/src/sio_pc87306.c index 3761d53d5..f21946c69 100644 --- a/src/sio_pc87306.c +++ b/src/sio_pc87306.c @@ -8,7 +8,7 @@ * * Emulation of the NatSemi PC87306 Super I/O chip. * - * Version: @(#)sio_pc87306.c 1.0.12 2018/05/11 + * Version: @(#)sio_pc87306.c 1.0.13 2018/10/02 * * Author: Miran Grca, * Copyright 2016-2018 Miran Grca. @@ -29,7 +29,6 @@ #include "disk/hdc_ide.h" #include "floppy/fdd.h" #include "floppy/fdc.h" -#include "machine/machine.h" #include "sio.h" diff --git a/src/sio_w83877f.c b/src/sio_w83877f.c index 1aa45b7ea..1dd4a5d56 100644 --- a/src/sio_w83877f.c +++ b/src/sio_w83877f.c @@ -11,7 +11,7 @@ * Winbond W83877F Super I/O Chip * Used by the Award 430HX * - * Version: @(#)sio_w83877f.c 1.0.12 2018/09/12 + * Version: @(#)sio_w83877f.c 1.0.13 2018/10/02 * * Author: Miran Grca, * Copyright 2016-2018 Miran Grca. @@ -21,7 +21,6 @@ #include #include #include "86box.h" -#include "machine/machine.h" #include "device.h" #include "io.h" #include "pci.h" diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 178095702..4606eec06 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -7,9 +7,6 @@ #include "../io.h" #include "../dma.h" #include "../pic.h" -#include "../pit.h" -#include "../mem.h" -#include "../rom.h" #include "../device.h" #include "../nvr.h" #include "../timer.h" diff --git a/src/sound/sound.c b/src/sound/sound.c index 035f01665..ebae3610e 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.19 2018/09/11 + * Version: @(#)sound.c 1.0.20 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -26,7 +26,7 @@ #include "../86box.h" #include "../device.h" #include "../timer.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../cdrom/cdrom.h" #include "../plat.h" #include "sound.h" diff --git a/src/video/vid_ati18800.c b/src/video/vid_ati18800.c index f63238fd0..59a8f3ca3 100644 --- a/src/video/vid_ati18800.c +++ b/src/video/vid_ati18800.c @@ -8,7 +8,7 @@ * * ATI 18800 emulation (VGA Edge-16) * - * Version: @(#)vid_ati18800.c 1.0.13 2018/09/19 + * Version: @(#)vid_ati18800.c 1.0.14 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include "../86box.h" -#include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/vid_ati28800.c b/src/video/vid_ati28800.c index edecc80ed..cfb9f2d64 100644 --- a/src/video/vid_ati28800.c +++ b/src/video/vid_ati28800.c @@ -8,7 +8,7 @@ * * ATI 28800 emulation (VGA Charger and Korean VGA) * - * Version: @(#)vid_ati28800.c 1.0.23 2018/09/21 + * Version: @(#)vid_ati28800.c 1.0.24 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -26,13 +26,10 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../cpu/cpu.h" #include "../io.h" -#include "../pit.h" #include "../mem.h" #include "../rom.h" #include "../device.h" -#include "../timer.h" #include "video.h" #include "vid_ati28800.h" #include "vid_ati_eeprom.h" @@ -113,7 +110,7 @@ static void ati28800_out(uint16_t addr, uint8_t val, void *p) svga_t *svga = &ati28800->svga; uint8_t old; - ati28800_log("ati28800_out : %04X %02X %04X:%04X\n", addr, val, CS, cpu_state.pc); + ati28800_log("ati28800_out : %04X %02X\n", addr, val); if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout&1)) addr ^= 0x60; @@ -330,7 +327,7 @@ static uint8_t ati28800_in(uint16_t addr, void *p) temp = svga_in(addr, svga); break; } - if (addr != 0x3da) ati28800_log("%02X %04X:%04X\n", temp, CS,cpu_state.pc); + if (addr != 0x3da) ati28800_log("%02X\n", temp); return temp; } @@ -372,7 +369,7 @@ uint8_t ati28800k_in(uint16_t addr, void *p) temp = ati28800_in(oldaddr, p); break; } - if (addr != 0x3da) ati28800_log("%02X %04X:%04X\n", temp, CS,cpu_state.pc); + if (addr != 0x3da) ati28800_log("%02X\n", temp); return temp; } diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 496d12626..7e014eeef 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -8,7 +8,7 @@ * * ATi Mach64 graphics card emulation. * - * Version: @(#)vid_ati_mach64.c 1.0.23 2018/09/19 + * Version: @(#)vid_ati_mach64.c 1.0.24 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -24,8 +24,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../cpu/cpu.h" -#include "../machine/machine.h" #include "../device.h" #include "../io.h" #include "../mem.h" @@ -1718,7 +1716,7 @@ uint8_t mach64_ext_readb(uint32_t addr, void *p) uint8_t ret; if (!(addr & 0x400)) { - mach64_log("nmach64_ext_readb: addr=%04x %04x(%08x):%08x\n", addr, CS, cs, cpu_state.pc); + mach64_log("nmach64_ext_readb: addr=%04x\n", addr); switch (addr & 0x3ff) { case 0x00: case 0x01: case 0x02: case 0x03: @@ -2085,7 +2083,7 @@ uint16_t mach64_ext_readw(uint32_t addr, void *p) uint16_t ret; if (!(addr & 0x400)) { - mach64_log("nmach64_ext_readw: addr=%04x %04x(%08x):%08x\n", addr, CS, cs, cpu_state.pc); + mach64_log("nmach64_ext_readw: addr=%04x\n", addr); ret = 0xffff; } else switch (addr & 0x3ff) @@ -2104,7 +2102,7 @@ uint32_t mach64_ext_readl(uint32_t addr, void *p) uint32_t ret; if (!(addr & 0x400)) { - mach64_log("nmach64_ext_readl: addr=%04x %04x(%08x):%08x\n", addr, CS, cs, cpu_state.pc); + mach64_log("nmach64_ext_readl: addr=%04x\n", addr); ret = 0xffffffff; } else switch (addr & 0x3ff) @@ -2136,7 +2134,7 @@ void mach64_ext_writeb(uint32_t addr, uint8_t val, void *p) mach64_t *mach64 = (mach64_t *)p; svga_t *svga = &mach64->svga; - mach64_log("mach64_ext_writeb : addr %08X val %02X %04x(%08x):%08x\n", addr, val, CS,cs,cpu_state.pc); + mach64_log("mach64_ext_writeb : addr %08X val %02X\n", addr, val); if (!(addr & 0x400)) { @@ -2353,7 +2351,7 @@ void mach64_ext_writew(uint32_t addr, uint16_t val, void *p) mach64_log("mach64_ext_writew : addr %08X val %04X\n", addr, val); if (!(addr & 0x400)) { - mach64_log("nmach64_ext_writew: addr=%04x val=%04x %04x(%08x):%08x\n", addr, val, CS, cs, cpu_state.pc); + mach64_log("nmach64_ext_writew: addr=%04x val=%04x\n", addr, val); mach64_ext_writeb(addr, val, p); mach64_ext_writeb(addr + 1, val >> 8, p); @@ -2377,7 +2375,7 @@ void mach64_ext_writel(uint32_t addr, uint32_t val, void *p) mach64_log("mach64_ext_writel : addr %08X val %08X\n", addr, val); if (!(addr & 0x400)) { - mach64_log("nmach64_ext_writel: addr=%04x val=%08x %04x(%08x):%08x\n", addr, val, CS, cs, cpu_state.pc); + mach64_log("nmach64_ext_writel: addr=%04x val=%08x\n", addr, val); mach64_ext_writew(addr, val, p); mach64_ext_writew(addr + 2, val >> 16, p); @@ -2513,7 +2511,7 @@ uint8_t mach64_ext_inb(uint16_t port, void *p) ret = 0; break; } - mach64_log("mach64_ext_inb : port %04X ret %02X %04X:%04X\n", port, ret, CS,cpu_state.pc); + mach64_log("mach64_ext_inb : port %04X ret %02X\n", port, ret); return ret; } uint16_t mach64_ext_inw(uint16_t port, void *p) @@ -2553,7 +2551,7 @@ uint32_t mach64_ext_inl(uint16_t port, void *p) void mach64_ext_outb(uint16_t port, uint8_t val, void *p) { mach64_t *mach64 = (mach64_t *)p; - mach64_log("mach64_ext_outb : port %04X val %02X %04X:%04X\n", port, val, CS,cpu_state.pc); + mach64_log("mach64_ext_outb : port %04X val %02X\n", port, val); switch (port) { case 0x02ec: case 0x02ed: case 0x02ee: case 0x02ef: @@ -2682,7 +2680,7 @@ static uint8_t mach64_block_inb(uint16_t port, void *p) uint8_t ret; ret = mach64_ext_readb(0x400 | (port & 0x3ff), mach64); - mach64_log("mach64_block_inb : port %04X ret %02X %04x:%04x\n", port, ret, CS,cpu_state.pc); + mach64_log("mach64_block_inb : port %04X ret %02X\n", port, ret); return ret; } static uint16_t mach64_block_inw(uint16_t port, void *p) @@ -3376,7 +3374,7 @@ static void *mach64vt2_init(const device_t *info) mach64->config_chip_id = 0x40005654; mach64->dac_cntl = 1 << 16; /*Internal 24-bit DAC*/ mach64->config_stat0 = 4; - mach64->use_block_decoded_io = PCI ? 4 : 0; + mach64->use_block_decoded_io = 4; ati_eeprom_load(&mach64->eeprom, L"mach64vt.nvr", 1); diff --git a/src/video/vid_cga.h b/src/video/vid_cga.h index 74aba09c2..839c810fa 100644 --- a/src/video/vid_cga.h +++ b/src/video/vid_cga.h @@ -8,7 +8,7 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * Version: @(#)vid_cga.h 1.0.3 2018/03/18 + * Version: @(#)vid_cga.h 1.0.4 2018/10/02 * * Author: Sarah Walker, * Miran Grca, @@ -61,5 +61,7 @@ uint8_t cga_read(uint32_t addr, void *p); void cga_recalctimings(cga_t *cga); void cga_poll(void *p); +#ifdef EMU_DEVICE_H extern const device_config_t cga_config[]; extern const device_t cga_device; +#endif diff --git a/src/video/vid_cga_comp.c b/src/video/vid_cga_comp.c index 008627bcd..d53dc3ea4 100644 --- a/src/video/vid_cga_comp.c +++ b/src/video/vid_cga_comp.c @@ -9,13 +9,13 @@ * IBM CGA composite filter, borrowed from reenigne's DOSBox * patch and ported to C. * - * Version: @(#)vid_cga_comp.c 1.0.3 2017/11/04 + * Version: @(#)vid_cga_comp.c 1.0.4 2018/10/02 * * Authors: reenigne, * Miran Grca, * - * Copyright 2015-2017 reenigne. - * Copyright 2015-2017 Miran Grca. + * Copyright 2015-2018 reenigne. + * Copyright 2015-2018 Miran Grca. */ #include #include @@ -24,7 +24,6 @@ #include #include #include "../86box.h" -#include "../device.h" #include "../mem.h" #include "vid_cga.h" #include "vid_cga_comp.h" diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index 7345aa1c0..707c8a28c 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -28,7 +28,7 @@ #include #include #include "../86box.h" -#include "../cpu/cpu.h" + #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" #include "../pci.h" diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index b95887b08..c311b8608 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -10,7 +10,7 @@ * * Known bugs: Accelerator doesn't work in planar modes * - * Version: @(#)vid_et4000w32.c 1.0.18 2018/09/30 + * Version: @(#)vid_et4000w32.c 1.0.19 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -26,7 +26,6 @@ #include #define HAVE_STDARG_H #include "../86box.h" -#include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" #include "../pci.h" diff --git a/src/video/vid_icd2061.c b/src/video/vid_icd2061.c index 1f7893457..82d55242f 100644 --- a/src/video/vid_icd2061.c +++ b/src/video/vid_icd2061.c @@ -10,7 +10,7 @@ * * Used by ET4000w32/p (Diamond Stealth 32) * - * Version: @(#)vid_icd2061.c 1.0.5 2018/01/10 + * Version: @(#)vid_icd2061.c 1.0.6 2018/10/02 * * Authors: Miran Grca, * @@ -21,9 +21,6 @@ #include #include #include "../86box.h" -#include "../mem.h" -#include "video.h" -#include "vid_svga.h" #include "vid_icd2061.h" void diff --git a/src/video/vid_icd2061.h b/src/video/vid_icd2061.h index 6a203dc52..b3be37211 100644 --- a/src/video/vid_icd2061.h +++ b/src/video/vid_icd2061.h @@ -10,7 +10,7 @@ * * Used by ET4000w32/p (Diamond Stealth 32) * - * Version: @(#)vid_icd2061.h 1.0.0 2018/09/30 + * Version: @(#)vid_icd2061.h 1.0.1 2018/10/02 * * Authors: Miran Grca, * @@ -18,7 +18,6 @@ */ typedef struct icd2061_t { - svga_t svga; float freq[3]; int count, bit_count; diff --git a/src/video/vid_oak_oti.c b/src/video/vid_oak_oti.c index 48271fd5b..a32ed8201 100644 --- a/src/video/vid_oak_oti.c +++ b/src/video/vid_oak_oti.c @@ -8,7 +8,7 @@ * * Oak OTI037C/67/077 emulation. * - * Version: @(#)vid_oak_oti.c 1.0.13 2018/09/19 + * Version: @(#)vid_oak_oti.c 1.0.14 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -16,10 +16,9 @@ * Copyright 2008-2018 Sarah Walker. * Copyright 2016-2018 Miran Grca. */ -#include #include -#include #include +#include #include #include "../86box.h" #include "../io.h" @@ -29,7 +28,6 @@ #include "video.h" #include "vid_oak_oti.h" #include "vid_svga.h" -#include "../machine/machine.h" #define BIOS_37C_PATH L"roms/video/oti/bios.bin" #define BIOS_67_AMA932J_PATH L"roms/machines/ama932j/oti067.bin" @@ -274,17 +272,18 @@ oti_init(const device_t *info) romfn = BIOS_37C_PATH; break; + case 3: + romfn = BIOS_67_AMA932J_PATH; + break; case 2: - if (romset == ROM_AMA932J) /*In case of any other future board uses another variant*/ - { - romfn = BIOS_67_AMA932J_PATH; - break; - } case 5: romfn = BIOS_77_PATH; break; } + if (oti->chip_id == 3) + oti->chip_id = 2; + rom_init(&oti->bios_rom, romfn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); @@ -430,7 +429,7 @@ const device_t oti067_ama932j_device = { "Oak OTI-067 (AMA-932J)", DEVICE_ISA, - 2, + 3, oti_init, oti_close, NULL, oti067_ama932j_available, oti_speed_changed, diff --git a/src/video/vid_table.c b/src/video/vid_table.c index c716d7042..af98054d9 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -8,7 +8,7 @@ * * Define all known video cards. * - * Version: @(#)vid_table.c 1.0.39 2018/09/30 + * Version: @(#)vid_table.c 1.0.40 2018/10/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -19,16 +19,14 @@ #include #include #include -#include #include +#include #include #define HAVE_STDARG_H #include "../86box.h" #include "../machine/machine.h" #include "../mem.h" -#include "../rom.h" #include "../device.h" -#include "../timer.h" #include "../plat.h" #include "video.h" #include "vid_svga.h" diff --git a/src/video/vid_ti_cf62011.c b/src/video/vid_ti_cf62011.c index fecbf2a03..8210778f1 100644 --- a/src/video/vid_ti_cf62011.c +++ b/src/video/vid_ti_cf62011.c @@ -42,7 +42,7 @@ * which are the same as the XGA. It supports up to 1MB of VRAM, * but we lock it down to 512K. The PS/1 2122 had 256K. * - * Version: @(#)vid_ti_cf62011.c 1.0.8 2018/09/19 + * Version: @(#)vid_ti_cf62011.c 1.0.9 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -58,7 +58,6 @@ #include #include #include "../86box.h" -#include "../config.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/video/video.c b/src/video/video.c index f35c02d2e..d9ecd3e21 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -40,7 +40,7 @@ * W = 3 bus clocks * L = 4 bus clocks * - * Version: @(#)video.c 1.0.26 2018/09/19 + * Version: @(#)video.c 1.0.27 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -56,7 +56,6 @@ #include #include "../86box.h" #include "../cpu/cpu.h" -#include "../machine/machine.h" #include "../io.h" #include "../mem.h" #include "../rom.h" diff --git a/src/win/win_cdrom.c b/src/win/win_cdrom.c index 012772655..bf577aa86 100644 --- a/src/win/win_cdrom.c +++ b/src/win/win_cdrom.c @@ -8,7 +8,7 @@ * * Handle the platform-side of CDROM drives. * - * Version: @(#)win_cdrom.c 1.0.8 2018/06/02 + * Version: @(#)win_cdrom.c 1.0.9 2018/10/02 * * Authors: Sarah Walker, * Miran Grca, @@ -29,7 +29,7 @@ #include #include "../config.h" #include "../disk/hdd.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../cdrom/cdrom.h" #include "../disk/zip.h" #include "../cdrom/cdrom_image.h" diff --git a/src/win/win_new_floppy.c b/src/win/win_new_floppy.c index a7954672b..e0d800f06 100644 --- a/src/win/win_new_floppy.c +++ b/src/win/win_new_floppy.c @@ -8,7 +8,7 @@ * * Handle the New Floppy Image dialog. * - * Version: @(#)win_new_floppy.c 1.0.8 2018/05/25 + * Version: @(#)win_new_floppy.c 1.0.9 2018/10/02 * * Authors: Miran Grca, * @@ -29,7 +29,7 @@ #include "../plat.h" #include "../random.h" #include "../ui.h" -#include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../disk/zip.h" #include "win.h" diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 41ffe3920..db332c34b 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Windows 86Box Settings dialog handler. * - * Version: @(#)win_settings.c 1.0.62 2018/09/19 + * Version: @(#)win_settings.c 1.0.63 2018/10/02 * * Authors: Miran Grca, * David Hrdlička, @@ -41,6 +41,7 @@ #include "../lpt.h" #include "../mouse.h" #include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../cdrom/cdrom.h" #include "../disk/hdd.h" #include "../disk/hdc.h" diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 750b8837d..58bbadcb3 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -8,7 +8,7 @@ * * Implement the application's Status Bar. * - * Version: @(#)win_stbar.c 1.0.18 2018/05/25 + * Version: @(#)win_stbar.c 1.0.19 2018/10/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -37,6 +37,7 @@ #include "../disk/hdc.h" #include "../floppy/fdd.h" #include "../scsi/scsi.h" +#include "../scsi/scsi_device.h" #include "../cdrom/cdrom.h" #include "../disk/zip.h" #include "../cdrom/cdrom_image.h"