Jump to content

DSK_SETDEVICEPARAMS

From EDM2
Revision as of 04:23, 19 May 2025 by Martini (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Category
IOCTL_DISK (08h)
Function
DSK_SETDEVICEPARAMS (43h)
Description
Set Device Parameters

Description

This function sets the parameters for a specified device.

Command Information

The two low bits of the command byte are used to indicate one of three possible actions:

  • 00: Revert to building the BIOS Parameter Block (BPB) off the medium for all subsequent Build BPB functions. This is used after a format operation to reset the device parameters to their original state.
  • 01: Change the default BPB for the physical device. This changes the physical parameters for the drive as opposed to parameters for the media in the drive.
  • 10: Change the BPB for the medium to the specified BPB, and return the new BPB for the medium for all subsequent Build BPB calls. This is used to prepare the device for a format media operation according to the device parameters specified.
  • All other bits are reserved, and must be set to 0.

Parameter Packet Format

Parameter Packet
Field Length C Datatype
Command Information BYTE UCHAR
Drive Unit BYTE UCHAR

Extended BPB for Devices

The term Extended BPB refers to the BIOS Parameter Block. It is a table that describes the structure of the media and the physical layout of the drive (heads, tracks, sectors). The Extended BPB has the following format:

Extended BPB
Field Length
Bytes per Sector WORD
Sectors per Cluster BYTE
Reserved Sectors WORD
Number of FATs BYTE
Root Directory Entries WORD
Total Sectors WORD
Media Descriptor BYTE
Sectors per FAT WORD
Sectors per Track WORD
Number of Heads WORD
Hidden Sectors DWORD
Large Total Sectors DWORD
Reserved 6 BYTES

Data Packet Format

Data Packet
Field Length C Datatype
Extended BPB for Devices 31 BYTES BYTE[31]
Number of Cylinders WORD USHORT
Device Type BYTE BYTE
Device Attributes WORD USHORT

Device Type

Describes the physical layout of the device specified, and has one of the following values:

  • 0: 48 TPI low-density diskette drive
  • 1: 96 TPI high-density diskette drive
  • 2: Small (3.5-inch) 720KB drive
  • 3: 8-inch single-density diskette drive
  • 4: 8-inch double-density diskette drive
  • 5: Fixed disk
  • 6: Tape drive
  • 7: Other (includes 1.44MB 3.5-inch diskette drive)
  • 8: R/W optical disk
  • 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)

Device Attributes

A bit field that returns flag information about the specified drive:

  • Bit 0: Removable Media flag. This bit is set to 1 if the media cannot be removed. It is set to 0 if the media is removable.
  • Bit 1: Changeline flag. This bit is set to 1 if the device support determines that the media was removed since the last I/O operation. To query whether the media has changed, call the device driver Strategy Command "1h - MEDIA CHECK". (See "Physical Device Driver Strategy Commands" in the Physical Device Driver Reference for more information.) If this bit is set to 0, then the physical device driver can return the value 0, Unsure if media has changed, from the Media Check function.

Returns

Possible values are shown in the following list:

Code Description
0 NO_ERROR
1 ERROR_INVALID_FUNCTION
6 ERROR_INVALID_HANDLE
15 ERROR_INVALID_DRIVE
31 ERROR_GEN_FAILURE
87 ERROR_INVALID_PARAMETER
111 ERROR_BUFFER_OVERFLOW
115 ERROR_PROTECTION_VIOLATION
117 ERROR_INVALID_CATEGORY
119 ERROR_BAD_DRIVER_LEVEL
163 ERROR_UNCERTAIN_MEDIA
165 ERROR_MONITORS_NOT_SUPPORTED

Remarks

The Drive Unit field is used only when this IOCtl is issued without using a previously allocated file handle and when Command Information is set to 01. A file handle of -1 must be used. Note that media in the drive is not required. Drive Unit values are 0=A, 1=B, 2=C, and so forth. The BIOSPARAMETERBLOCK data structure can be used by C programmers. To include this data structure in your file, make sure INCL_DOSDEVIOCTL is defined before you include OS2.H.