HW_VTBL
This structure stores function pointers to the functions that serial port drivers must implement.
Syntax
typedef struct __HW_VTBL {
PVOID (*HWInit)(ULONG Identifier, PVOID pMDDContext, PHWOBJ pHWObj);
ULONG (*HWDeinit)(PVOID pHead);
BOOL (*HWOpen)(PVOID pHead);
ULONG (*HWClose)(PVOID pHead);
ULONG (*HWGetBytes)(PVOID pHead, PUCHAR pTarget,
PULONG pBytes);
PVOID (*HWGetRxStart)(PVOID pHead);
INTERRUPT_TYPE (*HWGetIntrType)(PVOID pHead);
VOID (*HWOtherIntrHandler)(PVOID pHead);
VOID (*HWLineIntrHandler)(PVOID pHead);
ULONG (*HWGetRxBufferSize)(PVOID pHead);
VOID (*HWTxIntrHandler)(PVOID pHead);
ULONG (*HWPutBytes)(PVOID pHead, PUCHAR pSrc,
ULONG NumBytes, PULONG pBytesSent);
BOOL (*HWPowerOff)(PVOID pHead);
BOOL (*HWPowerOn)(PVOID pHead);
VOID (*HWClearDTR)(PVOID pHead);
VOID (*HWSetDTR)(PVOID pHead);
VOID (*HWClearRTS)(PVOID pHead);
VOID (*HWSetRTS)(PVOID pHead);
BOOL (*HWEnableIR)(PVOID pHead, ULONG BaudRate);
BOOL (*HWDisableIR)(PVOID pHead);
VOID (*HWClearBreak)(PVOID pHead);
VOID (*HWSetBreak)(PVOID pHead);
BOOL (*HWXmitComChar)(PVOID pHead, UCHAR ComChar);
ULONG (*HWGetStatus)(PVOID pHead, LPCOMSTAT lpStat);
VOID (*HWReset)(PVOID pHead);
VOID (*HWGetModemStatus)(PVOID pHead, PULONG pModemStatus);
VOID (*HWGetCommProperties)(PVOID pHead,
LPCOMMPROP pCommProp);
VOID (*HWPurgeComm)(PVOID pHead, DWORD fdwAction);
BOOL (*HWSetDCB)(PVOID pHead, LPDCB pDCB);
BOOL (*HWSetCommTimeouts)(PVOID pHead,
LPCOMMTIMEOUTS lpCommTO);
BOOL (*HWIoctl)(PVOID pHead, DWORD dwCode,
PBYTE pBufIn,DWORD dwLenIn,
PBYTE pBufOut,DWORD dwLenOut,
PDWORD pdwActualOut);
} HW_VTBL, *PHW_VTBL;
Members
- HWInit
- A function which performs the required initialization for the serial port driver's PDD layer.
- HWDeinit
- A function which performs any required work when the driver is uninitialized, such as freeing allocated data structures.
- HWOpen
- A function that is called when an application opens a serial port. Typically this function is responsible for powering the serial port hardware and initializing its state, if it is not already open.
- HWClose
- A function that is called when an application closes a serial port. Typically this function is responsible for freeing any data allocated in HWOpen and removing power from serial port hardware.
- HWGetBytes
- A function that is called by the MDD layer to retrieve received characters from the UART when RX_INTR is returned from the function HWGetIntrType. The return value indicates number of received bytes, if any, that were dropped by the UART or the PDD.
- HWGetRxStart
- A function that returns the address of the start of the hardware receive buffer. This is subsequently passed to the function InterruptInitialize.
- HWGetIntrType
- This function is called by the MDD layer when an interrupt event is signaled. This function determines the cause of the interrupt and returns an interrupt mask composed of the possible types INTR_RX, INTR_TX, INTR_MODEM, INTR_LINE, or INTR_NONE.
- HWOtherIntrHandler
- This function is called by the MDD layer to handle an INTR_MODEM interrupt.
- HWLineIntrHandler
- This function is called by the MDD layer to handle an INTR_LINE interrupt.
- HWGetRxBufferSize
- This function returns the number of bytes which can be held in the receive buffer or FIFO.
- HWTxIntrHandler
- This function is called by the MDD layer to handle an INTR_TX interrupt.
- HWPutBytes
- This function is called by the MDD layer'ss COM_Write function to transmit data. It loads the FIFO and returns to the MDD. A non-zero return code indicates that the MDD must perform polling to detect changes in the flow control state. Hardware which supports interrupt generation when the line state changes should return 0. The return value indicates number of milliseconds to wait before polling.
- HWPowerOff
- This function is called as part of the system's power down sequence. This function may make no system calls, and should perform the minimum work required to save the serial port hardware's status.
- HWPowerOn
- This function is called as part of the system's power on sequence. It should use data saved in HWPowerOff to restore the state of the serial port hardware. This function may not make system calls.
- HWClearDTR
- This function clears the DTR signal.
- HWSetDTR
- This function sets the DTR signal.
- HWClearRTS
- This function clears the RTS line
- HWSetRTS
- This function sets the RTS line.
- HWEnableIR
- This function enables the IR interface for ports which support IR mode. Typically, this involves switching the UART outputs from a standard line driver to an IR LED interface.
- HWDisableIR
- This function disables IR mode on ports which support it.
- HWClearBreak
- This function clears the break condition on the TX line.
- HWSetBreak
- This function sets the break condition on the TX line. It is not supported by all UART chips.
- HWXmitComChar
- This function transmits the specified character ahead of any other data which may already have been queued by the HWPutBytes routine. Not supported by all hardware.
- HWGetStatus
- This function is called in response to the IOCTL_SERIAL_GET_COMMSTATUS I/O control code. It returns the serial port's current status. Note, this function must also clear the CommErrors field.
- HWReset
- This function resets the ComStatus structure used by HWGetStatus.
- HWGetModemStatus
- This function is called in response to the IOCTL_SERIAL_GET_MODEMSTATUS I/O control code. See the Win32 documentation for description of the ModemStatus structure.
- HWGetCommProperties
- This function fills in the CommProperties structure with information about the serial port's device capabilities.
- HWPurgeComm
- This function clears the UART data as indicated by the TX_CLEAR, RX_CLEAR, TX_ABORT, and RX_ABORT flags.
- HWSetDCB
- This function sets the port characteristics as indicated by the DCB structure passed as input to the function.
- HWSetCommTimeouts
- This function sets communications timeout values as indicated. Note, one of the primary tasks of the MDD layer is to handle communications timeouts. The PDD layer typically does not have to do anything in its implement of this function.
- HWIoctl
- This function candles any I/O control codes. In addition to the standard Win32 codes, any PDD layer may choose to implement additional codes specific to the underlying hardware capabilities.