2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-12-23 20:13:29 +03:00
|
|
|
// Copyright (C) 2004-2014 The Bochs Project
|
2009-02-08 12:05:52 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-18 04:30:14 +03:00
|
|
|
|
|
|
|
#if USE_RAW_SERIAL
|
|
|
|
|
2004-01-18 14:58:07 +03:00
|
|
|
#ifdef __linux__
|
2001-06-16 23:27:41 +04:00
|
|
|
#include <linux/serial.h>
|
2004-01-18 14:58:07 +03:00
|
|
|
#endif
|
2001-06-16 23:27:41 +04:00
|
|
|
|
2004-05-13 20:23:15 +04:00
|
|
|
#ifdef WIN32
|
|
|
|
// experimental raw serial receive support on win32
|
|
|
|
//#define WIN32_RECEIVE_RAW
|
|
|
|
#endif
|
|
|
|
|
2004-02-28 16:10:57 +03:00
|
|
|
#define P_NONE 0
|
|
|
|
#define P_ODD 1
|
|
|
|
#define P_EVEN 2
|
|
|
|
#define P_HIGH 3
|
|
|
|
#define P_LOW 4
|
2004-03-28 16:41:12 +04:00
|
|
|
|
|
|
|
#define RAW_EVENT_BREAK -1
|
|
|
|
#define RAW_EVENT_CTS_ON -2
|
|
|
|
#define RAW_EVENT_CTS_OFF -3
|
|
|
|
#define RAW_EVENT_DSR_ON -4
|
|
|
|
#define RAW_EVENT_DSR_OFF -5
|
|
|
|
#define RAW_EVENT_RING_ON -6
|
|
|
|
#define RAW_EVENT_RING_OFF -7
|
|
|
|
#define RAW_EVENT_RLSD_ON -8
|
|
|
|
#define RAW_EVENT_RLSD_OFF -9
|
|
|
|
#define RAW_EVENT_FRAME -10
|
|
|
|
#define RAW_EVENT_OVERRUN -11
|
|
|
|
#define RAW_EVENT_PARITY -12
|
2001-06-16 23:27:41 +04:00
|
|
|
|
2004-05-13 20:23:15 +04:00
|
|
|
#define THREAD_RX_BUFSIZE 8192
|
|
|
|
#define RX_BUFSIZE 256
|
|
|
|
|
2001-06-16 23:27:41 +04:00
|
|
|
class serial_raw : public logfunctions {
|
2006-03-08 00:11:20 +03:00
|
|
|
public:
|
2007-11-03 19:47:49 +03:00
|
|
|
serial_raw(const char *devname);
|
|
|
|
virtual ~serial_raw();
|
|
|
|
void set_baudrate(int rate);
|
2013-02-23 19:15:59 +04:00
|
|
|
void set_data_bits(int val);
|
|
|
|
void set_stop_bits(int val);
|
2007-11-03 19:47:49 +03:00
|
|
|
void set_parity_mode(int mode);
|
|
|
|
void set_break(int mode);
|
|
|
|
void set_modem_control(int ctrl);
|
|
|
|
int get_modem_status();
|
|
|
|
void transmit(Bit8u byte);
|
|
|
|
bx_bool ready_transmit();
|
|
|
|
bx_bool ready_receive();
|
2013-02-23 19:15:59 +04:00
|
|
|
int receive();
|
2004-05-13 20:23:15 +04:00
|
|
|
#ifdef WIN32_RECEIVE_RAW
|
2007-11-03 19:47:49 +03:00
|
|
|
void serial_thread();
|
2004-05-13 20:23:15 +04:00
|
|
|
#endif
|
2004-03-09 00:51:19 +03:00
|
|
|
|
2004-02-29 00:28:28 +03:00
|
|
|
private:
|
2007-11-03 19:47:49 +03:00
|
|
|
void setup_port();
|
2004-05-13 20:23:15 +04:00
|
|
|
#ifdef WIN32_RECEIVE_RAW
|
2007-11-03 19:47:49 +03:00
|
|
|
void enq_event(Bit16s event);
|
2004-05-13 20:23:15 +04:00
|
|
|
#endif
|
2004-02-29 00:28:28 +03:00
|
|
|
bx_bool present;
|
2004-05-13 20:23:15 +04:00
|
|
|
unsigned rxdata_count;
|
2004-02-29 00:28:28 +03:00
|
|
|
#ifdef WIN32
|
2004-03-09 00:51:19 +03:00
|
|
|
HANDLE hCOM;
|
2004-02-29 00:28:28 +03:00
|
|
|
DCB dcb;
|
|
|
|
BOOL DCBchanged;
|
2004-05-13 20:23:15 +04:00
|
|
|
DWORD MSR_value;
|
|
|
|
Bit16s rxdata_buffer[RX_BUFSIZE];
|
|
|
|
#ifdef WIN32_RECEIVE_RAW
|
|
|
|
HANDLE hRawSerialThread;
|
|
|
|
BOOL thread_active;
|
|
|
|
BOOL thread_quit;
|
|
|
|
OVERLAPPED rx_ovl;
|
|
|
|
OVERLAPPED thread_ovl;
|
|
|
|
unsigned thread_rxdata_count;
|
|
|
|
Bit16s thread_rxdata_buffer[THREAD_RX_BUFSIZE];
|
2014-12-23 20:13:29 +03:00
|
|
|
CRITICAL_SECTION serialCS;
|
2004-05-13 20:23:15 +04:00
|
|
|
#endif
|
2004-02-29 00:28:28 +03:00
|
|
|
#endif
|
2001-06-16 23:27:41 +04:00
|
|
|
};
|
2004-01-18 04:30:14 +03:00
|
|
|
#endif
|