00001 /* ES40 emulator. 00002 * Copyright (C) 2007-2008 by the ES40 Emulator Project 00003 * 00004 * WWW : http://sourceforge.net/projects/es40 00005 * E-mail : camiel@camicom.com 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 * Although this is not required, the author would appreciate being notified of, 00022 * and receiving any modifications you may make to the source code that might serve 00023 * the general public. 00024 */ 00025 00093 #if !defined(INCLUDED_SERIAL_H) 00094 #define INCLUDED_SERIAL_H 00095 00096 #include "SystemComponent.h" 00097 #include "telnet.h" 00098 00104 class CSerial : public CSystemComponent, public Poco::Runnable 00105 { 00106 public: 00107 void write(const char* s); 00108 virtual void WriteMem(int index, u64 address, int dsize, u64 data); 00109 virtual u64 ReadMem(int index, u64 address, int dsize); 00110 CSerial(CConfigurator* cfg, CSystem* c, u16 number); 00111 virtual ~CSerial(); 00112 void receive(const char* data); 00113 virtual void check_state(); 00114 virtual int SaveState(FILE* f); 00115 virtual int RestoreState(FILE* f); 00116 void eval_interrupts(); 00117 void WaitForConnection(); 00118 virtual void run(); 00119 void execute(); 00120 00121 virtual void init(); 00122 virtual void start_threads(); 00123 virtual void stop_threads(); 00124 private: 00125 void serial_menu(); 00126 00127 Poco::Thread * myThread; 00128 bool StopThread; 00129 bool breakHit; 00130 00132 struct SSrl_state 00133 { 00134 u8 bTHR; 00135 u8 bRDR; 00136 u8 bBRB_LSB; 00137 u8 bBRB_MSB; 00138 u8 bIER; 00139 u8 bIIR; 00140 u8 bFCR; 00141 u8 bLCR; 00142 u8 bMCR; 00143 u8 bLSR; 00144 u8 bMSR; 00145 u8 bSPR; 00146 int serial_cycles; 00147 char rcvBuffer[1024]; 00148 int rcvW; 00149 int rcvR; 00150 int iNumber; 00151 bool irq_active; 00152 } state; 00153 int listenPort; 00154 int listenSocket; 00155 int connectSocket; 00156 #if defined(IDB) && defined(LS_MASTER) 00157 int throughSocket; 00158 #endif 00159 }; 00160 #endif // !defined(INCLUDED_SERIAL_H)