Serial Port Driver Architecture

The serial port driver handles any I/O devices that behave like serial ports, including those based on 16450 and 16550 universal asynchronous receiver-transmitter (UART) chips and those that use direct memory access (DMA). Many platforms have devices of this type, including ordinary 9-pin serial ports, infrared I/O ports, and PC Card serial devices, such as modems. If multiple types of serial ports exist on a platform, you can either create several different serial drivers, one per serial port type, or create several different lower layers and link them to a single upper layer. This creates one multipurpose serial driver.

Creating separate drivers can simplify debugging and maintenance because each driver supports only one type of port. Creating a multipurpose driver, such as the sample serial port driver, is more complex but gives a small memory savings.

The COM_Open function in the serial port upper layer does not implement the fErrorChar, fNull, and fAbortOnChar members of the DCB structure. You must add support for this functionality in your lower layer, if it is appropriate for your serial port hardware.

Because the functionality of serial ports maps to the functionality provided by standard stream interface functions, the serial port driver uses the stream interface as its device interface.

Serial port devices make extensive use of I/O control codes to set and query various attributes of a serial port. For example, there are I/O control codes for setting and clearing the Data Terminal Ready (DTR) line, for purging any undelivered data, and for getting the status of a modem device. Therefore, you should support as many serial I/O control codes as possible in your implementation of COM_IOControl.

The following table shows the functions for the serial port driver. These function names are listed as they are defined in the sample serial port code. You can change this set of functions or the function names by modifying the serial object table, which is a table of HWOBJ type objects, in the serial port lower layer.

Function Description
COM_Close Closes the serial device. It is called in response to an application's call to the CloseHandle function.
COM_Deinit De-initializes the serial port.
COM_Init Initializes the serial device.
COM_IOControl Implements the serial port's I/O control routine. It is called by serial port functions such as GetComState, which is a wrapper around this function.
COM_Open Initializes the serial port driver.
COM_PowerDown Indicates to the serial port driver that the platform is about to go into suspend mode.
COM_PowerUp Indicates to the serial port driver that the platform is resuming from suspend mode.
COM_Read Enables an application to receive characters from the serial port.
COM_Write Enables an application to transmit bytes to the serial port.
GetSerialObject Returns a pointer to a HWOBJ structure, which contains the correct function pointers and parameters for the relevant lower layer's hardware interface functions.
HWClearBreak Clears a RS-232 line break condition.
HWClearDTR Clears the Data Terminal Ready (DTR) signal.
HWClearRTS Clears the Request to Send (RTS) signal.
HWClose Closes the device initialized by the HWInit function.
HWDeinit Called by the upper layer to de-initialize the hardware when a device driver is unloaded.
HWDisableIR Disables the infrared (IR) serial interface, returning the port to standard RS-232 serial if it supports both modes.
HWEnableIR Enables the infrared (IR) serial interface.
HWGetCommProperties Retrieves the current properties of the communications device.
HWGetIntrType Returns the current interrupt type.
HWGetModemStatus Retrieves the modem status.
HWGetRxBufferSize Returns the maximum number of bytes that the hardware buffer can hold, not counting the padding, stop, and start bits.
HWGetRxStart Returns the start of the hardware receive buffer.
HWGetStatus Specifies the hardware status API.
HWInit Initializes a serial device.
HWIoctl The device I/O control routine.
HWLineIntrHandler Handles line interrupts for serial port devices.
HWModemIntrHandler Handles the modem interrupt.
HWOpen Called by the MDD layer to open the serial device.
HWPostInit Called by the MDD layer to perform any post initialization for serial port drivers. This call occurs as the last step of the COM_Init routine, after the driver has initialized all data structures and prepared the serial IST to begin handling interrupts.
HWPowerOff Called by the model device driver to notify the platform-dependent driver that the platform is about to enter suspend mode.
HWPowerOn Called by the model device driver to notify the platform-dependent driver that the platform is resuming from suspend mode.
HWPurgeComm Purges the communications device.
HWPutBytes Called by a driver to write bytes to hardware.
HWReset Resets the hardware API.
HWRxIntrHandler Handles receive interrupts for serial port device drivers, it gets a number of bytes from the device; the number may be 0.
HWSetBreak Sets the line break condition on the transmit line.
HWSetCommTimeouts Sets the communications time-outs in response to a call to the SetCommTimeouts function.
HWSetDCB Sets the device control block.
HWSetDTR Sets the Data Terminal Ready (DTR) signal.
HWSetRTS Sets the Request to Send (RTS) signal.
HWTxIntrHandler Handles the transmit interrupt for serial port devices.
HWXmitComChar Transmits a single character.

See Also

Serial Port Drivers | Power Management in Serial Port Drivers | Automatic Detection of Docking for Serial Ports | Serial Port Driver Samples

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.