Read (Device-Driver Function 04h)

READWRITEREQUEST STRUC

rwrLength db ? ;length of record, in bytes

rwrUnit db ? ;unit number

rwrFunction db 04h ;function number

rwrStatus dw ? ;status

rwrReserved db 8 dup(?) ;reserved

rwrMediaID db ? ;INPUT: media descriptor

rwrBuffer dd ? ;INPUT: buffer address

rwrBytesSec dw ? ;INPUT: number bytes/sectors to read

;OUTPUT: number bytes/sectors read

rwrStartSec dw ? ;INPUT: starting-sector number

rwrVolumeID dd ? ;OUTPUT: volume identifier

rwrHugeStartSec dd ? ;INPUT: 32-bit starting-sector number

READWRITEREQUEST ENDS

Read (Device-Driver Function 04h) transfers data from a device into the specified buffer.

This function is required for both block- and character-device drivers.

Fields

rwrLength

Specifies the length, in bytes, of the READWRITEREQUEST structure.

rwrUnit

Specifies the device from which data is to be read. This field is used for block-device drivers only.

rwrFunction

Specifies the Read function: 04h.

rwrStatus

Specifies the status of the completed function. If the function is successful, the driver must set the done bit (bit 8). Otherwise, the driver must set both the error and done bits (bits 15 and 8) and copy an error value to the low-order byte.

rwrReserved

Reserved; do not use.

rwrMediaID

Specifies the media descriptor for the medium that MS-DOS assumes is in the drive. This field can be any one of the media-descriptor values specified in Media Check (Device-Driver Function 01h). This field is used for block-device drivers only.

rwrBuffer

Contains the 32-bit address (segment:offset) of the buffer that receives the data read from the device.

rwrBytesSec

Contains the number of bytes or sectors to read and receives the number of bytes or sectors read. The following table describes input and output:

Input/output Description

Input Specifies the number of bytes to read from a character device, or the number of sectors to read from a block device.
Output Specifies the number of bytes read from a character device, or the number of sectors read from the block device. The driver must set this field; if there is an error, the driver should return the number of bytes or sectors read before the error occurred.

rwrStartSec

Specifies the first logical sector to read. If the first sector is larger than 65,535 bytes, this field contains 0FFFFh and the rwrHugeStartSec field specifies the first sector. This field is used for block-device drivers only.

rwrVolumeID

Contains the 32-bit address (segment:offset) of a zero-terminated ASCII string specifying the volume identifier for the most recently accessed disk. If the driver returns error value 0Fh (invalid disk change), MS-DOS uses the volume identifier to prompt the user to insert the appropriate disk. This field is used for block-device drivers only.

rwrHugeStartSec

Specifies the first logical sector to read. This field is used only if the rwrStartSec field contains 0FFFFh. This field is used for block-device drivers only.

Comments

The driver must translate the logical-sector number supplied in the rwrStartSec or rwrHugeStartSec field to the appropriate head, track, and sector numbers.

The rwrHugeStartSec field is used only if bit 1 is set in the dhAttributes field in the block-device driver's DEVICEHEADER structure. For a full description of the DEVICEHEADER structure, see Section 9.9, “Structures.”

See Also

Device-Driver Function 01h Media Check
Device-Driver Function 08h Write
Device-Driver Function 09h Write with Verify
Interrupt 21h Function 3Fh Read File or Device