2017-06-14 03:03:29 +02:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2020-03-25 00:46:02 +02:00
|
|
|
*
|
2017-06-14 03:03:29 +02:00
|
|
|
*
|
2017-12-15 00:46:37 -05:00
|
|
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
2017-08-22 21:28:22 +02:00
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
2017-12-15 00:46:37 -05:00
|
|
|
* TheCollector1995, <mariogplayer@gmail.com>
|
2017-10-14 20:04:21 -04:00
|
|
|
*
|
2018-01-26 22:17:09 +01:00
|
|
|
* Copyright 2016-2018 Miran Grca.
|
|
|
|
|
* Copyright 2017,2018 Fred N. van Kempen.
|
2017-06-14 03:03:29 +02:00
|
|
|
*/
|
2018-05-21 19:04:05 +02:00
|
|
|
#include <stdarg.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdint.h>
|
2018-05-21 19:04:05 +02:00
|
|
|
#include <stdio.h>
|
2016-11-12 15:06:38 +01:00
|
|
|
#include <string.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <wchar.h>
|
2018-05-21 19:04:05 +02:00
|
|
|
#define HAVE_STDARG_H
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/86box.h>
|
|
|
|
|
#include <86box/device.h>
|
2021-07-22 20:13:44 +02:00
|
|
|
#include <86box/machine.h>
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/hdc.h>
|
|
|
|
|
#include <86box/hdd.h>
|
|
|
|
|
#include <86box/plat.h>
|
|
|
|
|
#include <86box/scsi.h>
|
|
|
|
|
#include <86box/scsi_device.h>
|
|
|
|
|
#include <86box/cdrom.h>
|
|
|
|
|
#include <86box/zip.h>
|
|
|
|
|
#include <86box/scsi_disk.h>
|
|
|
|
|
#include <86box/scsi_aha154x.h>
|
|
|
|
|
#include <86box/scsi_buslogic.h>
|
|
|
|
|
#include <86box/scsi_ncr5380.h>
|
|
|
|
|
#include <86box/scsi_ncr53c8xx.h>
|
2020-09-02 17:50:24 +02:00
|
|
|
#include <86box/scsi_pcscsi.h>
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/scsi_spock.h>
|
2017-12-15 01:04:01 -05:00
|
|
|
#ifdef WALTJE
|
|
|
|
|
# include "scsi_wd33c93.h"
|
|
|
|
|
#endif
|
2017-05-05 01:49:42 +02:00
|
|
|
|
|
|
|
|
|
2021-07-22 20:13:44 +02:00
|
|
|
int scsi_card_current[SCSI_BUS_MAX] = { 0, 0 };
|
|
|
|
|
|
|
|
|
|
static uint8_t next_scsi_bus = 0;
|
2017-05-05 01:49:42 +02:00
|
|
|
|
|
|
|
|
|
2022-02-02 17:48:04 -05:00
|
|
|
static const device_t scsi_none_device = {
|
2022-03-13 09:54:10 -04:00
|
|
|
.name = "None",
|
|
|
|
|
.internal_name = "none",
|
|
|
|
|
.flags = 0,
|
|
|
|
|
.local = 0,
|
|
|
|
|
.init = NULL,
|
|
|
|
|
.close = NULL,
|
|
|
|
|
.reset = NULL,
|
|
|
|
|
{ .available = NULL },
|
|
|
|
|
.speed_changed = NULL,
|
|
|
|
|
.force_redraw = NULL,
|
|
|
|
|
.config = NULL
|
2022-02-02 17:48:04 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
typedef const struct {
|
|
|
|
|
const device_t *device;
|
2017-05-05 01:49:42 +02:00
|
|
|
} SCSI_CARD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static SCSI_CARD scsi_cards[] = {
|
2022-03-13 09:54:10 -04:00
|
|
|
// clang-format off
|
|
|
|
|
{ &scsi_none_device, },
|
|
|
|
|
{ &aha154xa_device, },
|
|
|
|
|
{ &aha154xb_device, },
|
|
|
|
|
{ &aha154xc_device, },
|
|
|
|
|
{ &aha154xcf_device, },
|
|
|
|
|
{ &aha154xcp_device, },
|
|
|
|
|
{ &buslogic_542b_device, },
|
|
|
|
|
{ &buslogic_542bh_device, },
|
|
|
|
|
{ &buslogic_545s_device, },
|
|
|
|
|
{ &buslogic_545c_device, },
|
|
|
|
|
{ &scsi_ls2000_device, },
|
|
|
|
|
{ &scsi_lcs6821n_device, },
|
|
|
|
|
{ &scsi_rt1000b_device, },
|
|
|
|
|
{ &scsi_t128_device, },
|
|
|
|
|
{ &scsi_t130b_device, },
|
2017-12-15 00:46:37 -05:00
|
|
|
#ifdef WALTJE
|
2022-03-13 09:54:10 -04:00
|
|
|
{ &scsi_wd33c93_device, },
|
2017-12-15 00:46:37 -05:00
|
|
|
#endif
|
2022-03-13 09:54:10 -04:00
|
|
|
{ &aha1640_device, },
|
|
|
|
|
{ &buslogic_640a_device, },
|
|
|
|
|
{ &ncr53c90_mca_device, },
|
|
|
|
|
{ &spock_device, },
|
|
|
|
|
{ &buslogic_958d_pci_device, },
|
|
|
|
|
{ &ncr53c810_pci_device, },
|
|
|
|
|
{ &ncr53c815_pci_device, },
|
|
|
|
|
{ &ncr53c820_pci_device, },
|
|
|
|
|
{ &ncr53c825a_pci_device, },
|
|
|
|
|
{ &ncr53c860_pci_device, },
|
|
|
|
|
{ &ncr53c875_pci_device, },
|
|
|
|
|
{ &dc390_pci_device, },
|
|
|
|
|
{ &buslogic_445s_device, },
|
|
|
|
|
{ &buslogic_445c_device, },
|
|
|
|
|
{ NULL, },
|
|
|
|
|
// clang-format on
|
2017-05-05 01:49:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-07-22 20:13:44 +02:00
|
|
|
void
|
|
|
|
|
scsi_reset(void)
|
|
|
|
|
{
|
|
|
|
|
next_scsi_bus = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t
|
|
|
|
|
scsi_get_bus(void)
|
|
|
|
|
{
|
|
|
|
|
uint8_t ret = next_scsi_bus;
|
|
|
|
|
|
|
|
|
|
if (next_scsi_bus >= SCSI_BUS_MAX)
|
|
|
|
|
return 0xff;
|
|
|
|
|
|
|
|
|
|
next_scsi_bus++;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 21:59:45 +02:00
|
|
|
int
|
|
|
|
|
scsi_card_available(int card)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
if (scsi_cards[card].device)
|
|
|
|
|
return(device_available(scsi_cards[card].device));
|
|
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 21:59:45 +02:00
|
|
|
const device_t *
|
|
|
|
|
scsi_card_getdevice(int card)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
return(scsi_cards[card].device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 21:59:45 +02:00
|
|
|
int
|
|
|
|
|
scsi_card_has_config(int card)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
if (! scsi_cards[card].device) return(0);
|
|
|
|
|
|
2022-04-04 18:16:53 +02:00
|
|
|
return(device_had_config(scsi_cards[card].device) ? 1 : 0);
|
2017-05-05 01:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 21:59:45 +02:00
|
|
|
char *
|
|
|
|
|
scsi_card_get_internal_name(int card)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
2022-02-03 03:10:06 +01:00
|
|
|
return device_get_internal_name(scsi_cards[card].device);
|
2017-05-05 01:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 21:59:45 +02:00
|
|
|
int
|
|
|
|
|
scsi_card_get_from_internal_name(char *s)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
int c = 0;
|
|
|
|
|
|
2022-02-03 03:10:06 +01:00
|
|
|
while (scsi_cards[c].device != NULL) {
|
2022-01-31 16:14:36 -05:00
|
|
|
if (!strcmp((char *) scsi_cards[c].device->internal_name, s))
|
2017-05-05 01:49:42 +02:00
|
|
|
return(c);
|
|
|
|
|
c++;
|
|
|
|
|
}
|
2022-02-20 02:26:27 -05:00
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-23 17:11:59 +01:00
|
|
|
|
2020-06-14 21:59:45 +02:00
|
|
|
void
|
|
|
|
|
scsi_card_init(void)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
2021-07-22 20:13:44 +02:00
|
|
|
int i = 0, max = SCSI_BUS_MAX;
|
2018-04-25 23:51:13 +02:00
|
|
|
|
2021-07-22 20:13:44 +02:00
|
|
|
/* On-board SCSI controllers get the first bus, so if one is present,
|
|
|
|
|
increase our instance number here. */
|
2021-12-13 01:23:06 +01:00
|
|
|
if (machine_has_flags(machine, MACHINE_SCSI))
|
2021-07-22 20:13:44 +02:00
|
|
|
max--;
|
2017-05-05 01:49:42 +02:00
|
|
|
|
2021-07-22 20:13:44 +02:00
|
|
|
/* Do not initialize any controllers if we have do not have any SCSI
|
|
|
|
|
bus left. */
|
|
|
|
|
if (max > 0) {
|
|
|
|
|
for (i = 0; i < max; i++) {
|
|
|
|
|
if (!scsi_cards[scsi_card_current[i]].device)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
device_add_inst(scsi_cards[scsi_card_current[i]].device, i + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-05 01:49:42 +02:00
|
|
|
}
|