4.2 Parallel I/O Control Codes

Since a printer is the standard device connected to a parallel port, this section summarizes the public I/O control codes that must be supported by parallel class drivers for printing devices. A class driver for another type of device might handle a completely different set of I/O control codes, depending on what kind of application support it must provide and on the nature of its device.

This section also summarizes the set of internal I/O control codes that all class drivers set into IRPs that they send down to the parallel port driver.

IOCTL_PAR_QUERY_INFORMATION

Operation

Returns the status of the printer represented by the input device object.

Input

Parameters.DeviceIoControl.OutputBufferLength indicates the size in bytes of the buffer, which must be >= sizeof(UCHAR).

Output

Returns the Status of the printer, one of PARALLEL_PAPER_EMPTY, PARALLEL_OFF_LINE, PARALLEL_POWER_OFF, PARALLEL_NOT_CONNECTED, PARALLEL_BUSY, or PARALLEL_SELECTED, to the buffer at
Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information is set to sizeof(UCHAR) when the Status field is set to STATUS_SUCCESS. Otherwise, the Information field is set to zero, and the Status field can be set to STATUS_CANCELLED, STATUS_PENDING, or STATUS_BUFFER_TOO_SMALL.

IOCTL_PAR_SET_INFORMATION

Operation

Sets up the printer for a job (write operation), according to the specified constant, PARALLEL_INIT, optionally ORed with PARALLEL_AUTOFEED.

Input

The buffer at Irp->AssociatedIrp.SystemBuffer contains the value to be set, and Parameters.DeviceIoControl.InputBufferLength indicates the size of the buffer, which must be >= sizeof(UCHAR).

Output

None

I/O Status Block

The Information field is set to zero. The Status field can be set to STATUS_SUCCESS or possibly to STATUS_PENDING, STATUS_CANCELLED, or STATUS_INVALID_PARAMETER.

IOCTL_PAR_QUERY_DEVICE_ID

Operation

Returns the IEEE 1284 device identifier for the device.

Input

Parameters.DeviceIoControl.OutputBufferLength indicates the size in bytes of the buffer. A device identifier can be up to 64 K. An application can use IOCTL_PAR_QUERY_DEVICE_ID_SIZE to determine the size of the ID for a particular device.

Output

Returns the device ID to the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

When the driver sets Status to STATUS_SUCCESS, it sets the Information field to the size of the returned device ID. When Status is an error, such as STATUS_IO_DEVICE_ERROR or STATUS_BUFFER_TOO_SMALL, the driver sets Information to zero.

IOCTL_PAR_QUERY_DEVICE_ID_SIZE

Operation

Returns the size of the IEEE 1284 device identifier for the device.

Input

Irp->AssociatedIrp.SystemBuffer of type PPAR_DEVICE_ID_SIZE_INFORMATION to receive the ID size.

Output

Returns the size of the device ID to the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

When the driver sets Status to STATUS_SUCCESS, it sets the Information field to sizeof(PPAR_DEVICE_ID_SIZE_INFORMATION). When Status is an error, such as STATUS_IO_DEVICE_ERROR, the driver sets Information to zero.

IOCTL_SERIAL_GET_TIMEOUTS

Operation

Returns the current time-out setting on the printer for writes to the device.

Input

Parameters.DeviceIoControl.OutputBufferLength indicates the size of the buffer, which must be >= sizeof(SERIAL_TIMEOUTS).

Output

The driver returns the information to the buffer at
Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field is set to sizeof(SERIAL_TIMEOUTS) if the Status field is set to STATUS_SUCCESS. Otherwise, the Status field is set to STATUS_BUFFER_TOO_SMALL.

IOCTL_SERIAL_SET_TIMEOUTS

Operation

Resets the time-out value for writes to the printer.

Input

The buffer at Irp->AssociatedIrp.SystemBuffer contains the value to be set, and Parameters.DeviceIoControl.InputBufferLength indicates the size of the buffer, which must be >= sizeof(SERIAL_TIMEOUTS).

Output

None

I/O Status Block

The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_INVALID_PARAMETER, STATUS_PENDING, or STATUS_CANCELLED.

IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO

Operation

Returns the address range, as a controller base address and span of bytes, for the port controller registers so the class driver can do I/O operations on its device. Class drivers can store the port address range in their device extensions when they initialize. A class driver can access and program the controller registers only when it has successfully allocated the port, for example with an IOCTL_INTERNAL_PARALLEL_PORT_ALLOCATE request.

Also returns pointers to three functions: TryAllocatePort, FreePort and QueryNumWaiters.

TryAllocate Port returns immediately from the port driver with a TRUE status if the port was successfully allocated or a FALSE status if the port was busy.

FreePort releases a previously allocated port that the class driver has been using. The class driver must switch the device back to compatibility mode if necessary.

QueryNumWaiters is used by a class driver to query the number of other class drivers waiting for a port so that a driver that allocates a port for a long time can release the port if it detects that another driver is waiting. QueryNumWaiters returns the number of IRPs queued to a port.

Input

Parameters.DeviceIoControl.OutputBufferLength indicates the size in bytes of the output buffer, which must be >= sizeof(PARALLEL_PORT_INFORMATION).

Output

The port driver returns the information to the buffer at
Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field contains the number of bytes returned if the Status field is set to STATUS_SUCCESS. Otherwise, the Information field is set to zero and the Status field can be set to STATUS_BUFFER_TOO_SMALL.

IOCTL_INTERNAL_PARALLEL_PORT_ALLOCATE

Operation

Gives a class driver exclusive access to a parallel port temporarily. The port driver queues this IRP, that is cancelable, if the port is currently in use by a class driver. A class driver that has allocated the port should call the FreePort function when it has satisfied its current IRP or when its device is busy, if possible. This allows other class drivers to use the port.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. When the port has been allocated to the caller, the Status field is set to STATUS_SUCCESS. Otherwise, the Status field can be set to STATUS_PENDING or STATUS_CANCELLED.

IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT

Operation

A parallel class driver uses the IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT function to supply an interrupt service routine to a port driver. This ISR will be called by the port driver whenever the parallel port generates an interrupt.

A parallel class driver can also use this IOCTL to supply a deferred port check function that will be called by the port driver whenever the port is not in use. The port is allocated by the port driver prior to calling this deferred port check function and freed by the port driver after this deferred port check function returns.

The IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT function returns a pointer to the Interrupt object as well as pointers to functions to allocate the port and free the port at DIRQL.

If the class driver does not already have the port allocated, it can attempt to allocate the port in the ISR by calling TryAllocatePortAtInterruptLevel.

Input

Parameters.DeviceIoControl.InputBufferLength indicates the size in bytes of the input buffer which must be >= sizeof(PARALLEL_INTERRUPT_SERVICE_ROUTINE).  Parameters.DeviceIoControl.OutputBufferLength indicates the size in bytes of the output buffer which must be >= sizeof(PARALLEL_INTERRUPT_INFORMATION).

Output

The port driver returns the information to the buffer at Irp->AssociatedIrp.SystemBuffer.

Status Block

The Information field contains the number of bytes returned if the Status field is set to STATUS_SUCCESS. Otherwise the Information field is set to zero and the Status field can be set to STATUS_BUFFER_TOO_SMALL.

IOCTL_INTERNAL_PARALLEL_DISCONNECT_INTERRUPT

Operation

This function is called during Unload by a class driver that called IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT. It disconnects the Interrupt Service Routine and the Deferred Port Check Routine if one was specified in the Connect call.

Input

Parameters.DeviceIoControl.InputBufferLength indicates the length in bytes of the input buffer, which must be >= sizeof(PARALLEL_INTERRUPT_SERVICE_ROUTINE).  The parameters in the input buffer must be the same as those supplied to IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT.

Output

None

Status Block

The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly STATUS_BUFFER_TOO_SMALL or STATUS_INVALID_PARAMETER.