2006-02-25 20:50:29 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
#include "Card.h"
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
enum {COMMEVT_WAIT=0, COMMEVT_ACK, COMMEVT_TERM, COMMEVT_MAX};
|
|
|
|
enum eFWMODE {FWMODE_CIC=0, FWMODE_SIC_P8, FWMODE_PPC, FWMODE_SIC_P8A}; // NB. CIC = SSC
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//DIPSW1
|
|
|
|
UINT uBaudRate;
|
|
|
|
eFWMODE eFirmwareMode;
|
|
|
|
|
|
|
|
//DIPSW2
|
|
|
|
UINT uStopBits;
|
|
|
|
UINT uByteSize;
|
|
|
|
UINT uParity;
|
|
|
|
bool bLinefeed;
|
2018-04-08 16:37:26 +00:00
|
|
|
bool bInterrupts; // NB. Can't be read from s/w
|
2007-05-28 11:16:42 +00:00
|
|
|
} SSC_DIPSW;
|
|
|
|
|
2009-10-07 21:38:42 +00:00
|
|
|
#define TEXT_SERIAL_COM TEXT("COM")
|
|
|
|
#define TEXT_SERIAL_TCP TEXT("TCP")
|
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
class CSuperSerialCard : public Card
|
2007-05-28 11:16:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-25 19:21:36 +00:00
|
|
|
CSuperSerialCard(UINT slot);
|
2009-10-07 21:38:42 +00:00
|
|
|
virtual ~CSuperSerialCard();
|
2021-11-13 18:13:01 +00:00
|
|
|
virtual void Update(const ULONG nExecutedCycles) {}
|
2022-03-11 22:17:03 +00:00
|
|
|
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
|
|
|
|
virtual void Reset(const bool powerCycle);
|
|
|
|
virtual void Destroy() {}
|
2022-02-28 20:52:18 +00:00
|
|
|
static const std::string& GetSnapshotCardName(void);
|
2021-11-25 20:23:21 +00:00
|
|
|
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
|
|
|
|
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
|
2007-05-28 11:16:42 +00:00
|
|
|
|
2022-03-11 22:17:03 +00:00
|
|
|
void CommSetSerialPort(DWORD dwNewSerialPortItem);
|
|
|
|
|
2022-02-26 17:54:06 +00:00
|
|
|
std::string const& GetSerialPortChoices();
|
2009-10-07 21:38:42 +00:00
|
|
|
DWORD GetSerialPort() { return m_dwSerialPortItem; } // Drop-down list item
|
2021-09-17 19:43:10 +00:00
|
|
|
const std::string& GetSerialPortName() { return m_currentSerialPortName; }
|
2009-10-07 21:38:42 +00:00
|
|
|
bool IsActive() { return (m_hCommHandle != INVALID_HANDLE_VALUE) || (m_hCommListenSocket != INVALID_SOCKET); }
|
2017-03-23 21:36:26 +00:00
|
|
|
void SupportDCD(bool bEnable) { m_bCfgSupportDCD = bEnable; } // Status
|
2007-05-28 11:16:42 +00:00
|
|
|
|
2009-01-26 15:24:40 +00:00
|
|
|
void CommTcpSerialAccept();
|
|
|
|
void CommTcpSerialReceive();
|
|
|
|
void CommTcpSerialClose();
|
|
|
|
void CommTcpSerialCleanup();
|
|
|
|
|
2018-03-03 21:27:50 +00:00
|
|
|
static BYTE __stdcall SSC_IORead(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
|
|
|
|
static BYTE __stdcall SSC_IOWrite(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
private:
|
2018-03-03 21:27:50 +00:00
|
|
|
BYTE __stdcall CommCommand(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
|
|
|
BYTE __stdcall CommControl(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
|
|
|
BYTE __stdcall CommDipSw(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
|
|
|
BYTE __stdcall CommReceive(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
|
|
|
BYTE __stdcall CommStatus(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
|
|
|
BYTE __stdcall CommTransmit(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
2018-04-08 16:37:26 +00:00
|
|
|
BYTE __stdcall CommProgramReset(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
2007-05-28 11:16:42 +00:00
|
|
|
|
2009-10-07 21:38:42 +00:00
|
|
|
void InternalReset();
|
2018-05-10 12:47:26 +00:00
|
|
|
void UpdateCommandAndControlRegs(BYTE command, BYTE control);
|
2018-04-08 16:37:26 +00:00
|
|
|
void UpdateCommandReg(BYTE command);
|
2018-05-10 12:47:26 +00:00
|
|
|
void UpdateControlReg(BYTE control);
|
2007-05-28 11:16:42 +00:00
|
|
|
void GetDIPSW();
|
|
|
|
void SetDIPSWDefaults();
|
|
|
|
UINT BaudRateToIndex(UINT uBaudRate);
|
|
|
|
void UpdateCommState();
|
2018-04-08 16:37:26 +00:00
|
|
|
void TransmitDone(void);
|
|
|
|
bool CheckComm();
|
2007-05-28 11:16:42 +00:00
|
|
|
void CloseComm();
|
|
|
|
void CheckCommEvent(DWORD dwEvtMask);
|
|
|
|
static DWORD WINAPI CommThread(LPVOID lpParameter);
|
|
|
|
bool CommThInit();
|
|
|
|
void CommThUninit();
|
2009-10-07 21:38:42 +00:00
|
|
|
UINT GetNumSerialPortChoices() { return m_vecSerialPortsItems.size(); }
|
|
|
|
void ScanCOMPorts();
|
2021-09-17 19:43:10 +00:00
|
|
|
void SetSerialPortName(const char* pSerialPortName);
|
|
|
|
void SetRegistrySerialPortName(void);
|
2015-12-05 16:50:27 +00:00
|
|
|
void SaveSnapshotDIPSW(class YamlSaveHelper& yamlSaveHelper, std::string key, SSC_DIPSW& dipsw);
|
|
|
|
void LoadSnapshotDIPSW(class YamlLoadHelper& yamlLoadHelper, std::string key, SSC_DIPSW& dipsw);
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
private:
|
2021-09-17 19:43:10 +00:00
|
|
|
std::string m_currentSerialPortName;
|
2009-10-07 21:38:42 +00:00
|
|
|
DWORD m_dwSerialPortItem;
|
|
|
|
|
|
|
|
static const UINT SERIALPORTITEM_INVALID_COM_PORT = 0;
|
|
|
|
std::vector<UINT> m_vecSerialPortsItems; // Includes "None" & "TCP" items
|
2022-02-26 17:54:06 +00:00
|
|
|
std::string m_strSerialPortChoices;
|
2009-10-07 21:38:42 +00:00
|
|
|
UINT m_uTCPChoiceItemIdx;
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
static SSC_DIPSW m_DIPSWDefault;
|
|
|
|
SSC_DIPSW m_DIPSWCurrent;
|
|
|
|
|
2018-05-05 15:56:15 +00:00
|
|
|
static const UINT m_kDefaultBaudRate = CBR_9600;
|
2007-05-28 11:16:42 +00:00
|
|
|
UINT m_uBaudRate;
|
|
|
|
UINT m_uStopBits;
|
|
|
|
UINT m_uByteSize;
|
|
|
|
UINT m_uParity;
|
|
|
|
|
|
|
|
// SSC Registers
|
|
|
|
BYTE m_uControlByte;
|
|
|
|
BYTE m_uCommandByte;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
HANDLE m_hCommHandle;
|
2009-01-26 15:24:40 +00:00
|
|
|
SOCKET m_hCommListenSocket;
|
|
|
|
SOCKET m_hCommAcceptSocket;
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
2019-11-02 19:53:00 +00:00
|
|
|
CRITICAL_SECTION m_CriticalSection; // To guard /m_vuRxCurrBuffer/ and /m_vbTxEmpty/
|
2018-04-08 16:37:26 +00:00
|
|
|
std::deque<BYTE> m_qComSerialBuffer[2];
|
2009-10-07 21:38:42 +00:00
|
|
|
volatile UINT m_vuRxCurrBuffer; // Written to on COM recv. SSC reads from other one
|
2018-04-08 16:37:26 +00:00
|
|
|
std::deque<BYTE> m_qTcpSerialBuffer;
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
bool m_bTxIrqEnabled;
|
|
|
|
bool m_bRxIrqEnabled;
|
|
|
|
|
2018-04-08 16:37:26 +00:00
|
|
|
volatile bool m_vbTxIrqPending;
|
|
|
|
volatile bool m_vbRxIrqPending;
|
|
|
|
volatile bool m_vbTxEmpty;
|
2007-05-28 11:16:42 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
HANDLE m_hCommThread;
|
|
|
|
|
|
|
|
HANDLE m_hCommEvent[COMMEVT_MAX];
|
|
|
|
OVERLAPPED m_o;
|
|
|
|
|
|
|
|
BYTE* m_pExpansionRom;
|
2017-03-18 13:56:18 +00:00
|
|
|
|
2017-03-19 21:44:20 +00:00
|
|
|
bool m_bCfgSupportDCD;
|
2018-04-08 16:37:26 +00:00
|
|
|
UINT m_uDTR;
|
2018-04-22 13:37:59 +00:00
|
|
|
|
|
|
|
static const DWORD m_kDefaultModemStatus = 0; // MS_RLSD_OFF(=DCD_OFF), MS_DSR_OFF, MS_CTS_OFF
|
|
|
|
volatile DWORD m_dwModemStatus; // Updated by CommThread when any of RLSD|DSR|CTS changes / Read by main thread - CommStatus()& CommDipSw()
|
2018-04-08 16:37:26 +00:00
|
|
|
|
|
|
|
UINT m_uRTS;
|
2007-05-28 11:16:42 +00:00
|
|
|
};
|