summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Miodrag Milanović <mmicko@gmail.com>2022-07-07 11:08:04 +0200
committer GitHub <noreply@github.com>2022-07-07 19:08:04 +1000
commitf3fb60fee6fb83c80e776fcfd1bd271dc83d126f (patch)
tree4c35a9c28c78b71cb359ad05708eaefca1318019
parentf079cbf8dc162dcf7a2ddb79baae8a65e12933b6 (diff)
bus/ide: Added ATA CompactFlash device. (#9782)
-rw-r--r--src/devices/bus/ata/atadev.cpp1
-rw-r--r--src/devices/bus/ata/idehd.cpp76
-rw-r--r--src/devices/bus/ata/idehd.h18
-rw-r--r--src/devices/bus/rc2014/cf.cpp2
4 files changed, 95 insertions, 2 deletions
diff --git a/src/devices/bus/ata/atadev.cpp b/src/devices/bus/ata/atadev.cpp
index b5873fd2a6e..d4e3e3cd3fa 100644
--- a/src/devices/bus/ata/atadev.cpp
+++ b/src/devices/bus/ata/atadev.cpp
@@ -70,4 +70,5 @@ void ata_devices(device_slot_interface &device)
device.option_add("hdd", IDE_HARDDISK);
device.option_add("cdrom", ATAPI_CDROM);
device.option_add("px320a", PX320A);
+ device.option_add("cf", ATA_CF);
}
diff --git a/src/devices/bus/ata/idehd.cpp b/src/devices/bus/ata/idehd.cpp
index ba5829e6d9c..38ea6c21c6c 100644
--- a/src/devices/bus/ata/idehd.cpp
+++ b/src/devices/bus/ata/idehd.cpp
@@ -877,3 +877,79 @@ void ide_hdd_device::device_add_mconfig(machine_config &config)
{
HARDDISK(config, "image", "ide_hdd");
}
+
+//**************************************************************************
+// ATA COMPACTFLASH CARD DEVICE
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(ATA_CF, ide_cf_device, "atacf", "ATA CompactFlash Card")
+
+//-------------------------------------------------
+// ide_cf_device - constructor
+//-------------------------------------------------
+
+ide_cf_device::ide_cf_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : ide_hdd_device(mconfig, ATA_CF, tag, owner, clock)
+{
+}
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void ide_cf_device::device_add_mconfig(machine_config &config)
+{
+ HARDDISK(config, "image", "ata_cf");
+}
+
+//-------------------------------------------------
+// ide_build_identify_device
+//-------------------------------------------------
+
+void ide_cf_device::ide_build_identify_device()
+{
+ memset(m_identify_buffer, 0, sizeof(m_identify_buffer));
+ int total_sectors = m_num_cylinders * m_num_heads * m_num_sectors;
+
+ /* basic geometry */
+ m_identify_buffer[0] = 0x848a; /* 0: configuration bits */
+ m_identify_buffer[1] = m_num_cylinders; /* 1: logical cylinders */
+ m_identify_buffer[2] = 0; /* 2: reserved */
+ m_identify_buffer[3] = m_num_heads; /* 3: logical heads */
+ m_identify_buffer[4] = 0; /* 4: number of unformatted bytes per track */
+ m_identify_buffer[5] = 0; /* 5: number of unformatted bytes per sector */
+ m_identify_buffer[6] = m_num_sectors; /* 6: logical sectors per logical track */
+ m_identify_buffer[7] = total_sectors >> 16; /* 7: number of sectors per card MSW */
+ m_identify_buffer[8] = total_sectors & 0xffff; /* 8: number of sectors per card LSW */
+ m_identify_buffer[9] = 0; /* 9: vendor-specific */
+ swap_strncpy(&m_identify_buffer[10], /* 10-19: serial number */
+ "00000000000000000000", 10);
+ m_identify_buffer[20] = 0; /* 20: buffer type */
+ m_identify_buffer[21] = 0; /* 21: buffer size in 512 byte increments */
+ m_identify_buffer[22] = 4; /* 22: # of vendor-specific bytes on read/write long commands */
+ swap_strncpy(&m_identify_buffer[23], /* 23-26: firmware revision */
+ "1.0", 4);
+ swap_strncpy(&m_identify_buffer[27], /* 27-46: model number */
+ "MAME Compressed CompactFlash", 20);
+ m_identify_buffer[47] = 0x0001; /* 47: read/write multiple support */
+ m_identify_buffer[48] = 0; /* 48: double word not supported */
+ m_identify_buffer[49] = 0x0200; /* 49: capabilities */
+ m_identify_buffer[50] = 0; /* 50: reserved */
+ m_identify_buffer[51] = 0x0200; /* 51: PIO data transfer cycle timing mode */
+ m_identify_buffer[52] = 0x0000; /* 52: single word DMA transfer cycle timing mode */
+ m_identify_buffer[53] = 0x0003; /* 53: translation parameters are valid */
+ m_identify_buffer[54] = m_num_cylinders; /* 54: number of current logical cylinders */
+ m_identify_buffer[55] = m_num_heads; /* 55: number of current logical heads */
+ m_identify_buffer[56] = m_num_sectors; /* 56: number of current logical sectors per track */
+ m_identify_buffer[57] = total_sectors & 0xffff; /* 57-58: current capacity in sectors */
+ m_identify_buffer[58] = total_sectors >> 16;
+ m_identify_buffer[59] = 0; /* 59: multiple sector timing */
+ m_identify_buffer[60] = total_sectors & 0xffff; /* 60-61: total user addressable sectors for LBA mode */
+ m_identify_buffer[61] = total_sectors >> 16;
+ m_identify_buffer[62] = 0x00; /* 62-127: reserved */
+ m_identify_buffer[128] = 0x00; /* 128: security status */
+ m_identify_buffer[129] = 0x00; /* 129-159: vendor specific */
+ m_identify_buffer[160] = 0x00; /* 160: Power requirement description*/
+ m_identify_buffer[161] = 0x00; /* 161-255: reserved */
+}
diff --git a/src/devices/bus/ata/idehd.h b/src/devices/bus/ata/idehd.h
index 684082cc4a7..0d7a999a412 100644
--- a/src/devices/bus/ata/idehd.h
+++ b/src/devices/bus/ata/idehd.h
@@ -44,7 +44,7 @@ protected:
virtual int write_sector(uint32_t lba, const void *buffer) = 0;
virtual attotime seek_time();
- void ide_build_identify_device();
+ virtual void ide_build_identify_device();
static const int IDE_DISK_SECTOR_SIZE = 512;
virtual int sector_length() override { return IDE_DISK_SECTOR_SIZE; }
@@ -119,7 +119,23 @@ private:
emu_timer * m_last_status_timer;
};
+// ======================> ide_cf_device
+
+class ide_cf_device : public ide_hdd_device
+{
+public:
+ // construction/destruction
+ ide_cf_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ // optional information overrides
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ void ide_build_identify_device() override;
+};
+
// device type definition
DECLARE_DEVICE_TYPE(IDE_HARDDISK, ide_hdd_device)
+DECLARE_DEVICE_TYPE(ATA_CF, ide_cf_device)
#endif // MAME_BUS_ATA_IDEHD_H
diff --git a/src/devices/bus/rc2014/cf.cpp b/src/devices/bus/rc2014/cf.cpp
index c30da3f429e..9640853da86 100644
--- a/src/devices/bus/rc2014/cf.cpp
+++ b/src/devices/bus/rc2014/cf.cpp
@@ -56,7 +56,7 @@ void compact_flash_device::device_reset()
void compact_flash_device::device_add_mconfig(machine_config &config)
{
- ATA_INTERFACE(config, m_ata).options(ata_devices, "hdd", nullptr, true);
+ ATA_INTERFACE(config, m_ata).options(ata_devices, "cf", nullptr, true);
}
}