|
|
1.1 root 1: /*
2: * NT_com.h
3: *
4: * function and structure definitions used external to NT_com.c
5: *
6: * copyright 1992, 1993 by Microsoft Corporation
7: * portions copyright 1991 by Insignia Solutions Ltd., used by permission.
8: *
9: * revision history:
10: * 24-Dec-1992 John Morgan: written based on nt_com.h written by D.A.Bartlett
11: * 4-Jan-1993 John Morgan: added support for buffered transmits
12: *
13: */
14:
15: #define XMIT_BUFFER 1
16:
17: typedef enum
18: {
19: HOST_ADAPTER_NOT_OPEN,
20: HOST_ADAPTER_OPEN,
21: HOST_ADAPTER_SUSPENDED,
22: HOST_ADAPTER_DISABLED
23: } host_adapter_status_t;
24:
25: // the maximum size of the receive buffer
26: #define RX_BUFFER_SIZE 250
27:
28: // the maximum size of a transmit buffer
29: #define TX_BUFFER_SIZE 250
30:
31: #if (XMIT_BUFFER)
32:
33: typedef struct tTX_buffer
34: {
35: HANDLE wait[2]; // mutal exclusion & FULL buffer signal
36: tAdapter adapter; // signal what port is using buffer
37: DWORD byte_count; // number of characters in buffer
38: BYTE bytes[TX_BUFFER_SIZE]; // the bytes to be output
39: OVERLAPPED Overlap; // Overlapped I/O structure
40: } tTX_buffer, *pTX_buffer;
41:
42: #endif
43:
44: typedef struct
45: {
46: UART_STATE uart; // state of simulated UART
47:
48: /*...................................................... Host interface */
49: host_adapter_status_t host_adapter_status;
50: int ReOpenCounter; // Counter to restrict open attempts
51: HANDLE handle; // Device handle
52: DCB dcb; // device control block
53:
54: long modem_status; // modem status line settings
55: HANDLE ModemEvent; // Get modem status control event
56:
57: /*.............................................. Access control objects */
58: int AdapterLockCnt; // Adapter lock count
59: CRITICAL_SECTION AdapterLock;
60:
61: DWORD EvtMask; // Communication events
62: OVERLAPPED WaitOverlap;
63: OVERLAPPED RXOverlap;
64:
65: #if (!XMIT_BUFFER)
66: /*......................................... TX overlapped I/O structure */
67: OVERLAPPED TXOverlap;
68:
69: #else
70: /*......................................... TX buffer control variables */
71: int TX_full_length; // how many characters before xmit full
72: volatile pTX_buffer tx_buffer; // TX transmit buffer
73:
74: /*............................................. TX thread handle and ID */
75: DWORD TXThreadID; // RX thread ID
76: HANDLE TXThreadHandle; // RX thread handle
77:
78: #endif
79:
80: /*......................................... RX buffer control variables */
81: DWORD rx_error; // error for char at end of buffer
82: char rx_buffer[RX_BUFFER_SIZE]; // RX character buffer
83: char *rx_end; // end of current chars
84: char *rx_curr; // Next character to read
85: BOOLEAN rx_waiting; // Waiting for rx interrupt
86:
87: /*............................................. RX thread handle and ID */
88: volatile BOOL TerminateRXThread;
89: DWORD RXThreadID; // RX thread ID
90: HANDLE RXThreadHandle; // RX thread handle
91:
92: } tHostCom, *pHostCom;
93:
94: extern tHostCom host_com[NUM_SERIAL_PORTS];
95: #define UART_ADAPTER(x) host_com[x].uart
96:
97: /*:::::::::::::::::::::::::::::::::::::::::::::::::::::: host com interface */
98:
99: void host_com_lock( tAdapter );
100: void host_com_unlock( tAdapter );
101: void host_com_rx_wait( tAdapter );
102:
103: void host_com_init();
104: void host_com_exit();
105:
106: void host_com_close( tAdapter );
107: //void host_com_reset( tAdapter ); // not used
108: #define host_com_reset(x)
109: ULONG host_com_ioctl( tAdapter, int, long );
110: DWORD host_com_get_error( tAdapter );
111: BOOL host_com_data_avail( tAdapter );
112: BOOL host_com_read_rx( tAdapter, BYTE* );
113: BOOL host_com_write_tx( tAdapter, BYTE );
114:
115: void host_com_char_read( tAdapter, int );
116:
117: // short host_com_valid
118: // ( BYTE hostID, ConfigValues *val, NameTable *dummy, CHAR *errString );
119: void host_com_change( BYTE hostID, BOOL apply );
120: short host_com_active( BYTE hostID, BOOL active, CHAR *errString );
121:
122:
123: /*:::::::::::::::::::::::::::::::::::::::::::::::::: Enumeration definitions */
124:
125: #define HOST_COM_MODEM_CTRL 0000001
126: #define HOST_COM_LINE_CTRL 0000002
127: #define HOST_COM_BAUD 0000003
128: #define HOST_COM_CBRK 0000004
129: #define HOST_COM_SBRK 0000005
130: #define HOST_COM_MSTATUS 0000010
131: //#define HOST_COM_FLUSH 0000011
132: //#define HOST_COM_INPUT_READY 0000012
133:
134: // bit masks for defining host modem status
135: #define HOST_MS_CTS (1 << 0)
136: #define HOST_MS_RI (1 << 1)
137: #define HOST_MS_DSR (1 << 2)
138: #define HOST_MS_RLSD (1 << 3)
139:
140: // bit masks for defining host modem control
141: #define HOST_MC_RTS (1 << 0)
142: #define HOST_MC_DTR (1 << 1)
143:
144: // bit masks for defining host line control
145: #define HOST_LC_DATABITS 0x00F
146: #define HOST_LC_DATA_5 0x005
147: #define HOST_LC_DATA_6 0x006
148: #define HOST_LC_DATA_7 0x007
149: #define HOST_LC_DATA_8 0x008
150:
151: #define HOST_LC_STOPBITS 0x0F0
152: #define HOST_LC_STOP_1 0x010
153: #define HOST_LC_STOP_2 0x020
154: #define HOST_LC_STOP_15 0x030
155:
156: #define HOST_LC_PARITY 0xF00
157: #define HOST_LC_PARITY_NONE 0xF00
158: #define HOST_LC_PARITY_EVEN 0x000
159: #define HOST_LC_PARITY_ODD 0x100
160: #define HOST_LC_PARITY_SPACE 0x200
161: #define HOST_LC_PARITY_MARK 0x300
162:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.