simplified status flags & fixed ct486 booting in mess (nw)

This commit is contained in:
smf- 2013-06-15 12:23:32 +00:00
parent 5bc13ef7f6
commit a682441465
5 changed files with 67 additions and 102 deletions

View File

@ -9,6 +9,9 @@ ata_flash_pccard_device::ata_flash_pccard_device(const machine_config &mconfig,
void ata_flash_pccard_device::device_reset() void ata_flash_pccard_device::device_reset()
{ {
m_locked = 0x1ff;
m_gnetreadlock = 1;
ide_hdd_device::device_reset(); ide_hdd_device::device_reset();
UINT32 metalength; UINT32 metalength;
@ -16,9 +19,6 @@ void ata_flash_pccard_device::device_reset()
if (m_handle != NULL) if (m_handle != NULL)
m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength); m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength);
m_locked = 0x1ff;
m_gnetreadlock = 1;
} }
READ16_MEMBER( ata_flash_pccard_device::read_memory ) READ16_MEMBER( ata_flash_pccard_device::read_memory )

View File

@ -351,7 +351,7 @@ void ide_controller_device::device_start()
} }
dev->write_csel(i); dev->write_csel(i);
dev->write_dasp(m_slot[1]->dev() != NULL); dev->write_dasp(m_slot[1]->dev() != NULL && m_slot[1]->dev()->device_present());
} }
} }

View File

@ -16,7 +16,6 @@
#define TIME_PER_SECTOR (attotime::from_usec(100)) #define TIME_PER_SECTOR (attotime::from_usec(100))
#define TIME_PER_ROTATION (attotime::from_hz(5400/60)) #define TIME_PER_ROTATION (attotime::from_hz(5400/60))
#define TIME_SECURITY_ERROR (attotime::from_msec(1000))
#define TIME_SEEK_MULTISECTOR (attotime::from_msec(13)) #define TIME_SEEK_MULTISECTOR (attotime::from_msec(13))
#define TIME_NO_SEEK_MULTISECTOR (attotime::from_nsec(16300)) #define TIME_NO_SEEK_MULTISECTOR (attotime::from_nsec(16300))
@ -67,7 +66,6 @@ enum
TID_DELAYED_INTERRUPT, TID_DELAYED_INTERRUPT,
TID_DELAYED_INTERRUPT_BUFFER_READY, TID_DELAYED_INTERRUPT_BUFFER_READY,
TID_RESET_CALLBACK, TID_RESET_CALLBACK,
TID_SECURITY_ERROR_DONE,
TID_READ_SECTOR_DONE_CALLBACK, TID_READ_SECTOR_DONE_CALLBACK,
TID_WRITE_SECTOR_DONE_CALLBACK TID_WRITE_SECTOR_DONE_CALLBACK
}; };
@ -387,13 +385,12 @@ void ide_mass_storage_device::device_reset()
m_gnetreadlock = 0; m_gnetreadlock = 0;
m_master_password_enable = (m_master_password != NULL); m_master_password_enable = (m_master_password != NULL);
m_user_password_enable = (m_user_password != NULL); m_user_password_enable = (m_user_password != NULL);
m_error = IDE_ERROR_DEFAULT; m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
m_status = IDE_STATUS_DSC; m_status = IDE_STATUS_DSC;
if (is_ready())
{ if (!m_gnetreadlock)
m_status |= IDE_STATUS_DRDY; m_status |= IDE_STATUS_DRDY;
}
m_cur_drive = 0; m_cur_drive = 0;
@ -422,12 +419,6 @@ void ide_mass_storage_device::device_timer(emu_timer &timer, device_timer_id id,
reset(); reset();
break; break;
case TID_SECURITY_ERROR_DONE:
/* clear error state */
m_status &= ~IDE_STATUS_ERR;
m_status |= IDE_STATUS_DRDY;
break;
case TID_READ_SECTOR_DONE_CALLBACK: case TID_READ_SECTOR_DONE_CALLBACK:
read_sector_done(); read_sector_done();
break; break;
@ -504,10 +495,8 @@ void ide_mass_storage_device::security_error()
{ {
/* set error state */ /* set error state */
m_status |= IDE_STATUS_ERR; m_status |= IDE_STATUS_ERR;
m_error = IDE_ERROR_NONE;
m_status &= ~IDE_STATUS_DRDY; m_status &= ~IDE_STATUS_DRDY;
/* just set a timer and mark ourselves error */
timer_set(TIME_SECURITY_ERROR, TID_SECURITY_ERROR_DONE);
} }
@ -523,24 +512,20 @@ void ide_mass_storage_device::read_buffer_empty()
/* reset the totals */ /* reset the totals */
m_buffer_offset = 0; m_buffer_offset = 0;
/* clear the buffer ready and busy flag */
m_status &= ~IDE_STATUS_DRQ; m_status &= ~IDE_STATUS_DRQ;
m_status &= ~IDE_STATUS_BSY;
m_error = IDE_ERROR_DEFAULT;
set_dmarq(CLEAR_LINE); set_dmarq(CLEAR_LINE);
if (m_master_password_enable || m_user_password_enable) if (m_master_password_enable || m_user_password_enable)
{ {
security_error(); security_error();
m_sector_count = 0; m_sector_count = 0;
return; return;
} }
/* if there is more data to read, keep going */ /* if there is more data to read, keep going */
if (m_sector_count > 0) if (m_sector_count > 0)
m_sector_count--; m_sector_count--;
if (m_sector_count > 0) if (m_sector_count > 0)
read_next_sector(); read_next_sector();
} }
@ -550,26 +535,17 @@ void ide_mass_storage_device::read_sector_done()
{ {
int lba = lba_address(), count = 0; int lba = lba_address(), count = 0;
m_status &= ~IDE_STATUS_BSY;
/* GNET readlock check */ /* GNET readlock check */
if (m_gnetreadlock) { if (m_gnetreadlock)
m_status &= ~IDE_STATUS_ERR; {
m_status &= ~IDE_STATUS_BSY;
return; return;
} }
/* now do the read */ /* now do the read */
count = read_sector(lba, m_buffer); count = read_sector(lba, m_buffer);
/* by default, mark the buffer ready and the seek complete */
if (!m_verify_only)
m_status |= IDE_STATUS_DRQ;
m_status |= IDE_STATUS_DSC;
/* and clear the busy and error flags */
m_status &= ~IDE_STATUS_ERR;
m_status &= ~IDE_STATUS_BSY;
/* if we succeeded, advance to the next sector and set the nice bits */ /* if we succeeded, advance to the next sector and set the nice bits */
if (count == 1) if (count == 1)
{ {
@ -578,9 +554,6 @@ void ide_mass_storage_device::read_sector_done()
if (m_sector_count != 1) if (m_sector_count != 1)
next_sector(); next_sector();
/* clear the error value */
m_error = IDE_ERROR_NONE;
/* signal an interrupt */ /* signal an interrupt */
if (!m_verify_only) if (!m_verify_only)
m_sectors_until_int--; m_sectors_until_int--;
@ -590,13 +563,18 @@ void ide_mass_storage_device::read_sector_done()
set_irq(ASSERT_LINE); set_irq(ASSERT_LINE);
} }
/* handle DMA */
if (m_dma_active)
set_dmarq(ASSERT_LINE);
/* if we're just verifying we can read the next sector */ /* if we're just verifying we can read the next sector */
if (m_verify_only) if (m_verify_only)
{
read_buffer_empty(); read_buffer_empty();
}
else
{
m_status |= IDE_STATUS_DRQ;
if (m_dma_active)
set_dmarq(ASSERT_LINE);
}
} }
/* if we got an error, we need to report it */ /* if we got an error, we need to report it */
@ -669,7 +647,6 @@ void ide_mass_storage_device::continue_write()
m_buffer_offset = 0; m_buffer_offset = 0;
/* clear the buffer ready flag */ /* clear the buffer ready flag */
m_status &= ~IDE_STATUS_DRQ;
m_status |= IDE_STATUS_BSY; m_status |= IDE_STATUS_BSY;
if (m_command == IDE_COMMAND_WRITE_MULTIPLE) if (m_command == IDE_COMMAND_WRITE_MULTIPLE)
@ -695,6 +672,7 @@ void ide_mass_storage_device::continue_write()
void ide_mass_storage_device::write_buffer_full() void ide_mass_storage_device::write_buffer_full()
{ {
m_status &= ~IDE_STATUS_DRQ;
set_dmarq(CLEAR_LINE); set_dmarq(CLEAR_LINE);
if (m_command == IDE_COMMAND_SECURITY_UNLOCK) if (m_command == IDE_COMMAND_SECURITY_UNLOCK)
@ -724,15 +702,8 @@ void ide_mass_storage_device::write_buffer_full()
mame_printf_debug("\n"); mame_printf_debug("\n");
} }
/* clear the busy and error flags */
m_status &= ~IDE_STATUS_ERR;
m_status &= ~IDE_STATUS_BSY;
m_status &= ~IDE_STATUS_DRQ;
if (m_master_password_enable || m_user_password_enable) if (m_master_password_enable || m_user_password_enable)
security_error(); security_error();
else
m_status |= IDE_STATUS_DRDY;
} }
else if (m_command == IDE_COMMAND_TAITO_GNET_UNLOCK_2) else if (m_command == IDE_COMMAND_TAITO_GNET_UNLOCK_2)
{ {
@ -743,12 +714,13 @@ void ide_mass_storage_device::write_buffer_full()
for (i=0; !bad && i<512; i++) for (i=0; !bad && i<512; i++)
bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != key[i-2]); bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != key[i-2]);
m_status &= ~IDE_STATUS_BSY;
m_status &= ~IDE_STATUS_DRQ;
if (bad) if (bad)
{
m_status |= IDE_STATUS_ERR; m_status |= IDE_STATUS_ERR;
else { m_error = IDE_ERROR_NONE;
m_status &= ~IDE_STATUS_ERR; }
else
{
m_gnetreadlock= 0; m_gnetreadlock= 0;
} }
} }
@ -763,17 +735,11 @@ void ide_mass_storage_device::write_sector_done()
{ {
int lba = lba_address(), count = 0; int lba = lba_address(), count = 0;
m_status &= ~IDE_STATUS_BSY;
/* now do the write */ /* now do the write */
count = write_sector(lba, m_buffer); count = write_sector(lba, m_buffer);
/* by default, mark the buffer ready and the seek complete */
m_status |= IDE_STATUS_DRQ;
m_status |= IDE_STATUS_DSC;
/* and clear the busy adn error flags */
m_status &= ~IDE_STATUS_ERR;
m_status &= ~IDE_STATUS_BSY;
/* if we succeeded, advance to the next sector and set the nice bits */ /* if we succeeded, advance to the next sector and set the nice bits */
if (count == 1) if (count == 1)
{ {
@ -782,9 +748,6 @@ void ide_mass_storage_device::write_sector_done()
if (m_sector_count != 1) if (m_sector_count != 1)
next_sector(); next_sector();
/* clear the error value */
m_error = IDE_ERROR_NONE;
/* signal an interrupt */ /* signal an interrupt */
if (--m_sectors_until_int == 0 || m_sector_count == 1) if (--m_sectors_until_int == 0 || m_sector_count == 1)
{ {
@ -795,13 +758,15 @@ void ide_mass_storage_device::write_sector_done()
/* signal an interrupt if there's more data needed */ /* signal an interrupt if there's more data needed */
if (m_sector_count > 0) if (m_sector_count > 0)
m_sector_count--; m_sector_count--;
if (m_sector_count == 0)
m_status &= ~IDE_STATUS_DRQ;
/* keep going for DMA */ if (m_sector_count > 0)
if (m_dma_active && m_sector_count != 0)
{ {
set_dmarq(ASSERT_LINE); m_status |= IDE_STATUS_DRQ;
if (m_dma_active)
{
set_dmarq(ASSERT_LINE);
}
} }
} }
@ -833,6 +798,8 @@ void ide_mass_storage_device::handle_command()
set_irq(CLEAR_LINE); set_irq(CLEAR_LINE);
set_dmarq(CLEAR_LINE); set_dmarq(CLEAR_LINE);
m_status &= ~IDE_STATUS_ERR;
switch (m_command) switch (m_command)
{ {
case IDE_COMMAND_READ_SECTORS: case IDE_COMMAND_READ_SECTORS:
@ -962,38 +929,25 @@ void ide_mass_storage_device::handle_command()
/* indicate everything is ready */ /* indicate everything is ready */
m_status |= IDE_STATUS_DRQ; m_status |= IDE_STATUS_DRQ;
m_status |= IDE_STATUS_DSC;
m_status |= IDE_STATUS_DRDY;
/* and clear the busy adn error flags */
m_status &= ~IDE_STATUS_ERR;
m_status &= ~IDE_STATUS_BSY; m_status &= ~IDE_STATUS_BSY;
/* clear the error too */
m_error = IDE_ERROR_NONE;
/* signal an interrupt */ /* signal an interrupt */
signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 1); signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 1);
break; break;
case IDE_COMMAND_DIAGNOSTIC: case IDE_COMMAND_DIAGNOSTIC:
m_error = IDE_ERROR_DEFAULT; m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
/* signal an interrupt */ /* signal an interrupt */
signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0); signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
break; break;
case IDE_COMMAND_RECALIBRATE: case IDE_COMMAND_RECALIBRATE:
/* clear the error too */
m_error = IDE_ERROR_NONE;
/* signal an interrupt */ /* signal an interrupt */
signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0); signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
break; break;
case IDE_COMMAND_IDLE: case IDE_COMMAND_IDLE:
/* clear the error too */
m_error = IDE_ERROR_NONE;
/* for timeout disabled value is 0 */ /* for timeout disabled value is 0 */
m_sector_count = 0; m_sector_count = 0;
/* signal an interrupt */ /* signal an interrupt */
@ -1002,8 +956,6 @@ void ide_mass_storage_device::handle_command()
case IDE_COMMAND_SET_CONFIG: case IDE_COMMAND_SET_CONFIG:
LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", m_cur_head + 1, m_sector_count)); LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", m_cur_head + 1, m_sector_count));
m_status &= ~IDE_STATUS_ERR;
m_error = IDE_ERROR_NONE;
set_geometry(m_sector_count,m_cur_head + 1); set_geometry(m_sector_count,m_cur_head + 1);
/* signal an interrupt */ /* signal an interrupt */
@ -1029,8 +981,6 @@ void ide_mass_storage_device::handle_command()
LOGPRINT(("IDE Set block count (%02X)\n", m_sector_count)); LOGPRINT(("IDE Set block count (%02X)\n", m_sector_count));
m_block_count = m_sector_count; m_block_count = m_sector_count;
// judge dredd wants 'drive ready' on this command
m_status |= IDE_STATUS_DRDY;
/* signal an interrupt */ /* signal an interrupt */
set_irq(ASSERT_LINE); set_irq(ASSERT_LINE);
@ -1041,7 +991,7 @@ void ide_mass_storage_device::handle_command()
m_sector_count = 1; m_sector_count = 1;
m_status |= IDE_STATUS_DRDY; m_status |= IDE_STATUS_DRDY;
m_status &= ~IDE_STATUS_ERR;
set_irq(ASSERT_LINE); set_irq(ASSERT_LINE);
break; break;
@ -1068,10 +1018,11 @@ void ide_mass_storage_device::handle_command()
{ {
m_gnetreadlock= 0; m_gnetreadlock= 0;
} }
else
{
m_status &= ~IDE_STATUS_DRDY;
}
/* update flags */
m_status |= IDE_STATUS_DRDY;
m_status &= ~IDE_STATUS_ERR;
set_irq(ASSERT_LINE); set_irq(ASSERT_LINE);
break; break;
@ -1081,8 +1032,6 @@ void ide_mass_storage_device::handle_command()
are all already set in this case so no need are all already set in this case so no need
so that implements actual seek so that implements actual seek
*/ */
/* clear the error too */
m_error = IDE_ERROR_NONE;
/* for timeout disabled value is 0 */ /* for timeout disabled value is 0 */
m_sector_count = 0; m_sector_count = 0;
@ -1250,12 +1199,18 @@ READ16_MEMBER( ide_mass_storage_device::read_cs0 )
m_last_status_timer->adjust(attotime::never); m_last_status_timer->adjust(attotime::never);
} }
if (!(m_status & IDE_STATUS_DRDY) && !m_gnetreadlock)
{
m_status |= IDE_STATUS_DRDY;
}
set_irq(CLEAR_LINE); set_irq(CLEAR_LINE);
} }
else else
{ {
result = 0; result = 0;
} }
break; break;
/* log anything else */ /* log anything else */
@ -1354,6 +1309,9 @@ void ide_mass_storage_device::write_dma( UINT16 data )
WRITE16_MEMBER( ide_mass_storage_device::write_cs0 ) WRITE16_MEMBER( ide_mass_storage_device::write_cs0 )
{ {
if (!device_present())
return;
/* logit */ /* logit */
if (offset != IDE_CS0_DATA_RW) if (offset != IDE_CS0_DATA_RW)
LOG(("%s:IDE cs0 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask)); LOG(("%s:IDE cs0 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));
@ -1445,6 +1403,9 @@ WRITE16_MEMBER( ide_mass_storage_device::write_cs0 )
WRITE16_MEMBER( ide_mass_storage_device::write_cs1 ) WRITE16_MEMBER( ide_mass_storage_device::write_cs1 )
{ {
if (!device_present())
return;
/* logit */ /* logit */
LOG(("%s:IDE cs1 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask)); LOG(("%s:IDE cs1 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));

View File

@ -28,12 +28,16 @@
#define IDE_STATUS_BSY (0x80) #define IDE_STATUS_BSY (0x80)
#define IDE_ERROR_NONE 0x00 #define IDE_ERROR_NONE 0x00
#define IDE_ERROR_DEFAULT 0x01 #define IDE_ERROR_DIAGNOSTIC_OK 0x01
#define IDE_ERROR_TRACK0_NOT_FOUND 0x02 #define IDE_ERROR_TRACK0_NOT_FOUND 0x02
#define IDE_ERROR_UNKNOWN_COMMAND 0x04 #define IDE_ERROR_UNKNOWN_COMMAND 0x04
#define IDE_ERROR_BAD_LOCATION 0x10 #define IDE_ERROR_BAD_LOCATION 0x10
#define IDE_ERROR_BAD_SECTOR 0x80 #define IDE_ERROR_BAD_SECTOR 0x80
#define IDE_ERROR_DIAGNOSTIC_FAILED 0x00
#define IDE_ERROR_DIAGNOSTIC_PASSED 0x01
#define IDE_ERROR_DIAGNOSTIC_DEVICE1_FAILED 0x81
// ======================> ide_device_interface // ======================> ide_device_interface
class ide_device_interface class ide_device_interface
@ -53,6 +57,7 @@ public:
virtual DECLARE_WRITE_LINE_MEMBER(write_csel) = 0; virtual DECLARE_WRITE_LINE_MEMBER(write_csel) = 0;
virtual DECLARE_WRITE_LINE_MEMBER(write_dasp) = 0; virtual DECLARE_WRITE_LINE_MEMBER(write_dasp) = 0;
virtual bool device_present() = 0;
virtual UINT8 *get_features() = 0; virtual UINT8 *get_features() = 0;
UINT8 m_master_password_enable; UINT8 m_master_password_enable;
@ -91,11 +96,10 @@ protected:
virtual int read_sector(UINT32 lba, void *buffer) = 0; virtual int read_sector(UINT32 lba, void *buffer) = 0;
virtual int write_sector(UINT32 lba, const void *buffer) = 0; virtual int write_sector(UINT32 lba, const void *buffer) = 0;
virtual bool is_ready() = 0;
virtual void read_key(UINT8 key[]) = 0; virtual void read_key(UINT8 key[]) = 0;
bool device_selected() { return m_cur_drive == m_csel; } bool device_selected() { return m_csel == m_cur_drive && device_present(); }
bool single_device() { return m_csel == 0 && m_dasp == 0; } bool single_device() { return m_csel == 0 && m_dasp == 0 && device_present(); }
void set_irq(int state); void set_irq(int state);
void set_dmarq(int state); void set_dmarq(int state);
@ -177,7 +181,7 @@ protected:
// optional information overrides // optional information overrides
virtual machine_config_constructor device_mconfig_additions() const; virtual machine_config_constructor device_mconfig_additions() const;
virtual bool is_ready() { return (m_disk != NULL); } virtual bool device_present() { return (m_disk != NULL); }
virtual void read_key(UINT8 key[]); virtual void read_key(UINT8 key[]);
chd_file *m_handle; chd_file *m_handle;

View File

@ -2664,7 +2664,7 @@ public:
virtual int read_sector(UINT32 lba, void *buffer); virtual int read_sector(UINT32 lba, void *buffer);
virtual int write_sector(UINT32 lba, const void *buffer); virtual int write_sector(UINT32 lba, const void *buffer);
virtual bool is_ready() { return true; } virtual bool device_present() { return true; }
virtual void read_key(UINT8 key[]) { } virtual void read_key(UINT8 key[]) { }
protected: protected:
// device-level overrides // device-level overrides