Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>biosdisk() hard disk / floppy i/o</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
biosdisk()               Hard Disk / Floppy I/O

 #include   <bios.h>

 int        biosdisk(cmd,drive,head,track,sector,nsects,buffer);
 int        cmd;                         Operation to perform
 int        drive;                       Disk drive to be used
 int        head;                        Starting sector
 int        track;                       Starting sector
 int        sector;                      Starting sector
 int        nsects;                      Number of sectors
 void       *buffer;                     Table of sector headers

    biosdisk() issues disk operations directly to the BIOS via interrupt
    call 0x13.  'drive' specifies which disk drive is to be used (0 =
    first floppy disk drive, 1 = second floppy disk drive, 2 = third,
    etc).  For hard disk drives, 0x80 specifies the first hard drive,
    0x81 = the second hard drive, 0x82 = the third, etc.  For hard disks,
    the physical drive is specified, but not the disk partition.  The
    application program must interpret the partition table information
    itself.

    'cmd' references the operation to perform.  Depending on the value of
    'cmd', the other parameters may or may not be needed. The possible
    values for 'cmd' for any IBM PC, XT, or AT are:

           0    Resets diskette system. The drive controller is forced 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 is given by 'head', 'track', and 'sector'.
                'nsects' indicates the number of sectors.  The data is
                read, 512 bytes per sector, into 'buffer'.

           3    Writes one or more disk sectors from memory. The starting
                sector is given by 'head', 'track', and 'sector'.
                'nsects' indicates the number of sectors.  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'. 'nsects' indicates
                the number of sectors.

           5    Formats a track.  The track is specified by 'head' and
                'track'.  'buffer' points to a table of sector headers to
                be written on 'track'.

    'cmd' values allowed only for an XT or AT are:

           6    Formats a track and sets bad sector flags
           7    Formats the drive beginning at a specified track
           8    Returns the current drive parameters (drive information
                is returned in 'buffer' in the first four 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

    Returns:    A status byte composed of the following bits:

                0x00     Operation successful
                0x01     Bad command
                0x02     Address mark not found
                0x04     Record not found
                0x05     Reset failed
                0x07     Drive parameter activity failed
                0x09     Attempt to DMA across 64K boundary
                0x0B     Bad track flag detected
                0x10     Bad ECC on disk read
                0x11     ECC corrected data error
                0x20     Controller has failed
                0x40     Seek operation failed
                0x80     Attachment failed to respond
                0xBB     Undefined error occurred
                0xFF     Sense operation failed

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

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson