_bios_disk
Issues BIOS disk drive services
Defined in header <bios.h>
Syntax
#include <bios.h>
unsigned _bios_disk(unsigned cmd, struct diskinfot *dinfo);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
_bios_disk uses interrupt 0x13 to issue disk operations directly to the BIOS. The cmd argument specifies the operation to perform, and dinfo points to a diskinfo_t structure that contains the remaining parameters required by the operation.
The diskinfo_t structure (defined in bios.h) has the following format:
struct diskinfo_t { unsigned drive, head, track, sector, nsectors; void far *buffer; }; 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.
Depending on the value of cmd, the other parameters in the dJskinfo_t structure may or may not be needed.
The possible values for cmd (defined in bios.h) are the following:
_DISK_RESET Resets disk system, forcing the drive controller to do a hard reset. All dlskinfo_t parameters are ignored.
_DISK_STATUS Returns the status of the last disk operation. All diskinfo_t parameters are ignored.
_DISK_READ 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 nsectors. The data is read, 512 bytes per sector, into buffer. If the operation is successful, the high byte of the return value will be 0 and the low byte will contain the number of sectors. If an error occurred, the high byte of the return value will have one of the following values:
| 0x01 | Bad command. |
| Dx02 | Address mark not found. |
| 0x03 | Attempt to write to write-protected disk. |
| 0x04 | Sector not found. |
| 0x05 | Reset failed (hard disk). |
| 0x06 | Disk changed since last operation. |
| 0x07 | Drive parameter activity failed. |
| 0x08 | Direct memory access (DMA) overrun. |
| 0x09 | Attempt to perform DMA across 64K boundary. |
| OxOA | Bad sector detected. |
| OxOB | Bad track detected. |
| OxOC | Unsupported track. |
0x10 Bad CRC/ECC on disk read.
| 0x11 | CRC/ECC corrected data error. |
| 0x20 | Controller has failed. |
| 0x40 | Seek operation failed. |
| 0x80 | Attachment failed to respond. |
| 0xAA | Drive not ready (hard disk only). |
| 0xBB | Undefined error occurred (hard disk only). |
| 0xCC | Write fault occurred. |
| OxEO | Status error. |
| 0xFF | Sense 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.
_DISK_WRITE 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 nsectors. The data is written, 512 bytes per sector, from buffer. See
| _DISK_READ | (above) for a description of the return value. |
_DISK_VERIFY Verifies one or more sectors. The starting sector is given by head, track, and sector. The number of sectors is given by nsectors. See
| DISKREAD | (above) for a description of the return value. |
_DISK_FORMAT 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.
Return value
_bios_disk returns the value of the AX register set by the INT 0x13 BIOS call.
See also
Example
#include <bios.h>
#include <stdio.h>
int main(void)
{
struct diskinfo_t dinfo;
int result;
static char dbuf[512];
dinfo.drive = /* drive number for A: */
dinfo.head = /* disk head number */
dinfo.track = /* track number */
dinfo.sector = /* sector number */
dinfo.nsectors 1; /* sector count */
dinfo.buffer = dbuf; /* data buffer */
printf("Attempting to read from drive A:\n";
result = _bios_disk(_DISK_READ, &dinfo);
if ((result & OxffOO) == 0) {
printfC'Disk read from A: successful.\n");
printf("First three bytes read are 0x%02x 0x%02x 0x%02x\n"
dbuf[0] & 0xff, dbuf[l] & 0xff, dbuf[2] & 0xff);
}
else
printf("Cannot read drive A, status = 0x%02x\n", result);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `bios disk` read as `_bios_disk`
Stable link: /3.1/bios.h/_bios_disk/
· short form /3.1/_bios_disk/