[Front] [Prev Chapter] [Next Chapter]

Appendix A Device I/O Control


The Device I/O Control (44H) function performs operations for setting or obtaining information for input and output from character and block devices. The operation performed depends on the value supplied in register AL on entry. The table on the following page lists these values, and their associated operations.

A.1 Summary of I/O Control Operations

Value of AL

Operation performed

00H

Obtain information about a device

01H

Set information for a device

02H

Receive a control string from a character device driver

03H

Send a control string to a character device driver

04H

Receive a control string from a block device driver

05H

Send a control string to a block device driver

06H

Enables application to check directly whether the device is ready for input

07H

Enables application to check directly whether the device is ready for output

08H

Checks whether the media on a block device is removable

09H

Determines whether the device is networked

0AH

Checks whether a handle refers to a local or a networked device

0BH

Controls retries on sharing and lock resource conflicts

0CH

Supports code page switching

0DH

Enables an application to request the device driver to perform functions (described later in the specification) on a block device

0EH

Checks whether there is more than one logical drive assigned to a block device and which was the last drive to be used

0FH

Sets the number of the next logical drive for use on a block device

The entry and return values for each operation are described fully on the following pages.

A.2 Get or Set Device Information

Entry Parameters:

Register AH:

44H

AL:

00H to get device information01H to set device information

BX:DH:DL:

Handle0 when AL=1Device information when AL=1

Returned Values:

Register DX:

Device information

The device information returned in DX has two forms:

Table A 1
Information Returned for Character Device

bit number

0

ISCIN = 1 if console input device

1

ISCOT = 1 if console output device

2

ISNUL = 1 if null device

3

ISCLK = if clock device

4

Reserved

5

BINARY
= 1 if device is in binary mode
= 0 if device is in ASCII mode (Ctrl-Z treated as end-of-file)

6

EOF = 0 if end-of-file on input

7

ISDEV = 1 channel is a device

8-12

Reserved

13

Output until busy

14

CTRL = 1 if device can process control strings

15

Reserved

Table A 2
Information Returned for a Disk File

bit number

0-5

Block device number for the channel (0=A, 1=B, and so on)

6

EOF = 0 if channel has been written to

7

ISDEV = 0 if channel is a disk file

8-15

Not used (set to 0)

A.3 Receive/Send Control Strings from/to a Character Device

Entry Parameters:

RegisterAH:44H
AL:02H to Read
03H to Write
BX:Handle
CX:Number of bytes to be read or written
DS:Data or Buffer - Segment
DX:Data or Buffer - Offset

Returned Values:

Register AX:

Number of transferred bytes

If the IOCTRL bit in the device driver header is zero, an Invalid Function error is returned (see Figures 6-2 and 6-3).

A.4 Receive/Send Control Strings from/to a Block Device

Entry Parameters:

Register AH: 44H
AL:04H to Read
05H to Write
BL:Drive number (0 = default,1 = A, 2 = B, and so on)
CX:Number of bytes to be read or written
DS:Data or Buffer - Segment
DX:Data or Buffer - Offset

Returned Values:

Register AX:Number of transferred bytes

If the IOCTRL bit in the device driver header is zero, an Invalid Function error is returned (see Figures 6-2 and 6-3). If the drive is invalid, an Access Denied error is returned.

A.5 Check Handle Ready for Input/Output

Entry Parameters:
RegisterAH:44H
AL:06H to get input status
07H to get output status
BX:Handle
Returned Values:
RegisterAL:If device, FFH = ready, 00H = not ready if a file, FFH until end-of-file, 00H thereafter

A.6 Removable Media Check

Entry Parameters:
RegisterAH:44H
AL:08H
BL:Drive number ( 0 = default, 1 = A, 2 = B and so on)
Returned Values:
Register AX:00H if device is removable 01H if device is fixed 0FH if drive number is invalid

If the device checked is part of a network, the error Invalid Function is returned.

A.7 Distinguish Network/Local Device

Entry Parameters:
Register AH:44H
AL:09H
BL:Drive number ( 0 = default, 1 = A, 2 = B and so on)
Returned Values:
RegisterDX:Bit 12 = 0 if a local device
Bit 12 = 1 if a remote device
the other DX bits are reserved.


A.8 Distinguish Network/Local Handle

Entry Parameters:
RegisterAH:44H
AL:0AH
BX:Handle
Returned Values:
RegisterDX:Bit 15 = 0 if handle is for a local device
Bit 15 = 1 if handle is for a remote device

A.9 Control Retries on Sharing and Lock Resource Conflicts

Entry Parameters:
RegisterAH:44H
AL:0BH - Change sharing retry count
CX:Number of times to execute a delay loop
DX:Number of retries
Returned Values:
RegisterAX:Error code if Carry flag is set

This call sets the number of times a disk operation is retried after a failure caused by a file-sharing violation before it returns a DOS error or a critical error. You can select both the number of retries and the delay time between retries. On input, register CX contains the number of times to execute a delay loop, and DX contains the number of retries.

A.10 Implement Code Page Switching

Entry Parameters:
RegisterAH:44H - IOCTL Request
AL:0CH - Handle Generic IOCTL(Code page switching)
BX:Handle
CH:Category code (device type)
00 - Unknown
01 - COMx
03 - CON
05 - LPTx
CL:Function within category code (Minor code)
4CH = Prepare start
4DH = Prepare end
4AH = Select
6AH = Query selected
6BH = Query prepare list
DS:DXPointer to parameter block
Returned Values:
RegisterAX:Error code if the Carry flag is set.

This call allows a device driver to support a set of subfunction calls that implement code page switching.

Refresh requests the device driver to set up the device with the most recently selected code page. The refresh operation is requested by doing a Prepare Start with all the CODEPAGE fields set to a -1 (see the structure of the Prepare Start parameter block in section A.10.1). This operation must be followed immediately by a Prepare End.

If the operation is successful, many of the function calls return the Carry flag clear. If an error condition was encountered, the Carry flag is set. Issue the Get Extended Error (59H) call to determine the actual error condition.

After a Prepare Start, data defining the code page font is written to the driver using one or more Send Control String (AX = 4403H) calls. This is assumed to be information to download to the device.

The stream is ended by a Prepare End. The stream format is device specific.

If no data is written for a prepare operation, the driver is to interpret the newly prepared code page(s) as a hardware code page. This allows devices that support user changeable hardware fonts (usually in cartridges) to be supported.

A prepare is not needed for hardware-defined code pages.

A.10.1 Structure of Parameter Block

Select, Prepare End, Query Prepare List
(CL= 4AH, 4DH, or 6BH)

When CL = 4AH (Select), 4DH (Prepare End), or 6BH (Query Prepare List) the parameter block, pointed to by DS:DX, has the layout shown below.

Undisplayed Graphic

Figure A-1
Parameter Block for Select, Prepare End, and Query Prepare List

Prepare Start (CL= 4CH)

When CL = 4CH, the parameter block, pointed to by DS:DX, has the layout shown below.

Undisplayed Graphic

Figure A-2
Parameter Block for Prepare Start

PAGETOT specifies the number of additional code pages given in the DEVICE command in CONFIG.SYS. The maximum value for PAGETOT is 12.

A value of -1 for any CODEPAGE field tells the device driver not to change the code page value for that position. Any other value is a codepage to be prepared.

For cartridge-prepares set FLAGS to 1.

Select (AL = 4AH)

When CL = 6AH, the parameter block, pointed to by DS:DX, has the layout shown below.

Undisplayed Graphic

Figure A-3
Parameter Block for Query Selected

There can be a maximum of 12 hardware code pages, and a maximum of 12 prepared code pages.

A.10.2 Error Codes

The table below shows the possible error codes returned from Get Extended Error for code page switching operations. The meanings of the codes are different to the standard interpretations described in Chapter 5, Error Handling.

Code

Meaning

Prepare Start Error Codes

01

Invalid function number

27

Code page conflict (used for keyb xx mismatch)

29

Device error

22

Unknown command

Send Control String Error Codes

27

Device not found in file, or code page not found in file

29

Device error

31

File contents not a font file, or file contents structure damaged

Prepare End Error Codes

19

Bad data read from font file

31

No prepare start

Select Error Codes

26

Code page not prepared

27

Current keyb does not support this code page

29

Device error

Query Selected Error Codes

26

No code page has been selected

27

Device error

Query Prepared List Error Codes

27

Keyboard/code page conflict

29

Device error

31

Device driver does not have copy of code page to download to device

A.11 Request I/O Function for Block Device

Entry Parameters:
RegisterAH:44H
AL:0DH
BL:Drive number (0 = default drive, 1 = A, 2 = B, and so on)
CH:08H - category code
CL:Function code:
40H - Set block device parameters
60H - Get block device parameters
41H - Write to track on logical device
61H - Read from track on logical device
42H - Format and verify track on a logical device
62H - Verify without formatting
46h - Set media ID
66h - Get media ID
DS:Data or Buffer - Segment
DX:Data or Buffer - Offset

This call tells block device drivers to perform one of the following instructions:

Register CH contains the category code (08H for all functions), and CL contains the function code.

A.11.1 Structure of the Parameter Block

Get or Set Device Parameters (CL= 40H or 60H)

When CL = 60H or CL = 40H, the parameter block has the layout shown below.

Undisplayed Graphic

Figure A-4
Parameter Block for Get or Set Device Parameters

FUNCTION

FUNCTION is a 1-byte field that further defines the functions of Get and Set Device Parameters.

For the Get Device Parameters function:
Bit 0 = 1Return the BPB that BUILD BPB would return, that is, the MEDIA BPB.
= 0Return the default BPB for the device.
All other bits must be set off.
For the Set Device Parameters function:
Bit 0 = 1 All subsequent BUILD BPB requests return DEVBPB.
BUILD BPB returns the actual medial if another Set Device
request is received with bit 0 reset.
= 0 Indicates that the DEVBPB field contains the new default BPB
for this device, but does not change the media BPB. If a previous
Set Device request set this bit on, the actual media BPB is returned.
Otherwise, the default BPB for the device is returned by BUILD BPB.
Set Device should be called with this bit set before the Format
function is issued, in order to set the format media type.
Bit 1 = 1 All fields in the Parameter Block except the LAYOUT field are ignored.
= 0 Read all fields of the parameter block.
Bit 2 = 1All sectors in the track are the same size, and all sector numbers
range from 1 to the total number of sectors in the track.)
= 0All sectors in the track may be different sizes.
Bits 3-7 must be reset.

It is invalid to set bits 0 and 1 at the same time, and this should be considered an error.

Set bit 2 for normal track layouts. Format Track can be more efficient if bit 2 is set.

DEVICE

DEVICE is a 1-byte field that descibes the physical device type. This field must be set to the correct value when calling Set Device Parameters. The values in this field have the following meanings:

0 320/360Kb, 5 1/4 - inch disk
1 1.2Mb, 5 1/4 - inch disk
2 720Kb, 3 1/2 - inch disk
3 8- inch single density disk
4 8- inch double density
5 Fixed disk
6 Tape drive
7 1.4Mb, 3 1/2 - inch disk
8 Other
DEV_ATTR

DEV_ATTR is a 1-byte field that describes the physical attributes of the device. This field must be set to the correct value when calling Set Device Parameters.

Only bits 0 and 1 of this field are used. They have the following meanings:

Bit 0 = 1 Nonremovable media.
= 0 Removable media.
Bit 1 = 1Diskette changeline is supported.
= 0Diskette changeline is not supported.
Bits 2 - 7 are reserved.
CYLINDERS

CYLINDERS specifies the maximum number of cylinders that can be supported on the physical device, independent of the media type. This field must be set to the correct value when calling Set Device Parameters.

MEDIA

For multimedia drives, the MEDIA field indicates which media is expected to be in the drive.

The MEDIA field is used only when the actual media in the drive cannot otherwise be determined. Media type is dependent on device type.

Regardless of the device type, a value of 0 represents the default. For example, a 5 1/4 - inch 1.2Mb diskette drive is a multi-media drive. The media type is defined as follows:

0 = High density 1.2 Mb (96 tpi) diskette

1 = Double density 320/360 Kb (48 tpi) diskette

The default media type for a 1.2 Mb drive is a high density
1.2Mb diskette.

DEVBPB

For the Get Device Parameters function, bit 0 of the FUNCTION field has the following effect:

Bit 0 = 1The device driver returns the BPB that BUILD BPB would return.
= 0The device driver returns the default BPB for the device.
For the Set Device Parameters function, bit 0 of the FUNCTION field has the following effect:
Bit 0 = 1 The device driver is requested to return the BPB from this field for all subsequent BUILD BPB requests until a Set Device Parameters request is received with bit 0 in the FUNCTION field reset.
= 0 The BPB contained in this field becomes the new default BPB for the device.
The DEVBPB field has the format shown in Figure A-5.

Undisplayed Graphic

Figure A-5
Format of the DEVBPB Field

LAYOUT

LAYOUT is a variable length table that indicates the expected layout of sectors on the media track.

DOS device drivers do not keep a track layout table for each logical device. The global track table must be updated, using via Set Device Parameters, when the attributes of the media change.

Note that the Set Device Parameters call (CL = 40H) modifies the track table irrespective of how bit 1 of the FUNCTION field is set.

The LAYOUT field is not used for the Get Device Parameters function, but the track layout is used by subsequent Read/Write Track, Format/Verify Track and Verify Track functions.

Figure A-6 shows how the LAYOUT field is formatted.

Undisplayed Graphic

Figure A-6
Format of the LAYOUT Field

The COUNT field specifies the total number of sectors. Each sector number must be unique and in a range between 1 and n (sector count). The first sector number is 1 and the last sector number is equal to the sector count (n). Sector sizes are measured in bytes. If bit 2 of the FUNCTION field is set, all sector sizes must be the same.

Example contents in LAYOUT might be:

FieldContent
COUNT2
SECTOR_NUMBER11H
SECTOR_SIZE1200H
SECTOR_NUMBER22H
SECTOR_SIZE2200H
SECTOR_NUMBERnnH
SECTOR_SIZE200H

See the description of the FUNCTION field, bit 2.

Note that you should change the DEVICE, DEV_ATTR, and MAX_CYL fields only if the physical device has been changed.

Read/Write Track on Logical Device (CL= 41H or 61H)

When CL = 41H (Read Track on Logical Device) or CL = 61H (Write Track on Logical Device), the parameter block has the layout shown below.

Undisplayed Graphic

Figure A-7
Parameter Block for Read/Write Track on Logical Device

All bits in the FUNCTION field must be reset before a Read or Write Track on Logical Device function is called.

The value in the FIRST_SECTOR, CYLINDER , and HEAD fields starts at zero. For example, to indicate sector 9, set the value to 8.

Format/Verify Track on Logical Drive (IOCTL Write)
(CL = 42H or 62H)

When CL = 42H (Format/Verify Track on Logical Drive) or CL = 62H (Format Track on Logical Device), the parameter block has the layout shown below.

Undisplayed Graphic

Figure A-8
Parameter Block for Format/Verify Track on Logical Drive

On entry, bit 0 of the FUNCTION field has the following effect:

Bit 0 = 1Format status check call to determine if a combination of number-of-tracks and sectors-per-track is supported.
= 0 Format/verify track call.
To find out whether a combination of ‘number of tracks’ and ‘sectors per track’ is supported, you must issue a Set Device Parameters call with the correct BPB for that combination, before you issue the Format Status call. The device driver can then return the correct code to indicate what is supported.
The values returned in the FUNCTION field for a Format Status Check call are:
= 0Function is supported by the ROM BIOS. The
specified combination of number-of-tracks and
sectors-per-track is allowed for the diskette drive.
= 1 Function is not supported by the ROM BIOS.

= 2 Function is supported by the ROM BIOS., but the
specified combination of number-of-tracks and
sectors-per-track is not allowed for the diskette drive.

= 3Function is supported by the ROM BIOS, but the
diskette drive is empty and therefore the ROM BIOS
cannot determine if the number-of-tracks and
sectors-per-track are allowed.

To format a track:

  1. Issue the Set Device Parameters function call.
  2. Issue the Format Status Check function call to validate the combination of number-of-tracks and sectors-per-track. If the value returned is 1, ignore the result, because the ROM BIOS does not support this function.
  3. Issue the Format/Verify Track function call with the FUNCTION bit 0 reset for each track on the medium.

A.12 Determine Logical Drive for Block Device

Entry Parameters:
RegisterAH:44H
AL:0EH
BL:Drive number (0 = default, 1 = A, 2 = B,and so on)
Returned Values:
RegisterAL:Drive number (0 if only one driveassigned)
AX:Error code if Carry flag is set

This call allows the device driver to determine if more than one logical drive is assigned to a block device. When the call is issued, a drive number is passed in BL on input.

If the block device has more than one logical drive letter assigned to it, on output a drive number corresponding to the last drive letter that was used to reference the device is returned in AL. If only one drive letter is assigned to the device, 0 is returned in AL by this call.

A.13 Set Next Logical Drive Number for Block Device

Entry Parameters:
RegisterAH:44H
AL:0FH
BL:Drive number (0 = default, 1 = A, 2 = B,and so on)
Returned Values:
Register AL:Drive number (0 if only one driveassigned)
AX:Error code if Carry flag is set

[Front] [Prev Chapter] [Next Chapter]


info@caldera.com
Copyright © 1993, 1997 Caldera, Inc All rights reserved.