ntdll: Created infrastructure to support IOCTL for serial devices.

- created infrastructure in ntdll to support IOCTL for serial devices
- implemented IOCTLs in ntdll for serial break support
- implemented the kernel32 equivalent on top of those IOCTLs
This commit is contained in:
Eric Pouech 2006-01-12 13:32:51 +01:00 committed by Alexandre Julliard
parent 978f470692
commit 2cdace2760
7 changed files with 632 additions and 48 deletions

View File

@ -61,6 +61,8 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winioctl.h"
#include "ddk/ntddser.h"
#include "wine/server.h"
#include "wine/unicode.h"
@ -686,6 +688,9 @@ static BOOL COMM_GetCommError(HANDLE handle, LPDWORD lperror)
*
* Halts the transmission of characters to a communications device.
*
* PARAMS
* handle [in] The communications device to suspend
*
* RETURNS
*
* True on success, and false if the communications device could not be found,
@ -695,28 +700,9 @@ static BOOL COMM_GetCommError(HANDLE handle, LPDWORD lperror)
*
* Only TIOCSBRK and TIOCCBRK are supported.
*/
BOOL WINAPI SetCommBreak(
HANDLE handle) /* [in] The communications device to suspend. */
BOOL WINAPI SetCommBreak(HANDLE handle)
{
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
int fd,result;
fd = get_comm_fd( handle, FILE_READ_DATA );
if(fd<0) return FALSE;
result = ioctl(fd,TIOCSBRK,0);
release_comm_fd( handle, fd );
if (result ==-1)
{
TRACE("ioctl failed\n");
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
}
return TRUE;
#else
FIXME("ioctl not available\n");
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
#endif
return DeviceIoControl(handle, IOCTL_SERIAL_SET_BREAK_ON, NULL, 0, NULL, 0, NULL, NULL);
}
/*****************************************************************************
@ -724,6 +710,10 @@ BOOL WINAPI SetCommBreak(
*
* Resumes character transmission from a communication device.
*
* PARAMS
*
* handle [in] The halted communication device whose character transmission is to be resumed
*
* RETURNS
*
* True on success and false if the communications device could not be found.
@ -732,28 +722,9 @@ BOOL WINAPI SetCommBreak(
*
* Only TIOCSBRK and TIOCCBRK are supported.
*/
BOOL WINAPI ClearCommBreak(
HANDLE handle) /* [in] The halted communication device whose character transmission is to be resumed. */
BOOL WINAPI ClearCommBreak(HANDLE handle)
{
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
int fd,result;
fd = get_comm_fd( handle, FILE_READ_DATA );
if(fd<0) return FALSE;
result = ioctl(fd,TIOCCBRK,0);
release_comm_fd( handle, fd );
if (result ==-1)
{
TRACE("ioctl failed\n");
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
}
return TRUE;
#else
FIXME("ioctl not available\n");
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
#endif
return DeviceIoControl(handle, IOCTL_SERIAL_SET_BREAK_OFF, NULL, 0, NULL, 0, NULL, NULL);
}
/*****************************************************************************

View File

@ -36,6 +36,7 @@ C_SRCS = \
rtlbitmap.c \
rtlstr.c \
sec.c \
serial.c \
server.c \
signal_i386.c \
signal_powerpc.c \

View File

@ -872,18 +872,27 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent,
PVOID OutputBuffer,
ULONG OutputBufferSize)
{
NTSTATUS ret;
TRACE("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx)\n",
DeviceHandle, hEvent, UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize);
if (CDROM_DeviceIoControl(DeviceHandle, hEvent,
UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize,
OutputBuffer, OutputBufferSize) == STATUS_NO_SUCH_DEVICE)
if ((IoControlCode >> 16) == FILE_DEVICE_SERIAL_PORT)
ret = COMM_DeviceIoControl(DeviceHandle, hEvent,
UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize,
OutputBuffer, OutputBufferSize);
else ret = CDROM_DeviceIoControl(DeviceHandle, hEvent,
UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize,
OutputBuffer, OutputBufferSize);
if (ret == STATUS_NO_SUCH_DEVICE)
{
/* it wasn't a CDROM */
/* it wasn't a supported device (CDROM, COMM) */
FIXME("Unimplemented dwIoControlCode=%08lx\n", IoControlCode);
IoStatusBlock->u.Status = STATUS_NOT_IMPLEMENTED;
IoStatusBlock->Information = 0;

View File

@ -81,6 +81,13 @@ extern NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice,
ULONG IoControlCode,
LPVOID lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize);
extern NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
PVOID UserApcContext,
PIO_STATUS_BLOCK piosb,
ULONG IoControlCode,
LPVOID lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize);
/* file I/O */
extern NTSTATUS FILE_GetNtStatus(void);

197
dlls/ntdll/serial.c Normal file
View File

@ -0,0 +1,197 @@
/* Main file for COMM support
*
* DEC 93 Erik Bos <erik@xs4all.nl>
* Copyright 1996 Marcus Meissner
* Copyright 2005 Eric Pouech
*
* 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.1 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#ifdef HAVE_IO_H
# include <io.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#include <fcntl.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
#ifdef HAVE_SYS_MODEM_H
# include <sys/modem.h>
#endif
#ifdef HAVE_SYS_STRTIO_H
# include <sys/strtio.h>
#endif
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winternl.h"
#include "winioctl.h"
#include "ddk/ntddser.h"
#include "ntdll_misc.h"
#include "wine/server.h"
#include "wine/library.h"
#include "wine/debug.h"
#ifdef HAVE_LINUX_SERIAL_H
#include <linux/serial.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL(comm);
static const char* iocode2str(DWORD ioc)
{
switch (ioc)
{
#define X(x) case (x): return #x;
X(IOCTL_SERIAL_CLEAR_STATS);
X(IOCTL_SERIAL_CLR_DTR);
X(IOCTL_SERIAL_CLR_RTS);
X(IOCTL_SERIAL_CONFIG_SIZE);
X(IOCTL_SERIAL_GET_BAUD_RATE);
X(IOCTL_SERIAL_GET_CHARS);
X(IOCTL_SERIAL_GET_COMMSTATUS);
X(IOCTL_SERIAL_GET_DTRRTS);
X(IOCTL_SERIAL_GET_HANDFLOW);
X(IOCTL_SERIAL_GET_LINE_CONTROL);
X(IOCTL_SERIAL_GET_MODEM_CONTROL);
X(IOCTL_SERIAL_GET_MODEMSTATUS);
X(IOCTL_SERIAL_GET_PROPERTIES);
X(IOCTL_SERIAL_GET_STATS);
X(IOCTL_SERIAL_GET_TIMEOUTS);
X(IOCTL_SERIAL_GET_WAIT_MASK);
X(IOCTL_SERIAL_IMMEDIATE_CHAR);
X(IOCTL_SERIAL_LSRMST_INSERT);
X(IOCTL_SERIAL_PURGE);
X(IOCTL_SERIAL_RESET_DEVICE);
X(IOCTL_SERIAL_SET_BAUD_RATE);
X(IOCTL_SERIAL_SET_BREAK_ON);
X(IOCTL_SERIAL_SET_BREAK_OFF);
X(IOCTL_SERIAL_SET_CHARS);
X(IOCTL_SERIAL_SET_DTR);
X(IOCTL_SERIAL_SET_FIFO_CONTROL);
X(IOCTL_SERIAL_SET_HANDFLOW);
X(IOCTL_SERIAL_SET_LINE_CONTROL);
X(IOCTL_SERIAL_SET_MODEM_CONTROL);
X(IOCTL_SERIAL_SET_QUEUE_SIZE);
X(IOCTL_SERIAL_SET_RTS);
X(IOCTL_SERIAL_SET_TIMEOUTS);
X(IOCTL_SERIAL_SET_WAIT_MASK);
X(IOCTL_SERIAL_SET_XOFF);
X(IOCTL_SERIAL_SET_XON);
X(IOCTL_SERIAL_WAIT_ON_MASK);
X(IOCTL_SERIAL_XOFF_COUNTER);
#undef X
default: { static char tmp[32]; sprintf(tmp, "IOCTL_SERIAL_%ld\n", ioc); return tmp; }
}
}
/******************************************************************
* COMM_DeviceIoControl
*
*
*/
NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
PVOID UserApcContext,
PIO_STATUS_BLOCK piosb,
ULONG dwIoControlCode,
LPVOID lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize)
{
DWORD sz = 0, access = FILE_READ_DATA;
NTSTATUS status = STATUS_SUCCESS;
int fd;
TRACE("%p %s %p %ld %p %ld %p\n",
hDevice, iocode2str(dwIoControlCode), lpInBuffer, nInBufferSize,
lpOutBuffer, nOutBufferSize, piosb);
piosb->Information = 0;
if ((status = wine_server_handle_to_fd( hDevice, access, &fd, NULL ))) goto error;
switch (dwIoControlCode)
{
case IOCTL_SERIAL_SET_BREAK_OFF:
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
if (ioctl(fd, TIOCCBRK, 0) == -1)
{
TRACE("ioctl failed\n");
status = FILE_GetNtStatus();
}
#else
FIXME("ioctl not available\n");
status = STATUS_NOT_SUPPORTED;
#endif
break;
case IOCTL_SERIAL_SET_BREAK_ON:
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
if (ioctl(fd, TIOCSBRK, 0) == -1)
{
TRACE("ioctl failed\n");
status = FILE_GetNtStatus();
}
#else
FIXME("ioctl not available\n");
status = STATUS_NOT_SUPPORTED;
#endif
break;
default:
FIXME("Unsupported IOCTL %lx (type=%lx access=%lx func=%lx meth=%lx)\n",
dwIoControlCode, dwIoControlCode >> 16, (dwIoControlCode >> 14) & 3,
(dwIoControlCode >> 2) & 0xFFF, dwIoControlCode & 3);
sz = 0;
status = STATUS_INVALID_PARAMETER;
break;
}
wine_server_release_fd( hDevice, fd );
error:
piosb->u.Status = status;
piosb->Information = sz;
if (hEvent) NtSetEvent(hEvent, NULL);
return status;
}

View File

@ -91,6 +91,7 @@ WINDOWS_INCLUDES = \
dde.h \
ddeml.h \
ddk/cfgmgr32.h \
ddk/ntddser.h \
ddk/wdm.h \
ddk/winsplp.h \
ddraw.h \

398
include/ddk/ntddser.h Normal file
View File

@ -0,0 +1,398 @@
/*
* DDK definitions for serial port
*
* Copyright (C) 2006 Eric Pouech
* From w32api package
*
* 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.1 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _NTDDSER_H_
#define _NTDDSER_H_
#ifdef __cplusplus
extern "C" {
#endif
#define IOCTL_SERIAL_CLEAR_STATS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 36, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_CLR_DTR \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_CLR_RTS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_CONFIG_SIZE \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 32, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_BAUD_RATE \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_CHARS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_COMMSTATUS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 27, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_DTRRTS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_HANDFLOW \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_LINE_CONTROL \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_MODEM_CONTROL \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 37, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_MODEMSTATUS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_PROPERTIES \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 29, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_STATS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 35, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_TIMEOUTS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GET_WAIT_MASK \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 16, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_IMMEDIATE_CHAR \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
#ifndef IOCTL_SERIAL_LSRMST_INSERT
/* it's already defined in winioctl.h */
#define IOCTL_SERIAL_LSRMST_INSERT \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 31, METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif
#define IOCTL_SERIAL_PURGE \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 19, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_RESET_DEVICE \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_BAUD_RATE \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_BREAK_ON \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_BREAK_OFF \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_CHARS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_DTR \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_FIFO_CONTROL \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 39, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_HANDFLOW \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_LINE_CONTROL \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_MODEM_CONTROL \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 38, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_QUEUE_SIZE \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_RTS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_TIMEOUTS \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_WAIT_MASK \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_XOFF \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_XON \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_WAIT_ON_MASK \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SERIAL_XOFF_COUNTER \
CTL_CODE (FILE_DEVICE_SERIAL_PORT, 28, METHOD_BUFFERED, FILE_ANY_ACCESS)
typedef struct _SERIAL_BAUD_RATE
{
ULONG BaudRate;
} SERIAL_BAUD_RATE, *PSERIAL_BAUD_RATE;
/* SERIAL_BAUD_RATE.BaudRate constants */
#define SERIAL_BAUD_075 0x00000001
#define SERIAL_BAUD_110 0x00000002
#define SERIAL_BAUD_134_5 0x00000004
#define SERIAL_BAUD_150 0x00000008
#define SERIAL_BAUD_300 0x00000010
#define SERIAL_BAUD_600 0x00000020
#define SERIAL_BAUD_1200 0x00000040
#define SERIAL_BAUD_1800 0x00000080
#define SERIAL_BAUD_2400 0x00000100
#define SERIAL_BAUD_4800 0x00000200
#define SERIAL_BAUD_7200 0x00000400
#define SERIAL_BAUD_9600 0x00000800
#define SERIAL_BAUD_14400 0x00001000
#define SERIAL_BAUD_19200 0x00002000
#define SERIAL_BAUD_38400 0x00004000
#define SERIAL_BAUD_56K 0x00008000
#define SERIAL_BAUD_128K 0x00010000
#define SERIAL_BAUD_115200 0x00020000
#define SERIAL_BAUD_57600 0x00040000
#define SERIAL_BAUD_USER 0x10000000
typedef struct _SERIAL_CHARS
{
UCHAR EofChar;
UCHAR ErrorChar;
UCHAR BreakChar;
UCHAR EventChar;
UCHAR XonChar;
UCHAR XoffChar;
} SERIAL_CHARS, *PSERIAL_CHARS;
typedef struct _SERIAL_STATUS
{
ULONG Errors;
ULONG HoldReasons;
ULONG AmountInInQueue;
ULONG AmountInOutQueue;
BOOLEAN EofReceived;
BOOLEAN WaitForImmediate;
} SERIAL_STATUS, *PSERIAL_STATUS;
typedef struct _SERIAL_HANDFLOW
{
ULONG ControlHandShake;
ULONG FlowReplace;
LONG XonLimit;
LONG XoffLimit;
} SERIAL_HANDFLOW, *PSERIAL_HANDFLOW;
#define SERIAL_DTR_MASK 0x00000003
#define SERIAL_DTR_CONTROL 0x00000001
#define SERIAL_DTR_HANDSHAKE 0x00000002
#define SERIAL_CTS_HANDSHAKE 0x00000008
#define SERIAL_DSR_HANDSHAKE 0x00000010
#define SERIAL_DCD_HANDSHAKE 0x00000020
#define SERIAL_OUT_HANDSHAKEMASK 0x00000038
#define SERIAL_DSR_SENSITIVITY 0x00000040
#define SERIAL_ERROR_ABORT 0x80000000
#define SERIAL_CONTROL_INVALID 0x7fffff84
#define SERIAL_AUTO_TRANSMIT 0x00000001
#define SERIAL_AUTO_RECEIVE 0x00000002
#define SERIAL_ERROR_CHAR 0x00000004
#define SERIAL_NULL_STRIPPING 0x00000008
#define SERIAL_BREAK_CHAR 0x00000010
#define SERIAL_RTS_MASK 0x000000c0
#define SERIAL_RTS_CONTROL 0x00000040
#define SERIAL_RTS_HANDSHAKE 0x00000080
#define SERIAL_TRANSMIT_TOGGLE 0x000000c0
#define SERIAL_XOFF_CONTINUE 0x80000000
#define SERIAL_FLOW_INVALID 0x7fffff20
typedef struct _SERIAL_LINE_CONTROL
{
UCHAR StopBits;
UCHAR Parity;
UCHAR WordLength;
} SERIAL_LINE_CONTROL, *PSERIAL_LINE_CONTROL;
/* SERIAL_LINE_CONTROL.StopBits constants */
#define STOP_BIT_1 0x00
#define STOP_BITS_1_5 0x01
#define STOP_BITS_2 0x02
/* SERIAL_LINE_CONTROL.Parity constants */
#define NO_PARITY 0x00
#define ODD_PARITY 0x01
#define EVEN_PARITY 0x02
#define MARK_PARITY 0x03
#define SPACE_PARITY 0x04
/* IOCTL_SERIAL_(GET_MODEM_CONTROL, SET_MODEM_CONTROL) flags */
#define SERIAL_IOC_MCR_DTR 0x00000001
#define SERIAL_IOC_MCR_RTS 0x00000002
#define SERIAL_IOC_MCR_OUT1 0x00000004
#define SERIAL_IOC_MCR_OUT2 0x00000008
#define SERIAL_IOC_MCR_LOOP 0x00000010
typedef struct _SERIAL_COMMPROP
{
USHORT PacketLength;
USHORT PacketVersion;
ULONG ServiceMask;
ULONG Reserved1;
ULONG MaxTxQueue;
ULONG MaxRxQueue;
ULONG MaxBaud;
ULONG ProvSubType;
ULONG ProvCapabilities;
ULONG SettableParams;
ULONG SettableBaud;
USHORT SettableData;
USHORT SettableStopParity;
ULONG CurrentTxQueue;
ULONG CurrentRxQueue;
ULONG ProvSpec1;
ULONG ProvSpec2;
WCHAR ProvChar[1];
} SERIAL_COMMPROP, *PSERIAL_COMMPROP;
/* SERIAL_COMMPROP.SettableParams flags */
#define SERIAL_SP_PARITY 0x0001
#define SERIAL_SP_BAUD 0x0002
#define SERIAL_SP_DATABITS 0x0004
#define SERIAL_SP_STOPBITS 0x0008
#define SERIAL_SP_HANDSHAKING 0x0010
#define SERIAL_SP_PARITY_CHECK 0x0020
#define SERIAL_SP_CARRIER_DETECT 0x0040
/* SERIAL_COMMPROP.ProvCapabilities flags */
#define SERIAL_PCF_DTRDSR 0x00000001
#define SERIAL_PCF_RTSCTS 0x00000002
#define SERIAL_PCF_CD 0x00000004
#define SERIAL_PCF_PARITY_CHECK 0x00000008
#define SERIAL_PCF_XONXOFF 0x00000010
#define SERIAL_PCF_SETXCHAR 0x00000020
#define SERIAL_PCF_TOTALTIMEOUTS 0x00000040
#define SERIAL_PCF_INTTIMEOUTS 0x00000080
#define SERIAL_PCF_SPECIALCHARS 0x00000100
#define SERIAL_PCF_16BITMODE 0x00000200
/* SERIAL_COMMPROP.SettableData flags */
#define SERIAL_DATABITS_5 0x0001
#define SERIAL_DATABITS_6 0x0002
#define SERIAL_DATABITS_7 0x0004
#define SERIAL_DATABITS_8 0x0008
#define SERIAL_DATABITS_16 0x0010
#define SERIAL_DATABITS_16X 0x0020
/* SERIAL_COMMPROP.SettableStopParity flags */
#define SERIAL_STOPBITS_10 0x0001
#define SERIAL_STOPBITS_15 0x0002
#define SERIAL_STOPBITS_20 0x0004
#define SERIAL_PARITY_NONE 0x0100
#define SERIAL_PARITY_ODD 0x0200
#define SERIAL_PARITY_EVEN 0x0400
#define SERIAL_PARITY_MARK 0x0800
#define SERIAL_PARITY_SPACE 0x1000
typedef struct _SERIALPERF_STATS
{
ULONG ReceivedCount;
ULONG TransmittedCount;
ULONG FrameErrorCount;
ULONG SerialOverrunErrorCount;
ULONG BufferOverrunErrorCount;
ULONG ParityErrorCount;
} SERIALPERF_STATS, *PSERIALPERF_STATS;
typedef struct _SERIAL_TIMEOUTS
{
ULONG ReadIntervalTimeout;
ULONG ReadTotalTimeoutMultiplier;
ULONG ReadTotalTimeoutConstant;
ULONG WriteTotalTimeoutMultiplier;
ULONG WriteTotalTimeoutConstant;
} SERIAL_TIMEOUTS, *PSERIAL_TIMEOUTS;
/* IOCTL_SERIAL_(GET_WAIT_MASK, SET_WAIT_MASK, WAIT_ON_MASK) flags */
#define SERIAL_EV_RXCHAR 0x0001
#define SERIAL_EV_RXFLAG 0x0002
#define SERIAL_EV_TXEMPTY 0x0004
#define SERIAL_EV_CTS 0x0008
#define SERIAL_EV_DSR 0x0010
#define SERIAL_EV_RLSD 0x0020
#define SERIAL_EV_BREAK 0x0040
#define SERIAL_EV_ERR 0x0080
#define SERIAL_EV_RING 0x0100
#define SERIAL_EV_PERR 0x0200
#define SERIAL_EV_RX80FULL 0x0400
#define SERIAL_EV_EVENT1 0x0800
#define SERIAL_EV_EVENT2 0x1000
/* IOCTL_SERIAL_LSRMST_INSERT constants */
#define SERIAL_LSRMST_LSR_DATA 0x01
#define SERIAL_LSRMST_LSR_NODATA 0x02
#define SERIAL_LSRMST_MST 0x03
#define SERIAL_LSRMST_ESCAPE 0x00
/* IOCTL_SERIAL_PURGE constants */
#define SERIAL_PURGE_TXABORT 0x00000001
#define SERIAL_PURGE_RXABORT 0x00000002
#define SERIAL_PURGE_TXCLEAR 0x00000004
#define SERIAL_PURGE_RXCLEAR 0x00000008
/* IOCTL_SERIAL_SET_FIFO_CONTROL constants */
#define SERIAL_IOC_FCR_FIFO_ENABLE 0x00000001
#define SERIAL_IOC_FCR_RCVR_RESET 0x00000002
#define SERIAL_IOC_FCR_XMIT_RESET 0x00000004
#define SERIAL_IOC_FCR_DMA_MODE 0x00000008
#define SERIAL_IOC_FCR_RES1 0x00000010
#define SERIAL_IOC_FCR_RES2 0x00000020
#define SERIAL_IOC_FCR_RCVR_TRIGGER_LSB 0x00000040
#define SERIAL_IOC_FCR_RCVR_TRIGGER_MSB 0x00000080
typedef struct _SERIAL_QUEUE_SIZE
{
ULONG InSize;
ULONG OutSize;
} SERIAL_QUEUE_SIZE, *PSERIAL_QUEUE_SIZE;
typedef struct _SERIAL_XOFF_COUNTER
{
ULONG Timeout;
LONG Counter;
UCHAR XoffChar;
} SERIAL_XOFF_COUNTER, *PSERIAL_XOFF_COUNTER;
typedef struct _SERIAL_BASIC_SETTINGS
{
SERIAL_TIMEOUTS Timeouts;
SERIAL_HANDFLOW HandFlow;
ULONG RxFifo;
ULONG TxFifo;
} SERIAL_BASIC_SETTINGS, *PSERIAL_BASIC_SETTINGS;
#define SERIAL_ERROR_BREAK 0x00000001
#define SERIAL_ERROR_FRAMING 0x00000002
#define SERIAL_ERROR_OVERRUN 0x00000004
#define SERIAL_ERROR_QUEUEOVERRUN 0x00000008
#define SERIAL_ERROR_PARITY 0x00000010
#define SERIAL_SP_UNSPECIFIED 0x00000000
#define SERIAL_SP_RS232 0x00000001
#define SERIAL_SP_PARALLEL 0x00000002
#define SERIAL_SP_RS422 0x00000003
#define SERIAL_SP_RS423 0x00000004
#define SERIAL_SP_RS449 0x00000005
#define SERIAL_SP_MODEM 0X00000006
#define SERIAL_SP_FAX 0x00000021
#define SERIAL_SP_SCANNER 0x00000022
#define SERIAL_SP_BRIDGE 0x00000100
#define SERIAL_SP_LAT 0x00000101
#define SERIAL_SP_TELNET 0x00000102
#define SERIAL_SP_X25 0x00000103
#define SERIAL_SP_SERIALCOMM 0x00000001
#define SERIAL_TX_WAITING_FOR_CTS 0x00000001
#define SERIAL_TX_WAITING_FOR_DSR 0x00000002
#define SERIAL_TX_WAITING_FOR_DCD 0x00000004
#define SERIAL_TX_WAITING_FOR_XON 0x00000008
#define SERIAL_TX_WAITING_XOFF_SENT 0x00000010
#define SERIAL_TX_WAITING_ON_BREAK 0x00000020
#define SERIAL_RX_WAITING_FOR_DSR 0x00000040
#define SERIAL_DTR_STATE 0x00000001
#define SERIAL_RTS_STATE 0x00000002
#define SERIAL_CTS_STATE 0x00000010
#define SERIAL_DSR_STATE 0x00000020
#define SERIAL_RI_STATE 0x00000040
#define SERIAL_DCD_STATE 0x00000080
typedef struct _SERIALCONFIG
{
ULONG Size;
USHORT Version;
ULONG SubType;
ULONG ProvOffset;
ULONG ProviderSize;
WCHAR ProviderData[1];
} SERIALCONFIG,*PSERIALCONFIG;
#ifdef __cplusplus
}
#endif
#endif /* _NTDDSER_H_ */