From 1a3ad96f3a037c5757d46b6eb78e1e338740599b Mon Sep 17 00:00:00 2001 From: smf- Date: Fri, 14 Jun 2013 04:48:44 +0000 Subject: [PATCH] derive chihiro's baseboard ide from ide mass storage device (nw) --- src/emu/machine/idehd.c | 72 +++++++++++++++++++------------------- src/emu/machine/idehd.h | 7 ++-- src/mame/drivers/chihiro.c | 4 +-- 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/emu/machine/idehd.c b/src/emu/machine/idehd.c index fe8987189c3..041671b0c4b 100644 --- a/src/emu/machine/idehd.c +++ b/src/emu/machine/idehd.c @@ -159,7 +159,7 @@ static void swap_strncpy(UINT8 *dst, const char *src, int field_size_in_words) } -void ide_hdd_device::ide_build_features() +void ide_mass_storage_device::ide_build_features() { memset(m_features, 0, IDE_DISK_SECTOR_SIZE); int total_sectors = m_num_cylinders * m_num_heads * m_num_sectors; @@ -376,6 +376,41 @@ void ide_mass_storage_device::device_reset() set_dmarq(CLEAR_LINE); } +void ide_mass_storage_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch(id) + { + case TID_DELAYED_INTERRUPT: + m_status &= ~IDE_STATUS_BUSY; + set_irq(ASSERT_LINE); + break; + + case TID_DELAYED_INTERRUPT_BUFFER_READY: + m_status &= ~IDE_STATUS_BUSY; + m_status |= IDE_STATUS_BUFFER_READY; + set_irq(ASSERT_LINE); + break; + + case TID_RESET_CALLBACK: + reset(); + break; + + case TID_SECURITY_ERROR_DONE: + /* clear error state */ + m_status &= ~IDE_STATUS_ERROR; + m_status |= IDE_STATUS_DRIVE_READY; + break; + + case TID_READ_SECTOR_DONE_CALLBACK: + read_sector_done(); + break; + + case TID_WRITE_SECTOR_DONE_CALLBACK: + write_sector_done(); + break; + } +} + void ide_mass_storage_device::signal_delayed_interrupt(attotime time, int buffer_ready) { /* clear buffer ready and set the busy flag */ @@ -1368,41 +1403,6 @@ void ide_hdd_device::device_reset() } } -void ide_mass_storage_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch(id) - { - case TID_DELAYED_INTERRUPT: - m_status &= ~IDE_STATUS_BUSY; - set_irq(ASSERT_LINE); - break; - - case TID_DELAYED_INTERRUPT_BUFFER_READY: - m_status &= ~IDE_STATUS_BUSY; - m_status |= IDE_STATUS_BUFFER_READY; - set_irq(ASSERT_LINE); - break; - - case TID_RESET_CALLBACK: - reset(); - break; - - case TID_SECURITY_ERROR_DONE: - /* clear error state */ - m_status &= ~IDE_STATUS_ERROR; - m_status |= IDE_STATUS_DRIVE_READY; - break; - - case TID_READ_SECTOR_DONE_CALLBACK: - read_sector_done(); - break; - - case TID_WRITE_SECTOR_DONE_CALLBACK: - write_sector_done(); - break; - } -} - //------------------------------------------------- // read device key //------------------------------------------------- diff --git a/src/emu/machine/idehd.h b/src/emu/machine/idehd.h index bf82e573b46..2646d07b9ce 100644 --- a/src/emu/machine/idehd.h +++ b/src/emu/machine/idehd.h @@ -77,6 +77,7 @@ protected: void set_irq(int state); void set_dmarq(int state); + void ide_build_features(); UINT8 m_gnetreadlock; @@ -142,8 +143,8 @@ public: ide_hdd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ide_hdd_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - virtual int read_sector(UINT32 lba, void *buffer) { return hard_disk_read(m_disk, lba, buffer); } - virtual int write_sector(UINT32 lba, const void *buffer) { return hard_disk_write(m_disk, lba, buffer); } + virtual int read_sector(UINT32 lba, void *buffer) { return hard_disk_read(m_disk, lba, buffer); } + virtual int write_sector(UINT32 lba, const void *buffer) { return hard_disk_write(m_disk, lba, buffer); } protected: // device-level overrides @@ -155,8 +156,6 @@ protected: virtual bool is_ready() { return (m_disk != NULL); } virtual void read_key(UINT8 key[]); - void ide_build_features(); - chd_file *m_handle; hard_disk_file *m_disk; }; diff --git a/src/mame/drivers/chihiro.c b/src/mame/drivers/chihiro.c index 22db752d483..ee41bfed7d0 100644 --- a/src/mame/drivers/chihiro.c +++ b/src/mame/drivers/chihiro.c @@ -2656,7 +2656,7 @@ WRITE32_MEMBER( chihiro_state::dummy_w ) // ======================> ide_baseboard_device -class ide_baseboard_device : public ide_hdd_device +class ide_baseboard_device : public ide_mass_storage_device { public: // construction/destruction @@ -2684,7 +2684,7 @@ const device_type IDE_BASEBOARD = &device_creator; //------------------------------------------------- ide_baseboard_device::ide_baseboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : ide_hdd_device(mconfig, IDE_BASEBOARD, "IDE Baseboard", tag, owner, clock, "ide_baseboard", __FILE__) + : ide_mass_storage_device(mconfig, IDE_BASEBOARD, "IDE Baseboard", tag, owner, clock, "ide_baseboard", __FILE__) { }