summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/upd765.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/upd765.h')
-rw-r--r--src/devices/machine/upd765.h218
1 files changed, 136 insertions, 82 deletions
diff --git a/src/devices/machine/upd765.h b/src/devices/machine/upd765.h
index f796673d77a..5465ea7c10d 100644
--- a/src/devices/machine/upd765.h
+++ b/src/devices/machine/upd765.h
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
-#ifndef MAME_DEVICES_MACHINE_UPD765_H
-#define MAME_DEVICES_MACHINE_UPD765_H
+#ifndef MAME_MACHINE_UPD765_H
+#define MAME_MACHINE_UPD765_H
#pragma once
@@ -12,35 +12,12 @@ class floppy_image_device;
/*
* ready = true if the ready line is physically connected to the floppy drive
* select = true if the fdc controls the floppy drive selection
- * mode = MODE_AT, MODE_PS2 or MODE_M30 for the fdcs that have reset-time selection
+ * mode = mode_t::AT, mode_t::PS2 or mode_t::M30 for the fdcs that have reset-time selection
*/
-/* Interface required for PC ISA wrapping */
-class pc_fdc_interface : public device_t {
-protected:
- using device_t::device_t;
-
-public:
- typedef delegate<uint8_t ()> byte_read_cb;
- typedef delegate<void (uint8_t)> byte_write_cb;
-
- /* Note that the address map must cover and handle the whole 0-7
- * range. The upd765, while conforming to the rest of the
- * interface, is not eligible as a result.
- */
-
- virtual void map(address_map &map) = 0;
-
- virtual uint8_t dma_r() = 0;
- virtual void dma_w(uint8_t data) = 0;
-
- virtual void tc_w(bool val) = 0;
- virtual uint8_t do_dir_r() = 0;
-};
-
-class upd765_family_device : public pc_fdc_interface {
+class upd765_family_device : public device_t {
public:
- enum { MODE_AT, MODE_PS2, MODE_M30 };
+ enum class mode_t { AT, PS2, M30 };
auto intrq_wr_callback() { return intrq_cb.bind(); }
auto drq_wr_callback() { return drq_cb.bind(); }
@@ -48,10 +25,8 @@ public:
auto us_wr_callback() { return us_cb.bind(); }
auto idx_wr_callback() { return idx_cb.bind(); }
- virtual void map(address_map &map) override = 0;
+ virtual void map(address_map &map) = 0;
- uint8_t sra_r();
- uint8_t srb_r();
uint8_t dor_r();
void dor_w(uint8_t data);
uint8_t tdr_r();
@@ -63,21 +38,21 @@ public:
uint8_t dir_r() { return do_dir_r(); }
void ccr_w(uint8_t data);
- virtual uint8_t do_dir_r() override;
+ uint8_t do_dir_r();
- uint8_t dma_r() override;
- void dma_w(uint8_t data) override;
+ uint8_t dma_r();
+ void dma_w(uint8_t data);
bool get_irq() const;
bool get_drq() const;
- void tc_w(bool val) override;
+ void tc_w(bool val);
void ready_w(bool val);
- DECLARE_WRITE_LINE_MEMBER(tc_line_w) { tc_w(state == ASSERT_LINE); }
+ void tc_line_w(int state) { tc_w(state == ASSERT_LINE); }
+ void reset_w(int state);
void set_rate(int rate); // rate in bps, to be used when the fdc is externally frequency-controlled
- void set_mode(int mode);
void set_ready_line_connected(bool ready);
void set_select_lines_connected(bool select);
void set_floppy(floppy_image_device *image);
@@ -86,14 +61,10 @@ public:
protected:
upd765_family_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
- virtual void device_resolve_objects() override;
- virtual void device_start() override;
- virtual void device_reset() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
- enum {
- TIMER_DRIVE_READY_POLLING = 4
- };
+ TIMER_CALLBACK_MEMBER(update_floppy);
enum {
PHASE_CMD, PHASE_EXEC, PHASE_RESULT
@@ -257,33 +228,35 @@ protected:
static constexpr int rates[4] = { 500000, 300000, 250000, 1000000 };
- bool ready_connected, ready_polled, select_connected, select_multiplexed;
+ bool ready_connected, ready_polled, select_connected, select_multiplexed, has_dor;
bool external_ready;
- int mode;
+ int recalibrate_steps;
+
+ mode_t mode;
int main_phase;
live_info cur_live, checkpoint_live;
devcb_write_line intrq_cb, drq_cb, hdl_cb, idx_cb;
devcb_write8 us_cb;
- bool cur_irq, other_irq, data_irq, drq, internal_drq, tc, tc_done, locked, mfm, scan_done;
+ bool cur_irq, irq, drq, internal_drq, tc, tc_done, locked, mfm, scan_done;
floppy_info flopi[4];
int fifo_pos, fifo_expected, command_pos, result_pos, sectors_read;
bool fifo_write;
- uint8_t dor, dsr, msr, fifo[16], command[16], result[16];
+ uint8_t dor, dsr, fifo[16], command[16], result[16];
uint8_t st1, st2, st3;
- uint8_t fifocfg, motorcfg, dor_reset;
- uint8_t precomp, perpmode;
+ uint8_t fifocfg;
+ uint8_t precomp;
uint16_t spec;
int sector_size;
int cur_rate;
int selected_drive;
+ u8 drive_busy;
emu_timer *poll_timer;
- static std::string tts(attotime t);
std::string results() const;
std::string ttsn() const;
@@ -306,12 +279,18 @@ protected:
C_SCAN_LOW,
C_SCAN_HIGH,
C_MOTOR_ONOFF,
+ C_VERSION,
+ C_SLEEP,
+ C_ABORT,
+ C_SPECIFY2,
C_INVALID,
C_INCOMPLETE
};
- void delay_cycles(emu_timer *tm, int cycles);
+ void end_reset();
+
+ void delay_cycles(floppy_info &fi, int cycles);
void check_irq();
void fifo_expect(int size, bool write);
void fifo_push(uint8_t data, bool internal);
@@ -324,12 +303,13 @@ protected:
void disable_transfer();
int calc_sector_size(uint8_t size);
- void run_drive_ready_polling();
+ TIMER_CALLBACK_MEMBER(run_drive_ready_polling);
virtual int check_command();
virtual void start_command(int cmd);
virtual void execute_command(int cmd);
virtual void command_end(floppy_info &fi, bool data_completion);
+ virtual uint8_t get_st3(floppy_info &fi);
void recalibrate_start(floppy_info &fi);
void seek_start(floppy_info &fi);
@@ -370,8 +350,8 @@ protected:
bool read_one_bit(const attotime &limit);
bool write_one_bit(const attotime &limit);
- virtual u8 get_drive_busy() const { return 0; }
- virtual void clr_drive_busy() { };
+ u8 get_drive_busy() const { return drive_busy; }
+ void clr_drive_busy() { drive_busy = 0; }
};
class upd765a_device : public upd765_family_device {
@@ -384,7 +364,7 @@ public:
}
upd765a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
};
class upd765b_device : public upd765_family_device {
@@ -397,7 +377,7 @@ public:
}
upd765b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
};
class i8272a_device : public upd765_family_device {
@@ -409,7 +389,7 @@ public:
}
i8272a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
};
class i82072_device : public upd765_family_device {
@@ -421,10 +401,10 @@ public:
}
i82072_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
protected:
- virtual void device_start() override;
+ virtual void device_start() override ATTR_COLD;
enum motorcfg_mask
{
@@ -439,23 +419,40 @@ protected:
virtual void execute_command(int cmd) override;
virtual void command_end(floppy_info &fi, bool data_completion) override;
virtual void index_callback(floppy_image_device *floppy, int state) override;
- virtual u8 get_drive_busy() const override { return drive_busy; };
- virtual void clr_drive_busy() override { drive_busy = 0; };
void motor_control(int fid, bool start_motor);
private:
+ u8 motorcfg;
u8 motor_off_counter;
u8 motor_on_counter;
- u8 drive_busy;
int delayed_command;
};
-class smc37c78_device : public upd765_family_device {
+class ps2_fdc_device : public upd765_family_device {
+public:
+ void set_mode(mode_t mode);
+
+ uint8_t sra_r();
+ uint8_t srb_r();
+
+protected:
+ ps2_fdc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
+ virtual void soft_reset() override;
+ virtual int check_command() override;
+ virtual void execute_command(int cmd) override;
+
+ uint8_t perpmode;
+};
+
+class smc37c78_device : public ps2_fdc_device {
public:
smc37c78_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
};
class upd72065_device : public upd765_family_device {
@@ -469,49 +466,78 @@ public:
upd72065_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
- void auxcmd_w(uint8_t data);
+ virtual void map(address_map &map) override ATTR_COLD;
+ virtual void auxcmd_w(uint8_t data);
protected:
upd72065_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
};
+class upd72067_device : public upd72065_device {
+public:
+ upd72067_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void auxcmd_w(uint8_t data) override;
+};
+
class upd72069_device : public upd72065_device {
public:
upd72069_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void auxcmd_w(uint8_t data) override;
};
-class n82077aa_device : public upd765_family_device {
+class n82077aa_device : public ps2_fdc_device {
public:
- n82077aa_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, int mode)
+ n82077aa_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, mode_t mode)
: n82077aa_device(mconfig, tag, owner, clock)
{
set_mode(mode);
}
n82077aa_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
};
class pc_fdc_superio_device : public upd765_family_device {
public:
pc_fdc_superio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
};
class dp8473_device : public upd765_family_device {
public:
dp8473_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
+
+protected:
+ virtual void soft_reset() override;
};
-class pc8477a_device : public upd765_family_device {
+class pc8477a_device : public ps2_fdc_device {
public:
+ pc8477a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, mode_t mode)
+ : pc8477a_device(mconfig, tag, owner, clock)
+ {
+ set_mode(mode);
+ }
pc8477a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
+};
+
+class pc8477b_device : public ps2_fdc_device {
+public:
+ pc8477b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, mode_t mode)
+ : pc8477b_device(mconfig, tag, owner, clock)
+ {
+ set_mode(mode);
+ }
+ pc8477b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void map(address_map &map) override ATTR_COLD;
};
class wd37c65c_device : public upd765_family_device {
@@ -528,7 +554,8 @@ public:
void set_clock2(uint32_t clock) { m_clock2 = clock; }
void set_clock2(const XTAL &xtal) { set_clock2(xtal.value()); }
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
+ virtual uint8_t get_st3(floppy_info &fi) override;
private:
uint32_t m_clock2;
@@ -541,12 +568,9 @@ public:
// configuration helpers
auto input_handler() { return m_input_handler.bind(); }
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
uint8_t input_r();
-protected:
- virtual void device_start() override;
-
private:
devcb_read8 m_input_handler;
};
@@ -555,21 +579,49 @@ class tc8566af_device : public upd765_family_device {
public:
tc8566af_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map(address_map &map) override;
+ virtual void map(address_map &map) override ATTR_COLD;
void cr1_w(uint8_t data);
protected:
- virtual void device_start() override;
+ virtual void device_start() override ATTR_COLD;
private:
uint8_t m_cr1;
};
+class hd63266f_device : public upd765_family_device {
+public:
+ hd63266f_device(const machine_config &mconfig, const char *tag, device_t* owner, uint32_t clock);
+
+ virtual void map(address_map &map) override ATTR_COLD;
+ auto inp_rd_callback() { return inp_cb.bind(); } // this is really the ts signal
+
+ void rate_w(u8 state) { state ? set_rate(500000) : set_rate(250000); }
+ void abort_w(u8 data);
+ u8 extstat_r();
+
+protected:
+ virtual void soft_reset() override;
+
+private:
+ virtual int check_command() override;
+ virtual void execute_command(int cmd) override;
+ virtual void start_command(int cmd) override;
+ void motor_control(int fid, bool start_motor);
+ virtual void index_callback(floppy_image_device *floppy, int state) override;
+
+ u8 motor_on_counter;
+ int delayed_command;
+ u8 motor_state;
+ devcb_read_line inp_cb;
+};
+
DECLARE_DEVICE_TYPE(UPD765A, upd765a_device)
DECLARE_DEVICE_TYPE(UPD765B, upd765b_device)
DECLARE_DEVICE_TYPE(I8272A, i8272a_device)
DECLARE_DEVICE_TYPE(UPD72065, upd72065_device)
+DECLARE_DEVICE_TYPE(UPD72067, upd72067_device)
DECLARE_DEVICE_TYPE(UPD72069, upd72069_device)
DECLARE_DEVICE_TYPE(I82072, i82072_device)
DECLARE_DEVICE_TYPE(SMC37C78, smc37c78_device)
@@ -577,8 +629,10 @@ DECLARE_DEVICE_TYPE(N82077AA, n82077aa_device)
DECLARE_DEVICE_TYPE(PC_FDC_SUPERIO, pc_fdc_superio_device)
DECLARE_DEVICE_TYPE(DP8473, dp8473_device)
DECLARE_DEVICE_TYPE(PC8477A, pc8477a_device)
+DECLARE_DEVICE_TYPE(PC8477B, pc8477b_device)
DECLARE_DEVICE_TYPE(WD37C65C, wd37c65c_device)
DECLARE_DEVICE_TYPE(MCS3201, mcs3201_device)
DECLARE_DEVICE_TYPE(TC8566AF, tc8566af_device)
+DECLARE_DEVICE_TYPE(HD63266F, hd63266f_device)
-#endif // MAME_DEVICES_MACHINE_UPD765_H
+#endif // MAME_MACHINE_UPD765_H