Jump to content

DSK SETDEVICEPARAMS: Difference between revisions

From EDM2
Created page with "{{DISPLAYTITLE:DSK_SETDEVICEPARAMS}} ;Category:IOCTL_DISK (08h) ;Function:DSK_SETDEVICEPARAMS (43h) ;Description:Set Device Parameters ==Description== This function sets the parameters for a specified device. ==Parameter Packet Format== {| class="wikitable" |+ Parameter Packet |- ! Field ! Length ! C Datatype |- | Command Information | BYTE | UCHAR |- | Drive Unit | BYTE | UCHAR |} ==Data Packet Format== {| class="wikitable" |+ Data Packet |- ! Field ! Length !..."
 
No edit summary
 
Line 10: Line 10:


This function sets the parameters for a specified device.
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 Format==
Line 27: Line 35:
| BYTE
| BYTE
| UCHAR
| 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:
{| class="wikitable"
|+ 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
|}
|}


Line 54: Line 112:
| USHORT
| 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==
==Returns==
Line 80: Line 158:
| 87
| 87
| ERROR_INVALID_PARAMETER
| ERROR_INVALID_PARAMETER
|-
| 111
| ERROR_BUFFER_OVERFLOW
|-
|-
| 111
| 111
Line 105: Line 180:
==Remarks==
==Remarks==


The Command Information field uses the two low bits to indicate one of three actions: 00 (revert to building the BIOS Parameter Block (BPB) off the medium for all subsequent Build BPB functions, typically used after a format to reset device parameters), 01 (change the default BPB for the physical device, altering the drive's physical parameters), or 10 (change the BPB for the medium to the specified BPB and return the new BPB for subsequent Build BPB calls, used to prepare for a format operation). All other bits are reserved and must be set to 0. The Drive Unit field (0=A, 1=B, 2=C, etc.) is used only when the IOCtl is issued without a previously allocated file handle (using a file handle of -1) and when Command Information is set to 01; media in the drive is not required.
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.
 
The Extended BPB describes the media structure and physical drive layout (heads, tracks, sectors) with fields: 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), and Reserved (6 BYTES). The Number of Cylinders indicates the cylinders defined for the physical device. Device Type specifies the physical layout: 0 (48 TPI low-density diskette), 1 (96 TPI high-density diskette), 2 (3.5-inch 720KB), 3 (8-inch single-density diskette), 4 (8-inch double-density diskette), 5 (fixed disk), 6 (tape drive), 7 (other, including 1.44MB 3.5-inch diskette), 8 (R/W optical disk), or 9 (3.5-inch 4.0MB diskette). Device Attributes is a bit field: Bit 0 (1 for non-removable media, 0 for removable), Bit 1 (1 if the device supports detecting media removal since the last I/O, 0 otherwise, requiring a Media Check via Strategy Command 1h).
 
The [[BIOSPARAMETERBLOCK]] data structure can be used by C programmers by defining INCL_DOSDEVIOCTL before including OS2.H.


[[Category:IOCtl]]
[[Category:IOCtl]]

Latest revision as of 04:23, 19 May 2025


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.