Init (Device-Driver Function 00h)

INITREQUEST STRUC

irLength db ? ;length of record, in bytes

irUnit db ? ;not used

irFunction db 00h ;function number

irStatus dw ? ;status

irReserved db 8 dup(?) ;reserved

irUnits db ? ;OUTPUT: number of units

irEndAddress dd ? ;INPUT: end available driver memory

;OUTPUT: end resident code

irParamAddress dd ? ;INPUT: addr CONFIG.SYS device= line

;OUTPUT: addr BPB pointer array

irDriveNumber db ? ;INPUT: first drive number

irMessageFlag dw ? ;OUTPUT: error-message flag

INITREQUEST ENDS

Init (Device-Driver Function 00h) directs the driver to initialize the device driver and corresponding device. This function is called only once, when the driver is loaded.

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

Fields

irLength

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

irUnit

Not used.

irFunction

Specifies the Init function: 00h.

irStatus

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.

irReserved

Reserved; do not use.

irUnits

Specifies the number of units supported by the driver. MS-DOS uses this number to assign sequential drive numbers to the units. The driver must set this field.

Character-device drivers should set this field to zero.

irEndAddress

Contains the 32-bit address (segment:offset) of the end of memory available to the device driver and receives the 32-bit address of the end of the initialized driver. The following table describes input and output:

Input/output Description

Input Points to the first byte of memory that immediately follows the device driver and which must not be used by the driver. During initialization, the driver may use any memory between its starting address and this address. The driver can also reserve some or all of this memory for use after initialization. (This field is not used for input in MS-DOS versions earlier than version 5.0. The driver should check the MS-DOS version number before using the value in this field.)
Output Points to the first byte of memory that immediately follows the initialized driver. The driver must set this field to an address that is not greater than the end of available memory. If the driver fails to initialize, it should set this field to its starting address. This directs MS-DOS to remove the driver and free all memory associated with it.

irParamAddress

Contains a 32-bit address (segment:offset) of the initialization parameters and receives a 32-bit address of an array of pointers to BPB structures. The following table describes input and output:

Input/output Description

Input Points to the initialization parameters for the driver as copied from the CONFIG.SYS file. The parameters consist of the filename for the driver and any command-line switches—that is, all text on the corresponding device or devicehigh command line up to the terminating carriage-return character (ASCII 0Dh) or linefeed character (ASCII 0Ah) but not including the device or devicehigh command and equal sign.
Output Points to an array of pointers to BPB structures. These structures specify the BIOS parameters for each unit supported by the drive. (Each pointer is a 16-bit offset relative to the start of the driver.)
  The BPB structure has the following form:
  BPB STRUC
bpbBytesPerSec dw ? ;bytes per sector
bpbSecPerClust db ? ;sectors per cluster
bpbResSectors dw ? ;number of reserved sectors
bpbFATs db ? ;number of file allocation tables
bpbRootDirEnts dw ? ;number of root-directory entries
bpbSectors dw ? ;total number of sectors
bpbMedia db ? ;media descriptor
bpbFATsecs dw ? ;number of sectors per FAT
bpbSecPerTrack dw ? ;sectors per track
bpbHeads dw ? ;number of heads
bpbHiddenSecs dd ? ;number of hidden sectors
bpbHugeSectors dd ? ;number of sectors if bpbSectors = 0
BPB ENDS
  For a full description of the BPB structure, see Section 9.9, “Structures.” If all units are the same, all pointers in the array can be the same.
  Character device drivers must set the irParamAddress field to zero.

irDriveNumber

Contains the zero-based drive number for the driver's first unit as assigned by MS-DOS. MS-DOS supplies this number so that the driver can determine whether MS-DOS will accept all its supported units. MS-DOS allows no more than 26 units in the system.

irMessageFlag

Specifies whether MS-DOS displays an error message on initialization failure. To direct MS-DOS to display the message, the driver must set this field to 1. The message is displayed only if the driver also sets the irStatus field to indicate failure.

Comments

The Init function is called only once; its code and data need not be retained after it has initialized its device. A device driver can release the Init function's code and data by placing the function at the end of the driver and returning the function's starting address in the irEndAddress field.

If the Init function uses Interrupt 21h system functions, it may use only the functions in the following table:

Function number Description

01h-0Ch Character I/O
25h Set Interrupt Vector
30h Get Version Number
35h Get Interrupt Vector

See Also

Interrupt 21h Functions 01h-0Ch Character Input and Output
Interrupt 21h Function 25h Set Interrupt Vector
Interrupt 21h Function 30h Get Version Number
Interrupt 21h Function 35h Get Interrupt Vector