Borland C++ reference

biosdisk

raw OCR

Issues BIOS disk drive services.

Defined in header <bios.h>

Syntax

#include <bios.h>
int biosdisk(int   cmd,  int drive, int head, int track, int sector, int nsects,
               void  *buffer);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

biosdisk uses interrupt 0x13 to issue disk operations directly to the BIOS.

drive is a number that specifies which disk drive is to be used: 0 for the first floppy disk drive, 1 for the second floppy disk drive, 2 for the third, and so on. For hard disk drives, a drive value of 0x80 specifies the first drive, 0x81 specifies the second, 0x82 the third, and so forth.

For hard disks, the physical drive is specified, not the disk partition. If necessary, the application program must interpret the partition table information itself.

cmd indicates the operation to perform. Depending on the value of cmd, the other parameters may or may not be needed.

Here are the possible values for cmd for the IBM PC, XT, AT, or PS/2, or any compatible system:

0 Resets disk system, forcing the drive controller to do a hard reset. All other parameters are ignored.

1 Returns the status of the last disk operation. All other parameters are ignored.

2 Reads one or more disk sectors into memory. The starting sector to read is given by head, track, and sector. The number of sectors is given by nsects. The data is read, 512 bytes per sector, into buffer.

3 Writes one or more disk sectors from memory. The starting sector to write is given by head, track, and sector. The number of sectors is given by nsects. The data is written, 512 bytes per sector, from buffer.

4 Verifies one or more sectors. The starting sector is given by head, track, and sector. The number of sectors is given by nsects.

5 Formats a track. The track is specified by head and track, buffer points to a table of sector headers to be written on the named track. See the Technical Reference Manual for the IBM PC for a description of this table and the format operation.

The following cmd values are allowed only for the XT, AT, PS/2, and compatibles:

6 Formats a track and sets bad sector flags.

7 Formats the drive beginning at a specific track.

8 Returns the current drive parameters. The drive information is returned in buffer in the first 4 bytes.

9 Initializes drive-pair characteristics.

10 Does a long read, which reads 512 plus 4 extra bytes per sector.

11 Does a long write, which writes 512 plus 4 extra bytes per sector.

12 Does a disk seek.

13 Alternates disk reset.

14 Reads sector buffer.

15 Writes sector buffer.

16 Tests whether the named drive is ready.

17 Recalibrates the drive.

18 Controller RAM diagnostic.

19 Drive diagnostic.

20 Controller internal diagnostic.

y^

biosdisk operates below the level of files on raw sectors. It can destroy file contents and directories on a hard disk.

Return value

biosdisk returns a status byte composed of the following bits:

0x00 Operation successful. 0x01 Bad command.

0x02Address mark not found.
0x03Attempt to write to write-protected disk.
0x04Sector not found.
0x05Reset failed (hard disk).
0x06Disk changed since last operation.
0x07Drive parameter activity failed.
0x08Direct memory access (DMA) overrun.
0x09Attempt to perform DMA across 64K boundary.

0x0A Bad sector detected.

OxOBBad track detected.
OxOCUnsupported track.
0x10Bad CRC/ECCon disk read.
0x11CRC/ECCcorrected data error,
0x20Controller has failed.
0x40Seek operation failed.
0x80Attachment failed to respond.
0xAADrive not ready (hard disk only).
0xBBUndefined error occurred (hard disk only).
0xCCWrite fault occurred.
OxEOStatus error.
0xFFSense operation failed.

0x11 is not an error because the data is correct. The value is returned to give the application an opportunity to decide for itself.

See also

Example

#include <bios.h>
#include <stdio.h>

int main(void)
1[
   ttdefine CMD   2     /* read sector command */
   #define DRIVE  0     /*drive  number for A: */
   tdefine HEAD   0     /*disk  head number */
   Idefine TRACK  1     /* track number */
   tdefine SECT   1     /* sector number */
   tdefine NSECT  1     /* sector count */
   int result;
   char buffer[512];
   printf("Attempting to read  from drive A:\n");
   result = biosdisk (CMD, DRIVE, HEAD, TRACK, SECT, NSECT, buffer)
   if (result == 0)
      printf("Disk read from A:  successful.\n");
   else
      printf("Attempt to read  from drive A: failed.\n");
return

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.