/* * VARCem Virtual Archaelogical Computer EMulator. * An emulator of (mostly) x86-based PC systems and devices, * using the ISA,EISA,VLB,MCA and PCI system buses, roughly * spanning the era between 1981 and 1995. * * This file is part of the VARCem Project. * * Handling of the SCSI controllers. * * Version: @(#)scsi.c 1.0.1 2018/02/14 * * Authors: Fred N. van Kempen, * Miran Grca, * TheCollector1995, * * Copyright 2017,2018 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the: * * Free Software Foundation, Inc. * 59 Temple Place - Suite 330 * Boston, MA 02111-1307 * USA. */ #include #include #include #include #include #include "../emu.h" #include "../mem.h" #include "../rom.h" #include "../timer.h" #include "../device.h" #include "../cdrom/cdrom.h" #include "../zip.h" #include "../disk/hdc.h" #include "../plat.h" #include "scsi.h" #include "scsi_aha154x.h" #include "scsi_buslogic.h" #include "scsi_ncr5380.h" #include "scsi_ncr53c810.h" #ifdef WALTJE # include "scsi_wd33c93.h" #endif #include "scsi_x54x.h" scsi_device_t SCSIDevices[SCSI_ID_MAX][SCSI_LUN_MAX]; #if 0 uint8_t SCSIPhase = 0xff; uint8_t SCSIStatus = SCSI_STATUS_OK; #endif char scsi_fn[SCSI_NUM][512]; uint16_t scsi_hd_location[SCSI_NUM]; int scsi_card_current = 0; int scsi_card_last = 0; uint32_t SCSI_BufferLength; static volatile mutex_t *scsiMutex; typedef struct { const char *name; const char *internal_name; device_t *device; void (*reset)(void *p); } SCSI_CARD; static SCSI_CARD scsi_cards[] = { { "None", "none", NULL, NULL }, { "[ISA] Adaptec AHA-1540B","aha1540b", &aha1540b_device, x54x_device_reset }, { "[ISA] Adaptec AHA-1542C","aha1542c", &aha1542c_device, x54x_device_reset }, { "[ISA] Adaptec AHA-1542CF","aha1542cf", &aha1542cf_device, x54x_device_reset }, { "[ISA] BusLogic BT-542BH","bt542bh", &buslogic_device, BuslogicDeviceReset }, { "[ISA] BusLogic BT-545S", "bt545s", &buslogic_545s_device,BuslogicDeviceReset }, { "[ISA] Longshine LCS-6821N","lcs6821n", &scsi_lcs6821n_device,NULL }, { "[ISA] Ranco RT1000B", "rt1000b", &scsi_rt1000b_device, NULL }, { "[ISA] Trantor T130B", "t130b", &scsi_t130b_device, NULL }, { "[ISA] Sumo SCSI-AT", "scsiat", &scsi_scsiat_device, NULL }, #ifdef WALTJE_SCSI { "[ISA] Generic WDC33C93", "wd33c93", &scsi_wd33c93_device, NULL }, #endif { "[MCA] Adaptec AHA-1640", "aha1640", &aha1640_device, x54x_device_reset }, { "[MCA] BusLogic BT-640A", "bt640a", &buslogic_640a_device,BuslogicDeviceReset }, { "[PCI] BusLogic BT-958D", "bt958d", &buslogic_pci_device, BuslogicDeviceReset }, { "[PCI] NCR 53C810", "ncr53c810", &ncr53c810_pci_device,NULL }, { "[VLB] BusLogic BT-445S", "bt445s", &buslogic_445s_device,BuslogicDeviceReset }, { "", "", NULL, NULL }, }; int scsi_card_available(int card) { if (scsi_cards[card].device) return(device_available(scsi_cards[card].device)); return(1); } char * scsi_card_getname(int card) { return((char *)scsi_cards[card].name); } device_t * scsi_card_getdevice(int card) { return(scsi_cards[card].device); } int scsi_card_has_config(int card) { if (! scsi_cards[card].device) return(0); return(scsi_cards[card].device->config ? 1 : 0); } char * scsi_card_get_internal_name(int card) { return((char *)scsi_cards[card].internal_name); } int scsi_card_get_from_internal_name(char *s) { int c = 0; while (strlen((char *)scsi_cards[c].internal_name)) { if (! strcmp((char *)scsi_cards[c].internal_name, s)) return(c); c++; } return(0); } void scsi_mutex(uint8_t start) { if (start) scsiMutex = thread_create_mutex(L"VARCem.SCSIMutex"); else thread_close_mutex((mutex_t *) scsiMutex); } void scsi_card_init(void) { int i, j; pclog("Building SCSI hard disk map...\n"); build_scsi_hd_map(); pclog("Building SCSI CD-ROM map...\n"); build_scsi_cdrom_map(); pclog("Building SCSI ZIP map...\n"); build_scsi_zip_map(); for (i=0; i