1 // license:BSD-3-Clause 2 // copyright-holders: F. Ulivi 3 /********************************************************************* 4 5 isbc202.h 6 7 Intel iSBC-202 SSDD 8" floppy disk controller 8 9 *********************************************************************/ 10 11 #ifndef MAME_BUS_MULTIBUS_ISBC202_H 12 #define MAME_BUS_MULTIBUS_ISBC202_H 13 14 #pragma once 15 16 #include "multibus.h" 17 #include "machine/i3001.h" 18 #include "machine/i3002.h" 19 #include "machine/fdc_pll.h" 20 #include "imagedev/floppy.h" 21 22 class isbc202_device : public cpu_device, 23 public device_multibus_interface 24 { 25 public: 26 // Construction/destruction 27 isbc202_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); 28 virtual ~isbc202_device(); 29 30 // device_multibus_interface overrides 31 virtual void install_io_rw(address_space& space) override; 32 virtual void install_mem_rw(address_space& space) override; 33 34 // Access to I/O space by CPU 35 uint8_t io_r(address_space &space, offs_t offset); 36 void io_w(address_space &space, offs_t offset, uint8_t data); 37 38 DECLARE_WRITE_LINE_MEMBER(co_w); 39 40 uint8_t px_r(); 41 42 protected: 43 // device_t overrides 44 virtual void device_start() override; 45 virtual void device_reset() override; 46 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 47 virtual const tiny_rom_entry *device_rom_region() const override; 48 virtual void device_add_mconfig(machine_config &config) override; 49 // device_execute_interface overrides execute_min_cycles()50 virtual uint32_t execute_min_cycles() const noexcept override { return 1; } 51 virtual void execute_run() override; 52 // device_memory_interface overrides 53 virtual space_config_vector memory_space_config() const override; 54 // device_disasm_interface overrides 55 virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; 56 // device_state_interface overrides 57 virtual void state_import(const device_state_entry &entry) override; 58 virtual void state_export(const device_state_entry &entry) override; 59 virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; 60 61 private: 62 required_device<i3001_device> m_mcu; 63 required_device_array<i3002_device , 4> m_cpes; 64 required_device_array<floppy_connector , 4> m_drives; 65 66 address_space_config m_program_config; 67 memory_access<9, 2 , -2 , ENDIANNESS_BIG>::cache m_cache; 68 69 address_space *m_mem_space; 70 71 int m_icount; 72 uint8_t m_flags; 73 uint8_t m_regs[ i3002_device::REG_COUNT ]; 74 uint16_t m_microcode_addr; 75 uint32_t m_code_word; 76 uint8_t m_ac; 77 uint8_t m_fc; 78 bool m_fc32; 79 bool m_fc10; 80 enum { // m_in_sel Input on AC[0] 81 IN_SEL_AC0, // 0 AC[0] 82 IN_SEL_CO, // 1 CO 83 IN_SEL_START, // 2 START 84 IN_SEL_F, // 3 F 85 IN_SEL_AZ, // 4 AZ 86 IN_SEL_INDEX, // 5 INDEX 87 IN_SEL_XFERQ, // 6 XFERREQ 88 IN_SEL_TIMEOUT,//7 TIMEOUT 89 IN_SEL_COUNT 90 }; 91 uint8_t m_in_sel; 92 uint8_t m_out_sel; 93 uint8_t m_slk; 94 uint8_t m_mask; 95 uint8_t m_kbus; 96 bool m_inputs[ IN_SEL_COUNT ]; 97 // IC identifiers have this form: x-Ayy 98 // where x is either C (for channel board) or I (for interface board) 99 // and yy is the numeric IC ID. 100 uint8_t m_op_us; // C-A44 101 floppy_image_device *m_current_drive; 102 uint8_t m_px_s1s0; // C-A16-11 & C-A16-13 103 uint8_t m_cmd; // C-A8 104 cpu_device *m_cpu; // When != nullptr: CPU is suspended in wait state 105 bool m_cpu_rd; 106 uint8_t m_ready_in; 107 uint8_t m_ready_ff; // I-A44 & I-A43 108 bool m_gate_lower; // I-A58-9 109 bool m_irq; // C-A37-9 110 uint8_t m_data_low_out; // C-A43 111 uint8_t m_data_low_in; // C-A25 112 uint8_t m_cpu_data; 113 uint8_t m_addr_low_out; // C-A41 114 bool m_mem_wrt; // I-A58-4 115 bool m_wrt_inh; // I-A46-13 116 bool m_direction; // I-A58-11 117 bool m_ibus_cached; 118 uint8_t m_ibus; 119 uint16_t m_crc; // I-A62 120 bool m_crc_enabled; // I-A58-13 121 bool m_crc_out; // C-A16-2 122 bool m_reading; // I-A46-9 123 bool m_writing; // C-A16-4 124 uint16_t m_data_sr; // C-A36 & C-A29 (MSB), next byte in LSB 125 bool m_last_data_bit; // I-A48-6 126 uint16_t m_clock_sr; // C-A34 & C-A27 (MSB), next byte in LSB 127 attotime m_last_f_time; 128 bool m_clock_gate; // I-A10-8 129 bool m_amwrt; // I-A58-6 130 bool m_dlyd_amwrt; 131 132 // PLL 133 fdc_pll_t m_pll; 134 135 // Timers 136 emu_timer *m_timeout_timer; 137 emu_timer *m_byte_timer; 138 emu_timer *m_f_timer; 139 140 void set_output(); 141 unsigned selected_drive() const; 142 unsigned drive_idx(floppy_image_device *drive); 143 void floppy_ready_cb(floppy_image_device *floppy , int state); 144 void floppy_index_cb(floppy_image_device *floppy , int state); 145 uint8_t dbus_r() const; 146 uint8_t mbus_r() const; 147 uint8_t abus_r() const; 148 uint8_t ibus_r(); 149 void set_start(uint8_t off , bool read); 150 void set_rd_wr(bool new_rd , bool new_wr); 151 uint8_t aligned_rd_data(uint16_t sr); 152 void rd_bits(unsigned n); 153 void write_byte(); 154 bool update_crc(bool bit); 155 }; 156 157 // device type declaration 158 DECLARE_DEVICE_TYPE(ISBC202, isbc202_device) 159 160 #endif /* MAME_BUS_MULTIBUS_ISBC202_H */ 161