1 // license:BSD-3-Clause 2 // copyright-holders:Ariane Fugmann 3 #ifndef MAME_MACHINE_S32COMM_H 4 #define MAME_MACHINE_S32COMM_H 5 6 #pragma once 7 8 #define S32COMM_SIMULATION 9 10 #include "osdcore.h" 11 12 13 //************************************************************************** 14 // TYPE DEFINITIONS 15 //************************************************************************** 16 17 class s32comm_device : public device_t 18 { 19 public: 20 // construction/destruction 21 s32comm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 22 23 // single bit registers (74LS74) 24 uint8_t zfg_r(offs_t offset); 25 void zfg_w(uint8_t data); 26 // shared memory 2k 27 uint8_t share_r(offs_t offset); 28 void share_w(offs_t offset, uint8_t data); 29 30 // public API - stuff that gets called from host 31 // shared memory 2k 32 // reads/writes at I/O 0x800xxx 33 // - share_r 34 // - share_w 35 // single bit registers (74LS74) 36 // reads/writes at I/O 0x801000 37 uint8_t cn_r(); 38 void cn_w(uint8_t data); 39 // reads/writes at I/O 0x801002 40 uint8_t fg_r(); 41 void fg_w(uint8_t data); 42 43 // IRQ logic - 5 = VINT, 7 = DLC 44 void check_vint_irq(); 45 #ifdef S32COMM_SIMULATION 46 void set_linktype(uint16_t linktype); 47 #endif 48 49 protected: 50 // device-level overrides 51 virtual void device_start() override; 52 virtual void device_reset() override; 53 // optional information overrides 54 virtual void device_add_mconfig(machine_config &config) override; 55 56 private: 57 uint8_t m_shared[0x800]; // 2k shared memory 58 uint8_t m_zfg; // z80 flip gate? purpose unknown, bit0 is stored 59 uint8_t m_cn; // bit0 is used to enable/disable the comm board 60 uint8_t m_fg; // flip gate? purpose unknown, bit0 is stored, bit7 is connected to ZFG bit 0 61 62 osd_file::ptr m_line_rx; // rx line - can be either differential, simple serial or toslink 63 osd_file::ptr m_line_tx; // tx line - is differential, simple serial and toslink 64 char m_localhost[256]; 65 char m_remotehost[256]; 66 uint8_t m_buffer0[0x100]; 67 uint8_t m_buffer1[0x100]; 68 uint8_t m_framesync; 69 70 #ifdef S32COMM_SIMULATION 71 uint8_t m_linkenable; 72 uint16_t m_linktimer; 73 uint8_t m_linkalive; 74 uint8_t m_linkid; 75 uint8_t m_linkcount; 76 uint16_t m_linktype; 77 78 void comm_tick(); 79 int read_frame(int dataSize); 80 void send_data(uint8_t frameType, int frameStart, int frameSize, int dataSize); 81 void send_frame(int dataSize); 82 83 void comm_tick_14084(); 84 void comm_tick_15033(); 85 void comm_tick_15612(); 86 #endif 87 }; 88 89 // device type definition 90 DECLARE_DEVICE_TYPE(S32COMM, s32comm_device) 91 92 #endif // MAME_MACHINE_S32COMM_H 93