Updated files with upstream commits where needed.

Fixed "Settings"crash bug.
Cleaned up some video config issues.
This commit is contained in:
waltje
2018-03-06 15:51:10 -05:00
parent 8d10faf156
commit a4802a9231
58 changed files with 5246 additions and 1334 deletions

View File

@@ -9,7 +9,7 @@
* Implementation of the IDE emulation for hard disks and ATAPI
* CD-ROM devices.
*
* Version: @(#)hdc_ide.c 1.0.2 2018/02/24
* Version: @(#)hdc_ide.c 1.0.4 2018/03/05
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <tommowalker@tommowalker.co.uk>
@@ -465,6 +465,7 @@ static void ide_atapi_identify(IDE *ide)
ide->buffer[48] = 1; /*Dword transfers supported*/
ide->buffer[49] = 0x200; /* LBA supported */
ide->buffer[51] = 2 << 8; /*PIO timing mode*/
ide->buffer[126] = 0xfffe; /* Interpret zero byte count limit as maximum length */
if (PCI && (ide->board < 2) && (cdrom_drives[cdrom_id].bus_type == CDROM_BUS_ATAPI_PIO_AND_DMA))
{
@@ -517,6 +518,8 @@ static void ide_atapi_zip_identify(IDE *ide)
ide->buffer[48] = 1; /*Dword transfers supported*/
ide->buffer[51] = 2 << 8; /*PIO timing mode*/
ide->buffer[126] = 0xfffe; /* Interpret zero byte count limit as maximum length */
if (PCI && (ide->board < 2) && (zip_drives[zip_id].bus_type == ZIP_BUS_ATAPI_PIO_AND_DMA))
{
ide->buffer[49] |= 0x100; /* DMA supported */
@@ -1155,6 +1158,33 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
{
cdrom[atapi_cdrom_drives[ide->channel]].error = 0;
}
if (((val >= WIN_RESTORE) && (val <= 0x1F)) || ((val >= WIN_SEEK) && (val <= 0x7F)))
{
if (ide_drive_is_zip(ide))
{
zip[atapi_zip_drives[ide->channel]].status = READY_STAT;
}
else if (ide_drive_is_cdrom(ide))
{
cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT;
}
else
{
ide->atastat = BUSY_STAT;
}
timer_process();
if (ide_drive_is_zip(ide))
{
zip[atapi_zip_drives[ide->channel]].callback = 100LL*IDE_TIME;
}
if (ide_drive_is_cdrom(ide))
{
cdrom[atapi_cdrom_drives[ide->channel]].callback = 100LL*IDE_TIME;
}
idecallback[ide_board]=40000LL * TIMER_USEC /*100LL*IDE_TIME*/;
timer_update_outstanding();
return;
}
switch (val)
{
case WIN_SRST: /* ATAPI Device Reset */
@@ -1183,33 +1213,6 @@ void writeide(int ide_board, uint16_t addr, uint8_t val)
timer_update_outstanding();
return;
case WIN_RESTORE:
case WIN_SEEK:
if (ide_drive_is_zip(ide))
{
zip[atapi_zip_drives[ide->channel]].status = READY_STAT;
}
else if (ide_drive_is_cdrom(ide))
{
cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT;
}
else
{
ide->atastat = READY_STAT;
}
timer_process();
if (ide_drive_is_zip(ide))
{
zip[atapi_zip_drives[ide->channel]].callback = 100LL*IDE_TIME;
}
if (ide_drive_is_cdrom(ide))
{
cdrom[atapi_cdrom_drives[ide->channel]].callback = 100LL*IDE_TIME;
}
idecallback[ide_board]=100LL*IDE_TIME;
timer_update_outstanding();
return;
case WIN_READ_MULTIPLE:
/* Fatal removed in accordance with the official ATAPI reference:
If the Read Multiple command is attempted before the Set Multiple Mode
@@ -1906,6 +1909,24 @@ void callbackide(int ide_board)
zip_id = atapi_zip_drives[cur_ide[ide_board]];
zip_id_other = atapi_zip_drives[cur_ide[ide_board] ^ 1];
if (((ide->command >= WIN_RESTORE) && (ide->command <= 0x1F)) || ((ide->command >= WIN_SEEK) && (ide->command <= 0x7F)))
{
if (ide_drive_is_zip(ide) || ide_drive_is_cdrom(ide))
{
goto abort_cmd;
}
if ((ide->command >= WIN_SEEK) && (ide->command <= 0x7F))
{
full_size /= ide->t_hpc;
full_size /= ide->t_spt;
if ((ide->cylinder >= full_size) || (ide->head >= ide->t_hpc) || !ide->sector || (ide->sector > ide->t_spt))
goto id_not_found;
}
ide->atastat = READY_STAT | DSC_STAT;
ide_irq_raise(ide);
return;
}
switch (ide->command)
{
/* Initialize the Task File Registers as follows: Status = 00h, Error = 01h, Sector Count = 01h, Sector Number = 01h,
@@ -1937,12 +1958,6 @@ void callbackide(int ide_board)
}
return;
case WIN_RESTORE:
case WIN_SEEK:
if (ide_drive_is_zip(ide) || ide_drive_is_cdrom(ide))
{
goto abort_cmd;
}
case WIN_NOP:
case WIN_STANDBYNOW1:
case WIN_IDLENOW1:

View File

@@ -9,12 +9,12 @@
* Implementation of the Iomega ZIP drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)zip.c 1.0.2 2018/02/24
* Version: @(#)zip.c 1.0.3 2018/03/04
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2016-2018 Miran Grca.
* Copyright 2018 Miran Grca.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -474,8 +474,6 @@ static const mode_sense_pages_t zip_250_mode_sense_pages_changeable =
static mode_sense_pages_t zip_mode_sense_pages_saved[ZIP_NUM];
//FIXME: move to Makefile
#define ENABLE_ZIP_LOG 1
#ifdef ENABLE_ZIP_LOG
int zip_do_log = ENABLE_ZIP_LOG;
#endif
@@ -924,13 +922,18 @@ void zip_update_request_length(uint8_t id, int len, int block_len)
{
uint32_t bt;
if (!zip[id].request_length)
zip[id].max_transfer_len = 65534;
else
zip[id].max_transfer_len = zip[id].request_length;
/* For media access commands, make sure the requested DRQ length matches the block length. */
switch (zip[id].current_cdb[0]) {
case 0x08:
case 0x28:
case 0xa8:
if (zip[id].request_length < block_len)
zip[id].request_length = block_len;
if (zip[id].max_transfer_len < block_len)
zip[id].max_transfer_len = block_len;
bt = (zip[id].requested_blocks * block_len);
if (len > bt)
len = bt;
@@ -939,11 +942,11 @@ void zip_update_request_length(uint8_t id, int len, int block_len)
break;
}
/* If the DRQ length is odd, and the total remaining length is bigger, make sure it's even. */
if ((zip[id].request_length & 1) && (zip[id].request_length < len))
zip[id].request_length &= 0xfffe;
if ((zip[id].max_transfer_len & 1) && (zip[id].max_transfer_len < len))
zip[id].max_transfer_len &= 0xfffe;
/* If the DRQ length is smaller or equal in size to the total remaining length, set it to that. */
if (len <= zip[id].request_length)
zip[id].request_length = len;
if (len <= zip[id].max_transfer_len)
zip[id].max_transfer_len = len;
return;
}
@@ -1002,13 +1005,6 @@ static void zip_command_write_dma(uint8_t id)
zip_command_common(id);
}
static int zip_request_length_is_zero(uint8_t id)
{
if ((zip[id].request_length == 0) && (zip_drives[id].bus_type < ZIP_BUS_SCSI))
return 1;
return 0;
}
/* id = Current ZIP device ID;
len = Total transfer length;
block_len = Length of a single block (why does it matter?!);
@@ -1023,7 +1019,8 @@ static void zip_data_command_finish(uint8_t id, int len, int block_len, int allo
len = alloc_len;
}
}
if (zip_request_length_is_zero(id) || (len == 0) || (zip_current_mode(id) == 0)) {
if ((len == 0) || (zip_current_mode(id) == 0)) {
if (zip_drives[id].bus_type != ZIP_BUS_SCSI) {
zip[id].packet_len = 0;
}
@@ -2214,8 +2211,8 @@ void zip_pio_request(uint8_t id, uint8_t out)
/* If less than (packet length) bytes are remaining, update packet length
accordingly. */
if ((zip[id].packet_len - zip[id].pos) < (zip[id].request_length))
zip[id].request_length = zip[id].packet_len - zip[id].pos;
if ((zip[id].packet_len - zip[id].pos) < (zip[id].max_transfer_len))
zip[id].max_transfer_len = zip[id].packet_len - zip[id].pos;
old_pos = zip[id].pos;
zip[id].packet_status = out ? ZIP_PHASE_DATA_OUT : ZIP_PHASE_DATA_IN;
@@ -2283,7 +2280,7 @@ int zip_read_from_dma(uint8_t id)
in_data_length = *BufLen;
zip_log("ZIP %i: SCSI Input data length: %i\n", id, in_data_length);
} else {
in_data_length = zip[id].request_length;
in_data_length = zip[id].max_transfer_len;
zip_log("ZIP %i: ATAPI Input data length: %i\n", id, in_data_length);
}
@@ -2473,7 +2470,7 @@ uint32_t zip_read(uint8_t channel, int length)
}
if (zip[id].packet_status == ZIP_PHASE_DATA_IN) {
if ((zip[id].request_pos >= zip[id].request_length) || (zip[id].pos >= zip[id].packet_len)) {
if ((zip[id].request_pos >= zip[id].max_transfer_len) || (zip[id].pos >= zip[id].packet_len)) {
/* Time for a DRQ. */
// zip_log("ZIP %i: Issuing read callback\n", id);
zip_pio_request(id, 0);
@@ -2529,7 +2526,7 @@ void zip_write(uint8_t channel, uint32_t val, int length)
}
if (zip[id].packet_status == ZIP_PHASE_DATA_OUT) {
if ((zip[id].request_pos >= zip[id].request_length) || (zip[id].pos >= zip[id].packet_len)) {
if ((zip[id].request_pos >= zip[id].max_transfer_len) || (zip[id].pos >= zip[id].packet_len)) {
/* Time for a DRQ. */
zip_pio_request(id, 1);
}

View File

@@ -9,11 +9,11 @@
* Implementation of the Iomega ZIP drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)zip.h 1.0.1 2018/02/14
* Version: @(#)zip.h 1.0.2 2018/03/04
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2016-2018 Miran Grca.
* Copyright 2018 Miran Grca.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -92,6 +92,7 @@ typedef struct {
uint8_t error;
uint8_t features;
uint16_t request_length;
uint16_t max_transfer_len;
uint8_t status;
uint8_t phase;