This commit is contained in:
waltje
2017-06-14 00:56:47 -04:00
13 changed files with 161 additions and 45 deletions

View File

@@ -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)

View File

@@ -1,4 +1,4 @@
/* Copyright holders: The DOSBox Team, SA1988
/* Copyright holders: Sarah Walker, SA1988
see COPYING for more details
*/
#include "dbopl.h"

View File

@@ -1,4 +1,4 @@
/* Copyright holders: The DOSBox Team, SA1988
/* Copyright holders: Sarah Walker, SA1988
see COPYING for more details
*/
#ifdef __cplusplus

View File

@@ -1856,7 +1856,7 @@ int cdrom_read_blocks(uint8_t id, uint32_t *len, int first_batch)
}
else
{
type = 2;
type = 8;
flags = 0x10;
}

View File

@@ -447,7 +447,7 @@ static int image_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ism
if (cdrom_image[id].image_is_iso)
{
audio = 0;
mode2 = 0;
mode2 = cdimg[id]->IsMode2(real_pos) ? 1 : 0;
}
else
{
@@ -464,7 +464,7 @@ static int image_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ism
return 0;
}
if ((cdrom_sector_type == 3) || (cdrom_sector_type > 4))
if ((cdrom_sector_type == 3) || ((cdrom_sector_type > 4) && (cdrom_sector_type != 8)))
{
if (cdrom_sector_type == 3)
{
@@ -589,7 +589,7 @@ read_mode1:
}
else if (cdrom_sector_type == 4)
{
if (audio || !mode2 || cdrom_image[id].image_is_iso)
if (audio || !mode2)
{
cdrom_image_log("CD-ROM %i: [XA Mode 2 Form 1] Attempting to read a non-XA Mode 2 Form 1 sector from an audio track\n", id);
return 0;
@@ -626,7 +626,31 @@ read_mode2:
return 0;
}
cdimg[id]->ReadSector(cdrom_sector_buffer.buffer, true, real_pos);
if (cdrom_image[id].image_is_iso)
{
cdimg[id]->ReadSector(raw_buffer + 24, false, real_pos);
uint8_t *bb = raw_buffer;
/* sync bytes */
bb[0] = 0;
memset(bb + 1, 0xff, 10);
bb[11] = 0;
bb += 12;
bb[0] = (real_pos >> 16) & 0xff;
bb[1] = (real_pos >> 8) & 0xff;
bb[2] = real_pos & 0xff;
bb[3] = 1; /* mode 1 data */
bb += 12;
bb += 2048;
memset(bb, 0, 280);
}
else
{
cdimg[id]->ReadSector(raw_buffer, true, real_pos);
}
cdrom_sector_size = 0;
@@ -671,6 +695,23 @@ read_mode2:
temp_b += 280;
}
}
else if (cdrom_sector_type == 8)
{
if (audio)
{
cdrom_image_log("CD-ROM %i: [Any Data] Attempting to read a data sector from an audio track\n", id);
return 0;
}
if (mode2)
{
goto read_mode2;
}
else
{
goto read_mode1;
}
}
else
{
if (mode2)

View File

@@ -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

View File

@@ -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);

View File

@@ -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, <decwiz@yahoo.com>
* Original Buslogic version by SA1988 and Miran Grca.
* Copyright 2017 Fred N. van Kempen.
*/
#include <stdlib.h>
#include <string.h>
#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)
{

View File

@@ -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];

View File

@@ -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, <decwiz@yahoo.com>
* 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)
{

View File

@@ -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*/

View File

@@ -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, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -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)
{

View File

@@ -23,6 +23,8 @@
extern device_t buslogic_device;
extern device_t buslogic_pci_device;
extern void BuslogicDeviceReset(void *p);
#endif /*SCSI_BUSLOGIC_H*/