mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
Split hard drive emulation from the ide controller. [smf]
This commit is contained in:
parent
4096aa50a6
commit
75e814cfb4
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,9 @@ extern const device_type IDE_SLOT;
|
||||
#define MCFG_IDE_CONTROLLER_IRQ_HANDLER(_devcb) \
|
||||
devcb = &ide_controller_device::set_irq_handler(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_IDE_CONTROLLER_DMARQ_HANDLER(_devcb) \
|
||||
devcb = &ide_controller_device::set_dmarq_handler(*device, DEVCB2_##_devcb);
|
||||
|
||||
SLOT_INTERFACE_EXTERN(ide_devices);
|
||||
SLOT_INTERFACE_EXTERN(ide_devices);
|
||||
|
||||
@ -82,14 +85,13 @@ public:
|
||||
|
||||
// static configuration helpers
|
||||
template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ide_controller_device &>(device).m_irq_handler.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_dmarq_handler(device_t &device, _Object object) { return downcast<ide_controller_device &>(device).m_dmarq_handler.set_callback(object); }
|
||||
|
||||
UINT8 *ide_get_features(int drive);
|
||||
void ide_set_gnet_readlock(int drive, const UINT8 onoff);
|
||||
void ide_set_master_password(int drive, const UINT8 *password);
|
||||
void ide_set_user_password(int drive, const UINT8 *password);
|
||||
|
||||
DECLARE_READ8_MEMBER(read_via_config);
|
||||
DECLARE_WRITE8_MEMBER(write_via_config);
|
||||
UINT16 read_dma();
|
||||
DECLARE_READ16_MEMBER(read_cs0);
|
||||
DECLARE_READ16_MEMBER(read_cs1);
|
||||
@ -97,43 +99,38 @@ public:
|
||||
DECLARE_WRITE16_MEMBER(write_cs0);
|
||||
DECLARE_WRITE16_MEMBER(write_cs1);
|
||||
|
||||
DECLARE_READ8_MEMBER(read_via_config);
|
||||
DECLARE_WRITE8_MEMBER(write_via_config);
|
||||
DECLARE_READ16_MEMBER(read_cs0_pc);
|
||||
DECLARE_READ16_MEMBER(read_cs1_pc);
|
||||
DECLARE_WRITE16_MEMBER(write_cs0_pc);
|
||||
DECLARE_WRITE16_MEMBER(write_cs1_pc);
|
||||
|
||||
virtual void set_irq(int state);
|
||||
virtual void set_dmarq(int state);
|
||||
void read_sector_done();
|
||||
void write_sector_done();
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
void read_next_sector();
|
||||
void continue_write();
|
||||
virtual void set_irq(int state);
|
||||
virtual void set_dmarq(int state);
|
||||
|
||||
private:
|
||||
void signal_delayed_interrupt(attotime time, int buffer_ready);
|
||||
void next_sector();
|
||||
void security_error();
|
||||
void continue_read();
|
||||
void read_first_sector();
|
||||
void handle_command(UINT8 _command);
|
||||
void read_buffer_empty();
|
||||
void write_buffer_full();
|
||||
DECLARE_WRITE_LINE_MEMBER(irq0_write_line);
|
||||
DECLARE_WRITE_LINE_MEMBER(dmarq0_write_line);
|
||||
|
||||
UINT8 config_unknown;
|
||||
UINT8 config_register[IDE_CONFIG_REGISTERS];
|
||||
UINT8 config_register_num;
|
||||
DECLARE_WRITE_LINE_MEMBER(irq1_write_line);
|
||||
DECLARE_WRITE_LINE_MEMBER(dmarq1_write_line);
|
||||
|
||||
UINT8 cur_drive;
|
||||
ide_slot_device *slot[2];
|
||||
UINT8 m_config_unknown;
|
||||
UINT8 m_config_register[IDE_CONFIG_REGISTERS];
|
||||
UINT8 m_config_register_num;
|
||||
|
||||
ide_slot_device *m_slot[2];
|
||||
int m_irq[2];
|
||||
int m_dmarq[2];
|
||||
|
||||
devcb2_write_line m_irq_handler;
|
||||
devcb2_write_line m_dmarq_handler;
|
||||
};
|
||||
|
||||
extern const device_type IDE_CONTROLLER;
|
||||
@ -157,12 +154,12 @@ public:
|
||||
DECLARE_READ32_MEMBER( ide_bus_master32_r );
|
||||
DECLARE_WRITE32_MEMBER( ide_bus_master32_w );
|
||||
|
||||
virtual void set_irq(int state);
|
||||
virtual void set_dmarq(int state);
|
||||
|
||||
protected:
|
||||
virtual void device_start();
|
||||
|
||||
virtual void set_irq(int state);
|
||||
virtual void set_dmarq(int state);
|
||||
|
||||
private:
|
||||
void execute_dma();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,52 +23,37 @@ class ide_device_interface : public device_slot_card_interface
|
||||
{
|
||||
public:
|
||||
ide_device_interface(const machine_config &mconfig, device_t &device);
|
||||
public:
|
||||
virtual int read_sector(UINT32 lba, void *buffer) = 0;
|
||||
virtual int write_sector(UINT32 lba, const void *buffer) = 0;
|
||||
|
||||
virtual void set_irq(int state);
|
||||
virtual void set_dmarq(int state);
|
||||
|
||||
virtual UINT16 read_dma() = 0;
|
||||
virtual DECLARE_READ16_MEMBER(read_cs0) = 0;
|
||||
virtual DECLARE_READ16_MEMBER(read_cs1) = 0;
|
||||
virtual void write_dma(UINT16 data) = 0;
|
||||
virtual DECLARE_WRITE16_MEMBER(write_cs0) = 0;
|
||||
virtual DECLARE_WRITE16_MEMBER(write_cs1) = 0;
|
||||
|
||||
UINT8 *get_features() { return m_features;}
|
||||
|
||||
UINT16 get_cylinders() { return m_num_cylinders; }
|
||||
UINT16 get_sectors() { return m_num_sectors; }
|
||||
UINT16 get_heads() { return m_num_heads; }
|
||||
void set_geometry(UINT8 sectors, UINT8 heads) { m_num_sectors= sectors; m_num_heads=heads; }
|
||||
UINT32 lba_address();
|
||||
virtual bool is_ready() { return true; }
|
||||
virtual void read_key(UINT8 key[]) { }
|
||||
UINT16 cur_cylinder;
|
||||
UINT8 cur_sector;
|
||||
UINT8 cur_head;
|
||||
UINT8 cur_head_reg;
|
||||
UINT32 cur_lba;
|
||||
|
||||
UINT8 status;
|
||||
UINT8 error;
|
||||
UINT8 command;
|
||||
UINT8 m_master_password_enable;
|
||||
UINT8 m_user_password_enable;
|
||||
const UINT8 * m_master_password;
|
||||
const UINT8 * m_user_password;
|
||||
|
||||
UINT8 buffer[IDE_DISK_SECTOR_SIZE];
|
||||
UINT16 buffer_offset;
|
||||
UINT8 m_gnetreadlock;
|
||||
|
||||
UINT8 adapter_control;
|
||||
UINT8 precomp_offset;
|
||||
UINT16 sector_count;
|
||||
UINT16 block_count;
|
||||
int m_csel;
|
||||
int m_dasp;
|
||||
|
||||
UINT8 interrupt_pending;
|
||||
UINT16 sectors_until_int;
|
||||
|
||||
UINT8 dma_active;
|
||||
UINT8 verify_only;
|
||||
|
||||
UINT8 master_password_enable;
|
||||
UINT8 user_password_enable;
|
||||
const UINT8 * master_password;
|
||||
const UINT8 * user_password;
|
||||
|
||||
UINT8 gnetreadlock;
|
||||
|
||||
emu_timer * last_status_timer;
|
||||
emu_timer * reset_timer;
|
||||
devcb2_write_line m_irq_handler;
|
||||
devcb2_write_line m_dmarq_handler;
|
||||
|
||||
protected:
|
||||
UINT8 m_features[IDE_DISK_SECTOR_SIZE];
|
||||
@ -77,10 +62,76 @@ protected:
|
||||
UINT8 m_num_heads;
|
||||
};
|
||||
|
||||
class ide_mass_storage_device : public device_t,
|
||||
public ide_device_interface
|
||||
{
|
||||
public:
|
||||
ide_mass_storage_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 = __FILE__);
|
||||
|
||||
virtual int read_sector(UINT32 lba, void *buffer) = 0;
|
||||
virtual int write_sector(UINT32 lba, const void *buffer) = 0;
|
||||
|
||||
virtual void set_irq(int state);
|
||||
virtual UINT16 read_dma();
|
||||
virtual DECLARE_READ16_MEMBER(read_cs0);
|
||||
virtual DECLARE_READ16_MEMBER(read_cs1);
|
||||
virtual void write_dma(UINT16 data);
|
||||
virtual DECLARE_WRITE16_MEMBER(write_cs0);
|
||||
virtual DECLARE_WRITE16_MEMBER(write_cs1);
|
||||
|
||||
protected:
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
private:
|
||||
UINT32 lba_address();
|
||||
void set_geometry(UINT8 sectors, UINT8 heads) { m_num_sectors= sectors; m_num_heads=heads; }
|
||||
void read_sector_done();
|
||||
void write_sector_done();
|
||||
void read_next_sector();
|
||||
void continue_write();
|
||||
void signal_delayed_interrupt(attotime time, int buffer_ready);
|
||||
void next_sector();
|
||||
void security_error();
|
||||
void continue_read();
|
||||
void read_first_sector();
|
||||
void handle_command(UINT8 _command);
|
||||
void read_buffer_empty();
|
||||
void write_buffer_full();
|
||||
|
||||
int m_cur_drive;
|
||||
UINT16 m_cur_cylinder;
|
||||
UINT8 m_cur_sector;
|
||||
UINT8 m_cur_head;
|
||||
UINT8 m_cur_head_reg;
|
||||
UINT32 m_cur_lba;
|
||||
|
||||
UINT8 m_status;
|
||||
UINT8 m_error;
|
||||
UINT8 m_command;
|
||||
|
||||
UINT8 m_buffer[IDE_DISK_SECTOR_SIZE];
|
||||
UINT16 m_buffer_offset;
|
||||
|
||||
UINT8 m_adapter_control;
|
||||
UINT8 m_precomp_offset;
|
||||
UINT16 m_sector_count;
|
||||
UINT16 m_block_count;
|
||||
|
||||
UINT8 m_interrupt_pending;
|
||||
UINT16 m_sectors_until_int;
|
||||
|
||||
UINT8 m_dma_active;
|
||||
UINT8 m_verify_only;
|
||||
|
||||
emu_timer * m_last_status_timer;
|
||||
emu_timer * m_reset_timer;
|
||||
};
|
||||
|
||||
// ======================> ide_hdd_device
|
||||
|
||||
class ide_hdd_device : public device_t,
|
||||
public ide_device_interface
|
||||
class ide_hdd_device : public ide_mass_storage_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -92,9 +143,7 @@ public:
|
||||
virtual void read_key(UINT8 key[]);
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// optional information overrides
|
||||
virtual machine_config_constructor device_mconfig_additions() const;
|
||||
@ -105,5 +154,6 @@ protected:
|
||||
chd_file *m_handle;
|
||||
hard_disk_file *m_disk;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
extern const device_type IDE_HARDDISK;
|
||||
|
Loading…
Reference in New Issue
Block a user