| | Commands
A Win32 program passes a block of commands in an IOCTL input buffer. These commands are either run straightaway or are run one or more times during the processing of read or write requests.
A command is a single byte, followed by one or more parameter bytes. Table 15.2 lists all the commands, their parameters, and their output. The Ioctl.h header in the WdmIo\Sys directory contains the command definitions. Note that all operations are currently byte-sized. However, the two top bits of the command byte are reserved to indicate 16-bit word transfers and 32-bit long word transfers. If either of these bits is currently set, the command is not run and command processing is aborted. All command parameters are BYTEs. A BYTE is an unsigned 8-bit value, so you cannot use negative values.
Most of the commands are fairly self-explanatory. They are best explained using examples in the context of a sample application, WdmIoTest, that outputs data to the LPT printer parallel port.
Table 15.2 WdmIo and PhdIo commands
Command |
Input parameters |
Output |
Description |
PHDIO_OR |
reg, Value |
|
Read register, OR with value, and write back. Use to set bit(s) |
PHDIO_AND |
reg, Value |
|
Read register, AND with value, and write back. Use to clear bit(s) |
PHDIO_XOR |
reg, Value |
|
Read register, XOR with value, and write back. Use to toggle bit(s) |
PHDIO_WRITE |
reg, Value |
|
Write value to a register |
PHDIO_READ |
reg |
Value |
Read value from a register |
PHDIO_DELAY |
delay |
|
Delay for given microseconds. Delay must be 60µs or less |
PHDIO_WRITES |
reg, count, Values, delay |
|
Write values to same register with delay (<=60µs) |
PHDIO_READS |
reg, count, delay |
Values |
Read values from same register with delay (<=60µs) |
PHDIO_IRQ_CONNECT |
reg, mask, Value |
|
Connect to interrupt |
PHDIO_TIMEOUT |
seconds |
|
Specify time-out for reads and writes |
PHDIO_WRITE_NEXT |
reg |
|
Write next value from write buffer |
PHDIO_READ_NEXT |
reg |
|
Store next value in read buffer |
|