diff --git a/src/CPU/808x.c b/src/CPU/808x.c index 32a52e955..faa951409 100644 --- a/src/CPU/808x.c +++ b/src/CPU/808x.c @@ -34,6 +34,7 @@ #include "../mem.h" #include "../nmi.h" #include "../pic.h" +#include "../scsi.h" #include "../timer.h" int xt_cpu_multi; @@ -599,6 +600,7 @@ void resetx86() codegen_reset(); x86_was_reset = 1; port_92_clear_reset(); + scsi_card_reset(); } void softresetx86() @@ -618,6 +620,7 @@ void softresetx86() x86seg_reset(); x86_was_reset = 1; port_92_clear_reset(); + scsi_card_reset(); } static void setznp8(uint8_t val) diff --git a/src/SOUND/snd_dbopl.cc b/src/SOUND/snd_dbopl.cc index cf4bc1ebe..94480ad4f 100644 --- a/src/SOUND/snd_dbopl.cc +++ b/src/SOUND/snd_dbopl.cc @@ -1,4 +1,4 @@ -/* Copyright holders: The DOSBox Team, SA1988 +/* Copyright holders: Sarah Walker, SA1988 see COPYING for more details */ #include "dbopl.h" diff --git a/src/SOUND/snd_dbopl.h b/src/SOUND/snd_dbopl.h index 49b2aa095..6fd536f39 100644 --- a/src/SOUND/snd_dbopl.h +++ b/src/SOUND/snd_dbopl.h @@ -1,4 +1,4 @@ -/* Copyright holders: The DOSBox Team, SA1988 +/* Copyright holders: Sarah Walker, SA1988 see COPYING for more details */ #ifdef __cplusplus diff --git a/src/device.c b/src/device.c index 9b90c9ea1..9d8968f82 100644 --- a/src/device.c +++ b/src/device.c @@ -73,6 +73,22 @@ void device_close_all() } } +void *device_get_priv(device_t *d) +{ + int c; + + for (c = 0; c < 256; c++) + { + if (devices[c] != NULL) + { + if (devices[c] == d) + return device_priv[c]; + } + } + + return NULL; +} + int device_available(device_t *d) { #ifdef RELEASE_BUILD diff --git a/src/device.h b/src/device.h index 5a2f9b17e..e5613f836 100644 --- a/src/device.h +++ b/src/device.h @@ -72,6 +72,7 @@ typedef struct device_t extern void device_init(void); extern void device_add(device_t *d); extern void device_close_all(void); +extern void *device_get_priv(device_t *d); extern int device_available(device_t *d); extern void device_speed_changed(void); extern void device_force_redraw(void); diff --git a/src/scsi.c b/src/scsi.c index 4a2ce29fb..186a2495a 100644 --- a/src/scsi.c +++ b/src/scsi.c @@ -1,7 +1,21 @@ -/* Copyright holders: SA1988, Tenshi - see COPYING for more details -*/ -/*SCSI layer emulation*/ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Handling of the SCSI controllers. + * + * NOTE: THIS IS CURRENTLY A MESS, but will be cleaned up as I go. + * + * Version: @(#)scsi.c 1.0.0 2017/06/14 + * + * Authors: Fred N. van Kempen, + * Original Buslogic version by SA1988 and Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ #include #include #include "86box.h" @@ -28,17 +42,18 @@ typedef struct { char name[64]; char internal_name[32]; device_t *device; + void (*reset)(void *p); } SCSI_CARD; static SCSI_CARD scsi_cards[] = { - { "None", "none", NULL }, - { "Adaptec AHA-1540B", "aha1540b", &aha1540b_device }, - { "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device }, - { "Adaptec AHA-1640", "aha1640", &aha1640_device }, - { "BusLogic BT-542B", "bt542b", &buslogic_device }, - { "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device }, - { "", "", NULL } + { "None", "none", NULL, NULL }, + { "Adaptec AHA-1540B", "aha1540b", &aha1540b_device, aha_device_reset }, + { "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device, aha_device_reset }, + { "Adaptec AHA-1640", "aha1640", &aha1640_device, aha_device_reset }, + { "BusLogic BT-542B", "bt542b", &buslogic_device, BuslogicDeviceReset }, + { "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device, BuslogicDeviceReset }, + { "", "", NULL, NULL }, }; @@ -100,6 +115,24 @@ void scsi_card_init() } +void scsi_card_reset(void) +{ + void *p = NULL; + + if (scsi_cards[scsi_card_current].device) + { + p = device_get_priv(scsi_cards[scsi_card_current].device); + if (p) + { + if (scsi_cards[scsi_card_current].reset) + { + scsi_cards[scsi_card_current].reset(p); + } + } + } +} + + /* Initialization function for the SCSI layer */ void SCSIReset(uint8_t id, uint8_t lun) { diff --git a/src/scsi.h b/src/scsi.h index 8c3efc3b5..d0e4bfb91 100644 --- a/src/scsi.h +++ b/src/scsi.h @@ -260,6 +260,7 @@ int scsi_card_has_config(int card); char *scsi_card_get_internal_name(int card); int scsi_card_get_from_internal_name(char *s); void scsi_card_init(); +void scsi_card_reset(void); extern uint8_t scsi_hard_disks[16][8]; diff --git a/src/scsi_aha154x.c b/src/scsi_aha154x.c index 72f615843..f37838cf1 100644 --- a/src/scsi_aha154x.c +++ b/src/scsi_aha154x.c @@ -12,7 +12,7 @@ * * NOTE: THIS IS CURRENTLY A MESS, but will be cleaned up as I go. * - * Version: @(#)scsi_aha154x.c 1.0.6 2017/05/06 + * Version: @(#)scsi_aha154x.c 1.0.7 2017/06/14 * * Authors: Fred N. van Kempen, * Original Buslogic version by SA1988 and Miran Grca. @@ -179,6 +179,32 @@ static uint16_t aha_ports[] = { 0x0130, 0x0134, 0x0000, 0x0000 }; + +#ifdef WALTJE +int aha_do_log = 1; +# define ENABLE_AHA154X_LOG +#else +int aha_do_log = 0; +#endif + + +static void +aha_log(const char *format, ...) +{ +#ifdef ENABLE_AHA154X_LOG + va_list ap; + + if (aha_do_log) { + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + fflush(stdout); + } +#endif +} +#define pclog aha_log + + /* * Write data to the BIOS space. * @@ -839,31 +865,6 @@ enum { }; -#ifdef WALTJE -int aha_do_log = 1; -# define ENABLE_AHA154X_LOG -#else -int aha_do_log = 0; -#endif - - -static void -aha_log(const char *format, ...) -{ -#ifdef ENABLE_AHA154X_LOG - va_list ap; - - if (aha_do_log) { - va_start(ap, format); - vprintf(format, ap); - va_end(ap); - fflush(stdout); - } -#endif -} -#define pclog aha_log - - static void ClearIntr(aha_t *dev) { @@ -2168,6 +2169,14 @@ void aha_mca_write(int port, uint8_t val, void *p) } +void +aha_device_reset(void *p) +{ + aha_t *dev = (aha_t *) p; + aha_reset_ctrl(dev, 1); +} + + static void * aha_init(int chip, int has_bios) { diff --git a/src/scsi_aha154x.h b/src/scsi_aha154x.h index 0e7db0d0d..d15de7c2d 100644 --- a/src/scsi_aha154x.h +++ b/src/scsi_aha154x.h @@ -13,6 +13,8 @@ typedef struct { extern device_t aha1540b_device; extern device_t aha1542cf_device; extern device_t aha1640_device; + +extern void aha_device_reset(void *p); #endif /*SCSI_AHA154X_H*/ diff --git a/src/scsi_buslogic.c b/src/scsi_buslogic.c index d5113e000..1b4c8794d 100644 --- a/src/scsi_buslogic.c +++ b/src/scsi_buslogic.c @@ -10,7 +10,7 @@ * 0 - BT-542B ISA; * 1 - BT-958 PCI (but BT-542B ISA on non-PCI machines) * - * Version: @(#)scsi_buslogic.c 1.0.3 2017/06/03 + * Version: @(#)scsi_buslogic.c 1.0.4 2017/06/14 * * Authors: TheCollector1995, * Miran Grca, @@ -2226,6 +2226,14 @@ BuslogicPCIWrite(int func, int addr, uint8_t val, void *p) } +void +BuslogicDeviceReset(void *p) +{ + Buslogic_t *dev = (Buslogic_t *) p; + BuslogicResetControl(dev, 1); +} + + static void * BuslogicInit(int chip) { diff --git a/src/scsi_buslogic.h b/src/scsi_buslogic.h index c952e06d1..e835ea989 100644 --- a/src/scsi_buslogic.h +++ b/src/scsi_buslogic.h @@ -23,6 +23,8 @@ extern device_t buslogic_device; extern device_t buslogic_pci_device; + +extern void BuslogicDeviceReset(void *p); #endif /*SCSI_BUSLOGIC_H*/