summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/imagedev/harddriv.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/imagedev/harddriv.h')
-rw-r--r--src/devices/imagedev/harddriv.h70
1 files changed, 49 insertions, 21 deletions
diff --git a/src/devices/imagedev/harddriv.h b/src/devices/imagedev/harddriv.h
index 032d449ad68..5f51f70d828 100644
--- a/src/devices/imagedev/harddriv.h
+++ b/src/devices/imagedev/harddriv.h
@@ -11,19 +11,46 @@
#ifndef MAME_DEVICES_IMAGEDEV_HARDDRIV_H
#define MAME_DEVICES_IMAGEDEV_HARDDRIV_H
-#include "harddisk.h"
#include "softlist_dev.h"
+#include "chd.h"
+#include "harddisk.h"
+
+#include <memory>
+#include <string>
+#include <system_error>
+#include <utility>
+
+
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
+// ======================> harddisk_image_base_device
+
+class harddisk_image_base_device : public device_t, public device_image_interface
+{
+protected:
+ // construction/destruction
+ harddisk_image_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ // device_image_interface implementation
+ 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"; }
+};
+
// ======================> harddisk_image_device
-class harddisk_image_device : public device_t,
- public device_image_interface
+class harddisk_image_device : public harddisk_image_base_device
{
public:
+ typedef device_delegate<std::error_condition (device_image_interface &)> load_delegate;
+ typedef device_delegate<void (device_image_interface &)> unload_delegate;
+
// construction/destruction
harddisk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const char *intf)
: harddisk_image_device(mconfig, tag, owner, (uint32_t)0)
@@ -37,30 +64,30 @@ public:
template <typename... T> void set_device_unload(T &&... args) { m_device_image_unload.set(std::forward<T>(args)...); }
void set_interface(const char *interface) { m_interface = interface; }
- // image-level overrides
- virtual image_init_result call_load() override;
- virtual image_init_result call_create(int create_format, util::option_resolution *create_args) override;
+ // device_image_interface implementation
+ virtual std::pair<std::error_condition, std::string> call_load() override;
+ virtual std::pair<std::error_condition, std::string> call_create(int create_format, util::option_resolution *create_args) override;
virtual void call_unload() override;
- virtual iodevice_t image_type() const noexcept override { return IO_HARDDISK; }
-
- virtual bool is_readable() const noexcept override { return 1; }
- virtual bool is_writeable() const noexcept override { return 1; }
- virtual bool is_creatable() const noexcept override { return 0; }
- virtual bool must_be_loaded() const noexcept override { return 0; }
- virtual bool is_reset_on_load() const noexcept override { return 0; }
+ virtual bool image_is_chd_type() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return m_interface; }
virtual const char *file_extensions() const noexcept override { return "chd,hd,hdv,2mg,hdi"; }
virtual const util::option_guide &create_option_guide() const override;
- // specific implementation
- hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle; }
- chd_file *get_chd_file();
+ const hard_disk_file::info &get_info() const;
+ bool read(uint32_t lbasector, void *buffer);
+ bool write(uint32_t lbasector, const void *buffer);
+
+ bool set_block_size(uint32_t blocksize);
+
+ 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;
protected:
harddisk_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
- // device-level overrides
+ // device_t implementation
virtual void device_config_complete() override;
virtual void device_start() override;
virtual void device_stop() override;
@@ -68,12 +95,13 @@ protected:
// device_image_interface implementation
virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
- image_init_result internal_load_hd();
+ void setup_current_preset_image();
+ std::error_condition internal_load_hd();
chd_file *m_chd;
- chd_file m_origchd; /* handle to the original CHD */
- chd_file m_diffchd; /* handle to the diff CHD */
- hard_disk_file *m_hard_disk_handle;
+ chd_file m_origchd; // handle to the original CHD
+ chd_file m_diffchd; // handle to the diff CHD
+ std::unique_ptr<hard_disk_file> m_hard_disk_handle;
load_delegate m_device_image_load;
unload_delegate m_device_image_unload;