summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2022-04-04 17:23:05 +0200
committer Olivier Galibert <galibert@pobox.com>2022-04-04 17:42:19 +0200
commit3fc66954975655066d0109c49986a360f9f24df1 (patch)
treec20637bf2157f99663b383f5e15b6780994e6f67 /src
parent65a2e8d004dd8ddcd27e22df30ec48626f6b3187 (diff)
hard_disk_file: Hide the chd
Diffstat (limited to 'src')
-rw-r--r--src/devices/bus/ata/idehd.cpp8
-rw-r--r--src/devices/bus/ata/idehd.h1
-rw-r--r--src/devices/bus/nscsi/hd.cpp5
-rw-r--r--src/devices/imagedev/diablo.cpp16
-rw-r--r--src/devices/imagedev/diablo.h1
-rw-r--r--src/devices/imagedev/harddriv.cpp16
-rw-r--r--src/devices/imagedev/harddriv.h1
-rw-r--r--src/devices/imagedev/mfmhd.cpp72
-rw-r--r--src/devices/imagedev/mfmhd.h14
-rw-r--r--src/devices/machine/ataflash.cpp26
-rw-r--r--src/devices/machine/ataflash.h8
-rw-r--r--src/devices/machine/diablo_hd.cpp7
-rw-r--r--src/devices/machine/diablo_hd.h1
-rw-r--r--src/lib/util/harddisk.cpp33
-rw-r--r--src/lib/util/harddisk.h8
15 files changed, 103 insertions, 114 deletions
diff --git a/src/devices/bus/ata/idehd.cpp b/src/devices/bus/ata/idehd.cpp
index b40b33fb7b5..9b20827d4fd 100644
--- a/src/devices/bus/ata/idehd.cpp
+++ b/src/devices/bus/ata/idehd.cpp
@@ -821,7 +821,6 @@ void ide_hdd_device::device_start()
void ide_hdd_device::device_reset()
{
- m_handle = m_image->get_chd_file();
m_disk = m_image->get_hard_disk_file();
if (m_disk != nullptr && !m_can_identify_device)
@@ -837,12 +836,13 @@ void ide_hdd_device::device_reset()
}
// build the features page
- uint32_t metalength;
- if (m_handle && !m_handle->read_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, &m_buffer[0], 512, metalength))
+ std::vector<u8> ident;
+ m_disk->get_inquiry_data(ident);
+ if (ident.size() == 512)
{
for( int w = 0; w < 256; w++ )
{
- m_identify_buffer[w] = (m_buffer[(w * 2) + 1] << 8) | m_buffer[w * 2];
+ m_identify_buffer[w] = (ident[(w * 2) + 1] << 8) | ident[w * 2];
}
}
else
diff --git a/src/devices/bus/ata/idehd.h b/src/devices/bus/ata/idehd.h
index 4eb0edd3671..684082cc4a7 100644
--- a/src/devices/bus/ata/idehd.h
+++ b/src/devices/bus/ata/idehd.h
@@ -106,7 +106,6 @@ protected:
virtual int write_sector(uint32_t lba, const void *buffer) override { return !m_disk ? 0 : m_disk->write(lba, buffer); }
virtual uint8_t calculate_status() override;
- chd_file *m_handle;
hard_disk_file *m_disk;
enum
diff --git a/src/devices/bus/nscsi/hd.cpp b/src/devices/bus/nscsi/hd.cpp
index f51ad798a15..7e0f48730a8 100644
--- a/src/devices/bus/nscsi/hd.cpp
+++ b/src/devices/bus/nscsi/hd.cpp
@@ -45,10 +45,7 @@ void nscsi_harddisk_device::device_reset()
} else {
const auto &hdinfo = harddisk->get_info();
bytes_per_sector = hdinfo.sectorbytes;
-
- chd_file *chd = image->get_chd_file();
- if(chd != nullptr)
- chd->read_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, m_inquiry_data);
+ harddisk->get_inquiry_data(m_inquiry_data);
}
cur_lba = -1;
}
diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp
index 60ae6fc5fd7..5f8b45e4064 100644
--- a/src/devices/imagedev/diablo.cpp
+++ b/src/devices/imagedev/diablo.cpp
@@ -262,19 +262,3 @@ image_init_result diablo_image_device::internal_load_dsk()
return image_init_result::FAIL;
}
-
-/*************************************
- *
- * Get the CHD file (from the src/chd.c core)
- * after an image has been opened with the hd core
- *
- *************************************/
-
-chd_file *diablo_image_device::get_chd_file()
-{
- chd_file *result = nullptr;
- hard_disk_file *hd_file = get_hard_disk_file();
- if (hd_file)
- result = hd_file->get_chd();
- return result;
-}
diff --git a/src/devices/imagedev/diablo.h b/src/devices/imagedev/diablo.h
index 14e3d9c2fc3..2b483bf8388 100644
--- a/src/devices/imagedev/diablo.h
+++ b/src/devices/imagedev/diablo.h
@@ -43,7 +43,6 @@ public:
// specific implementation
hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle; }
- chd_file *get_chd_file();
protected:
// device-level overrides
diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp
index 35b656c8409..decb4e09909 100644
--- a/src/devices/imagedev/harddriv.cpp
+++ b/src/devices/imagedev/harddriv.cpp
@@ -341,19 +341,3 @@ image_init_result harddisk_image_device::internal_load_hd()
return image_init_result::FAIL;
}
-
-/*************************************
- *
- * Get the CHD file (from the src/chd.c core)
- * after an image has been opened with the hd core
- *
- *************************************/
-
-chd_file *harddisk_image_device::get_chd_file()
-{
- chd_file *result = nullptr;
- hard_disk_file *hd_file = get_hard_disk_file();
- if (hd_file)
- result = hd_file->get_chd();
- return result;
-}
diff --git a/src/devices/imagedev/harddriv.h b/src/devices/imagedev/harddriv.h
index 93eb4e3c19f..5b3b8d7dde3 100644
--- a/src/devices/imagedev/harddriv.h
+++ b/src/devices/imagedev/harddriv.h
@@ -65,7 +65,6 @@ public:
// specific implementation
hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle; }
- chd_file *get_chd_file();
protected:
harddisk_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
diff --git a/src/devices/imagedev/mfmhd.cpp b/src/devices/imagedev/mfmhd.cpp
index a766aafdca7..de67f3eb887 100644
--- a/src/devices/imagedev/mfmhd.cpp
+++ b/src/devices/imagedev/mfmhd.cpp
@@ -270,8 +270,10 @@
**************************************************************************/
#include "emu.h"
-#include "harddisk.h"
+#include "romload.h"
#include "mfmhd.h"
+#include "util/ioprocs.h"
+#include "util/ioprocsfilter.h"
#define LOG_WARN (1U<<1) // Warnings
#define LOG_CONFIG (1U<<2) // Configuration
@@ -303,16 +305,9 @@ enum
STEP_SETTLE
};
-std::string mfm_harddisk_device::tts(const attotime &t)
-{
- char buf[256];
- int nsec = t.attoseconds() / ATTOSECONDS_PER_NANOSECOND;
- sprintf(buf, "%4d.%03d,%03d,%03d", int(t.seconds()), nsec/1000000, (nsec/1000)%1000, nsec % 1000);
- return buf;
-}
-
mfm_harddisk_device::mfm_harddisk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
- : harddisk_image_device(mconfig, type, tag, owner, clock),
+ : device_t(mconfig, type, tag, owner, clock),
+ device_image_interface(mconfig, *this),
m_index_timer(nullptr),
m_spinup_timer(nullptr),
m_seek_timer(nullptr),
@@ -421,26 +416,41 @@ void mfm_harddisk_device::device_stop()
*/
image_init_result mfm_harddisk_device::call_load()
{
- image_init_result loaded = harddisk_image_device::call_load();
+ std::error_condition err;
+
+ /* open the CHD file */
+ if (loaded_through_softlist())
+ {
+ m_chd = machine().rom_load().get_disk_handle(device().subtag("harddriv").c_str());
+ }
+ else
+ {
+ auto io = util::random_read_write_fill(image_core_file(), 0xff);
+ if(!io) {
+ seterror(std::errc::not_enough_memory, nullptr);
+ return image_init_result::FAIL;
+ }
+ m_chd = new chd_file;
+ err = m_chd->open(std::move(io), true);
+ }
std::string devtag(tag());
devtag += ":format";
m_format->set_tag(devtag);
- if (loaded==image_init_result::PASS)
+ if (!err)
{
std::string metadata;
- chd_file* chdfile = get_chd_file();
- if (chdfile==nullptr)
+ if (m_chd==nullptr)
{
- LOG("chdfile is null\n");
+ LOG("m_chd is null\n");
return image_init_result::FAIL;
}
// Read the hard disk metadata
- std::error_condition state = chdfile->read_metadata(HARD_DISK_METADATA_TAG, 0, metadata);
+ std::error_condition state = m_chd->read_metadata(HARD_DISK_METADATA_TAG, 0, metadata);
if (state)
{
LOG("Failed to read CHD metadata\n");
@@ -474,7 +484,7 @@ image_init_result mfm_harddisk_device::call_load()
param.write_precomp_cylinder = -1;
param.reduced_wcurr_cylinder = -1;
- state = chdfile->read_metadata(MFM_HARD_DISK_METADATA_TAG, 0, metadata);
+ state = m_chd->read_metadata(MFM_HARD_DISK_METADATA_TAG, 0, metadata);
if (state)
{
LOGMASKED(LOG_WARN, "Failed to read CHD sector arrangement/recording specs, applying defaults\n");
@@ -493,7 +503,7 @@ image_init_result mfm_harddisk_device::call_load()
LOGMASKED(LOG_CONFIG, "MFM HD rec specs: interleave=%d, cylskew=%d, headskew=%d, wpcom=%d, rwc=%d\n",
param.interleave, param.cylskew, param.headskew, param.write_precomp_cylinder, param.reduced_wcurr_cylinder);
- state = chdfile->read_metadata(MFM_HARD_DISK_METADATA_TAG, 1, metadata);
+ state = m_chd->read_metadata(MFM_HARD_DISK_METADATA_TAG, 1, metadata);
if (state)
{
LOGMASKED(LOG_WARN, "Failed to read CHD track gap specs, applying defaults\n");
@@ -540,8 +550,9 @@ image_init_result mfm_harddisk_device::call_load()
else
{
LOGMASKED(LOG_WARN, "Could not load CHD\n");
+ return image_init_result::FAIL;
}
- return loaded;
+ return image_init_result::PASS;
}
const char *MFMHD_REC_METADATA_FORMAT = "IL:%d,CSKEW:%d,HSKEW:%d,WPCOM:%d,RWC:%d";
@@ -559,9 +570,7 @@ void mfm_harddisk_device::call_unload()
if (m_format->save_param(MFMHD_IL) && !params->equals_rec(oldparams))
{
LOGMASKED(LOG_WARN, "MFM HD sector arrangement and recording specs have changed; updating CHD metadata\n");
- chd_file* chdfile = get_chd_file();
-
- std::error_condition err = chdfile->write_metadata(MFM_HARD_DISK_METADATA_TAG, 0, string_format(MFMHD_REC_METADATA_FORMAT, params->interleave, params->cylskew, params->headskew, params->write_precomp_cylinder, params->reduced_wcurr_cylinder), 0);
+ std::error_condition err = m_chd->write_metadata(MFM_HARD_DISK_METADATA_TAG, 0, string_format(MFMHD_REC_METADATA_FORMAT, params->interleave, params->cylskew, params->headskew, params->write_precomp_cylinder, params->reduced_wcurr_cylinder), 0);
if (err)
{
LOGMASKED(LOG_WARN, "Failed to save MFM HD sector arrangement/recording specs to CHD\n");
@@ -571,16 +580,15 @@ void mfm_harddisk_device::call_unload()
if (m_format->save_param(MFMHD_GAP1) && !params->equals_gap(oldparams))
{
LOGMASKED(LOG_WARN, "MFM HD track gap specs have changed; updating CHD metadata\n");
- chd_file* chdfile = get_chd_file();
-
- std::error_condition err = chdfile->write_metadata(MFM_HARD_DISK_METADATA_TAG, 1, string_format(MFMHD_GAP_METADATA_FORMAT, params->gap1, params->gap2, params->gap3, params->sync, params->headerlen, params->ecctype), 0);
+ std::error_condition err = m_chd->write_metadata(MFM_HARD_DISK_METADATA_TAG, 1, string_format(MFMHD_GAP_METADATA_FORMAT, params->gap1, params->gap2, params->gap3, params->sync, params->headerlen, params->ecctype), 0);
if (err)
{
LOGMASKED(LOG_WARN, "Failed to save MFM HD track gap specs to CHD\n");
}
}
}
- harddisk_image_device::call_unload();
+
+ m_chd = nullptr;
}
void mfm_harddisk_device::setup_index_pulse_cb(index_pulse_cb cb)
@@ -615,7 +623,7 @@ attotime mfm_harddisk_device::track_end_time()
if (!m_revolution_start_time.is_never())
{
endtime = m_revolution_start_time + nexttime;
- LOGMASKED(LOG_TIMING, "Track start time = %s, end time = %s\n", tts(m_revolution_start_time).c_str(), tts(endtime).c_str());
+ LOGMASKED(LOG_TIMING, "Track start time = %s, end time = %s\n", (m_revolution_start_time).to_string(), (endtime).to_string());
}
return endtime;
}
@@ -712,7 +720,7 @@ void mfm_harddisk_device::head_move()
m_step_phase = STEP_MOVING;
m_seek_timer->adjust(m_step_time * steps);
- LOGMASKED(LOG_TIMING, "Head movement takes %s time\n", tts(m_step_time * steps).c_str());
+ LOGMASKED(LOG_TIMING, "Head movement takes %s time\n", (m_step_time * steps).to_string());
// We pretend that we already arrived
// TODO: Check auto truncation?
m_current_cylinder += m_track_delta;
@@ -811,7 +819,7 @@ bool mfm_harddisk_device::find_position(attotime &from_when, const attotime &lim
// Reached the end
if (bytepos >= m_trackimage_size)
{
- LOGMASKED(LOG_TIMING, "Reached end: rev_start = %s, live = %s\n", tts(m_revolution_start_time).c_str(), tts(from_when).c_str());
+ LOGMASKED(LOG_TIMING, "Reached end: rev_start = %s, live = %s\n", (m_revolution_start_time).to_string(), (from_when).to_string());
m_revolution_start_time += m_rev_time;
cell = (from_when - m_revolution_start_time).as_ticks(freq);
bytepos = cell / 16;
@@ -819,7 +827,7 @@ bool mfm_harddisk_device::find_position(attotime &from_when, const attotime &lim
if (bytepos < 0)
{
- LOGMASKED(LOG_TIMING, "Negative cell number: rev_start = %s, live = %s\n", tts(m_revolution_start_time).c_str(), tts(from_when).c_str());
+ LOGMASKED(LOG_TIMING, "Negative cell number: rev_start = %s, live = %s\n", (m_revolution_start_time).to_string(), (from_when).to_string());
bytepos = 0;
}
bit = cell % 16;
@@ -856,7 +864,7 @@ bool mfm_harddisk_device::read(attotime &from_when, const attotime &limit, uint1
{
// We will deliver a single bit
cdata = ((track[bytepos] << bitpos) & 0x8000) >> 15;
- LOGMASKED(LOG_BITS, "Reading (c=%d,h=%d,bit=%d) at cell %d [%s] = %d\n", m_current_cylinder, m_current_head, bitpos, ((bytepos<<4) + bitpos), tts(fw).c_str(), cdata);
+ LOGMASKED(LOG_BITS, "Reading (c=%d,h=%d,bit=%d) at cell %d [%s] = %d\n", m_current_cylinder, m_current_head, bitpos, ((bytepos<<4) + bitpos), fw.to_string(), cdata);
}
else
{
@@ -1060,8 +1068,6 @@ void mfmhd_trackimage_cache::mark_current_as_dirty()
m_tracks->dirty = true;
}
-const char *encnames[] = { "MFM_BITS","MFM_BYTE","SEPARATE","SSIMPLE " };
-
/*
Initialize the cache by loading the first <trackslots> tracks.
*/
diff --git a/src/devices/imagedev/mfmhd.h b/src/devices/imagedev/mfmhd.h
index 50327f48372..758dd1bb349 100644
--- a/src/devices/imagedev/mfmhd.h
+++ b/src/devices/imagedev/mfmhd.h
@@ -52,7 +52,7 @@ private:
running_machine & m_machine;
};
-class mfm_harddisk_device : public harddisk_image_device
+class mfm_harddisk_device : public device_t, public device_image_interface
{
public:
~mfm_harddisk_device();
@@ -61,6 +61,14 @@ public:
typedef delegate<void (mfm_harddisk_device*, int)> ready_cb;
typedef delegate<void (mfm_harddisk_device*, int)> seek_complete_cb;
+ virtual bool is_readable() const noexcept override { return true; }
+ virtual bool is_writeable() const noexcept override { return true; }
+ virtual bool is_creatable() const noexcept override { return false; }
+ virtual bool is_reset_on_load() const noexcept override { return false; }
+ virtual const char *image_type_name() const noexcept override { return "harddisk"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "hard"; }
+ virtual const char *file_extensions() const noexcept override { return "chd"; }
+
void setup_index_pulse_cb(index_pulse_cb cb);
void setup_ready_cb(ready_cb cb);
void setup_seek_complete_cb(seek_complete_cb cb);
@@ -112,8 +120,6 @@ protected:
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
- std::string tts(const attotime &t);
-
emu_timer *m_index_timer, *m_spinup_timer, *m_seek_timer, *m_cache_timer;
index_pulse_cb m_index_pulse_cb;
ready_cb m_ready_cb;
@@ -158,7 +164,7 @@ private:
std::unique_ptr<mfmhd_trackimage_cache> m_cache;
mfmhd_image_format_t* m_format;
-
+ chd_file *m_chd;
void head_move();
void recalibrate();
diff --git a/src/devices/machine/ataflash.cpp b/src/devices/machine/ataflash.cpp
index 155ec34bcd3..d1fb49054d9 100644
--- a/src/devices/machine/ataflash.cpp
+++ b/src/devices/machine/ataflash.cpp
@@ -20,13 +20,11 @@ void ata_flash_pccard_device::device_reset()
{
ide_hdd_device::device_reset();
- uint32_t metalength;
- memset(m_cis, 0xff, 512);
-
- if (m_handle != nullptr)
+ if (m_disk)
{
- m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength);
+ m_disk->get_cis_data(m_cis);
}
+ m_cis.resize(512, 0xff);
m_configuration_option = 0;
m_configuration_and_status = 0;
@@ -137,13 +135,11 @@ void taito_pccard1_device::device_reset()
{
ata_flash_pccard_device::device_reset();
- uint32_t metalength;
- memset(m_key, 0, sizeof(m_key));
-
- if (m_handle && !m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, m_key, 5, metalength))
+ if (m_disk && !m_disk->get_disk_key_data(m_key) && m_key.size() == 5)
{
m_locked = 0x1ff;
}
+ m_key.resize(5, 0);
}
uint16_t taito_pccard1_device::read_reg(offs_t offset, uint16_t mem_mask)
@@ -228,13 +224,11 @@ void taito_pccard2_device::device_reset()
{
ata_flash_pccard_device::device_reset();
- uint32_t metalength;
- memset(m_key, 0, sizeof(m_key));
-
- if (m_handle && !m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, m_key, 5, metalength))
+ if (m_disk && !m_disk->get_disk_key_data(m_key) && m_key.size() == 5)
{
m_locked = true;
}
+ m_key.resize(5, 0);
}
void taito_pccard2_device::process_command()
@@ -327,13 +321,11 @@ void taito_compact_flash_device::device_reset()
{
ata_flash_pccard_device::device_reset();
- uint32_t metalength;
- memset(m_key, 0, sizeof(m_key));
-
- if (m_handle && !m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, m_key, 5, metalength))
+ if (m_disk && !m_disk->get_disk_key_data(m_key) && m_key.size() == 5)
{
m_locked = true;
}
+ m_key.resize(5, 0);
}
void taito_compact_flash_device::process_command()
diff --git a/src/devices/machine/ataflash.h b/src/devices/machine/ataflash.h
index e52c78ee27a..c9e3cbbf991 100644
--- a/src/devices/machine/ataflash.h
+++ b/src/devices/machine/ataflash.h
@@ -30,7 +30,7 @@ protected:
uint8_t calculate_status() override { return ata_hle_device::calculate_status(); }
private:
- uint8_t m_cis[512];
+ std::vector<uint8_t> m_cis;
uint8_t m_configuration_option;
uint8_t m_configuration_and_status;
uint8_t m_pin_replacement;
@@ -53,7 +53,7 @@ protected:
virtual bool is_ready() override;
private:
- uint8_t m_key[5];
+ std::vector<uint8_t> m_key;
uint16_t m_locked;
};
@@ -75,7 +75,7 @@ protected:
static const int IDE_COMMAND_TAITO_GNET_UNLOCK_2 = 0xfc;
private:
- uint8_t m_key[5];
+ std::vector<uint8_t> m_key;
bool m_locked;
};
@@ -95,7 +95,7 @@ protected:
static constexpr int IDE_COMMAND_TAITO_COMPACT_FLASH_UNLOCK = 0x0f;
private:
- uint8_t m_key[5];
+ std::vector<uint8_t> m_key;
bool m_locked;
};
diff --git a/src/devices/machine/diablo_hd.cpp b/src/devices/machine/diablo_hd.cpp
index a3a8b027d03..c963d582989 100644
--- a/src/devices/machine/diablo_hd.cpp
+++ b/src/devices/machine/diablo_hd.cpp
@@ -102,7 +102,6 @@ diablo_hd_device::diablo_hd_device(const machine_config &mconfig, const char *ta
m_sector_callback(nullptr),
m_timer(nullptr),
m_image(nullptr),
- m_handle(nullptr),
m_disk(nullptr)
{
memset(m_description, 0x00, sizeof(m_description));
@@ -1328,8 +1327,7 @@ void diablo_hd_device::device_reset()
m_cache[page] = nullptr;
// free previous bits cache
m_bits.reset();
- m_handle = m_image->get_chd_file();
- m_diablo31 = true; // FIXME: get from m_handle meta data?
+ m_diablo31 = true; // FIXME: get from disk meta data?
m_disk = m_image->get_hard_disk_file();
if (m_diablo31) {
snprintf(m_description, sizeof(m_description), "DIABLO31");
@@ -1350,7 +1348,6 @@ void diablo_hd_device::device_reset()
m_cylinders = 2 * DIABLO_CYLINDERS;
m_pages = 2 * DIABLO_PAGES;
}
- LOG_DRIVE(0,"[DHD%u] m_handle : %p\n", m_unit, reinterpret_cast<void const *>(m_handle));
LOG_DRIVE(0,"[DHD%u] m_disk : %p\n", m_unit, reinterpret_cast<void const *>(m_disk));
LOG_DRIVE(0,"[DHD%u] rotation time : %.0fns\n", m_unit, m_rotation_time.as_double() * ATTOSECONDS_PER_NANOSECOND);
LOG_DRIVE(0,"[DHD%u] sector time : %.0fns\n", m_unit, m_sector_time.as_double() * ATTOSECONDS_PER_NANOSECOND);
@@ -1385,7 +1382,7 @@ void diablo_hd_device::device_reset()
m_rdfirst = -1;
m_rdlast = -1;
- if (!m_handle)
+ if (!m_image)
return;
// for units with a CHD assigned to them start the timer
m_bits = std::make_unique<std::unique_ptr<uint32_t[]>[]>(m_pages);
diff --git a/src/devices/machine/diablo_hd.h b/src/devices/machine/diablo_hd.h
index 60809d3cf1a..eec79c648ba 100644
--- a/src/devices/machine/diablo_hd.h
+++ b/src/devices/machine/diablo_hd.h
@@ -110,7 +110,6 @@ private:
void (*m_sector_callback)(void*,int); //!< callback to call at the start of each sector
emu_timer* m_timer; //!< sector timer
diablo_image_device* m_image; //!< diablo_image_device interfacing the CHD
- chd_file* m_handle; //!< underlying CHD handle
hard_disk_file* m_disk; //!< underlying hard disk file
//! translate C/H/S to a page and read the sector
diff --git a/src/lib/util/harddisk.cpp b/src/lib/util/harddisk.cpp
index d009317922e..46cf88bab43 100644
--- a/src/lib/util/harddisk.cpp
+++ b/src/lib/util/harddisk.cpp
@@ -24,7 +24,7 @@ hard_disk_file::hard_disk_file(chd_file *_chd)
{
chd = _chd;
fhandle = nullptr;
- hdinfo.fileoffset = 0;
+ fileoffset = 0;
std::string metadata;
std::error_condition err;
@@ -56,7 +56,7 @@ hard_disk_file::hard_disk_file(util::random_read_write &corefile, uint32_t skipo
hdinfo.cylinders = 0;
hdinfo.heads = 0;
hdinfo.sectors = 0;
- hdinfo.fileoffset = skipoffs;
+ fileoffset = skipoffs;
// attempt to guess geometry in case this is an ATA situation
for (uint32_t totalsectors = (length - skipoffs) / hdinfo.sectorbytes; ; totalsectors++)
@@ -113,7 +113,7 @@ bool hard_disk_file::read(uint32_t lbasector, void *buffer)
else
{
size_t actual = 0;
- std::error_condition err = fhandle->seek(hdinfo.fileoffset + (lbasector * hdinfo.sectorbytes), SEEK_SET);
+ std::error_condition err = fhandle->seek(fileoffset + (lbasector * hdinfo.sectorbytes), SEEK_SET);
if (!err)
err = fhandle->read(buffer, hdinfo.sectorbytes, actual);
return !err && (actual == hdinfo.sectorbytes);
@@ -146,7 +146,7 @@ bool hard_disk_file::write(uint32_t lbasector, const void *buffer)
else
{
size_t actual = 0;
- std::error_condition err = fhandle->seek(hdinfo.fileoffset + (lbasector * hdinfo.sectorbytes), SEEK_SET);
+ std::error_condition err = fhandle->seek(fileoffset + (lbasector * hdinfo.sectorbytes), SEEK_SET);
if (!err)
err = fhandle->write(buffer, hdinfo.sectorbytes, actual);
return !err && (actual == hdinfo.sectorbytes);
@@ -190,3 +190,28 @@ bool hard_disk_file::set_block_size(uint32_t blocksize)
return true;
}
}
+
+
+std::error_condition hard_disk_file::get_inquiry_data(std::vector<uint8_t> &data) const
+{
+ if(chd)
+ return chd->read_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, data);
+ else
+ return std::error_condition(chd_file::error::METADATA_NOT_FOUND);
+}
+
+std::error_condition hard_disk_file::get_cis_data(std::vector<uint8_t> &data) const
+{
+ if(chd)
+ return chd->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, data);
+ else
+ return std::error_condition(chd_file::error::METADATA_NOT_FOUND);
+}
+
+std::error_condition hard_disk_file::get_disk_key_data(std::vector<uint8_t> &data) const
+{
+ if(chd)
+ return chd->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, data);
+ else
+ return std::error_condition(chd_file::error::METADATA_NOT_FOUND);
+}
diff --git a/src/lib/util/harddisk.h b/src/lib/util/harddisk.h
index d7aff5b8384..ab70bad995f 100644
--- a/src/lib/util/harddisk.h
+++ b/src/lib/util/harddisk.h
@@ -27,16 +27,13 @@ public:
uint32_t heads;
uint32_t sectors;
uint32_t sectorbytes;
- uint32_t fileoffset; // offset in the file where the HDD image starts. not valid for CHDs.
};
-
hard_disk_file(chd_file *chd);
hard_disk_file(util::random_read_write &corefile, uint32_t skipoffs);
~hard_disk_file();
- chd_file *get_chd() const { return chd; }
const info &get_info() const { return hdinfo; }
bool set_block_size(uint32_t blocksize);
@@ -44,10 +41,15 @@ public:
bool read(uint32_t lbasector, void *buffer);
bool write(uint32_t lbasector, const void *buffer);
+ std::error_condition get_inquiry_data(std::vector<uint8_t> &data) const;
+ std::error_condition get_cis_data(std::vector<uint8_t> &data) const;
+ std::error_condition get_disk_key_data(std::vector<uint8_t> &data) const;
+
private:
chd_file * chd; // CHD file
util::random_read_write * fhandle; // file if not a CHD
info hdinfo; // hard disk info
+ uint32_t fileoffset; // offset in the file where the HDD image starts. not valid for CHDs.
};
#endif // MAME_LIB_UTIL_HARDDISK_H