clang-format in src/disk/

This commit is contained in:
Jasmine Iwanek
2022-09-18 17:13:50 -04:00
parent 9a3cabbe85
commit 696f6f7e2f
17 changed files with 8516 additions and 8938 deletions

View File

@@ -29,14 +29,11 @@
#include <86box/hdc_ide.h> #include <86box/hdc_ide.h>
#include <86box/hdd.h> #include <86box/hdd.h>
int hdc_current; int hdc_current;
#ifdef ENABLE_HDC_LOG #ifdef ENABLE_HDC_LOG
int hdc_do_log = ENABLE_HDC_LOG; int hdc_do_log = ENABLE_HDC_LOG;
static void static void
hdc_log(const char *fmt, ...) hdc_log(const char *fmt, ...)
{ {
@@ -146,7 +143,6 @@ hdc_init(void)
hdd_image_init(); hdd_image_init();
} }
/* Reset the HDC, whichever one that is. */ /* Reset the HDC, whichever one that is. */
void void
hdc_reset(void) hdc_reset(void)
@@ -165,14 +161,12 @@ hdc_reset(void)
device_add(&ide_qua_device); device_add(&ide_qua_device);
} }
char * char *
hdc_get_internal_name(int hdc) hdc_get_internal_name(int hdc)
{ {
return device_get_internal_name(controllers[hdc].device); return device_get_internal_name(controllers[hdc].device);
} }
int int
hdc_get_from_internal_name(char *s) hdc_get_from_internal_name(char *s)
{ {
@@ -187,34 +181,32 @@ hdc_get_from_internal_name(char *s)
return 0; return 0;
} }
const device_t * const device_t *
hdc_get_device(int hdc) hdc_get_device(int hdc)
{ {
return (controllers[hdc].device); return (controllers[hdc].device);
} }
int int
hdc_has_config(int hdc) hdc_has_config(int hdc)
{ {
const device_t *dev = hdc_get_device(hdc); const device_t *dev = hdc_get_device(hdc);
if (dev == NULL) return(0); if (dev == NULL)
return (0);
if (!device_has_config(dev)) return(0); if (!device_has_config(dev))
return (0);
return (1); return (1);
} }
int int
hdc_get_flags(int hdc) hdc_get_flags(int hdc)
{ {
return (controllers[hdc].device->flags); return (controllers[hdc].device->flags);
} }
int int
hdc_available(int hdc) hdc_available(int hdc)
{ {

View File

@@ -40,7 +40,6 @@
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdd.h> #include <86box/hdd.h>
#define HDC_TIME 10.0 #define HDC_TIME 10.0
#define BIOS_FILE "roms/hdd/esdi_at/62-000279-061.bin" #define BIOS_FILE "roms/hdd/esdi_at/62-000279-061.bin"
@@ -71,7 +70,6 @@
#define CMD_SET_PARAMETERS 0x91 #define CMD_SET_PARAMETERS 0x91
#define CMD_READ_PARAMETERS 0xec #define CMD_READ_PARAMETERS 0xec
typedef struct { typedef struct {
int cfg_spt; int cfg_spt;
int cfg_hpc; int cfg_hpc;
@@ -103,15 +101,12 @@ typedef struct {
rom_t bios_rom; rom_t bios_rom;
} esdi_t; } esdi_t;
static uint8_t esdi_read(uint16_t port, void *priv); static uint8_t esdi_read(uint16_t port, void *priv);
static void esdi_write(uint16_t port, uint8_t val, void *priv); static void esdi_write(uint16_t port, uint8_t val, void *priv);
#ifdef ENABLE_ESDI_AT_LOG #ifdef ENABLE_ESDI_AT_LOG
int esdi_at_do_log = ENABLE_ESDI_AT_LOG; int esdi_at_do_log = ENABLE_ESDI_AT_LOG;
static void static void
esdi_at_log(const char *fmt, ...) esdi_at_log(const char *fmt, ...)
{ {
@@ -127,7 +122,6 @@ esdi_at_log(const char *fmt, ...)
# define esdi_at_log(fmt, ...) # define esdi_at_log(fmt, ...)
#endif #endif
static __inline void static __inline void
irq_raise(esdi_t *esdi) irq_raise(esdi_t *esdi)
{ {
@@ -137,14 +131,12 @@ irq_raise(esdi_t *esdi)
esdi->irqstat = 1; esdi->irqstat = 1;
} }
static __inline void static __inline void
irq_lower(esdi_t *esdi) irq_lower(esdi_t *esdi)
{ {
picintc(1 << 14); picintc(1 << 14);
} }
static __inline void static __inline void
irq_update(esdi_t *esdi) irq_update(esdi_t *esdi)
{ {
@@ -195,16 +187,14 @@ get_sector(esdi_t *esdi, off64_t *addr)
sector = esdi->sector ? esdi->sector : 1; sector = esdi->sector ? esdi->sector : 1;
if (drive->cfg_spt == drive->real_spt && drive->cfg_hpc == drive->real_hpc) { if (drive->cfg_spt == drive->real_spt && drive->cfg_hpc == drive->real_hpc) {
*addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) * *addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) * sectors) + (sector - 1);
sectors) + (sector - 1);
} else { } else {
/* /*
* When performing translation, the firmware seems to leave 1 * When performing translation, the firmware seems to leave 1
* sector per track inaccessible (spare sector) * sector per track inaccessible (spare sector)
*/ */
*addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) * *addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) * sectors) + (sector - 1);
sectors) + (sector - 1);
s = *addr % (drive->real_spt - 1); s = *addr % (drive->real_spt - 1);
h = (*addr / (drive->real_spt - 1)) % drive->real_hpc; h = (*addr / (drive->real_spt - 1)) % drive->real_hpc;
@@ -216,7 +206,6 @@ get_sector(esdi_t *esdi, off64_t *addr)
return (0); return (0);
} }
/* Move to the next sector using CHS addressing. */ /* Move to the next sector using CHS addressing. */
static void static void
next_sector(esdi_t *esdi) next_sector(esdi_t *esdi)
@@ -235,7 +224,6 @@ next_sector(esdi_t *esdi)
} }
} }
static void static void
esdi_writew(uint16_t port, uint16_t val, void *priv) esdi_writew(uint16_t port, uint16_t val, void *priv)
{ {
@@ -261,7 +249,6 @@ esdi_writew(uint16_t port, uint16_t val, void *priv)
} }
} }
static void static void
esdi_write(uint16_t port, uint8_t val, void *priv) esdi_write(uint16_t port, uint8_t val, void *priv)
{ {
@@ -429,7 +416,6 @@ esdi_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static uint16_t static uint16_t
esdi_readw(uint16_t port, void *priv) esdi_readw(uint16_t port, void *priv)
{ {
@@ -469,7 +455,6 @@ esdi_readw(uint16_t port, void *priv)
return (temp); return (temp);
} }
static uint8_t static uint8_t
esdi_read(uint16_t port, void *priv) esdi_read(uint16_t port, void *priv)
{ {
@@ -516,7 +501,6 @@ esdi_read(uint16_t port, void *priv)
return (temp); return (temp);
} }
static void static void
esdi_callback(void *priv) esdi_callback(void *priv)
{ {
@@ -802,7 +786,6 @@ esdi_callback(void *priv)
} }
} }
static void static void
loadhd(esdi_t *esdi, int hdd_num, int d, const char *fn) loadhd(esdi_t *esdi, int hdd_num, int d, const char *fn)
{ {
@@ -823,7 +806,6 @@ loadhd(esdi_t *esdi, int hdd_num, int d, const char *fn)
drive->present = 1; drive->present = 1;
} }
static void static void
esdi_rom_write(uint32_t addr, uint8_t val, void *p) esdi_rom_write(uint32_t addr, uint8_t val, void *p)
{ {
@@ -835,7 +817,6 @@ esdi_rom_write(uint32_t addr, uint8_t val, void *p)
rom->rom[addr] = val; rom->rom[addr] = val;
} }
static void * static void *
wd1007vse1_init(const device_t *info) wd1007vse1_init(const device_t *info)
{ {
@@ -849,7 +830,8 @@ wd1007vse1_init(const device_t *info)
if ((hdd[d].bus == HDD_BUS_ESDI) && (hdd[d].esdi_channel < ESDI_NUM)) { if ((hdd[d].bus == HDD_BUS_ESDI) && (hdd[d].esdi_channel < ESDI_NUM)) {
loadhd(esdi, hdd[d].esdi_channel, d, hdd[d].fn); loadhd(esdi, hdd[d].esdi_channel, d, hdd[d].fn);
if (++c >= ESDI_NUM) break; if (++c >= ESDI_NUM)
break;
} }
} }
@@ -879,7 +861,6 @@ wd1007vse1_init(const device_t *info)
return (esdi); return (esdi);
} }
static void static void
wd1007vse1_close(void *priv) wd1007vse1_close(void *priv)
{ {
@@ -898,7 +879,6 @@ wd1007vse1_close(void *priv)
ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 0); ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 0);
} }
static int static int
wd1007vse1_available(void) wd1007vse1_available(void)
{ {

View File

@@ -46,7 +46,6 @@
#include <86box/zip.h> #include <86box/zip.h>
#include <86box/version.h> #include <86box/version.h>
/* Bits of 'atastat' */ /* Bits of 'atastat' */
#define ERR_STAT 0x01 /* Error */ #define ERR_STAT 0x01 /* Error */
#define IDX_STAT 0x02 /* Index */ #define IDX_STAT 0x02 /* Index */
@@ -110,7 +109,6 @@
#define IDE_TIME 10.0 #define IDE_TIME 10.0
typedef struct { typedef struct {
int bit32, cur_dev, int bit32, cur_dev,
irq, inited, irq, inited,
@@ -182,11 +180,9 @@ int ide_ter_enabled = 0, ide_qua_enabled = 0;
static void ide_atapi_callback(ide_t *ide); static void ide_atapi_callback(ide_t *ide);
static void ide_callback(void *priv); static void ide_callback(void *priv);
#ifdef ENABLE_IDE_LOG #ifdef ENABLE_IDE_LOG
int ide_do_log = ENABLE_IDE_LOG; int ide_do_log = ENABLE_IDE_LOG;
static void static void
ide_log(const char *fmt, ...) ide_log(const char *fmt, ...)
{ {
@@ -202,13 +198,12 @@ ide_log(const char *fmt, ...)
# define ide_log(fmt, ...) # define ide_log(fmt, ...)
#endif #endif
uint8_t uint8_t
getstat(ide_t *ide) { getstat(ide_t *ide)
{
return ide->atastat; return ide->atastat;
} }
ide_t * ide_t *
ide_get_drive(int ch) ide_get_drive(int ch)
{ {
@@ -218,7 +213,6 @@ ide_get_drive(int ch)
return ide_drives[ch]; return ide_drives[ch];
} }
double double
ide_get_xfer_time(ide_t *ide, int size) ide_get_xfer_time(ide_t *ide, int size)
{ {
@@ -300,7 +294,6 @@ ide_get_xfer_time(ide_t *ide, int size)
return period * ((double) size); /* multiply by bytes to get period for the entire transfer */ return period * ((double) size); /* multiply by bytes to get period for the entire transfer */
} }
double double
ide_atapi_get_period(uint8_t channel) ide_atapi_get_period(uint8_t channel)
{ {
@@ -316,7 +309,6 @@ ide_atapi_get_period(uint8_t channel)
return ide_get_xfer_time(ide, 1); return ide_get_xfer_time(ide, 1);
} }
void void
ide_irq_raise(ide_t *ide) ide_irq_raise(ide_t *ide)
{ {
@@ -338,7 +330,6 @@ ide_irq_raise(ide_t *ide)
ide->service = 1; ide->service = 1;
} }
void void
ide_irq_lower(ide_t *ide) ide_irq_lower(ide_t *ide)
{ {
@@ -359,7 +350,6 @@ ide_irq_lower(ide_t *ide)
ide->irqstat = 0; ide->irqstat = 0;
} }
static void static void
ide_irq_update(ide_t *ide) ide_irq_update(ide_t *ide)
{ {
@@ -386,7 +376,6 @@ ide_irq_update(ide_t *ide)
} }
} }
/** /**
* Copy a string into a buffer, padding with spaces, and placing characters as * Copy a string into a buffer, padding with spaces, and placing characters as
* if they were packed into 16-bit values, stored little-endian. * if they were packed into 16-bit values, stored little-endian.
@@ -410,7 +399,6 @@ ide_padstr(char *str, const char *src, int len)
} }
} }
/** /**
* Copy a string into a buffer, padding with spaces. Does not add string * Copy a string into a buffer, padding with spaces. Does not add string
* terminator. * terminator.
@@ -420,7 +408,8 @@ ide_padstr(char *str, const char *src, int len)
* this length will be padded with spaces. * this length will be padded with spaces.
* @param src Source string * @param src Source string
*/ */
void ide_padstr8(uint8_t *buf, int buf_size, const char *src) void
ide_padstr8(uint8_t *buf, int buf_size, const char *src)
{ {
int i; int i;
@@ -432,7 +421,6 @@ void ide_padstr8(uint8_t *buf, int buf_size, const char *src)
} }
} }
static int static int
ide_get_max(ide_t *ide, int type) ide_get_max(ide_t *ide, int type)
{ {
@@ -466,7 +454,6 @@ ide_get_max(ide_t *ide, int type)
} }
} }
static int static int
ide_get_timings(ide_t *ide, int type) ide_get_timings(ide_t *ide, int type)
{ {
@@ -492,11 +479,11 @@ ide_get_timings(ide_t *ide, int type)
} }
} }
/** /**
* Fill in ide->buffer with the output of the "IDENTIFY DEVICE" command * Fill in ide->buffer with the output of the "IDENTIFY DEVICE" command
*/ */
static void ide_hd_identify(ide_t *ide) static void
ide_hd_identify(ide_t *ide)
{ {
char device_identify[9] = { '8', '6', 'B', '_', 'H', 'D', '0', '0', 0 }; char device_identify[9] = { '8', '6', 'B', '_', 'H', 'D', '0', '0', 0 };
@@ -586,7 +573,6 @@ static void ide_hd_identify(ide_t *ide)
} }
} }
static void static void
ide_identify(ide_t *ide) ide_identify(ide_t *ide)
{ {
@@ -681,7 +667,6 @@ ide_identify(ide_t *ide)
} }
} }
/* /*
* Return the sector offset for the current register values * Return the sector offset for the current register values
*/ */
@@ -698,12 +683,10 @@ ide_get_sector(ide_t *ide)
uint8_t sector = ide->sector ? ide->sector : 1; uint8_t sector = ide->sector ? ide->sector : 1;
return ((((off64_t) ide->cylinder * heads) + ide->head) * return ((((off64_t) ide->cylinder * heads) + ide->head) * sectors) + (sector - 1);
sectors) + (sector - 1);
} }
} }
/** /**
* Move to the next sector using CHS addressing * Move to the next sector using CHS addressing
*/ */
@@ -725,7 +708,6 @@ ide_next_sector(ide_t *ide)
} }
} }
static void static void
loadhd(ide_t *ide, int d, const char *fn) loadhd(ide_t *ide, int d, const char *fn)
{ {
@@ -743,7 +725,6 @@ loadhd(ide_t *ide, int d, const char *fn)
ide->hdd_num = d; ide->hdd_num = d;
} }
void void
ide_set_signature(ide_t *ide) ide_set_signature(ide_t *ide)
{ {
@@ -763,7 +744,6 @@ ide_set_signature(ide_t *ide)
} }
} }
static int static int
ide_set_features(ide_t *ide) ide_set_features(ide_t *ide)
{ {
@@ -851,7 +831,6 @@ ide_set_features(ide_t *ide)
return 1; return 1;
} }
void void
ide_set_sector(ide_t *ide, int64_t sector_num) ide_set_sector(ide_t *ide, int64_t sector_num)
{ {
@@ -869,7 +848,6 @@ ide_set_sector(ide_t *ide, int64_t sector_num)
} }
} }
static void static void
ide_zero(int d) ide_zero(int d)
{ {
@@ -889,7 +867,6 @@ ide_zero(int d)
timer_add(&dev->timer, ide_callback, dev, 0); timer_add(&dev->timer, ide_callback, dev, 0);
} }
void void
ide_allocate_buffer(ide_t *dev) ide_allocate_buffer(ide_t *dev)
{ {
@@ -898,7 +875,6 @@ ide_allocate_buffer(ide_t *dev)
memset(dev->buffer, 0, 65536 * sizeof(uint16_t)); memset(dev->buffer, 0, 65536 * sizeof(uint16_t));
} }
void void
ide_atapi_attach(ide_t *ide) ide_atapi_attach(ide_t *ide)
{ {
@@ -913,7 +889,6 @@ ide_atapi_attach(ide_t *ide)
ide->cfg_spt = ide->cfg_hpc = 0; ide->cfg_spt = ide->cfg_hpc = 0;
} }
void void
ide_set_callback(ide_t *ide, double callback) ide_set_callback(ide_t *ide, double callback)
{ {
@@ -931,7 +906,6 @@ ide_set_callback(ide_t *ide, double callback)
timer_on_auto(&ide->timer, callback); timer_on_auto(&ide->timer, callback);
} }
void void
ide_set_board_callback(uint8_t board, double callback) ide_set_board_callback(uint8_t board, double callback)
{ {
@@ -950,7 +924,6 @@ ide_set_board_callback(uint8_t board, double callback)
timer_on_auto(&dev->timer, callback); timer_on_auto(&dev->timer, callback);
} }
static void static void
ide_atapi_command_bus(ide_t *ide) ide_atapi_command_bus(ide_t *ide)
{ {
@@ -961,7 +934,6 @@ ide_atapi_command_bus(ide_t *ide)
ide_set_callback(ide, ide->sc->callback); ide_set_callback(ide, ide->sc->callback);
} }
static void static void
ide_atapi_callback(ide_t *ide) ide_atapi_callback(ide_t *ide)
{ {
@@ -1053,7 +1025,6 @@ ide_atapi_callback(ide_t *ide)
} }
} }
/* This is the general ATAPI PIO request function. */ /* This is the general ATAPI PIO request function. */
static void static void
ide_atapi_pio_request(ide_t *ide, uint8_t out) ide_atapi_pio_request(ide_t *ide, uint8_t out)
@@ -1100,7 +1071,6 @@ ide_atapi_pio_request(ide_t *ide, uint8_t out)
} }
} }
static uint32_t static uint32_t
ide_atapi_packet_read(ide_t *ide, int length) ide_atapi_packet_read(ide_t *ide, int length)
{ {
@@ -1153,7 +1123,6 @@ ide_atapi_packet_read(ide_t *ide, int length)
return 0; return 0;
} }
static void static void
ide_atapi_packet_write(ide_t *ide, uint32_t val, int length) ide_atapi_packet_write(ide_t *ide, uint32_t val, int length)
{ {
@@ -1215,7 +1184,6 @@ ide_atapi_packet_write(ide_t *ide, uint32_t val, int length)
} }
} }
void void
ide_write_data(ide_t *ide, uint32_t val, int length) ide_write_data(ide_t *ide, uint32_t val, int length)
{ {
@@ -1267,7 +1235,6 @@ ide_write_data(ide_t *ide, uint32_t val, int length)
} }
} }
void void
ide_writew(uint16_t addr, uint16_t val, void *priv) ide_writew(uint16_t addr, uint16_t val, void *priv)
{ {
@@ -1300,7 +1267,6 @@ ide_writew(uint16_t addr, uint16_t val, void *priv)
} }
} }
static void static void
ide_writel(uint16_t addr, uint32_t val, void *priv) ide_writel(uint16_t addr, uint32_t val, void *priv)
{ {
@@ -1327,7 +1293,8 @@ ide_writel(uint16_t addr, uint32_t val, void *priv)
else else
ide_writew(addr + 2, (val >> 16) & 0xffff, priv); ide_writew(addr + 2, (val >> 16) & 0xffff, priv);
break; break;
case 0x6: case 0x7: case 0x6:
case 0x7:
ide_writew(addr, val & 0xffff, priv); ide_writew(addr, val & 0xffff, priv);
break; break;
default: default:
@@ -1337,7 +1304,6 @@ ide_writel(uint16_t addr, uint32_t val, void *priv)
} }
} }
static void static void
dev_reset(ide_t *ide) dev_reset(ide_t *ide)
{ {
@@ -1347,7 +1313,6 @@ dev_reset(ide_t *ide)
ide->stop(ide->sc); ide->stop(ide->sc);
} }
void void
ide_write_devctl(uint16_t addr, uint8_t val, void *priv) ide_write_devctl(uint16_t addr, uint8_t val, void *priv)
{ {
@@ -1450,7 +1415,6 @@ ide_write_devctl(uint16_t addr, uint8_t val, void *priv)
ide_irq_update(ide); ide_irq_update(ide);
} }
void void
ide_writeb(uint16_t addr, uint8_t val, void *priv) ide_writeb(uint16_t addr, uint8_t val, void *priv)
{ {
@@ -1713,15 +1677,13 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
} else } else
ide->atastat = BSY_STAT; ide->atastat = BSY_STAT;
if ((ide->type == IDE_HDD) && if ((ide->type == IDE_HDD) && ((val == WIN_WRITE_DMA) || (val == WIN_WRITE_DMA_ALT))) {
((val == WIN_WRITE_DMA) || (val == WIN_WRITE_DMA_ALT))) {
uint32_t sec_count = ide->secount ? ide->secount : 256; uint32_t sec_count = ide->secount ? ide->secount : 256;
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count); double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
double xfer_time = ide_get_xfer_time(ide, 512 * sec_count); double xfer_time = ide_get_xfer_time(ide, 512 * sec_count);
double wait_time = seek_time > xfer_time ? seek_time : xfer_time; double wait_time = seek_time > xfer_time ? seek_time : xfer_time;
ide_set_callback(ide, wait_time); ide_set_callback(ide, wait_time);
} else if ((ide->type == IDE_HDD) && } else if ((ide->type == IDE_HDD) && ((val == WIN_VERIFY) || (val == WIN_VERIFY_ONCE))) {
((val == WIN_VERIFY) || (val == WIN_VERIFY_ONCE))) {
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), ide->secount); double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), ide->secount);
ide_set_callback(ide, seek_time + ide_get_xfer_time(ide, 2)); ide_set_callback(ide, seek_time + ide_get_xfer_time(ide, 2));
} else if (val == WIN_IDENTIFY) } else if (val == WIN_IDENTIFY)
@@ -1830,7 +1792,6 @@ ide_bad_command:
} }
} }
static uint32_t static uint32_t
ide_read_data(ide_t *ide, int length) ide_read_data(ide_t *ide, int length)
{ {
@@ -1913,7 +1874,6 @@ ide_read_data(ide_t *ide, int length)
return temp; return temp;
} }
static uint8_t static uint8_t
ide_status(ide_t *ide, ide_t *ide_other, int ch) ide_status(ide_t *ide, ide_t *ide_other, int ch)
{ {
@@ -1931,7 +1891,6 @@ ide_status(ide_t *ide, ide_t *ide_other, int ch)
return ide->atastat; return ide->atastat;
} }
uint8_t uint8_t
ide_readb(uint16_t addr, void *priv) ide_readb(uint16_t addr, void *priv)
{ {
@@ -2026,7 +1985,6 @@ ide_readb(uint16_t addr, void *priv)
return temp; return temp;
} }
uint8_t uint8_t
ide_read_alt_status(uint16_t addr, void *priv) ide_read_alt_status(uint16_t addr, void *priv)
{ {
@@ -2048,7 +2006,6 @@ ide_read_alt_status(uint16_t addr, void *priv)
return temp; return temp;
} }
uint16_t uint16_t
ide_readw(uint16_t addr, void *priv) ide_readw(uint16_t addr, void *priv)
{ {
@@ -2078,7 +2035,6 @@ ide_readw(uint16_t addr, void *priv)
return temp; return temp;
} }
static uint32_t static uint32_t
ide_readl(uint16_t addr, void *priv) ide_readl(uint16_t addr, void *priv)
{ {
@@ -2101,7 +2057,8 @@ ide_readl(uint16_t addr, void *priv)
else else
temp = temp2 | (ide_readw(addr + 2, priv) << 16); temp = temp2 | (ide_readw(addr + 2, priv) << 16);
break; break;
case 0x6: case 0x7: case 0x6:
case 0x7:
temp = ide_readw(addr, priv) | 0xffff0000; temp = ide_readw(addr, priv) | 0xffff0000;
break; break;
default: default:
@@ -2113,7 +2070,6 @@ ide_readl(uint16_t addr, void *priv)
return temp; return temp;
} }
static void static void
ide_board_callback(void *priv) ide_board_callback(void *priv)
{ {
@@ -2139,7 +2095,6 @@ ide_board_callback(void *priv)
} }
} }
static void static void
atapi_error_no_ready(ide_t *ide) atapi_error_no_ready(ide_t *ide)
{ {
@@ -2156,7 +2111,6 @@ atapi_error_no_ready(ide_t *ide)
ide_irq_raise(ide); ide_irq_raise(ide);
} }
static void static void
ide_callback(void *priv) ide_callback(void *priv)
{ {
@@ -2166,15 +2120,13 @@ ide_callback(void *priv)
ide_log("CALLBACK %02X %i %i\n", ide->command, ide->reset, ide->channel); ide_log("CALLBACK %02X %i %i\n", ide->command, ide->reset, ide->channel);
if (((ide->command >= WIN_RECAL) && (ide->command <= 0x1F)) || if (((ide->command >= WIN_RECAL) && (ide->command <= 0x1F)) || ((ide->command >= WIN_SEEK) && (ide->command <= 0x7F))) {
((ide->command >= WIN_SEEK) && (ide->command <= 0x7F))) {
if (ide->type != IDE_HDD) { if (ide->type != IDE_HDD) {
atapi_error_no_ready(ide); atapi_error_no_ready(ide);
return; return;
} }
if ((ide->command >= WIN_SEEK) && (ide->command <= 0x7F) && !ide->lba) { if ((ide->command >= WIN_SEEK) && (ide->command <= 0x7F) && !ide->lba) {
if ((ide->cylinder >= ide->tracks) || (ide->head >= ide->hpc) || if ((ide->cylinder >= ide->tracks) || (ide->head >= ide->hpc) || !ide->sector || (ide->sector > ide->spt))
!ide->sector || (ide->sector > ide->spt))
goto id_not_found; goto id_not_found;
} }
ide->atastat = DRDY_STAT | DSC_STAT; ide->atastat = DRDY_STAT | DSC_STAT;
@@ -2564,7 +2516,6 @@ id_not_found:
ide_irq_raise(ide); ide_irq_raise(ide);
} }
uint8_t uint8_t
ide_read_ali_75(void) ide_read_ali_75(void)
{ {
@@ -2589,7 +2540,6 @@ ide_read_ali_75(void)
return ret; return ret;
} }
uint8_t uint8_t
ide_read_ali_76(void) ide_read_ali_76(void)
{ {
@@ -2618,7 +2568,6 @@ ide_read_ali_76(void)
return ret; return ret;
} }
void void
ide_set_handlers(uint8_t board) ide_set_handlers(uint8_t board)
{ {
@@ -2640,7 +2589,6 @@ ide_set_handlers(uint8_t board)
} }
} }
void void
ide_remove_handlers(uint8_t board) ide_remove_handlers(uint8_t board)
{ {
@@ -2662,35 +2610,30 @@ ide_remove_handlers(uint8_t board)
} }
} }
void void
ide_pri_enable(void) ide_pri_enable(void)
{ {
ide_set_handlers(0); ide_set_handlers(0);
} }
void void
ide_pri_disable(void) ide_pri_disable(void)
{ {
ide_remove_handlers(0); ide_remove_handlers(0);
} }
void void
ide_sec_enable(void) ide_sec_enable(void)
{ {
ide_set_handlers(1); ide_set_handlers(1);
} }
void void
ide_sec_disable(void) ide_sec_disable(void)
{ {
ide_remove_handlers(1); ide_remove_handlers(1);
} }
void void
ide_set_base(int board, uint16_t port) ide_set_base(int board, uint16_t port)
{ {
@@ -2702,7 +2645,6 @@ ide_set_base(int board, uint16_t port)
ide_boards[board]->base_main = port; ide_boards[board]->base_main = port;
} }
void void
ide_set_side(int board, uint16_t port) ide_set_side(int board, uint16_t port)
{ {
@@ -2714,7 +2656,6 @@ ide_set_side(int board, uint16_t port)
ide_boards[board]->side_main = port; ide_boards[board]->side_main = port;
} }
static void static void
ide_clear_bus_master(int board) ide_clear_bus_master(int board)
{ {
@@ -2724,7 +2665,6 @@ ide_clear_bus_master(int board)
} }
} }
/* This so drives can be forced to ATA-3 (no DMA) for machines that hide the on-board PCI IDE controller /* This so drives can be forced to ATA-3 (no DMA) for machines that hide the on-board PCI IDE controller
(eg. Packard Bell PB640 and ASUS P/I-P54TP4XE), breaking DMA drivers unless this is done. */ (eg. Packard Bell PB640 and ASUS P/I-P54TP4XE), breaking DMA drivers unless this is done. */
extern void extern void
@@ -2738,7 +2678,6 @@ ide_board_set_force_ata3(int board, int force_ata3)
ide_boards[board]->force_ata3 = force_ata3; ide_boards[board]->force_ata3 = force_ata3;
} }
static void static void
ide_board_close(int board) ide_board_close(int board)
{ {
@@ -2793,7 +2732,6 @@ ide_board_close(int board)
ide_boards[board] = NULL; ide_boards[board] = NULL;
} }
static void static void
ide_board_setup(int board) ide_board_setup(int board)
{ {
@@ -2828,7 +2766,8 @@ ide_board_setup(int board)
if (ide_drives[ch]->sector_buffer == NULL) if (ide_drives[ch]->sector_buffer == NULL)
ide_drives[ch]->sector_buffer = (uint8_t *) malloc(256 * 512); ide_drives[ch]->sector_buffer = (uint8_t *) malloc(256 * 512);
memset(ide_drives[ch]->sector_buffer, 0, 256 * 512); memset(ide_drives[ch]->sector_buffer, 0, 256 * 512);
if (++c >= 2) break; if (++c >= 2)
break;
} }
} }
ide_log("IDE: board %i: done, loaded %d disks.\n", board, c); ide_log("IDE: board %i: done, loaded %d disks.\n", board, c);
@@ -2851,7 +2790,6 @@ ide_board_setup(int board)
} }
} }
static void static void
ide_board_init(int board, int irq, int base_main, int side_main, int type) ide_board_init(int board, int irq, int base_main, int side_main, int type)
{ {
@@ -2879,7 +2817,6 @@ ide_board_init(int board, int irq, int base_main, int side_main, int type)
ide_boards[board]->inited = 1; ide_boards[board]->inited = 1;
} }
void void
ide_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv) ide_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
{ {
@@ -2907,7 +2844,6 @@ ide_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
} }
} }
static void * static void *
ide_ter_init(const device_t *info) ide_ter_init(const device_t *info)
{ {
@@ -2932,7 +2868,6 @@ ide_ter_init(const device_t *info)
return (ide_boards[2]); return (ide_boards[2]);
} }
/* Close a standalone IDE unit. */ /* Close a standalone IDE unit. */
static void static void
ide_ter_close(void *priv) ide_ter_close(void *priv)
@@ -2940,7 +2875,6 @@ ide_ter_close(void *priv)
ide_board_close(2); ide_board_close(2);
} }
static void * static void *
ide_qua_init(const device_t *info) ide_qua_init(const device_t *info)
{ {
@@ -2965,7 +2899,6 @@ ide_qua_init(const device_t *info)
return (ide_boards[3]); return (ide_boards[3]);
} }
/* Close a standalone IDE unit. */ /* Close a standalone IDE unit. */
static void static void
ide_qua_close(void *priv) ide_qua_close(void *priv)
@@ -2973,7 +2906,6 @@ ide_qua_close(void *priv)
ide_board_close(3); ide_board_close(3);
} }
void * void *
ide_xtide_init(void) ide_xtide_init(void)
{ {
@@ -2982,14 +2914,12 @@ ide_xtide_init(void)
return ide_boards[0]; return ide_boards[0];
} }
void void
ide_xtide_close(void) ide_xtide_close(void)
{ {
ide_board_close(0); ide_board_close(0);
} }
void void
ide_set_bus_master(int board, ide_set_bus_master(int board,
int (*dma)(int channel, uint8_t *data, int transfer_length, int out, void *priv), int (*dma)(int channel, uint8_t *data, int transfer_length, int out, void *priv),
@@ -3003,7 +2933,6 @@ ide_set_bus_master(int board,
ide_bm[board]->priv = priv; ide_bm[board]->priv = priv;
} }
static void * static void *
ide_init(const device_t *info) ide_init(const device_t *info)
{ {
@@ -3026,7 +2955,6 @@ ide_init(const device_t *info)
return (ide_drives); return (ide_drives);
} }
static void static void
ide_drive_reset(int d) ide_drive_reset(int d)
{ {
@@ -3053,7 +2981,6 @@ ide_drive_reset(int d)
memset(ide_drives[d]->buffer, 0, 65536 * sizeof(uint16_t)); memset(ide_drives[d]->buffer, 0, 65536 * sizeof(uint16_t));
} }
static void static void
ide_board_reset(int board) ide_board_reset(int board)
{ {
@@ -3070,7 +2997,6 @@ ide_board_reset(int board)
ide_drive_reset(d); ide_drive_reset(d);
} }
/* Reset a standalone IDE unit. */ /* Reset a standalone IDE unit. */
static void static void
ide_reset(void *p) ide_reset(void *p)
@@ -3084,7 +3010,6 @@ ide_reset(void *p)
ide_board_reset(1); ide_board_reset(1);
} }
/* Close a standalone IDE unit. */ /* Close a standalone IDE unit. */
static void static void
ide_close(void *priv) ide_close(void *priv)

View File

@@ -37,7 +37,6 @@
#include <86box/zip.h> #include <86box/zip.h>
#include <86box/mo.h> #include <86box/mo.h>
typedef struct typedef struct
{ {
uint8_t vlb_idx, id, uint8_t vlb_idx, id,
@@ -48,10 +47,8 @@ typedef struct
irq_pin, irq_line; irq_pin, irq_line;
} cmd640_t; } cmd640_t;
static int next_id = 0; static int next_id = 0;
#ifdef ENABLE_CMD640_LOG #ifdef ENABLE_CMD640_LOG
int cmd640_do_log = ENABLE_CMD640_LOG; int cmd640_do_log = ENABLE_CMD640_LOG;
static void static void
@@ -59,8 +56,7 @@ cmd640_log(const char *fmt, ...)
{ {
va_list ap; va_list ap;
if (cmd640_do_log) if (cmd640_do_log) {
{
va_start(ap, fmt); va_start(ap, fmt);
pclog_ex(fmt, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
@@ -70,7 +66,6 @@ cmd640_log(const char *fmt, ...)
# define cmd640_log(fmt, ...) # define cmd640_log(fmt, ...)
#endif #endif
void void
cmd640_set_irq(int channel, void *priv) cmd640_set_irq(int channel, void *priv)
{ {
@@ -103,7 +98,6 @@ cmd640_set_irq(int channel, void *priv)
} }
} }
static void static void
cmd640_ide_handlers(cmd640_t *dev) cmd640_ide_handlers(cmd640_t *dev)
{ {
@@ -145,7 +139,6 @@ cmd640_ide_handlers(cmd640_t *dev)
ide_sec_enable(); ide_sec_enable();
} }
static void static void
cmd640_common_write(int addr, uint8_t val, cmd640_t *dev) cmd640_common_write(int addr, uint8_t val, cmd640_t *dev)
{ {
@@ -154,11 +147,15 @@ cmd640_common_write(int addr, uint8_t val, cmd640_t *dev)
dev->regs[addr] = val; dev->regs[addr] = val;
cmd640_ide_handlers(dev); cmd640_ide_handlers(dev);
break; break;
case 0x52: case 0x54: case 0x56: case 0x58: case 0x52:
case 0x54:
case 0x56:
case 0x58:
case 0x59: case 0x59:
dev->regs[addr] = val; dev->regs[addr] = val;
break; break;
case 0x53: case 0x55: case 0x53:
case 0x55:
dev->regs[addr] = val & 0xc0; dev->regs[addr] = val & 0xc0;
break; break;
case 0x57: case 0x57:
@@ -170,7 +167,6 @@ cmd640_common_write(int addr, uint8_t val, cmd640_t *dev)
} }
} }
static void static void
cmd640_vlb_write(uint16_t addr, uint8_t val, void *priv) cmd640_vlb_write(uint16_t addr, uint8_t val, void *priv)
{ {
@@ -193,7 +189,6 @@ cmd640_vlb_write(uint16_t addr, uint8_t val, void *priv)
} }
} }
static void static void
cmd640_vlb_writew(uint16_t addr, uint16_t val, void *priv) cmd640_vlb_writew(uint16_t addr, uint16_t val, void *priv)
{ {
@@ -201,7 +196,6 @@ cmd640_vlb_writew(uint16_t addr, uint16_t val, void *priv)
cmd640_vlb_write(addr + 1, val >> 8, priv); cmd640_vlb_write(addr + 1, val >> 8, priv);
} }
static void static void
cmd640_vlb_writel(uint16_t addr, uint32_t val, void *priv) cmd640_vlb_writel(uint16_t addr, uint32_t val, void *priv)
{ {
@@ -209,7 +203,6 @@ cmd640_vlb_writel(uint16_t addr, uint32_t val, void *priv)
cmd640_vlb_writew(addr + 2, val >> 16, priv); cmd640_vlb_writew(addr + 2, val >> 16, priv);
} }
static uint8_t static uint8_t
cmd640_vlb_read(uint16_t addr, void *priv) cmd640_vlb_read(uint16_t addr, void *priv)
{ {
@@ -237,7 +230,6 @@ cmd640_vlb_read(uint16_t addr, void *priv)
return ret; return ret;
} }
static uint16_t static uint16_t
cmd640_vlb_readw(uint16_t addr, void *priv) cmd640_vlb_readw(uint16_t addr, void *priv)
{ {
@@ -249,7 +241,6 @@ cmd640_vlb_readw(uint16_t addr, void *priv)
return ret; return ret;
} }
static uint32_t static uint32_t
cmd640_vlb_readl(uint16_t addr, void *priv) cmd640_vlb_readl(uint16_t addr, void *priv)
{ {
@@ -261,7 +252,6 @@ cmd640_vlb_readl(uint16_t addr, void *priv)
return ret; return ret;
} }
static void static void
cmd640_pci_write(int func, int addr, uint8_t val, void *priv) cmd640_pci_write(int func, int addr, uint8_t val, void *priv)
{ {
@@ -269,7 +259,8 @@ cmd640_pci_write(int func, int addr, uint8_t val, void *priv)
cmd640_log("cmd640_pci_write(%i, %02X, %02X)\n", func, addr, val); cmd640_log("cmd640_pci_write(%i, %02X, %02X)\n", func, addr, val);
if (func == 0x00) switch (addr) { if (func == 0x00)
switch (addr) {
case 0x04: case 0x04:
dev->regs[addr] = (val & 0x41); dev->regs[addr] = (val & 0x41);
cmd640_ide_handlers(dev); cmd640_ide_handlers(dev);
@@ -339,7 +330,6 @@ cmd640_pci_write(int func, int addr, uint8_t val, void *priv)
} }
} }
static uint8_t static uint8_t
cmd640_pci_read(int func, int addr, void *priv) cmd640_pci_read(int func, int addr, void *priv)
{ {
@@ -359,7 +349,6 @@ cmd640_pci_read(int func, int addr, void *priv)
return ret; return ret;
} }
static void static void
cmd640_reset(void *priv) cmd640_reset(void *priv)
{ {
@@ -367,18 +356,15 @@ cmd640_reset(void *priv)
int i = 0; int i = 0;
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && (cdrom[i].ide_channel < 4) && cdrom[i].priv)
(cdrom[i].ide_channel < 4) && cdrom[i].priv)
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv); scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
} }
for (i = 0; i < ZIP_NUM; i++) { for (i = 0; i < ZIP_NUM; i++) {
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
(zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
zip_reset((scsi_common_t *) zip_drives[i].priv); zip_reset((scsi_common_t *) zip_drives[i].priv);
} }
for (i = 0; i < MO_NUM; i++) { for (i = 0; i < MO_NUM; i++) {
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
(mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
mo_reset((scsi_common_t *) mo_drives[i].priv); mo_reset((scsi_common_t *) mo_drives[i].priv);
} }
@@ -412,10 +398,14 @@ cmd640_reset(void *priv)
/* Base addresses (1F0, 3F4, 170, 374) */ /* Base addresses (1F0, 3F4, 170, 374) */
if (dev->regs[0x50] & 0x40) { if (dev->regs[0x50] & 0x40) {
dev->regs[0x10] = 0xf1; dev->regs[0x11] = 0x01; dev->regs[0x10] = 0xf1;
dev->regs[0x14] = 0xf5; dev->regs[0x15] = 0x03; dev->regs[0x11] = 0x01;
dev->regs[0x18] = 0x71; dev->regs[0x19] = 0x01; dev->regs[0x14] = 0xf5;
dev->regs[0x1c] = 0x75; dev->regs[0x1d] = 0x03; dev->regs[0x15] = 0x03;
dev->regs[0x18] = 0x71;
dev->regs[0x19] = 0x01;
dev->regs[0x1c] = 0x75;
dev->regs[0x1d] = 0x03;
} }
dev->regs[0x3c] = 0x14; /* IRQ 14 */ dev->regs[0x3c] = 0x14; /* IRQ 14 */
@@ -436,7 +426,6 @@ cmd640_reset(void *priv)
cmd640_ide_handlers(dev); cmd640_ide_handlers(dev);
} }
static void static void
cmd640_close(void *priv) cmd640_close(void *priv)
{ {
@@ -447,7 +436,6 @@ cmd640_close(void *priv)
next_id = 0; next_id = 0;
} }
static void * static void *
cmd640_init(const device_t *info) cmd640_init(const device_t *info)
{ {

View File

@@ -37,7 +37,6 @@
#include <86box/zip.h> #include <86box/zip.h>
#include <86box/mo.h> #include <86box/mo.h>
typedef struct typedef struct
{ {
uint8_t vlb_idx, single_channel, uint8_t vlb_idx, single_channel,
@@ -48,7 +47,6 @@ typedef struct
sff8038i_t *bm[2]; sff8038i_t *bm[2];
} cmd646_t; } cmd646_t;
#ifdef ENABLE_CMD646_LOG #ifdef ENABLE_CMD646_LOG
int cmd646_do_log = ENABLE_CMD646_LOG; int cmd646_do_log = ENABLE_CMD646_LOG;
static void static void
@@ -56,8 +54,7 @@ cmd646_log(const char *fmt, ...)
{ {
va_list ap; va_list ap;
if (cmd646_do_log) if (cmd646_do_log) {
{
va_start(ap, fmt); va_start(ap, fmt);
pclog_ex(fmt, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
@@ -67,7 +64,6 @@ cmd646_log(const char *fmt, ...)
# define cmd646_log(fmt, ...) # define cmd646_log(fmt, ...)
#endif #endif
static void static void
cmd646_set_irq(int channel, void *priv) cmd646_set_irq(int channel, void *priv)
{ {
@@ -88,7 +84,6 @@ cmd646_set_irq(int channel, void *priv)
sff_bus_master_set_irq(channel, dev->bm[channel & 0x01]); sff_bus_master_set_irq(channel, dev->bm[channel & 0x01]);
} }
static int static int
cmd646_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out, void *priv) cmd646_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out, void *priv)
{ {
@@ -97,7 +92,6 @@ cmd646_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out,
return sff_bus_master_dma(channel, data, transfer_length, out, dev->bm[channel & 0x01]); return sff_bus_master_dma(channel, data, transfer_length, out, dev->bm[channel & 0x01]);
} }
static void static void
cmd646_ide_handlers(cmd646_t *dev) cmd646_ide_handlers(cmd646_t *dev)
{ {
@@ -150,10 +144,8 @@ cmd646_ide_handlers(cmd646_t *dev)
if ((dev->regs[0x04] & 0x01) && (dev->regs[0x51] & 0x08)) if ((dev->regs[0x04] & 0x01) && (dev->regs[0x51] & 0x08))
ide_sec_enable(); ide_sec_enable();
} }
static void static void
cmd646_ide_bm_handlers(cmd646_t *dev) cmd646_ide_bm_handlers(cmd646_t *dev)
{ {
@@ -163,7 +155,6 @@ cmd646_ide_bm_handlers(cmd646_t *dev)
sff_bus_master_handler(dev->bm[1], (dev->regs[0x04] & 1), base + 8); sff_bus_master_handler(dev->bm[1], (dev->regs[0x04] & 1), base + 8);
} }
static void static void
cmd646_pci_write(int func, int addr, uint8_t val, void *priv) cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
{ {
@@ -171,7 +162,8 @@ cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
cmd646_log("[%04X:%08X] (%08X) cmd646_pci_write(%i, %02X, %02X)\n", CS, cpu_state.pc, ESI, func, addr, val); cmd646_log("[%04X:%08X] (%08X) cmd646_pci_write(%i, %02X, %02X)\n", CS, cpu_state.pc, ESI, func, addr, val);
if (func == 0x00) switch (addr) { if (func == 0x00)
switch (addr) {
case 0x04: case 0x04:
dev->regs[addr] = (val & 0x45); dev->regs[addr] = (val & 0x45);
cmd646_ide_handlers(dev); cmd646_ide_handlers(dev);
@@ -247,11 +239,16 @@ cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
dev->regs[addr] = val & 0xc8; dev->regs[addr] = val & 0xc8;
cmd646_ide_handlers(dev); cmd646_ide_handlers(dev);
break; break;
case 0x52: case 0x54: case 0x56: case 0x58: case 0x52:
case 0x59: case 0x5b: case 0x54:
case 0x56:
case 0x58:
case 0x59:
case 0x5b:
dev->regs[addr] = val; dev->regs[addr] = val;
break; break;
case 0x53: case 0x55: case 0x53:
case 0x55:
dev->regs[addr] = val & 0xc0; dev->regs[addr] = val & 0xc0;
break; break;
case 0x57: case 0x57:
@@ -266,7 +263,6 @@ cmd646_pci_write(int func, int addr, uint8_t val, void *priv)
} }
} }
static uint8_t static uint8_t
cmd646_pci_read(int func, int addr, void *priv) cmd646_pci_read(int func, int addr, void *priv)
{ {
@@ -291,7 +287,6 @@ cmd646_pci_read(int func, int addr, void *priv)
return ret; return ret;
} }
static void static void
cmd646_reset(void *priv) cmd646_reset(void *priv)
{ {
@@ -299,18 +294,15 @@ cmd646_reset(void *priv)
int i = 0; int i = 0;
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && (cdrom[i].ide_channel < 4) && cdrom[i].priv)
(cdrom[i].ide_channel < 4) && cdrom[i].priv)
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv); scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
} }
for (i = 0; i < ZIP_NUM; i++) { for (i = 0; i < ZIP_NUM; i++) {
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
(zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
zip_reset((scsi_common_t *) zip_drives[i].priv); zip_reset((scsi_common_t *) zip_drives[i].priv);
} }
for (i = 0; i < MO_NUM; i++) { for (i = 0; i < MO_NUM; i++) {
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
(mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
mo_reset((scsi_common_t *) mo_drives[i].priv); mo_reset((scsi_common_t *) mo_drives[i].priv);
} }
@@ -335,10 +327,14 @@ cmd646_reset(void *priv)
If 0, they return 0 and are read-only 8 */ If 0, they return 0 and are read-only 8 */
/* Base addresses (1F0, 3F4, 170, 374) */ /* Base addresses (1F0, 3F4, 170, 374) */
dev->regs[0x10] = 0xf1; dev->regs[0x11] = 0x01; dev->regs[0x10] = 0xf1;
dev->regs[0x14] = 0xf5; dev->regs[0x15] = 0x03; dev->regs[0x11] = 0x01;
dev->regs[0x18] = 0x71; dev->regs[0x19] = 0x01; dev->regs[0x14] = 0xf5;
dev->regs[0x1c] = 0x75; dev->regs[0x1d] = 0x03; dev->regs[0x15] = 0x03;
dev->regs[0x18] = 0x71;
dev->regs[0x19] = 0x01;
dev->regs[0x1c] = 0x75;
dev->regs[0x1d] = 0x03;
} }
dev->regs[0x20] = 0x01; dev->regs[0x20] = 0x01;
@@ -361,7 +357,6 @@ cmd646_reset(void *priv)
cmd646_ide_bm_handlers(dev); cmd646_ide_bm_handlers(dev);
} }
static void static void
cmd646_close(void *priv) cmd646_close(void *priv)
{ {
@@ -370,7 +365,6 @@ cmd646_close(void *priv)
free(dev); free(dev);
} }
static void * static void *
cmd646_init(const device_t *info) cmd646_init(const device_t *info)
{ {

View File

@@ -29,7 +29,6 @@
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdc_ide.h> #include <86box/hdc_ide.h>
typedef struct typedef struct
{ {
uint8_t tries, uint8_t tries,
@@ -37,10 +36,8 @@ typedef struct
regs[19]; regs[19];
} opti611_t; } opti611_t;
static void opti611_ide_handler(opti611_t *dev); static void opti611_ide_handler(opti611_t *dev);
static void static void
opti611_cfg_write(uint16_t addr, uint8_t val, void *priv) opti611_cfg_write(uint16_t addr, uint8_t val, void *priv)
{ {
@@ -74,7 +71,6 @@ opti611_cfg_write(uint16_t addr, uint8_t val, void *priv)
} }
} }
static void static void
opti611_cfg_writew(uint16_t addr, uint16_t val, void *priv) opti611_cfg_writew(uint16_t addr, uint16_t val, void *priv)
{ {
@@ -82,7 +78,6 @@ opti611_cfg_writew(uint16_t addr, uint16_t val, void *priv)
opti611_cfg_write(addr + 1, val >> 8, priv); opti611_cfg_write(addr + 1, val >> 8, priv);
} }
static void static void
opti611_cfg_writel(uint16_t addr, uint32_t val, void *priv) opti611_cfg_writel(uint16_t addr, uint32_t val, void *priv)
{ {
@@ -90,7 +85,6 @@ opti611_cfg_writel(uint16_t addr, uint32_t val, void *priv)
opti611_cfg_writew(addr + 2, val >> 16, priv); opti611_cfg_writew(addr + 2, val >> 16, priv);
} }
static uint8_t static uint8_t
opti611_cfg_read(uint16_t addr, void *priv) opti611_cfg_read(uint16_t addr, void *priv)
{ {
@@ -109,7 +103,10 @@ opti611_cfg_read(uint16_t addr, void *priv)
if (ret & 0x80) if (ret & 0x80)
ret |= (dev->regs[addr] & 0x7f); ret |= (dev->regs[addr] & 0x7f);
break; break;
case 0x0003: case 0x0004: case 0x0005: case 0x0006: case 0x0003:
case 0x0004:
case 0x0005:
case 0x0006:
ret = dev->regs[addr]; ret = dev->regs[addr];
break; break;
} }
@@ -117,7 +114,6 @@ opti611_cfg_read(uint16_t addr, void *priv)
return ret; return ret;
} }
static uint16_t static uint16_t
opti611_cfg_readw(uint16_t addr, void *priv) opti611_cfg_readw(uint16_t addr, void *priv)
{ {
@@ -129,7 +125,6 @@ opti611_cfg_readw(uint16_t addr, void *priv)
return ret; return ret;
} }
static uint32_t static uint32_t
opti611_cfg_readl(uint16_t addr, void *priv) opti611_cfg_readl(uint16_t addr, void *priv)
{ {
@@ -141,7 +136,6 @@ opti611_cfg_readl(uint16_t addr, void *priv)
return ret; return ret;
} }
static void static void
opti611_ide_write(uint16_t addr, uint8_t val, void *priv) opti611_ide_write(uint16_t addr, uint8_t val, void *priv)
{ {
@@ -158,7 +152,6 @@ opti611_ide_write(uint16_t addr, uint8_t val, void *priv)
} }
} }
static void static void
opti611_ide_writew(uint16_t addr, uint16_t val, void *priv) opti611_ide_writew(uint16_t addr, uint16_t val, void *priv)
{ {
@@ -175,7 +168,6 @@ opti611_ide_writew(uint16_t addr, uint16_t val, void *priv)
} }
} }
static void static void
opti611_ide_writel(uint16_t addr, uint32_t val, void *priv) opti611_ide_writel(uint16_t addr, uint32_t val, void *priv)
{ {
@@ -191,7 +183,6 @@ opti611_ide_writel(uint16_t addr, uint32_t val, void *priv)
} }
} }
static uint8_t static uint8_t
opti611_ide_read(uint16_t addr, void *priv) opti611_ide_read(uint16_t addr, void *priv)
{ {
@@ -210,7 +201,6 @@ opti611_ide_read(uint16_t addr, void *priv)
return 0xff; return 0xff;
} }
static uint16_t static uint16_t
opti611_ide_readw(uint16_t addr, void *priv) opti611_ide_readw(uint16_t addr, void *priv)
{ {
@@ -237,7 +227,6 @@ opti611_ide_readw(uint16_t addr, void *priv)
return 0xffff; return 0xffff;
} }
static uint32_t static uint32_t
opti611_ide_readl(uint16_t addr, void *priv) opti611_ide_readl(uint16_t addr, void *priv)
{ {
@@ -255,7 +244,6 @@ opti611_ide_readl(uint16_t addr, void *priv)
return 0xffffffff; return 0xffffffff;
} }
static void static void
opti611_ide_handler(opti611_t *dev) opti611_ide_handler(opti611_t *dev)
{ {
@@ -284,7 +272,6 @@ opti611_ide_handler(opti611_t *dev)
} }
} }
static void static void
opti611_close(void *priv) opti611_close(void *priv)
{ {
@@ -293,7 +280,6 @@ opti611_close(void *priv)
free(dev); free(dev);
} }
static void * static void *
opti611_init(const device_t *info) opti611_init(const device_t *info)
{ {

View File

@@ -43,10 +43,8 @@
#include <86box/zip.h> #include <86box/zip.h>
#include <86box/mo.h> #include <86box/mo.h>
static int next_id = 0; static int next_id = 0;
uint8_t sff_bus_master_read(uint16_t port, void *priv); uint8_t sff_bus_master_read(uint16_t port, void *priv);
static uint16_t sff_bus_master_readw(uint16_t port, void *priv); static uint16_t sff_bus_master_readw(uint16_t port, void *priv);
static uint32_t sff_bus_master_readl(uint16_t port, void *priv); static uint32_t sff_bus_master_readl(uint16_t port, void *priv);
@@ -54,11 +52,9 @@ void sff_bus_master_write(uint16_t port, uint8_t val, void *priv);
static void sff_bus_master_writew(uint16_t port, uint16_t val, void *priv); static void sff_bus_master_writew(uint16_t port, uint16_t val, void *priv);
static void sff_bus_master_writel(uint16_t port, uint32_t val, void *priv); static void sff_bus_master_writel(uint16_t port, uint32_t val, void *priv);
#ifdef ENABLE_SFF_LOG #ifdef ENABLE_SFF_LOG
int sff_do_log = ENABLE_SFF_LOG; int sff_do_log = ENABLE_SFF_LOG;
static void static void
sff_log(const char *fmt, ...) sff_log(const char *fmt, ...)
{ {
@@ -74,7 +70,6 @@ sff_log(const char *fmt, ...)
# define sff_log(fmt, ...) # define sff_log(fmt, ...)
#endif #endif
void void
sff_bus_master_handler(sff8038i_t *dev, int enabled, uint16_t base) sff_bus_master_handler(sff8038i_t *dev, int enabled, uint16_t base)
{ {
@@ -96,7 +91,6 @@ sff_bus_master_handler(sff8038i_t *dev, int enabled, uint16_t base)
dev->base = base; dev->base = base;
} }
static void static void
sff_bus_master_next_addr(sff8038i_t *dev) sff_bus_master_next_addr(sff8038i_t *dev)
{ {
@@ -111,7 +105,6 @@ sff_bus_master_next_addr(sff8038i_t *dev)
dev->ptr_cur += 8; dev->ptr_cur += 8;
} }
void void
sff_bus_master_write(uint16_t port, uint8_t val, void *priv) sff_bus_master_write(uint16_t port, uint8_t val, void *priv)
{ {
@@ -170,7 +163,6 @@ sff_bus_master_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static void static void
sff_bus_master_writew(uint16_t port, uint16_t val, void *priv) sff_bus_master_writew(uint16_t port, uint16_t val, void *priv)
{ {
@@ -196,7 +188,6 @@ sff_bus_master_writew(uint16_t port, uint16_t val, void *priv)
} }
} }
static void static void
sff_bus_master_writel(uint16_t port, uint32_t val, void *priv) sff_bus_master_writel(uint16_t port, uint32_t val, void *priv)
{ {
@@ -218,7 +209,6 @@ sff_bus_master_writel(uint16_t port, uint32_t val, void *priv)
} }
} }
uint8_t uint8_t
sff_bus_master_read(uint16_t port, void *priv) sff_bus_master_read(uint16_t port, void *priv)
{ {
@@ -255,7 +245,6 @@ sff_bus_master_read(uint16_t port, void *priv)
return ret; return ret;
} }
static uint16_t static uint16_t
sff_bus_master_readw(uint16_t port, void *priv) sff_bus_master_readw(uint16_t port, void *priv)
{ {
@@ -282,7 +271,6 @@ sff_bus_master_readw(uint16_t port, void *priv)
return ret; return ret;
} }
static uint32_t static uint32_t
sff_bus_master_readl(uint16_t port, void *priv) sff_bus_master_readl(uint16_t port, void *priv)
{ {
@@ -306,7 +294,6 @@ sff_bus_master_readl(uint16_t port, void *priv)
return ret; return ret;
} }
int int
sff_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out, void *priv) sff_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out, void *priv)
{ {
@@ -377,7 +364,6 @@ sff_bus_master_dma(int channel, uint8_t *data, int transfer_length, int out, voi
return 1; return 1;
} }
void void
sff_bus_master_set_irq(int channel, void *priv) sff_bus_master_set_irq(int channel, void *priv)
{ {
@@ -432,7 +418,6 @@ sff_bus_master_set_irq(int channel, void *priv)
} }
} }
void void
sff_bus_master_reset(sff8038i_t *dev, uint16_t old_base) sff_bus_master_reset(sff8038i_t *dev, uint16_t old_base)
{ {
@@ -456,7 +441,6 @@ sff_bus_master_reset(sff8038i_t *dev, uint16_t old_base)
ide_sec_disable(); ide_sec_disable();
} }
static void static void
sff_reset(void *p) sff_reset(void *p)
{ {
@@ -467,18 +451,15 @@ sff_reset(void *p)
#endif #endif
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && (cdrom[i].ide_channel < 4) && cdrom[i].priv)
(cdrom[i].ide_channel < 4) && cdrom[i].priv)
scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv); scsi_cdrom_reset((scsi_common_t *) cdrom[i].priv);
} }
for (i = 0; i < ZIP_NUM; i++) { for (i = 0; i < ZIP_NUM; i++) {
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && (zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
(zip_drives[i].ide_channel < 4) && zip_drives[i].priv)
zip_reset((scsi_common_t *) zip_drives[i].priv); zip_reset((scsi_common_t *) zip_drives[i].priv);
} }
for (i = 0; i < MO_NUM; i++) { for (i = 0; i < MO_NUM; i++) {
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && (mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
(mo_drives[i].ide_channel < 4) && mo_drives[i].priv)
mo_reset((scsi_common_t *) mo_drives[i].priv); mo_reset((scsi_common_t *) mo_drives[i].priv);
} }
@@ -486,28 +467,24 @@ sff_reset(void *p)
sff_bus_master_set_irq(0x01, p); sff_bus_master_set_irq(0x01, p);
} }
void void
sff_set_slot(sff8038i_t *dev, int slot) sff_set_slot(sff8038i_t *dev, int slot)
{ {
dev->slot = slot; dev->slot = slot;
} }
void void
sff_set_irq_line(sff8038i_t *dev, int irq_line) sff_set_irq_line(sff8038i_t *dev, int irq_line)
{ {
dev->irq_line = irq_line; dev->irq_line = irq_line;
} }
void void
sff_set_irq_level(sff8038i_t *dev, int channel, int irq_level) sff_set_irq_level(sff8038i_t *dev, int channel, int irq_level)
{ {
dev->irq_level[channel] = 0; dev->irq_level[channel] = 0;
} }
void void
sff_set_irq_mode(sff8038i_t *dev, int channel, int irq_mode) sff_set_irq_mode(sff8038i_t *dev, int channel, int irq_mode)
{ {
@@ -539,14 +516,12 @@ sff_set_irq_mode(sff8038i_t *dev, int channel, int irq_mode)
} }
} }
void void
sff_set_irq_pin(sff8038i_t *dev, int irq_pin) sff_set_irq_pin(sff8038i_t *dev, int irq_pin)
{ {
dev->irq_pin = irq_pin; dev->irq_pin = irq_pin;
} }
static void static void
sff_close(void *p) sff_close(void *p)
{ {
@@ -559,9 +534,9 @@ sff_close(void *p)
next_id = 0; next_id = 0;
} }
static void static void
*sff_init(const device_t *info) *
sff_init(const device_t *info)
{ {
sff8038i_t *dev = (sff8038i_t *) malloc(sizeof(sff8038i_t)); sff8038i_t *dev = (sff8038i_t *) malloc(sizeof(sff8038i_t));
memset(dev, 0, sizeof(sff8038i_t)); memset(dev, 0, sizeof(sff8038i_t));
@@ -584,8 +559,7 @@ static void
return dev; return dev;
} }
const device_t sff8038i_device = const device_t sff8038i_device = {
{
.name = "SFF-8038i IDE Bus Master", .name = "SFF-8038i IDE Bus Master",
.internal_name = "sff8038i", .internal_name = "sff8038i",
.flags = DEVICE_PCI, .flags = DEVICE_PCI,

View File

@@ -39,7 +39,6 @@
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdd.h> #include <86box/hdd.h>
#define MFM_TIME (TIMER_USEC * 10) #define MFM_TIME (TIMER_USEC * 10)
/*Rough estimate - MFM drives spin at 3600 RPM, with 17 sectors per track, /*Rough estimate - MFM drives spin at 3600 RPM, with 17 sectors per track,
@@ -75,7 +74,6 @@
#define CMD_DIAGNOSE 0x90 #define CMD_DIAGNOSE 0x90
#define CMD_SET_PARAMETERS 0x91 #define CMD_SET_PARAMETERS 0x91
typedef struct { typedef struct {
int8_t present, /* drive is present */ int8_t present, /* drive is present */
hdd_num, /* drive number in system */ hdd_num, /* drive number in system */
@@ -91,7 +89,6 @@ typedef struct {
int16_t curcyl; /* current track number */ int16_t curcyl; /* current track number */
} drive_t; } drive_t;
typedef struct { typedef struct {
uint8_t precomp, /* 1: precomp/error register */ uint8_t precomp, /* 1: precomp/error register */
error, error,
@@ -116,15 +113,12 @@ typedef struct {
drive_t drives[MFM_NUM]; /* attached drives */ drive_t drives[MFM_NUM]; /* attached drives */
} mfm_t; } mfm_t;
static uint8_t mfm_read(uint16_t port, void *priv); static uint8_t mfm_read(uint16_t port, void *priv);
static void mfm_write(uint16_t port, uint8_t val, void *priv); static void mfm_write(uint16_t port, uint8_t val, void *priv);
#ifdef ENABLE_ST506_AT_LOG #ifdef ENABLE_ST506_AT_LOG
int st506_at_do_log = ENABLE_ST506_AT_LOG; int st506_at_do_log = ENABLE_ST506_AT_LOG;
static void static void
st506_at_log(const char *fmt, ...) st506_at_log(const char *fmt, ...)
{ {
@@ -140,7 +134,6 @@ st506_at_log(const char *fmt, ...)
# define st506_at_log(fmt, ...) # define st506_at_log(fmt, ...)
#endif #endif
static inline void static inline void
irq_raise(mfm_t *mfm) irq_raise(mfm_t *mfm)
{ {
@@ -150,15 +143,12 @@ irq_raise(mfm_t *mfm)
mfm->irqstat = 1; mfm->irqstat = 1;
} }
static inline void static inline void
irq_lower(mfm_t *mfm) irq_lower(mfm_t *mfm)
{ {
picintc(1 << 14); picintc(1 << 14);
} }
static void static void
irq_update(mfm_t *mfm) irq_update(mfm_t *mfm)
{ {
@@ -166,7 +156,6 @@ irq_update(mfm_t *mfm)
picint(1 << 14); picint(1 << 14);
} }
/* /*
* Return the sector offset for the current register values. * Return the sector offset for the current register values.
* *
@@ -214,13 +203,11 @@ get_sector(mfm_t *mfm, off64_t *addr)
return (1); return (1);
} }
*addr = ((((off64_t) mfm->cylinder * drive->cfg_hpc) + mfm->head) * *addr = ((((off64_t) mfm->cylinder * drive->cfg_hpc) + mfm->head) * drive->cfg_spt) + (mfm->sector - 1);
drive->cfg_spt) + (mfm->sector - 1);
return (0); return (0);
} }
/* Move to the next sector using CHS addressing. */ /* Move to the next sector using CHS addressing. */
static void static void
next_sector(mfm_t *mfm) next_sector(mfm_t *mfm)
@@ -238,7 +225,6 @@ next_sector(mfm_t *mfm)
} }
} }
static void static void
mfm_cmd(mfm_t *mfm, uint8_t val) mfm_cmd(mfm_t *mfm, uint8_t val)
{ {
@@ -367,7 +353,6 @@ mfm_cmd(mfm_t *mfm, uint8_t val)
} }
} }
static void static void
mfm_writew(uint16_t port, uint16_t val, void *priv) mfm_writew(uint16_t port, uint16_t val, void *priv)
{ {
@@ -389,7 +374,6 @@ mfm_writew(uint16_t port, uint16_t val, void *priv)
} }
} }
static void static void
mfm_write(uint16_t port, uint8_t val, void *priv) mfm_write(uint16_t port, uint8_t val, void *priv)
{ {
@@ -454,7 +438,6 @@ mfm_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static uint16_t static uint16_t
mfm_readw(uint16_t port, void *priv) mfm_readw(uint16_t port, void *priv)
{ {
@@ -488,7 +471,6 @@ mfm_readw(uint16_t port, void *priv)
return (ret); return (ret);
} }
static uint8_t static uint8_t
mfm_read(uint16_t port, void *priv) mfm_read(uint16_t port, void *priv)
{ {
@@ -538,7 +520,6 @@ mfm_read(uint16_t port, void *priv)
return (ret); return (ret);
} }
static void static void
do_seek(mfm_t *mfm) do_seek(mfm_t *mfm)
{ {
@@ -553,7 +534,6 @@ do_seek(mfm_t *mfm)
drive->curcyl = drive->tracks - 1; drive->curcyl = drive->tracks - 1;
} }
static void static void
do_callback(void *priv) do_callback(void *priv)
{ {
@@ -687,7 +667,6 @@ do_callback(void *priv)
} }
} }
static void static void
loadhd(mfm_t *mfm, int c, int d, const char *fn) loadhd(mfm_t *mfm, int c, int d, const char *fn)
{ {
@@ -706,7 +685,6 @@ loadhd(mfm_t *mfm, int c, int d, const char *fn)
drive->present = 1; drive->present = 1;
} }
static void * static void *
mfm_init(const device_t *info) mfm_init(const device_t *info)
{ {
@@ -725,7 +703,8 @@ mfm_init(const device_t *info)
st506_at_log("WD1003(%d): (%s) geometry %d/%d/%d\n", c, hdd[d].fn, st506_at_log("WD1003(%d): (%s) geometry %d/%d/%d\n", c, hdd[d].fn,
(int) hdd[d].tracks, (int) hdd[d].hpc, (int) hdd[d].spt); (int) hdd[d].tracks, (int) hdd[d].hpc, (int) hdd[d].spt);
if (++c >= MFM_NUM) break; if (++c >= MFM_NUM)
break;
} }
} }
@@ -746,7 +725,6 @@ mfm_init(const device_t *info)
return (mfm); return (mfm);
} }
static void static void
mfm_close(void *priv) mfm_close(void *priv)
{ {

View File

@@ -87,7 +87,6 @@
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdd.h> #include <86box/hdd.h>
#define XEBEC_BIOS_FILE "roms/hdd/st506/ibm_xebec_62x0822_1985.bin" #define XEBEC_BIOS_FILE "roms/hdd/st506/ibm_xebec_62x0822_1985.bin"
#define DTC_BIOS_FILE "roms/hdd/st506/dtc_cxd21a.bin" #define DTC_BIOS_FILE "roms/hdd/st506/dtc_cxd21a.bin"
#define ST11_BIOS_FILE_OLD "roms/hdd/st506/st11_bios_vers_1.7.bin" #define ST11_BIOS_FILE_OLD "roms/hdd/st506/st11_bios_vers_1.7.bin"
@@ -101,7 +100,6 @@
#define WD1004_27X_BIOS_FILE "roms/hdd/st506/western_digital_WD1004A-27X.bin" #define WD1004_27X_BIOS_FILE "roms/hdd/st506/western_digital_WD1004A-27X.bin"
#define WD1004A_27X_BIOS_FILE "roms/hdd/st506/western_digital_WD1004A-27X.bin" #define WD1004A_27X_BIOS_FILE "roms/hdd/st506/western_digital_WD1004A-27X.bin"
#define ST506_TIME (250 * TIMER_USEC) #define ST506_TIME (250 * TIMER_USEC)
#define ST506_TIME_MS (1000 * TIMER_USEC) #define ST506_TIME_MS (1000 * TIMER_USEC)
@@ -110,7 +108,6 @@
#define MFM_SECTORS 17 #define MFM_SECTORS 17
#define RLL_SECTORS 26 #define RLL_SECTORS 26
/* Status register. */ /* Status register. */
#define STAT_REQ 0x01 /* controller ready */ #define STAT_REQ 0x01 /* controller ready */
#define STAT_IO 0x02 /* input, data to host */ #define STAT_IO 0x02 /* input, data to host */
@@ -215,7 +212,6 @@ enum {
STATE_DONE STATE_DONE
}; };
typedef struct { typedef struct {
int8_t present; int8_t present;
uint8_t hdd_num; uint8_t hdd_num;
@@ -234,7 +230,6 @@ typedef struct {
uint16_t cfg_cyl; uint16_t cfg_cyl;
} drive_t; } drive_t;
typedef struct { typedef struct {
uint8_t type; /* controller type */ uint8_t type; /* controller type */
@@ -274,7 +269,6 @@ typedef struct {
uint8_t buff[SECTOR_SIZE + 4]; /* sector buffer RAM (+ ECC bytes) */ uint8_t buff[SECTOR_SIZE + 4]; /* sector buffer RAM (+ ECC bytes) */
} hdc_t; } hdc_t;
/* Supported drives table for the Xebec controller. */ /* Supported drives table for the Xebec controller. */
typedef struct { typedef struct {
uint16_t tracks; uint16_t tracks;
@@ -289,11 +283,9 @@ hd_type_t hd_types[4] = {
{ 306, 8, MFM_SECTORS} /* type 13 */ { 306, 8, MFM_SECTORS} /* type 13 */
}; };
#ifdef ENABLE_ST506_XT_LOG #ifdef ENABLE_ST506_XT_LOG
int st506_xt_do_log = ENABLE_ST506_XT_LOG; int st506_xt_do_log = ENABLE_ST506_XT_LOG;
static void static void
st506_xt_log(const char *fmt, ...) st506_xt_log(const char *fmt, ...)
{ {
@@ -309,7 +301,6 @@ st506_xt_log(const char *fmt, ...)
# define st506_xt_log(fmt, ...) # define st506_xt_log(fmt, ...)
#endif #endif
static void static void
st506_complete(hdc_t *dev) st506_complete(hdc_t *dev)
{ {
@@ -325,7 +316,6 @@ st506_complete(hdc_t *dev)
} }
} }
static void static void
st506_error(hdc_t *dev, uint8_t err) st506_error(hdc_t *dev, uint8_t err)
{ {
@@ -333,7 +323,6 @@ st506_error(hdc_t *dev, uint8_t err)
dev->error = err; dev->error = err;
} }
static int static int
get_sector(hdc_t *dev, drive_t *drive, off64_t *addr) get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
{ {
@@ -373,7 +362,6 @@ get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
return (1); return (1);
} }
static void static void
next_sector(hdc_t *dev, drive_t *drive) next_sector(hdc_t *dev, drive_t *drive)
{ {
@@ -394,7 +382,6 @@ next_sector(hdc_t *dev, drive_t *drive)
} }
} }
/* Extract the CHS info from a command block. */ /* Extract the CHS info from a command block. */
static int static int
get_chs(hdc_t *dev, drive_t *drive) get_chs(hdc_t *dev, drive_t *drive)
@@ -427,7 +414,6 @@ get_chs(hdc_t *dev, drive_t *drive)
return (1); return (1);
} }
static void static void
st506_callback(void *priv) st506_callback(void *priv)
{ {
@@ -494,10 +480,8 @@ st506_callback(void *priv)
dev->error = 0; dev->error = 0;
/* Give address of last operation. */ /* Give address of last operation. */
dev->buff[1] = (dev->drive_sel ? 0x20 : 0) | dev->buff[1] = (dev->drive_sel ? 0x20 : 0) | dev->head;
dev->head; dev->buff[2] = ((dev->cylinder & 0x0300) >> 2) | dev->sector;
dev->buff[2] = ((dev->cylinder & 0x0300) >> 2) |
dev->sector;
dev->buff[3] = (dev->cylinder & 0xff); dev->buff[3] = (dev->cylinder & 0xff);
dev->status = STAT_BSY | STAT_IO | STAT_REQ; dev->status = STAT_BSY | STAT_IO | STAT_REQ;
@@ -941,7 +925,8 @@ st506_callback(void *priv)
break; break;
case CMD_INQUIRY_ST11: case CMD_INQUIRY_ST11:
if (dev->type == 11 || dev->type == 12) switch (dev->state) { if (dev->type == 11 || dev->type == 12)
switch (dev->state) {
case STATE_START_COMMAND: case STATE_START_COMMAND:
st506_xt_log("ST506: INQUIRY (type=%i)\n", dev->type); st506_xt_log("ST506: INQUIRY (type=%i)\n", dev->type);
dev->buff_pos = 0; dev->buff_pos = 0;
@@ -957,7 +942,8 @@ st506_callback(void *priv)
case STATE_SENT_DATA: case STATE_SENT_DATA:
st506_complete(dev); st506_complete(dev);
break; break;
} else { }
else {
st506_error(dev, ERR_BAD_COMMAND); st506_error(dev, ERR_BAD_COMMAND);
st506_complete(dev); st506_complete(dev);
} }
@@ -1098,7 +1084,6 @@ st506_callback(void *priv)
} }
} }
/* Read from one of the registers. */ /* Read from one of the registers. */
static uint8_t static uint8_t
st506_read(uint16_t port, void *priv) st506_read(uint16_t port, void *priv)
@@ -1144,7 +1129,6 @@ st506_read(uint16_t port, void *priv)
return (ret); return (ret);
} }
/* Write to one of the registers. */ /* Write to one of the registers. */
static void static void
st506_write(uint16_t port, uint8_t val, void *priv) st506_write(uint16_t port, uint8_t val, void *priv)
@@ -1207,7 +1191,6 @@ st506_write(uint16_t port, uint8_t val, void *priv)
} }
} }
/* Write to ROM (or scratchpad RAM.) */ /* Write to ROM (or scratchpad RAM.) */
static void static void
mem_write(uint32_t addr, uint8_t val, void *priv) mem_write(uint32_t addr, uint8_t val, void *priv)
@@ -1235,12 +1218,10 @@ mem_write(uint32_t addr, uint8_t val, void *priv)
addr &= dev->bios_rom.mask; addr &= dev->bios_rom.mask;
ptr = (dev->bios_rom.mask & mask) - dev->bios_ram; ptr = (dev->bios_rom.mask & mask) - dev->bios_ram;
if (mask && ((addr & mask) > ptr) && if (mask && ((addr & mask) > ptr) && ((addr & mask) <= (ptr + dev->bios_ram)))
((addr & mask) <= (ptr + dev->bios_ram)))
dev->scratch[addr & (dev->bios_ram - 1)] = val; dev->scratch[addr & (dev->bios_ram - 1)] = val;
} }
static uint8_t static uint8_t
mem_read(uint32_t addr, void *priv) mem_read(uint32_t addr, void *priv)
{ {
@@ -1287,8 +1268,7 @@ mem_read(uint32_t addr, void *priv)
addr = addr & dev->bios_rom.mask; addr = addr & dev->bios_rom.mask;
ptr = (dev->bios_rom.mask & mask) - dev->bios_ram; ptr = (dev->bios_rom.mask & mask) - dev->bios_ram;
if (mask && ((addr & mask) > ptr) && if (mask && ((addr & mask) > ptr) && ((addr & mask) <= (ptr + dev->bios_ram)))
((addr & mask) <= (ptr + dev->bios_ram)))
ret = dev->scratch[addr & (dev->bios_ram - 1)]; ret = dev->scratch[addr & (dev->bios_ram - 1)];
else else
ret = dev->bios_rom.rom[addr]; ret = dev->bios_rom.rom[addr];
@@ -1296,7 +1276,6 @@ mem_read(uint32_t addr, void *priv)
return (ret); return (ret);
} }
/* /*
* Set up and load the ROM BIOS for this controller. * Set up and load the ROM BIOS for this controller.
* *
@@ -1347,7 +1326,6 @@ loadrom(hdc_t *dev, const char *fn)
dev->bios_rom.rom, MEM_MAPPING_EXTERNAL, dev); dev->bios_rom.rom, MEM_MAPPING_EXTERNAL, dev);
} }
static void static void
loadhd(hdc_t *dev, int c, int d, const char *fn) loadhd(hdc_t *dev, int c, int d, const char *fn)
{ {
@@ -1384,7 +1362,6 @@ loadhd(hdc_t *dev, int c, int d, const char *fn)
drive->present = 1; drive->present = 1;
} }
/* Set the "drive type" switches for the IBM Xebec controller. */ /* Set the "drive type" switches for the IBM Xebec controller. */
static void static void
set_switches(hdc_t *dev) set_switches(hdc_t *dev)
@@ -1397,12 +1374,11 @@ set_switches(hdc_t *dev)
for (d = 0; d < MFM_NUM; d++) { for (d = 0; d < MFM_NUM; d++) {
drive = &dev->drives[d]; drive = &dev->drives[d];
if (! drive->present) continue; if (!drive->present)
continue;
for (c = 0; c < 4; c++) { for (c = 0; c < 4; c++) {
if ((drive->spt == hd_types[c].spt) && if ((drive->spt == hd_types[c].spt) && (drive->hpc == hd_types[c].hpc) && (drive->tracks == hd_types[c].tracks)) {
(drive->hpc == hd_types[c].hpc) &&
(drive->tracks == hd_types[c].tracks)) {
dev->switches |= (c << (d ? 0 : 2)); dev->switches |= (c << (d ? 0 : 2));
break; break;
} }
@@ -1419,7 +1395,6 @@ set_switches(hdc_t *dev)
} }
} }
static void * static void *
st506_init(const device_t *info) st506_init(const device_t *info)
{ {
@@ -1535,7 +1510,8 @@ st506_init(const device_t *info)
hdd[i].fn, hdd[i].mfm_channel); hdd[i].fn, hdd[i].mfm_channel);
loadhd(dev, hdd[i].mfm_channel, i, hdd[i].fn); loadhd(dev, hdd[i].mfm_channel, i, hdd[i].fn);
if (++c > MFM_NUM) break; if (++c > MFM_NUM)
break;
} }
} }
st506_xt_log("ST506: %i disks loaded.\n", c); st506_xt_log("ST506: %i disks loaded.\n", c);
@@ -1554,7 +1530,6 @@ st506_init(const device_t *info)
return (dev); return (dev);
} }
static void static void
st506_close(void *priv) st506_close(void *priv)
{ {
@@ -1576,14 +1551,12 @@ st506_close(void *priv)
free(dev); free(dev);
} }
static int static int
xebec_available(void) xebec_available(void)
{ {
return (rom_present(XEBEC_BIOS_FILE)); return (rom_present(XEBEC_BIOS_FILE));
} }
static int static int
dtc5150x_available(void) dtc5150x_available(void)
{ {

View File

@@ -104,12 +104,10 @@
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdd.h> #include <86box/hdd.h>
#define HDC_TIME (50 * TIMER_USEC) #define HDC_TIME (50 * TIMER_USEC)
#define WD_BIOS_FILE "roms/hdd/xta/idexywd2.bin" #define WD_BIOS_FILE "roms/hdd/xta/idexywd2.bin"
enum { enum {
STATE_IDLE = 0, STATE_IDLE = 0,
STATE_RECV, STATE_RECV,
@@ -121,7 +119,6 @@ enum {
STATE_COMPL STATE_COMPL
}; };
/* Command values. */ /* Command values. */
#define CMD_TEST_READY 0x00 #define CMD_TEST_READY 0x00
#define CMD_RECALIBRATE 0x01 #define CMD_RECALIBRATE 0x01
@@ -184,7 +181,6 @@ enum {
#define IRQ_ENA 0x02 #define IRQ_ENA 0x02
#define DMA_ENA 0x01 #define DMA_ENA 0x01
/* The device control block (6 bytes) */ /* The device control block (6 bytes) */
#pragma pack(push, 1) #pragma pack(push, 1)
typedef struct { typedef struct {
@@ -237,7 +233,6 @@ typedef struct {
uint16_t cfg_tracks; uint16_t cfg_tracks;
} drive_t; } drive_t;
typedef struct { typedef struct {
const char *name; /* controller name */ const char *name; /* controller name */
@@ -276,11 +271,9 @@ typedef struct {
uint8_t sector_buf[512]; /* sector buffer */ uint8_t sector_buf[512]; /* sector buffer */
} hdc_t; } hdc_t;
#ifdef ENABLE_XTA_LOG #ifdef ENABLE_XTA_LOG
int xta_do_log = ENABLE_XTA_LOG; int xta_do_log = ENABLE_XTA_LOG;
static void static void
xta_log(const char *fmt, ...) xta_log(const char *fmt, ...)
{ {
@@ -296,7 +289,6 @@ xta_log(const char *fmt, ...)
# define xta_log(fmt, ...) # define xta_log(fmt, ...)
#endif #endif
static void static void
set_intr(hdc_t *dev) set_intr(hdc_t *dev)
{ {
@@ -309,7 +301,6 @@ set_intr(hdc_t *dev)
} }
} }
/* Get the logical (block) address of a CHS triplet. */ /* Get the logical (block) address of a CHS triplet. */
static int static int
get_sector(hdc_t *dev, drive_t *drive, off64_t *addr) get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
@@ -334,13 +325,11 @@ get_sector(hdc_t *dev, drive_t *drive, off64_t *addr)
} }
/* Calculate logical address (block number) of desired sector. */ /* Calculate logical address (block number) of desired sector. */
*addr = ((((off64_t) dev->track*drive->hpc) + \ *addr = ((((off64_t) dev->track * drive->hpc) + dev->head) * drive->spt) + dev->sector;
dev->head)*drive->spt) + dev->sector;
return (0); return (0);
} }
static void static void
next_sector(hdc_t *dev, drive_t *drive) next_sector(hdc_t *dev, drive_t *drive)
{ {
@@ -371,7 +360,6 @@ xta_set_callback(hdc_t *dev, uint64_t callback)
} }
} }
/* Perform the seek operation. */ /* Perform the seek operation. */
static void static void
do_seek(hdc_t *dev, drive_t *drive, int cyl) do_seek(hdc_t *dev, drive_t *drive, int cyl)
@@ -384,7 +372,6 @@ do_seek(hdc_t *dev, drive_t *drive, int cyl)
drive->cur_cyl = dev->track; drive->cur_cyl = dev->track;
} }
/* Format a track or an entire drive. */ /* Format a track or an entire drive. */
static void static void
do_format(hdc_t *dev, drive_t *drive, dcb_t *dcb) do_format(hdc_t *dev, drive_t *drive, dcb_t *dcb)
@@ -434,7 +421,8 @@ do_fmt:
dev->sector = s; dev->sector = s;
/* Get address of sector to write. */ /* Get address of sector to write. */
if (get_sector(dev, drive, &addr)) break; if (get_sector(dev, drive, &addr))
break;
/* Write the block to the image. */ /* Write the block to the image. */
hdd_image_write(drive->hdd_num, addr, 1, hdd_image_write(drive->hdd_num, addr, 1,
@@ -443,7 +431,8 @@ do_fmt:
} }
/* One more track done. */ /* One more track done. */
if (++start_cyl == end_cyl) break; if (++start_cyl == end_cyl)
break;
/* This saves us a LOT of code. */ /* This saves us a LOT of code. */
goto do_fmt; goto do_fmt;
@@ -453,7 +442,6 @@ do_fmt:
ui_sb_update_icon(SB_HDD | HDD_BUS_XTA, 0); ui_sb_update_icon(SB_HDD | HDD_BUS_XTA, 0);
} }
/* Execute the DCB we just received. */ /* Execute the DCB we just received. */
static void static void
hdc_callback(void *priv) hdc_callback(void *priv)
@@ -500,8 +488,7 @@ hdc_callback(void *priv)
dev->buf_ptr = dev->data; dev->buf_ptr = dev->data;
dev->buf_ptr[0] = dev->sense; dev->buf_ptr[0] = dev->sense;
dev->buf_ptr[1] = dcb->drvsel ? 0x20 : 0x00; dev->buf_ptr[1] = dcb->drvsel ? 0x20 : 0x00;
dev->buf_ptr[2] = (drive->cur_cyl >> 2) | \ dev->buf_ptr[2] = (drive->cur_cyl >> 2) | (dev->sector & 0x3f);
(dev->sector & 0x3f);
dev->buf_ptr[3] = (drive->cur_cyl & 0xff); dev->buf_ptr[3] = (drive->cur_cyl & 0xff);
dev->sense = ERR_NOERROR; dev->sense = ERR_NOERROR;
dev->status |= (STAT_IO | STAT_REQ); dev->status |= (STAT_IO | STAT_REQ);
@@ -765,8 +752,7 @@ do_recv:
case STATE_RDONE: case STATE_RDONE:
params = (dprm_t *) dev->data; params = (dprm_t *) dev->data;
drive->tracks = drive->tracks = (params->cyl_high << 8) | params->cyl_low;
(params->cyl_high << 8) | params->cyl_low;
drive->hpc = params->heads; drive->hpc = params->heads;
drive->spt = 17 /*hardcoded*/; drive->spt = 17 /*hardcoded*/;
dev->status &= ~STAT_REQ; dev->status &= ~STAT_REQ;
@@ -872,7 +858,6 @@ do_recv:
} }
} }
/* Read one of the controller registers. */ /* Read one of the controller registers. */
static uint8_t static uint8_t
hdc_read(uint16_t port, void *priv) hdc_read(uint16_t port, void *priv)
@@ -920,7 +905,6 @@ xta_log("DCB=%02X status=%02X comp=%02X\n", dev->dcb.cmd, dev->status, dev->com
return (ret); return (ret);
} }
/* Write to one of the controller registers. */ /* Write to one of the controller registers. */
static void static void
hdc_write(uint16_t port, uint8_t val, void *priv) hdc_write(uint16_t port, uint8_t val, void *priv)
@@ -980,14 +964,12 @@ hdc_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static int static int
xta_available(void) xta_available(void)
{ {
return (rom_present(WD_BIOS_FILE)); return (rom_present(WD_BIOS_FILE));
} }
static void * static void *
xta_init(const device_t *info) xta_init(const device_t *info)
{ {
@@ -1056,7 +1038,8 @@ xta_init(const device_t *info)
dev->name, hdd[i].xta_channel, drive->tracks, dev->name, hdd[i].xta_channel, drive->tracks,
drive->hpc, drive->spt, i); drive->hpc, drive->spt, i);
if (++c > max) break; if (++c > max)
break;
} }
} }
@@ -1076,7 +1059,6 @@ xta_init(const device_t *info)
return (dev); return (dev);
} }
static void static void
xta_close(void *priv) xta_close(void *priv)
{ {

View File

@@ -44,21 +44,18 @@
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdc_ide.h> #include <86box/hdc_ide.h>
#define ROM_PATH_XT "roms/hdd/xtide/ide_xt.bin" #define ROM_PATH_XT "roms/hdd/xtide/ide_xt.bin"
#define ROM_PATH_AT "roms/hdd/xtide/ide_at.bin" #define ROM_PATH_AT "roms/hdd/xtide/ide_at.bin"
#define ROM_PATH_PS2 "roms/hdd/xtide/SIDE1V12.BIN" #define ROM_PATH_PS2 "roms/hdd/xtide/SIDE1V12.BIN"
#define ROM_PATH_PS2AT "roms/hdd/xtide/ide_at_1_1_5.bin" #define ROM_PATH_PS2AT "roms/hdd/xtide/ide_at_1_1_5.bin"
#define ROM_PATH_AT_386 "roms/hdd/xtide/ide_386.bin" #define ROM_PATH_AT_386 "roms/hdd/xtide/ide_386.bin"
typedef struct { typedef struct {
void *ide_board; void *ide_board;
uint8_t data_high; uint8_t data_high;
rom_t bios_rom; rom_t bios_rom;
} xtide_t; } xtide_t;
static void static void
xtide_write(uint16_t port, uint8_t val, void *priv) xtide_write(uint16_t port, uint8_t val, void *priv)
{ {
@@ -89,7 +86,6 @@ xtide_write(uint16_t port, uint8_t val, void *priv)
} }
} }
static uint8_t static uint8_t
xtide_read(uint16_t port, void *priv) xtide_read(uint16_t port, void *priv)
{ {
@@ -127,7 +123,6 @@ xtide_read(uint16_t port, void *priv)
return (tempw & 0xff); return (tempw & 0xff);
} }
static void * static void *
xtide_init(const device_t *info) xtide_init(const device_t *info)
{ {
@@ -147,14 +142,12 @@ xtide_init(const device_t *info)
return (xtide); return (xtide);
} }
static int static int
xtide_available(void) xtide_available(void)
{ {
return (rom_present(ROM_PATH_XT)); return (rom_present(ROM_PATH_XT));
} }
static void * static void *
xtide_at_init(const device_t *info) xtide_at_init(const device_t *info)
{ {
@@ -175,21 +168,18 @@ xtide_at_init(const device_t *info)
return (xtide); return (xtide);
} }
static int static int
xtide_at_available(void) xtide_at_available(void)
{ {
return (rom_present(ROM_PATH_AT)); return (rom_present(ROM_PATH_AT));
} }
static int static int
xtide_at_386_available(void) xtide_at_386_available(void)
{ {
return (rom_present(ROM_PATH_AT_386)); return (rom_present(ROM_PATH_AT_386));
} }
static void * static void *
xtide_acculogic_init(const device_t *info) xtide_acculogic_init(const device_t *info)
{ {
@@ -209,14 +199,12 @@ xtide_acculogic_init(const device_t *info)
return (xtide); return (xtide);
} }
static int static int
xtide_acculogic_available(void) xtide_acculogic_available(void)
{ {
return (rom_present(ROM_PATH_PS2)); return (rom_present(ROM_PATH_PS2));
} }
static void static void
xtide_close(void *priv) xtide_close(void *priv)
{ {
@@ -227,7 +215,6 @@ xtide_close(void *priv)
ide_xtide_close(); ide_xtide_close();
} }
static void * static void *
xtide_at_ps2_init(const device_t *info) xtide_at_ps2_init(const device_t *info)
{ {
@@ -243,14 +230,12 @@ xtide_at_ps2_init(const device_t *info)
return (xtide); return (xtide);
} }
static int static int
xtide_at_ps2_available(void) xtide_at_ps2_available(void)
{ {
return (rom_present(ROM_PATH_PS2AT)); return (rom_present(ROM_PATH_PS2AT));
} }
static void static void
xtide_at_close(void *priv) xtide_at_close(void *priv)
{ {

View File

@@ -31,13 +31,10 @@
#include <86box/video.h> #include <86box/video.h>
#include "cpu.h" #include "cpu.h"
#define HDD_OVERHEAD_TIME 50.0 #define HDD_OVERHEAD_TIME 50.0
hard_disk_t hdd[HDD_NUM]; hard_disk_t hdd[HDD_NUM];
int int
hdd_init(void) hdd_init(void)
{ {
@@ -47,7 +44,6 @@ hdd_init(void)
return (0); return (0);
} }
int int
hdd_string_to_bus(char *str, int cdrom) hdd_string_to_bus(char *str, int cdrom)
{ {
@@ -66,7 +62,8 @@ no_cdrom:
/* FIXME: delete 'rll' in a year or so.. --FvK */ /* FIXME: delete 'rll' in a year or so.. --FvK */
if (!strcmp(str, "esdi") || !strcmp(str, "rll")) { if (!strcmp(str, "esdi") || !strcmp(str, "rll")) {
if (cdrom) goto no_cdrom; if (cdrom)
goto no_cdrom;
return (HDD_BUS_ESDI); return (HDD_BUS_ESDI);
} }
@@ -104,7 +101,6 @@ no_cdrom:
return (0); return (0);
} }
char * char *
hdd_bus_to_string(int bus, int cdrom) hdd_bus_to_string(int bus, int cdrom)
{ {
@@ -143,7 +139,6 @@ hdd_bus_to_string(int bus, int cdrom)
return (s); return (s);
} }
int int
hdd_is_valid(int c) hdd_is_valid(int c)
{ {
@@ -159,7 +154,6 @@ hdd_is_valid(int c)
return (1); return (1);
} }
double double
hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_t operation, uint8_t continuous, double max_seek_time) hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_t operation, uint8_t continuous, double max_seek_time)
{ {
@@ -173,8 +167,10 @@ hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_t operation, uint8_
break; break;
} }
double continuous_times[2][2] = { { hdd->head_switch_usec, hdd->cyl_switch_usec }, double continuous_times[2][2] = {
{ zone->sector_time_usec, zone->sector_time_usec } }; {hdd->head_switch_usec, hdd->cyl_switch_usec },
{ zone->sector_time_usec, zone->sector_time_usec}
};
double times[2] = { HDD_OVERHEAD_TIME, hdd->avg_rotation_lat_usec }; double times[2] = { HDD_OVERHEAD_TIME, hdd->avg_rotation_lat_usec };
uint32_t new_track = zone->start_track + ((dst_addr - zone->start_sector) / zone->sectors_per_track); uint32_t new_track = zone->start_track + ((dst_addr - zone->start_sector) / zone->sectors_per_track);
@@ -191,8 +187,7 @@ hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_t operation, uint8_
if (!cylinder_diff) if (!cylinder_diff)
seek_time = times[operation != HDD_OP_SEEK]; seek_time = times[operation != HDD_OP_SEEK];
else { else {
seek_time = hdd->cyl_switch_usec + (hdd->full_stroke_usec * (double)cylinder_diff / (double)hdd->phy_cyl) + seek_time = hdd->cyl_switch_usec + (hdd->full_stroke_usec * (double) cylinder_diff / (double) hdd->phy_cyl) + ((operation != HDD_OP_SEEK) * hdd->avg_rotation_lat_usec);
((operation != HDD_OP_SEEK) * hdd->avg_rotation_lat_usec);
} }
} }
@@ -205,7 +200,6 @@ hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_t operation, uint8_
return seek_time; return seek_time;
} }
static void static void
hdd_readahead_update(hard_disk_t *hdd) hdd_readahead_update(hard_disk_t *hdd)
{ {
@@ -240,7 +234,6 @@ hdd_readahead_update(hard_disk_t *hdd)
} }
} }
static double static double
hdd_writecache_flush(hard_disk_t *hdd) hdd_writecache_flush(hard_disk_t *hdd)
{ {
@@ -255,7 +248,6 @@ hdd_writecache_flush(hard_disk_t *hdd)
return seek_time; return seek_time;
} }
static void static void
hdd_writecache_update(hard_disk_t *hdd) hdd_writecache_update(hard_disk_t *hdd)
{ {
@@ -278,7 +270,6 @@ hdd_writecache_update(hard_disk_t *hdd)
} }
} }
double double
hdd_timing_write(hard_disk_t *hdd, uint32_t addr, uint32_t len) hdd_timing_write(hard_disk_t *hdd, uint32_t addr, uint32_t len)
{ {
@@ -318,7 +309,6 @@ hdd_timing_write(hard_disk_t *hdd, uint32_t addr, uint32_t len)
return seek_time; return seek_time;
} }
double double
hdd_timing_read(hard_disk_t *hdd, uint32_t addr, uint32_t len) hdd_timing_read(hard_disk_t *hdd, uint32_t addr, uint32_t len)
{ {
@@ -389,7 +379,6 @@ update_lru:
return seek_time; return seek_time;
} }
static void static void
hdd_cache_init(hard_disk_t *hdd) hdd_cache_init(hard_disk_t *hdd)
{ {
@@ -409,7 +398,6 @@ hdd_cache_init(hard_disk_t *hdd)
} }
} }
static void static void
hdd_zones_init(hard_disk_t *hdd) hdd_zones_init(hard_disk_t *hdd)
{ {
@@ -430,54 +418,42 @@ hdd_zones_init(hard_disk_t *hdd)
} }
} }
static hdd_preset_t hdd_speed_presets[] = { static hdd_preset_t hdd_speed_presets[] = {
{.name = "RAM Disk (max. speed)", .internal_name = "ramdisk", .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32}, {.name = "RAM Disk (max. speed)", .internal_name = "ramdisk", .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32},
{ .name = "[1989] 3500 RPM", .internal_name = "1989_3500rpm", .zones = 1, .avg_spt = 35, .heads = 2, .rpm = 3500, { .name = "[1989] 3500 RPM", .internal_name = "1989_3500rpm", .zones = 1, .avg_spt = 35, .heads = 2, .rpm = 3500, .full_stroke_ms = 40, .track_seek_ms = 8, .rcache_num_seg = 1, .rcache_seg_size = 16, .max_multiple = 8 },
.full_stroke_ms = 40, .track_seek_ms = 8, .rcache_num_seg = 1, .rcache_seg_size = 16, .max_multiple = 8 },
{ .name = "[1992] 3600 RPM", .internal_name = "1992_3600rpm", .zones = 1, .avg_spt = 45, .heads = 2, .rpm = 3600, { .name = "[1992] 3600 RPM", .internal_name = "1992_3600rpm", .zones = 1, .avg_spt = 45, .heads = 2, .rpm = 3600, .full_stroke_ms = 30, .track_seek_ms = 6, .rcache_num_seg = 4, .rcache_seg_size = 16, .max_multiple = 8 },
.full_stroke_ms = 30, .track_seek_ms = 6, .rcache_num_seg = 4, .rcache_seg_size = 16, .max_multiple = 8 },
{ .name = "[1994] 4500 RPM", .internal_name = "1994_4500rpm", .zones = 8, .avg_spt = 80, .heads = 4, .rpm = 4500, { .name = "[1994] 4500 RPM", .internal_name = "1994_4500rpm", .zones = 8, .avg_spt = 80, .heads = 4, .rpm = 4500, .full_stroke_ms = 26, .track_seek_ms = 5, .rcache_num_seg = 4, .rcache_seg_size = 32, .max_multiple = 16 },
.full_stroke_ms = 26, .track_seek_ms = 5, .rcache_num_seg = 4, .rcache_seg_size = 32, .max_multiple = 16 },
{ .name = "[1996] 5400 RPM", .internal_name = "1996_5400rpm", .zones = 16, .avg_spt = 135, .heads = 4, .rpm = 5400, { .name = "[1996] 5400 RPM", .internal_name = "1996_5400rpm", .zones = 16, .avg_spt = 135, .heads = 4, .rpm = 5400, .full_stroke_ms = 24, .track_seek_ms = 3, .rcache_num_seg = 4, .rcache_seg_size = 64, .max_multiple = 16 },
.full_stroke_ms = 24, .track_seek_ms = 3, .rcache_num_seg = 4, .rcache_seg_size = 64, .max_multiple = 16 },
{ .name = "[1997] 5400 RPM", .internal_name = "1997_5400rpm", .zones = 16, .avg_spt = 185, .heads = 6, .rpm = 5400, { .name = "[1997] 5400 RPM", .internal_name = "1997_5400rpm", .zones = 16, .avg_spt = 185, .heads = 6, .rpm = 5400, .full_stroke_ms = 20, .track_seek_ms = 2.5, .rcache_num_seg = 8, .rcache_seg_size = 64, .max_multiple = 32 },
.full_stroke_ms = 20, .track_seek_ms = 2.5, .rcache_num_seg = 8, .rcache_seg_size = 64, .max_multiple = 32 },
{ .name = "[1998] 5400 RPM", .internal_name = "1998_5400rpm", .zones = 16, .avg_spt = 300, .heads = 8, .rpm = 5400, { .name = "[1998] 5400 RPM", .internal_name = "1998_5400rpm", .zones = 16, .avg_spt = 300, .heads = 8, .rpm = 5400, .full_stroke_ms = 20, .track_seek_ms = 2, .rcache_num_seg = 8, .rcache_seg_size = 128, .max_multiple = 32 },
.full_stroke_ms = 20, .track_seek_ms = 2, .rcache_num_seg = 8, .rcache_seg_size = 128, .max_multiple = 32 },
{ .name = "[2000] 7200 RPM", .internal_name = "2000_7200rpm", .zones = 16, .avg_spt = 350, .heads = 6, .rpm = 7200, { .name = "[2000] 7200 RPM", .internal_name = "2000_7200rpm", .zones = 16, .avg_spt = 350, .heads = 6, .rpm = 7200, .full_stroke_ms = 15, .track_seek_ms = 2, .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32 },
.full_stroke_ms = 15, .track_seek_ms = 2, .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32 },
}; };
int int
hdd_preset_get_num() hdd_preset_get_num()
{ {
return sizeof(hdd_speed_presets) / sizeof(hdd_preset_t); return sizeof(hdd_speed_presets) / sizeof(hdd_preset_t);
} }
char * char *
hdd_preset_getname(int preset) hdd_preset_getname(int preset)
{ {
return (char *) hdd_speed_presets[preset].name; return (char *) hdd_speed_presets[preset].name;
} }
char * char *
hdd_preset_get_internal_name(int preset) hdd_preset_get_internal_name(int preset)
{ {
return (char *) hdd_speed_presets[preset].internal_name; return (char *) hdd_speed_presets[preset].internal_name;
} }
int int
hdd_preset_get_from_internal_name(char *s) hdd_preset_get_from_internal_name(char *s)
{ {
@@ -492,7 +468,6 @@ hdd_preset_get_from_internal_name(char *s)
return 0; return 0;
} }
void void
hdd_preset_apply(int hdd_id) hdd_preset_apply(int hdd_id)
{ {

View File

@@ -49,7 +49,6 @@ typedef struct
uint8_t loaded; uint8_t loaded;
} hdd_image_t; } hdd_image_t;
hdd_image_t hdd_images[HDD_NUM]; hdd_image_t hdd_images[HDD_NUM];
static char empty_sector[512]; static char empty_sector[512];
@@ -58,7 +57,6 @@ static char *empty_sector_1mb;
#ifdef ENABLE_HDD_IMAGE_LOG #ifdef ENABLE_HDD_IMAGE_LOG
int hdd_image_do_log = ENABLE_HDD_IMAGE_LOG; int hdd_image_do_log = ENABLE_HDD_IMAGE_LOG;
static void static void
hdd_image_log(const char *fmt, ...) hdd_image_log(const char *fmt, ...)
{ {
@@ -83,7 +81,6 @@ image_is_hdi(const char *s)
return 0; return 0;
} }
int int
image_is_hdx(const char *s, int check_signature) image_is_hdx(const char *s, int check_signature)
{ {
@@ -119,7 +116,6 @@ image_is_hdx(const char *s, int check_signature)
return 0; return 0;
} }
int int
image_is_vhd(const char *s, int check_signature) image_is_vhd(const char *s, int check_signature)
{ {
@@ -177,7 +173,6 @@ hdd_image_calc_chs(uint32_t *c, uint32_t *h, uint32_t *s, uint32_t size)
*s = spt; *s = spt;
} }
static int static int
prepare_new_hard_disk(uint8_t id, uint64_t full_size) prepare_new_hard_disk(uint8_t id, uint64_t full_size)
{ {
@@ -225,7 +220,6 @@ prepare_new_hard_disk(uint8_t id, uint64_t full_size)
return 1; return 1;
} }
void void
hdd_image_init(void) hdd_image_init(void)
{ {
@@ -255,15 +249,13 @@ hdd_image_load(int id)
path_normalize(fn); path_normalize(fn);
} }
hdd_images[id].base = 0; hdd_images[id].base = 0;
if (hdd_images[id].loaded) { if (hdd_images[id].loaded) {
if (hdd_images[id].file) { if (hdd_images[id].file) {
fclose(hdd_images[id].file); fclose(hdd_images[id].file);
hdd_images[id].file = NULL; hdd_images[id].file = NULL;
} } else if (hdd_images[id].vhd) {
else if (hdd_images[id].vhd) {
mvhd_close(hdd_images[id].vhd); mvhd_close(hdd_images[id].vhd);
hdd_images[id].vhd = NULL; hdd_images[id].vhd = NULL;
} }
@@ -303,9 +295,7 @@ hdd_image_load(int id)
return 0; return 0;
} else { } else {
if (image_is_hdi(fn)) { if (image_is_hdi(fn)) {
full_size = ((uint64_t) hdd[id].spt) * full_size = ((uint64_t) hdd[id].spt) * ((uint64_t) hdd[id].hpc) * ((uint64_t) hdd[id].tracks) << 9LL;
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
hdd_images[id].base = 0x1000; hdd_images[id].base = 0x1000;
fwrite(&zero, 1, 4, hdd_images[id].file); fwrite(&zero, 1, 4, hdd_images[id].file);
fwrite(&zero, 1, 4, hdd_images[id].file); fwrite(&zero, 1, 4, hdd_images[id].file);
@@ -319,9 +309,7 @@ hdd_image_load(int id)
fwrite(&zero, 1, 4, hdd_images[id].file); fwrite(&zero, 1, 4, hdd_images[id].file);
hdd_images[id].type = HDD_IMAGE_HDI; hdd_images[id].type = HDD_IMAGE_HDI;
} else if (is_hdx[0]) { } else if (is_hdx[0]) {
full_size = ((uint64_t) hdd[id].spt) * full_size = ((uint64_t) hdd[id].spt) * ((uint64_t) hdd[id].hpc) * ((uint64_t) hdd[id].tracks) << 9LL;
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
hdd_images[id].base = 0x28; hdd_images[id].base = 0x28;
fwrite(&signature, 1, 8, hdd_images[id].file); fwrite(&signature, 1, 8, hdd_images[id].file);
fwrite(&full_size, 1, 8, hdd_images[id].file); fwrite(&full_size, 1, 8, hdd_images[id].file);
@@ -338,9 +326,7 @@ hdd_image_load(int id)
geometry.cyl = hdd[id].tracks; geometry.cyl = hdd[id].tracks;
geometry.heads = hdd[id].hpc; geometry.heads = hdd[id].hpc;
geometry.spt = hdd[id].spt; geometry.spt = hdd[id].spt;
full_size = ((uint64_t) hdd[id].spt) * full_size = ((uint64_t) hdd[id].spt) * ((uint64_t) hdd[id].hpc) * ((uint64_t) hdd[id].tracks) << 9LL;
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
hdd_images[id].last_sector = (full_size >> 9LL) - 1; hdd_images[id].last_sector = (full_size >> 9LL) - 1;
hdd_images[id].vhd = mvhd_create_fixed(fn, geometry, &vhd_error, NULL); hdd_images[id].vhd = mvhd_create_fixed(fn, geometry, &vhd_error, NULL);
@@ -355,9 +341,7 @@ hdd_image_load(int id)
hdd_images[id].last_sector = 0; hdd_images[id].last_sector = 0;
} }
s = full_size = ((uint64_t) hdd[id].spt) * s = full_size = ((uint64_t) hdd[id].spt) * ((uint64_t) hdd[id].hpc) * ((uint64_t) hdd[id].tracks) << 9LL;
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
ret = prepare_new_hard_disk(id, full_size); ret = prepare_new_hard_disk(id, full_size);
return ret; return ret;
@@ -437,17 +421,14 @@ hdd_image_load(int id)
fatal("hdd_image_load(): VHD: Error opening VHD file '%s': %s\n", fn, strerror(mvhd_errno)); fatal("hdd_image_load(): VHD: Error opening VHD file '%s': %s\n", fn, strerror(mvhd_errno));
else else
fatal("hdd_image_load(): VHD: Error opening VHD file '%s': %s\n", fn, mvhd_strerr(vhd_error)); fatal("hdd_image_load(): VHD: Error opening VHD file '%s': %s\n", fn, mvhd_strerr(vhd_error));
} } else if (vhd_error == MVHD_ERR_TIMESTAMP) {
else if (vhd_error == MVHD_ERR_TIMESTAMP) {
fatal("hdd_image_load(): VHD: Parent/child timestamp mismatch for VHD file '%s'\n", fn); fatal("hdd_image_load(): VHD: Parent/child timestamp mismatch for VHD file '%s'\n", fn);
} }
hdd[id].tracks = hdd_images[id].vhd->footer.geom.cyl; hdd[id].tracks = hdd_images[id].vhd->footer.geom.cyl;
hdd[id].hpc = hdd_images[id].vhd->footer.geom.heads; hdd[id].hpc = hdd_images[id].vhd->footer.geom.heads;
hdd[id].spt = hdd_images[id].vhd->footer.geom.spt; hdd[id].spt = hdd_images[id].vhd->footer.geom.spt;
full_size = ((uint64_t) hdd[id].spt) * full_size = ((uint64_t) hdd[id].spt) * ((uint64_t) hdd[id].hpc) * ((uint64_t) hdd[id].tracks) << 9LL;
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
hdd_images[id].type = HDD_IMAGE_VHD; hdd_images[id].type = HDD_IMAGE_VHD;
/* If we're here, this means there is a valid VHD footer in the /* If we're here, this means there is a valid VHD footer in the
image, which means that by definition, all valid sectors image, which means that by definition, all valid sectors
@@ -456,9 +437,7 @@ hdd_image_load(int id)
hdd_images[id].loaded = 1; hdd_images[id].loaded = 1;
return 1; return 1;
} else { } else {
full_size = ((uint64_t) hdd[id].spt) * full_size = ((uint64_t) hdd[id].spt) * ((uint64_t) hdd[id].hpc) * ((uint64_t) hdd[id].tracks) << 9LL;
((uint64_t) hdd[id].hpc) *
((uint64_t) hdd[id].tracks) << 9LL;
hdd_images[id].type = HDD_IMAGE_RAW; hdd_images[id].type = HDD_IMAGE_RAW;
} }
} }
@@ -477,7 +456,6 @@ hdd_image_load(int id)
return ret; return ret;
} }
void void
hdd_image_seek(uint8_t id, uint32_t sector) hdd_image_seek(uint8_t id, uint32_t sector)
{ {
@@ -491,7 +469,6 @@ hdd_image_seek(uint8_t id, uint32_t sector)
} }
} }
void void
hdd_image_read(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer) hdd_image_read(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
{ {
@@ -512,21 +489,18 @@ hdd_image_read(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
} }
} }
uint32_t uint32_t
hdd_image_get_last_sector(uint8_t id) hdd_image_get_last_sector(uint8_t id)
{ {
return hdd_images[id].last_sector; return hdd_images[id].last_sector;
} }
uint32_t uint32_t
hdd_sectors(uint8_t id) hdd_sectors(uint8_t id)
{ {
return hdd_image_get_last_sector(id) - 1; return hdd_image_get_last_sector(id) - 1;
} }
int int
hdd_image_read_ex(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer) hdd_image_read_ex(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
{ {
@@ -543,7 +517,6 @@ hdd_image_read_ex(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
return 0; return 0;
} }
void void
hdd_image_write(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer) hdd_image_write(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
{ {
@@ -564,7 +537,6 @@ hdd_image_write(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
} }
} }
int int
hdd_image_write_ex(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer) hdd_image_write_ex(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
{ {
@@ -581,7 +553,6 @@ hdd_image_write_ex(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
return 0; return 0;
} }
void void
hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count) hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count)
{ {
@@ -608,7 +579,6 @@ hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count)
} }
} }
int int
hdd_image_zero_ex(uint8_t id, uint32_t sector, uint32_t count) hdd_image_zero_ex(uint8_t id, uint32_t sector, uint32_t count)
{ {
@@ -625,21 +595,18 @@ hdd_image_zero_ex(uint8_t id, uint32_t sector, uint32_t count)
return 0; return 0;
} }
uint32_t uint32_t
hdd_image_get_pos(uint8_t id) hdd_image_get_pos(uint8_t id)
{ {
return hdd_images[id].pos; return hdd_images[id].pos;
} }
uint8_t uint8_t
hdd_image_get_type(uint8_t id) hdd_image_get_type(uint8_t id)
{ {
return hdd_images[id].type; return hdd_images[id].type;
} }
void void
hdd_image_unload(uint8_t id, int fn_preserve) hdd_image_unload(uint8_t id, int fn_preserve)
{ {
@@ -665,7 +632,6 @@ hdd_image_unload(uint8_t id, int fn_preserve)
memset(hdd[id].fn, 0, sizeof(hdd[id].fn)); memset(hdd[id].fn, 0, sizeof(hdd[id].fn));
} }
void void
hdd_image_close(uint8_t id) hdd_image_close(uint8_t id)
{ {

View File

@@ -25,8 +25,8 @@
#include <86box/86box.h> #include <86box/86box.h>
#include <86box/hdd.h> #include <86box/hdd.h>
unsigned int hdd_table[128][3] = { unsigned int hdd_table[128][3] = {
// clang-format off
{ 306, 4, 17 }, /* 0 - 7 */ { 306, 4, 17 }, /* 0 - 7 */
{ 615, 2, 17 }, { 615, 2, 17 },
{ 306, 4, 26 }, { 306, 4, 26 },
@@ -170,4 +170,5 @@ unsigned int hdd_table[128][3] = {
{ 1120, 16, 59 }, { 1120, 16, 59 },
{ 1054, 16, 63 }, { 1054, 16, 63 },
{ 0, 0, 0 } { 0, 0, 0 }
// clang-format on
}; };

View File

@@ -51,10 +51,8 @@
mo_drive_t mo_drives[MO_NUM]; mo_drive_t mo_drives[MO_NUM];
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */ /* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
const uint8_t mo_command_flags[0x100] = const uint8_t mo_command_flags[0x100] = {
{
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */ IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */
IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */ IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */
0, 0,
@@ -122,8 +120,8 @@ const uint8_t mo_command_flags[0x100] =
static uint64_t mo_mode_sense_page_flags = (GPMODEP_ALL_PAGES); static uint64_t mo_mode_sense_page_flags = (GPMODEP_ALL_PAGES);
static const mode_sense_pages_t mo_mode_sense_pages_default = static const mode_sense_pages_t mo_mode_sense_pages_default =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
@@ -174,8 +172,10 @@ static const mode_sense_pages_t mo_mode_sense_pages_default =
{ 0, 0 }, { 0, 0 },
{ 0, 0 } { 0, 0 }
} }; } };
// clang-format on
static const mode_sense_pages_t mo_mode_sense_pages_default_scsi = static const mode_sense_pages_t mo_mode_sense_pages_default_scsi =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
@@ -226,9 +226,10 @@ static const mode_sense_pages_t mo_mode_sense_pages_default_scsi =
{ 0, 0 }, { 0, 0 },
{ 0, 0 } { 0, 0 }
} }; } };
// clang-format on
static const mode_sense_pages_t mo_mode_sense_pages_changeable = static const mode_sense_pages_t mo_mode_sense_pages_changeable =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
@@ -279,16 +280,14 @@ static const mode_sense_pages_t mo_mode_sense_pages_changeable =
{ 0, 0 }, { 0, 0 },
{ 0, 0 } { 0, 0 }
} }; } };
// clang-format on
static void mo_command_complete(mo_t *dev); static void mo_command_complete(mo_t *dev);
static void mo_init(mo_t *dev); static void mo_init(mo_t *dev);
#ifdef ENABLE_MO_LOG #ifdef ENABLE_MO_LOG
int mo_do_log = ENABLE_MO_LOG; int mo_do_log = ENABLE_MO_LOG;
static void static void
mo_log(const char *fmt, ...) mo_log(const char *fmt, ...)
{ {
@@ -304,7 +303,6 @@ mo_log(const char *fmt, ...)
# define mo_log(fmt, ...) # define mo_log(fmt, ...)
#endif #endif
int int
find_mo_for_channel(uint8_t channel) find_mo_for_channel(uint8_t channel)
{ {
@@ -317,7 +315,6 @@ find_mo_for_channel(uint8_t channel)
return 0xff; return 0xff;
} }
static int static int
mo_load_abort(mo_t *dev) mo_load_abort(mo_t *dev)
{ {
@@ -330,7 +327,6 @@ mo_load_abort(mo_t *dev)
return 0; return 0;
} }
int int
image_is_mdi(const char *s) image_is_mdi(const char *s)
{ {
@@ -340,7 +336,6 @@ image_is_mdi(const char *s)
return 0; return 0;
} }
int int
mo_load(mo_t *dev, char *fn) mo_load(mo_t *dev, char *fn)
{ {
@@ -391,7 +386,6 @@ mo_load(mo_t *dev, char *fn)
return 1; return 1;
} }
void void
mo_disk_reload(mo_t *dev) mo_disk_reload(mo_t *dev)
{ {
@@ -406,7 +400,6 @@ mo_disk_reload(mo_t *dev)
dev->unit_attention = 1; dev->unit_attention = 1;
} }
void void
mo_disk_unload(mo_t *dev) mo_disk_unload(mo_t *dev)
{ {
@@ -416,7 +409,6 @@ mo_disk_unload(mo_t *dev)
} }
} }
void void
mo_disk_close(mo_t *dev) mo_disk_close(mo_t *dev)
{ {
@@ -430,7 +422,6 @@ mo_disk_close(mo_t *dev)
} }
} }
static void static void
mo_set_callback(mo_t *dev) mo_set_callback(mo_t *dev)
{ {
@@ -438,7 +429,6 @@ mo_set_callback(mo_t *dev)
ide_set_callback(ide_drives[dev->drv->ide_channel], dev->callback); ide_set_callback(ide_drives[dev->drv->ide_channel], dev->callback);
} }
static void static void
mo_init(mo_t *dev) mo_init(mo_t *dev)
{ {
@@ -464,21 +454,18 @@ mo_init(mo_t *dev)
mo_sense_key = mo_asc = mo_ascq = dev->unit_attention = 0; mo_sense_key = mo_asc = mo_ascq = dev->unit_attention = 0;
} }
static int static int
mo_supports_pio(mo_t *dev) mo_supports_pio(mo_t *dev)
{ {
return (dev->drv->bus_mode & 1); return (dev->drv->bus_mode & 1);
} }
static int static int
mo_supports_dma(mo_t *dev) mo_supports_dma(mo_t *dev)
{ {
return (dev->drv->bus_mode & 2); return (dev->drv->bus_mode & 2);
} }
/* Returns: 0 for none, 1 for PIO, 2 for DMA. */ /* Returns: 0 for none, 1 for PIO, 2 for DMA. */
static int static int
mo_current_mode(mo_t *dev) mo_current_mode(mo_t *dev)
@@ -499,7 +486,6 @@ mo_current_mode(mo_t *dev)
return 0; return 0;
} }
/* Translates ATAPI phase (DRQ, I/O, C/D) to SCSI phase (MSG, C/D, I/O). */ /* Translates ATAPI phase (DRQ, I/O, C/D) to SCSI phase (MSG, C/D, I/O). */
int int
mo_atapi_phase_to_scsi(mo_t *dev) mo_atapi_phase_to_scsi(mo_t *dev)
@@ -525,7 +511,6 @@ mo_atapi_phase_to_scsi(mo_t *dev)
return 0; return 0;
} }
static void static void
mo_mode_sense_load(mo_t *dev) mo_mode_sense_load(mo_t *dev)
{ {
@@ -550,7 +535,6 @@ mo_mode_sense_load(mo_t *dev)
} }
} }
static void static void
mo_mode_sense_save(mo_t *dev) mo_mode_sense_save(mo_t *dev)
{ {
@@ -569,7 +553,6 @@ mo_mode_sense_save(mo_t *dev)
} }
} }
/*SCSI Mode Sense 6/10*/ /*SCSI Mode Sense 6/10*/
static uint8_t static uint8_t
mo_mode_sense_read(mo_t *dev, uint8_t page_control, uint8_t page, uint8_t pos) mo_mode_sense_read(mo_t *dev, uint8_t page_control, uint8_t page, uint8_t pos)
@@ -593,7 +576,6 @@ mo_mode_sense_read(mo_t *dev, uint8_t page_control, uint8_t page, uint8_t pos)
return 0; return 0;
} }
static uint32_t static uint32_t
mo_mode_sense(mo_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block_descriptor_len) mo_mode_sense(mo_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block_descriptor_len)
{ {
@@ -636,7 +618,6 @@ mo_mode_sense(mo_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block
return pos; return pos;
} }
static void static void
mo_update_request_length(mo_t *dev, int len, int block_len) mo_update_request_length(mo_t *dev, int len, int block_len)
{ {
@@ -692,7 +673,6 @@ mo_update_request_length(mo_t *dev, int len, int block_len)
return; return;
} }
static double static double
mo_bus_speed(mo_t *dev) mo_bus_speed(mo_t *dev)
{ {
@@ -713,7 +693,6 @@ mo_bus_speed(mo_t *dev)
} }
} }
static void static void
mo_command_common(mo_t *dev) mo_command_common(mo_t *dev)
{ {
@@ -738,7 +717,6 @@ mo_command_common(mo_t *dev)
mo_set_callback(dev); mo_set_callback(dev);
} }
static void static void
mo_command_complete(mo_t *dev) mo_command_complete(mo_t *dev)
{ {
@@ -747,7 +725,6 @@ mo_command_complete(mo_t *dev)
mo_command_common(dev); mo_command_common(dev);
} }
static void static void
mo_command_read(mo_t *dev) mo_command_read(mo_t *dev)
{ {
@@ -755,7 +732,6 @@ mo_command_read(mo_t *dev)
mo_command_common(dev); mo_command_common(dev);
} }
static void static void
mo_command_read_dma(mo_t *dev) mo_command_read_dma(mo_t *dev)
{ {
@@ -763,7 +739,6 @@ mo_command_read_dma(mo_t *dev)
mo_command_common(dev); mo_command_common(dev);
} }
static void static void
mo_command_write(mo_t *dev) mo_command_write(mo_t *dev)
{ {
@@ -771,7 +746,6 @@ mo_command_write(mo_t *dev)
mo_command_common(dev); mo_command_common(dev);
} }
static void static void
mo_command_write_dma(mo_t *dev) mo_command_write_dma(mo_t *dev)
{ {
@@ -779,7 +753,6 @@ mo_command_write_dma(mo_t *dev)
mo_command_common(dev); mo_command_common(dev);
} }
/* id = Current MO device ID; /* id = Current MO device ID;
len = Total transfer length; len = Total transfer length;
block_len = Length of a single block (why does it matter?!); block_len = Length of a single block (why does it matter?!);
@@ -822,14 +795,12 @@ mo_data_command_finish(mo_t *dev, int len, int block_len, int alloc_len, int dir
dev->id, dev->packet_status, dev->request_length, dev->packet_len, dev->pos, dev->phase); dev->id, dev->packet_status, dev->request_length, dev->packet_len, dev->pos, dev->phase);
} }
static void static void
mo_sense_clear(mo_t *dev, int command) mo_sense_clear(mo_t *dev, int command)
{ {
mo_sense_key = mo_asc = mo_ascq = 0; mo_sense_key = mo_asc = mo_ascq = 0;
} }
static void static void
mo_set_phase(mo_t *dev, uint8_t phase) mo_set_phase(mo_t *dev, uint8_t phase)
{ {
@@ -842,7 +813,6 @@ mo_set_phase(mo_t *dev, uint8_t phase)
scsi_devices[scsi_bus][scsi_id].phase = phase; scsi_devices[scsi_bus][scsi_id].phase = phase;
} }
static void static void
mo_cmd_error(mo_t *dev) mo_cmd_error(mo_t *dev)
{ {
@@ -860,7 +830,6 @@ mo_cmd_error(mo_t *dev)
mo_log("MO %i: [%02X] ERROR: %02X/%02X/%02X\n", dev->id, dev->current_cdb[0], mo_sense_key, mo_asc, mo_ascq); mo_log("MO %i: [%02X] ERROR: %02X/%02X/%02X\n", dev->id, dev->current_cdb[0], mo_sense_key, mo_asc, mo_ascq);
} }
static void static void
mo_unit_attention(mo_t *dev) mo_unit_attention(mo_t *dev)
{ {
@@ -878,7 +847,6 @@ mo_unit_attention(mo_t *dev)
mo_log("MO %i: UNIT ATTENTION\n", dev->id); mo_log("MO %i: UNIT ATTENTION\n", dev->id);
} }
static void static void
mo_buf_alloc(mo_t *dev, uint32_t len) mo_buf_alloc(mo_t *dev, uint32_t len)
{ {
@@ -887,7 +855,6 @@ mo_buf_alloc(mo_t *dev, uint32_t len)
dev->buffer = (uint8_t *) malloc(len); dev->buffer = (uint8_t *) malloc(len);
} }
static void static void
mo_buf_free(mo_t *dev) mo_buf_free(mo_t *dev)
{ {
@@ -898,7 +865,6 @@ mo_buf_free(mo_t *dev)
} }
} }
static void static void
mo_bus_master_error(scsi_common_t *sc) mo_bus_master_error(scsi_common_t *sc)
{ {
@@ -909,7 +875,6 @@ mo_bus_master_error(scsi_common_t *sc)
mo_cmd_error(dev); mo_cmd_error(dev);
} }
static void static void
mo_not_ready(mo_t *dev) mo_not_ready(mo_t *dev)
{ {
@@ -919,7 +884,6 @@ mo_not_ready(mo_t *dev)
mo_cmd_error(dev); mo_cmd_error(dev);
} }
static void static void
mo_write_protected(mo_t *dev) mo_write_protected(mo_t *dev)
{ {
@@ -929,7 +893,6 @@ mo_write_protected(mo_t *dev)
mo_cmd_error(dev); mo_cmd_error(dev);
} }
static void static void
mo_invalid_lun(mo_t *dev) mo_invalid_lun(mo_t *dev)
{ {
@@ -939,7 +902,6 @@ mo_invalid_lun(mo_t *dev)
mo_cmd_error(dev); mo_cmd_error(dev);
} }
static void static void
mo_illegal_opcode(mo_t *dev) mo_illegal_opcode(mo_t *dev)
{ {
@@ -949,7 +911,6 @@ mo_illegal_opcode(mo_t *dev)
mo_cmd_error(dev); mo_cmd_error(dev);
} }
static void static void
mo_lba_out_of_range(mo_t *dev) mo_lba_out_of_range(mo_t *dev)
{ {
@@ -959,7 +920,6 @@ mo_lba_out_of_range(mo_t *dev)
mo_cmd_error(dev); mo_cmd_error(dev);
} }
static void static void
mo_invalid_field(mo_t *dev) mo_invalid_field(mo_t *dev)
{ {
@@ -970,7 +930,6 @@ mo_invalid_field(mo_t *dev)
dev->status = 0x53; dev->status = 0x53;
} }
static void static void
mo_invalid_field_pl(mo_t *dev) mo_invalid_field_pl(mo_t *dev)
{ {
@@ -981,7 +940,6 @@ mo_invalid_field_pl(mo_t *dev)
dev->status = 0x53; dev->status = 0x53;
} }
static int static int
mo_blocks(mo_t *dev, int32_t *len, int first_batch, int out) mo_blocks(mo_t *dev, int32_t *len, int first_batch, int out)
{ {
@@ -1027,7 +985,6 @@ mo_blocks(mo_t *dev, int32_t *len, int first_batch, int out)
return 1; return 1;
} }
void void
mo_insert(mo_t *dev) mo_insert(mo_t *dev)
{ {
@@ -1149,7 +1106,6 @@ mo_sense_code_ok(mo_t *dev)
mo_ascq = 0; mo_ascq = 0;
} }
static int static int
mo_pre_execution_check(mo_t *dev, uint8_t *cdb) mo_pre_execution_check(mo_t *dev, uint8_t *cdb)
{ {
@@ -1226,7 +1182,6 @@ mo_pre_execution_check(mo_t *dev, uint8_t *cdb)
return 1; return 1;
} }
static void static void
mo_seek(mo_t *dev, uint32_t pos) mo_seek(mo_t *dev, uint32_t pos)
{ {
@@ -1234,7 +1189,6 @@ mo_seek(mo_t *dev, uint32_t pos)
dev->sector_pos = pos; dev->sector_pos = pos;
} }
static void static void
mo_rezero(mo_t *dev) mo_rezero(mo_t *dev)
{ {
@@ -1242,7 +1196,6 @@ mo_rezero(mo_t *dev)
mo_seek(dev, 0); mo_seek(dev, 0);
} }
void void
mo_reset(scsi_common_t *sc) mo_reset(scsi_common_t *sc)
{ {
@@ -1259,7 +1212,6 @@ mo_reset(scsi_common_t *sc)
dev->cur_lun = SCSI_LUN_USE_CDB; dev->cur_lun = SCSI_LUN_USE_CDB;
} }
static void static void
mo_request_sense(mo_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc) mo_request_sense(mo_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc)
{ {
@@ -1295,7 +1247,6 @@ mo_request_sense(mo_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc)
mo_sense_clear(dev, GPCMD_REQUEST_SENSE); mo_sense_clear(dev, GPCMD_REQUEST_SENSE);
} }
static void static void
mo_request_sense_for_scsi(scsi_common_t *sc, uint8_t *buffer, uint8_t alloc_length) mo_request_sense_for_scsi(scsi_common_t *sc, uint8_t *buffer, uint8_t alloc_length)
{ {
@@ -1316,7 +1267,6 @@ mo_request_sense_for_scsi(scsi_common_t *sc, uint8_t *buffer, uint8_t alloc_leng
mo_request_sense(dev, buffer, alloc_length, 0); mo_request_sense(dev, buffer, alloc_length, 0);
} }
static void static void
mo_set_buf_len(mo_t *dev, int32_t *BufLen, int32_t *src_len) mo_set_buf_len(mo_t *dev, int32_t *BufLen, int32_t *src_len)
{ {
@@ -1331,7 +1281,6 @@ mo_set_buf_len(mo_t *dev, int32_t *BufLen, int32_t *src_len)
} }
} }
static void static void
mo_command(scsi_common_t *sc, uint8_t *cdb) mo_command(scsi_common_t *sc, uint8_t *cdb)
{ {
@@ -1567,7 +1516,8 @@ mo_command(scsi_common_t *sc, uint8_t *cdb)
} }
if ((dev->sector_pos >= dev->drv->medium_size) /* || if ((dev->sector_pos >= dev->drv->medium_size) /* ||
((dev->sector_pos + dev->sector_len - 1) >= dev->drv->medium_size)*/) { ((dev->sector_pos + dev->sector_len - 1) >= dev->drv->medium_size)*/
) {
mo_lba_out_of_range(dev); mo_lba_out_of_range(dev);
return; return;
} }
@@ -1889,7 +1839,6 @@ mo_command(scsi_common_t *sc, uint8_t *cdb)
mo_buf_free(dev); mo_buf_free(dev);
} }
static void static void
mo_command_stop(scsi_common_t *sc) mo_command_stop(scsi_common_t *sc)
{ {
@@ -1899,7 +1848,6 @@ mo_command_stop(scsi_common_t *sc)
mo_buf_free(dev); mo_buf_free(dev);
} }
/* The command second phase function, needed for Mode Select. */ /* The command second phase function, needed for Mode Select. */
static uint8_t static uint8_t
mo_phase_data_out(scsi_common_t *sc) mo_phase_data_out(scsi_common_t *sc)
@@ -2010,7 +1958,6 @@ mo_phase_data_out(scsi_common_t *sc)
return 1; return 1;
} }
/* Peform a master init on the entire module. */ /* Peform a master init on the entire module. */
void void
mo_global_init(void) mo_global_init(void)
@@ -2019,7 +1966,6 @@ mo_global_init(void)
memset(mo_drives, 0x00, sizeof(mo_drives)); memset(mo_drives, 0x00, sizeof(mo_drives));
} }
static int static int
mo_get_max(int ide_has_dma, int type) mo_get_max(int ide_has_dma, int type)
{ {
@@ -2044,7 +1990,6 @@ mo_get_max(int ide_has_dma, int type)
return ret; return ret;
} }
static int static int
mo_get_timings(int ide_has_dma, int type) mo_get_timings(int ide_has_dma, int type)
{ {
@@ -2093,7 +2038,6 @@ mo_do_identify(ide_t *ide, int ide_has_dma)
} }
} }
static void static void
mo_identify(ide_t *ide, int ide_has_dma) mo_identify(ide_t *ide, int ide_has_dma)
{ {
@@ -2104,7 +2048,6 @@ mo_identify(ide_t *ide, int ide_has_dma)
mo_do_identify(ide, ide_has_dma); mo_do_identify(ide, ide_has_dma);
} }
static void static void
mo_drive_reset(int c) mo_drive_reset(int c)
{ {
@@ -2159,7 +2102,6 @@ mo_drive_reset(int c)
} }
} }
void void
mo_hard_reset(void) mo_hard_reset(void)
{ {
@@ -2210,7 +2152,6 @@ mo_hard_reset(void)
} }
} }
void void
mo_close(void) mo_close(void)
{ {

View File

@@ -36,13 +36,10 @@
#include <86box/hdc_ide.h> #include <86box/hdc_ide.h>
#include <86box/zip.h> #include <86box/zip.h>
zip_drive_t zip_drives[ZIP_NUM]; zip_drive_t zip_drives[ZIP_NUM];
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */ /* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
const uint8_t zip_command_flags[0x100] = const uint8_t zip_command_flags[0x100] = {
{
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */ IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */
IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */ IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */
0, 0,
@@ -111,18 +108,11 @@ const uint8_t zip_command_flags[0x100] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
static uint64_t zip_mode_sense_page_flags = (GPMODEP_R_W_ERROR_PAGE | static uint64_t zip_mode_sense_page_flags = (GPMODEP_R_W_ERROR_PAGE | GPMODEP_DISCONNECT_PAGE | GPMODEP_IOMEGA_PAGE | GPMODEP_ALL_PAGES);
GPMODEP_DISCONNECT_PAGE | static uint64_t zip_250_mode_sense_page_flags = (GPMODEP_R_W_ERROR_PAGE | GPMODEP_FLEXIBLE_DISK_PAGE | GPMODEP_CACHING_PAGE | GPMODEP_IOMEGA_PAGE | GPMODEP_ALL_PAGES);
GPMODEP_IOMEGA_PAGE |
GPMODEP_ALL_PAGES);
static uint64_t zip_250_mode_sense_page_flags = (GPMODEP_R_W_ERROR_PAGE |
GPMODEP_FLEXIBLE_DISK_PAGE |
GPMODEP_CACHING_PAGE |
GPMODEP_IOMEGA_PAGE |
GPMODEP_ALL_PAGES);
static const mode_sense_pages_t zip_mode_sense_pages_default = static const mode_sense_pages_t zip_mode_sense_pages_default =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ GPMODE_R_W_ERROR_PAGE, 0x0a, 0xc8, 22, 0, 0, 0, 0, 90, 0, 0x50, 0x20 }, { GPMODE_R_W_ERROR_PAGE, 0x0a, 0xc8, 22, 0, 0, 0, 0, 90, 0, 0x50, 0x20 },
@@ -173,8 +163,10 @@ static const mode_sense_pages_t zip_mode_sense_pages_default =
{ 0, 0 }, { 0, 0 },
{ GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0xff, 0x0f } { GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0xff, 0x0f }
} }; } };
// clang-format on
static const mode_sense_pages_t zip_250_mode_sense_pages_default = static const mode_sense_pages_t zip_250_mode_sense_pages_default =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ GPMODE_R_W_ERROR_PAGE, 0x06, 0xc8, 0x64, 0, 0, 0, 0 }, { GPMODE_R_W_ERROR_PAGE, 0x06, 0xc8, 0x64, 0, 0, 0, 0 },
@@ -224,8 +216,10 @@ static const mode_sense_pages_t zip_250_mode_sense_pages_default =
{ 0, 0 }, { 0, 0 },
{ GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0x3c, 0x0f } { GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0x3c, 0x0f }
} }; } };
// clang-format on
static const mode_sense_pages_t zip_mode_sense_pages_default_scsi = static const mode_sense_pages_t zip_mode_sense_pages_default_scsi =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ GPMODE_R_W_ERROR_PAGE, 0x0a, 0xc8, 22, 0, 0, 0, 0, 90, 0, 0x50, 0x20 }, { GPMODE_R_W_ERROR_PAGE, 0x0a, 0xc8, 22, 0, 0, 0, 0, 90, 0, 0x50, 0x20 },
@@ -276,8 +270,10 @@ static const mode_sense_pages_t zip_mode_sense_pages_default_scsi =
{ 0, 0 }, { 0, 0 },
{ GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0xff, 0x0f } { GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0xff, 0x0f }
} }; } };
// clang-format on
static const mode_sense_pages_t zip_250_mode_sense_pages_default_scsi = static const mode_sense_pages_t zip_250_mode_sense_pages_default_scsi =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ GPMODE_R_W_ERROR_PAGE, 0x06, 0xc8, 0x64, 0, 0, 0, 0 }, { GPMODE_R_W_ERROR_PAGE, 0x06, 0xc8, 0x64, 0, 0, 0, 0 },
@@ -328,8 +324,10 @@ static const mode_sense_pages_t zip_250_mode_sense_pages_default_scsi =
{ 0, 0 }, { 0, 0 },
{ GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0x3c, 0x0f } { GPMODE_IOMEGA_PAGE, 0x04, 0x5c, 0x0f, 0x3c, 0x0f }
} }; } };
// clang-format on
static const mode_sense_pages_t zip_mode_sense_pages_changeable = static const mode_sense_pages_t zip_mode_sense_pages_changeable =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
@@ -381,8 +379,10 @@ static const mode_sense_pages_t zip_mode_sense_pages_changeable =
{ 0, 0 }, { 0, 0 },
{ GPMODE_IOMEGA_PAGE, 0x04, 0xff, 0xff, 0xff, 0xff } { GPMODE_IOMEGA_PAGE, 0x04, 0xff, 0xff, 0xff, 0xff }
} }; } };
// clang-format on
static const mode_sense_pages_t zip_250_mode_sense_pages_changeable = static const mode_sense_pages_t zip_250_mode_sense_pages_changeable =
// clang-format off
{ { { {
{ 0, 0 }, { 0, 0 },
{ GPMODE_R_W_ERROR_PAGE, 0x06, 0xFF, 0xFF, 0, 0, 0, 0 }, { GPMODE_R_W_ERROR_PAGE, 0x06, 0xFF, 0xFF, 0, 0, 0, 0 },
@@ -433,16 +433,14 @@ static const mode_sense_pages_t zip_250_mode_sense_pages_changeable =
{ 0, 0 }, { 0, 0 },
{ GPMODE_IOMEGA_PAGE, 0x04, 0xff, 0xff, 0xff, 0xff } { GPMODE_IOMEGA_PAGE, 0x04, 0xff, 0xff, 0xff, 0xff }
} }; } };
// clang-format on
static void zip_command_complete(zip_t *dev); static void zip_command_complete(zip_t *dev);
static void zip_init(zip_t *dev); static void zip_init(zip_t *dev);
#ifdef ENABLE_ZIP_LOG #ifdef ENABLE_ZIP_LOG
int zip_do_log = ENABLE_ZIP_LOG; int zip_do_log = ENABLE_ZIP_LOG;
static void static void
zip_log(const char *fmt, ...) zip_log(const char *fmt, ...)
{ {
@@ -458,7 +456,6 @@ zip_log(const char *fmt, ...)
# define zip_log(fmt, ...) # define zip_log(fmt, ...)
#endif #endif
int int
find_zip_for_channel(uint8_t channel) find_zip_for_channel(uint8_t channel)
{ {
@@ -471,7 +468,6 @@ find_zip_for_channel(uint8_t channel)
return 0xff; return 0xff;
} }
static int static int
zip_load_abort(zip_t *dev) zip_load_abort(zip_t *dev)
{ {
@@ -483,7 +479,6 @@ zip_load_abort(zip_t *dev)
return 0; return 0;
} }
int int
zip_load(zip_t *dev, char *fn) zip_load(zip_t *dev, char *fn)
{ {
@@ -535,7 +530,6 @@ zip_load(zip_t *dev, char *fn)
return 1; return 1;
} }
void void
zip_disk_reload(zip_t *dev) zip_disk_reload(zip_t *dev)
{ {
@@ -550,7 +544,6 @@ zip_disk_reload(zip_t *dev)
dev->unit_attention = 1; dev->unit_attention = 1;
} }
void void
zip_disk_unload(zip_t *dev) zip_disk_unload(zip_t *dev)
{ {
@@ -560,7 +553,6 @@ zip_disk_unload(zip_t *dev)
} }
} }
void void
zip_disk_close(zip_t *dev) zip_disk_close(zip_t *dev)
{ {
@@ -574,7 +566,6 @@ zip_disk_close(zip_t *dev)
} }
} }
static void static void
zip_set_callback(zip_t *dev) zip_set_callback(zip_t *dev)
{ {
@@ -582,7 +573,6 @@ zip_set_callback(zip_t *dev)
ide_set_callback(ide_drives[dev->drv->ide_channel], dev->callback); ide_set_callback(ide_drives[dev->drv->ide_channel], dev->callback);
} }
static void static void
zip_init(zip_t *dev) zip_init(zip_t *dev)
{ {
@@ -608,21 +598,18 @@ zip_init(zip_t *dev)
zip_sense_key = zip_asc = zip_ascq = dev->unit_attention = 0; zip_sense_key = zip_asc = zip_ascq = dev->unit_attention = 0;
} }
static int static int
zip_supports_pio(zip_t *dev) zip_supports_pio(zip_t *dev)
{ {
return (dev->drv->bus_mode & 1); return (dev->drv->bus_mode & 1);
} }
static int static int
zip_supports_dma(zip_t *dev) zip_supports_dma(zip_t *dev)
{ {
return (dev->drv->bus_mode & 2); return (dev->drv->bus_mode & 2);
} }
/* Returns: 0 for none, 1 for PIO, 2 for DMA. */ /* Returns: 0 for none, 1 for PIO, 2 for DMA. */
static int static int
zip_current_mode(zip_t *dev) zip_current_mode(zip_t *dev)
@@ -643,7 +630,6 @@ zip_current_mode(zip_t *dev)
return 0; return 0;
} }
/* Translates ATAPI phase (DRQ, I/O, C/D) to SCSI phase (MSG, C/D, I/O). */ /* Translates ATAPI phase (DRQ, I/O, C/D) to SCSI phase (MSG, C/D, I/O). */
int int
zip_atapi_phase_to_scsi(zip_t *dev) zip_atapi_phase_to_scsi(zip_t *dev)
@@ -669,7 +655,6 @@ zip_atapi_phase_to_scsi(zip_t *dev)
return 0; return 0;
} }
static void static void
zip_mode_sense_load(zip_t *dev) zip_mode_sense_load(zip_t *dev)
{ {
@@ -701,7 +686,6 @@ zip_mode_sense_load(zip_t *dev)
} }
} }
static void static void
zip_mode_sense_save(zip_t *dev) zip_mode_sense_save(zip_t *dev)
{ {
@@ -720,7 +704,6 @@ zip_mode_sense_save(zip_t *dev)
} }
} }
/*SCSI Mode Sense 6/10*/ /*SCSI Mode Sense 6/10*/
static uint8_t static uint8_t
zip_mode_sense_read(zip_t *dev, uint8_t page_control, uint8_t page, uint8_t pos) zip_mode_sense_read(zip_t *dev, uint8_t page_control, uint8_t page, uint8_t pos)
@@ -758,7 +741,6 @@ zip_mode_sense_read(zip_t *dev, uint8_t page_control, uint8_t page, uint8_t pos)
return 0; return 0;
} }
static uint32_t static uint32_t
zip_mode_sense(zip_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block_descriptor_len) zip_mode_sense(zip_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t block_descriptor_len)
{ {
@@ -804,7 +786,6 @@ zip_mode_sense(zip_t *dev, uint8_t *buf, uint32_t pos, uint8_t page, uint8_t blo
return pos; return pos;
} }
static void static void
zip_update_request_length(zip_t *dev, int len, int block_len) zip_update_request_length(zip_t *dev, int len, int block_len)
{ {
@@ -860,7 +841,6 @@ zip_update_request_length(zip_t *dev, int len, int block_len)
return; return;
} }
static double static double
zip_bus_speed(zip_t *dev) zip_bus_speed(zip_t *dev)
{ {
@@ -881,7 +861,6 @@ zip_bus_speed(zip_t *dev)
} }
} }
static void static void
zip_command_common(zip_t *dev) zip_command_common(zip_t *dev)
{ {
@@ -906,7 +885,6 @@ zip_command_common(zip_t *dev)
zip_set_callback(dev); zip_set_callback(dev);
} }
static void static void
zip_command_complete(zip_t *dev) zip_command_complete(zip_t *dev)
{ {
@@ -915,7 +893,6 @@ zip_command_complete(zip_t *dev)
zip_command_common(dev); zip_command_common(dev);
} }
static void static void
zip_command_read(zip_t *dev) zip_command_read(zip_t *dev)
{ {
@@ -923,7 +900,6 @@ zip_command_read(zip_t *dev)
zip_command_common(dev); zip_command_common(dev);
} }
static void static void
zip_command_read_dma(zip_t *dev) zip_command_read_dma(zip_t *dev)
{ {
@@ -931,7 +907,6 @@ zip_command_read_dma(zip_t *dev)
zip_command_common(dev); zip_command_common(dev);
} }
static void static void
zip_command_write(zip_t *dev) zip_command_write(zip_t *dev)
{ {
@@ -939,7 +914,6 @@ zip_command_write(zip_t *dev)
zip_command_common(dev); zip_command_common(dev);
} }
static void static void
zip_command_write_dma(zip_t *dev) zip_command_write_dma(zip_t *dev)
{ {
@@ -947,7 +921,6 @@ zip_command_write_dma(zip_t *dev)
zip_command_common(dev); zip_command_common(dev);
} }
/* id = Current ZIP device ID; /* id = Current ZIP device ID;
len = Total transfer length; len = Total transfer length;
block_len = Length of a single block (why does it matter?!); block_len = Length of a single block (why does it matter?!);
@@ -990,14 +963,12 @@ zip_data_command_finish(zip_t *dev, int len, int block_len, int alloc_len, int d
dev->id, dev->packet_status, dev->request_length, dev->packet_len, dev->pos, dev->phase); dev->id, dev->packet_status, dev->request_length, dev->packet_len, dev->pos, dev->phase);
} }
static void static void
zip_sense_clear(zip_t *dev, int command) zip_sense_clear(zip_t *dev, int command)
{ {
zip_sense_key = zip_asc = zip_ascq = 0; zip_sense_key = zip_asc = zip_ascq = 0;
} }
static void static void
zip_set_phase(zip_t *dev, uint8_t phase) zip_set_phase(zip_t *dev, uint8_t phase)
{ {
@@ -1010,7 +981,6 @@ zip_set_phase(zip_t *dev, uint8_t phase)
scsi_devices[scsi_bus][scsi_id].phase = phase; scsi_devices[scsi_bus][scsi_id].phase = phase;
} }
static void static void
zip_cmd_error(zip_t *dev) zip_cmd_error(zip_t *dev)
{ {
@@ -1028,7 +998,6 @@ zip_cmd_error(zip_t *dev)
zip_log("ZIP %i: [%02X] ERROR: %02X/%02X/%02X\n", dev->id, dev->current_cdb[0], zip_sense_key, zip_asc, zip_ascq); zip_log("ZIP %i: [%02X] ERROR: %02X/%02X/%02X\n", dev->id, dev->current_cdb[0], zip_sense_key, zip_asc, zip_ascq);
} }
static void static void
zip_unit_attention(zip_t *dev) zip_unit_attention(zip_t *dev)
{ {
@@ -1046,7 +1015,6 @@ zip_unit_attention(zip_t *dev)
zip_log("ZIP %i: UNIT ATTENTION\n", dev->id); zip_log("ZIP %i: UNIT ATTENTION\n", dev->id);
} }
static void static void
zip_buf_alloc(zip_t *dev, uint32_t len) zip_buf_alloc(zip_t *dev, uint32_t len)
{ {
@@ -1055,7 +1023,6 @@ zip_buf_alloc(zip_t *dev, uint32_t len)
dev->buffer = (uint8_t *) malloc(len); dev->buffer = (uint8_t *) malloc(len);
} }
static void static void
zip_buf_free(zip_t *dev) zip_buf_free(zip_t *dev)
{ {
@@ -1066,7 +1033,6 @@ zip_buf_free(zip_t *dev)
} }
} }
static void static void
zip_bus_master_error(scsi_common_t *sc) zip_bus_master_error(scsi_common_t *sc)
{ {
@@ -1077,7 +1043,6 @@ zip_bus_master_error(scsi_common_t *sc)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static void static void
zip_not_ready(zip_t *dev) zip_not_ready(zip_t *dev)
{ {
@@ -1087,7 +1052,6 @@ zip_not_ready(zip_t *dev)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static void static void
zip_write_protected(zip_t *dev) zip_write_protected(zip_t *dev)
{ {
@@ -1097,7 +1061,6 @@ zip_write_protected(zip_t *dev)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static void static void
zip_invalid_lun(zip_t *dev) zip_invalid_lun(zip_t *dev)
{ {
@@ -1107,7 +1070,6 @@ zip_invalid_lun(zip_t *dev)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static void static void
zip_illegal_opcode(zip_t *dev) zip_illegal_opcode(zip_t *dev)
{ {
@@ -1117,7 +1079,6 @@ zip_illegal_opcode(zip_t *dev)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static void static void
zip_lba_out_of_range(zip_t *dev) zip_lba_out_of_range(zip_t *dev)
{ {
@@ -1127,7 +1088,6 @@ zip_lba_out_of_range(zip_t *dev)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static void static void
zip_invalid_field(zip_t *dev) zip_invalid_field(zip_t *dev)
{ {
@@ -1138,7 +1098,6 @@ zip_invalid_field(zip_t *dev)
dev->status = 0x53; dev->status = 0x53;
} }
static void static void
zip_invalid_field_pl(zip_t *dev) zip_invalid_field_pl(zip_t *dev)
{ {
@@ -1149,7 +1108,6 @@ zip_invalid_field_pl(zip_t *dev)
dev->status = 0x53; dev->status = 0x53;
} }
static void static void
zip_data_phase_error(zip_t *dev) zip_data_phase_error(zip_t *dev)
{ {
@@ -1159,7 +1117,6 @@ zip_data_phase_error(zip_t *dev)
zip_cmd_error(dev); zip_cmd_error(dev);
} }
static int static int
zip_blocks(zip_t *dev, int32_t *len, int first_batch, int out) zip_blocks(zip_t *dev, int32_t *len, int first_batch, int out)
{ {
@@ -1205,14 +1162,12 @@ zip_blocks(zip_t *dev, int32_t *len, int first_batch, int out)
return 1; return 1;
} }
void void
zip_insert(zip_t *dev) zip_insert(zip_t *dev)
{ {
dev->unit_attention = 1; dev->unit_attention = 1;
} }
/*SCSI Sense Initialization*/ /*SCSI Sense Initialization*/
void void
zip_sense_code_ok(zip_t *dev) zip_sense_code_ok(zip_t *dev)
@@ -1222,7 +1177,6 @@ zip_sense_code_ok(zip_t *dev)
zip_ascq = 0; zip_ascq = 0;
} }
static int static int
zip_pre_execution_check(zip_t *dev, uint8_t *cdb) zip_pre_execution_check(zip_t *dev, uint8_t *cdb)
{ {
@@ -1299,7 +1253,6 @@ zip_pre_execution_check(zip_t *dev, uint8_t *cdb)
return 1; return 1;
} }
static void static void
zip_seek(zip_t *dev, uint32_t pos) zip_seek(zip_t *dev, uint32_t pos)
{ {
@@ -1307,7 +1260,6 @@ zip_seek(zip_t *dev, uint32_t pos)
dev->sector_pos = pos; dev->sector_pos = pos;
} }
static void static void
zip_rezero(zip_t *dev) zip_rezero(zip_t *dev)
{ {
@@ -1315,7 +1267,6 @@ zip_rezero(zip_t *dev)
zip_seek(dev, 0); zip_seek(dev, 0);
} }
void void
zip_reset(scsi_common_t *sc) zip_reset(scsi_common_t *sc)
{ {
@@ -1332,7 +1283,6 @@ zip_reset(scsi_common_t *sc)
dev->cur_lun = SCSI_LUN_USE_CDB; dev->cur_lun = SCSI_LUN_USE_CDB;
} }
static void static void
zip_request_sense(zip_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc) zip_request_sense(zip_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc)
{ {
@@ -1368,7 +1318,6 @@ zip_request_sense(zip_t *dev, uint8_t *buffer, uint8_t alloc_length, int desc)
zip_sense_clear(dev, GPCMD_REQUEST_SENSE); zip_sense_clear(dev, GPCMD_REQUEST_SENSE);
} }
static void static void
zip_request_sense_for_scsi(scsi_common_t *sc, uint8_t *buffer, uint8_t alloc_length) zip_request_sense_for_scsi(scsi_common_t *sc, uint8_t *buffer, uint8_t alloc_length)
{ {
@@ -1389,7 +1338,6 @@ zip_request_sense_for_scsi(scsi_common_t *sc, uint8_t *buffer, uint8_t alloc_len
zip_request_sense(dev, buffer, alloc_length, 0); zip_request_sense(dev, buffer, alloc_length, 0);
} }
static void static void
zip_set_buf_len(zip_t *dev, int32_t *BufLen, int32_t *src_len) zip_set_buf_len(zip_t *dev, int32_t *BufLen, int32_t *src_len)
{ {
@@ -1404,7 +1352,6 @@ zip_set_buf_len(zip_t *dev, int32_t *BufLen, int32_t *src_len)
} }
} }
static void static void
zip_command(scsi_common_t *sc, uint8_t *cdb) zip_command(scsi_common_t *sc, uint8_t *cdb)
{ {
@@ -1655,7 +1602,8 @@ zip_command(scsi_common_t *sc, uint8_t *cdb)
} }
if ((dev->sector_pos >= dev->drv->medium_size) /* || if ((dev->sector_pos >= dev->drv->medium_size) /* ||
((dev->sector_pos + dev->sector_len - 1) >= dev->drv->medium_size)*/) { ((dev->sector_pos + dev->sector_len - 1) >= dev->drv->medium_size)*/
) {
zip_lba_out_of_range(dev); zip_lba_out_of_range(dev);
return; return;
} }
@@ -1707,7 +1655,8 @@ zip_command(scsi_common_t *sc, uint8_t *cdb)
dev->sector_pos = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; dev->sector_pos = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5];
if ((dev->sector_pos >= dev->drv->medium_size) /* || if ((dev->sector_pos >= dev->drv->medium_size) /* ||
((dev->sector_pos + dev->sector_len - 1) >= dev->drv->medium_size)*/) { ((dev->sector_pos + dev->sector_len - 1) >= dev->drv->medium_size)*/
) {
zip_lba_out_of_range(dev); zip_lba_out_of_range(dev);
return; return;
} }
@@ -2069,7 +2018,6 @@ atapi_out:
zip_buf_free(dev); zip_buf_free(dev);
} }
static void static void
zip_command_stop(scsi_common_t *sc) zip_command_stop(scsi_common_t *sc)
{ {
@@ -2079,7 +2027,6 @@ zip_command_stop(scsi_common_t *sc)
zip_buf_free(dev); zip_buf_free(dev);
} }
/* The command second phase function, needed for Mode Select. */ /* The command second phase function, needed for Mode Select. */
static uint8_t static uint8_t
zip_phase_data_out(scsi_common_t *sc) zip_phase_data_out(scsi_common_t *sc)
@@ -2225,7 +2172,6 @@ zip_phase_data_out(scsi_common_t *sc)
return 1; return 1;
} }
/* Peform a master init on the entire module. */ /* Peform a master init on the entire module. */
void void
zip_global_init(void) zip_global_init(void)
@@ -2234,7 +2180,6 @@ zip_global_init(void)
memset(zip_drives, 0x00, sizeof(zip_drives)); memset(zip_drives, 0x00, sizeof(zip_drives));
} }
static int static int
zip_get_max(int ide_has_dma, int type) zip_get_max(int ide_has_dma, int type)
{ {
@@ -2259,7 +2204,6 @@ zip_get_max(int ide_has_dma, int type)
return ret; return ret;
} }
static int static int
zip_get_timings(int ide_has_dma, int type) zip_get_timings(int ide_has_dma, int type)
{ {
@@ -2283,7 +2227,6 @@ zip_get_timings(int ide_has_dma, int type)
return ret; return ret;
} }
static void static void
zip_100_identify(ide_t *ide) zip_100_identify(ide_t *ide)
{ {
@@ -2291,7 +2234,6 @@ zip_100_identify(ide_t *ide)
ide_padstr((char *) (ide->buffer + 27), "IOMEGA ZIP 100 ATAPI", 40); /* Model */ ide_padstr((char *) (ide->buffer + 27), "IOMEGA ZIP 100 ATAPI", 40); /* Model */
} }
static void static void
zip_250_identify(ide_t *ide, int ide_has_dma) zip_250_identify(ide_t *ide, int ide_has_dma)
{ {
@@ -2304,7 +2246,6 @@ zip_250_identify(ide_t *ide, int ide_has_dma)
} }
} }
static void static void
zip_identify(ide_t *ide, int ide_has_dma) zip_identify(ide_t *ide, int ide_has_dma)
{ {
@@ -2327,7 +2268,6 @@ zip_identify(ide_t *ide, int ide_has_dma)
zip_100_identify(ide); zip_100_identify(ide);
} }
static void static void
zip_drive_reset(int c) zip_drive_reset(int c)
{ {
@@ -2382,7 +2322,6 @@ zip_drive_reset(int c)
} }
} }
void void
zip_hard_reset(void) zip_hard_reset(void)
{ {
@@ -2433,7 +2372,6 @@ zip_hard_reset(void)
} }
} }
void void
zip_close(void) zip_close(void)
{ {