Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with 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() performs disk operations by communicating directly with
    the BIOS through interrupt 0x13.

    'drive' specifies the disk drive to be used. For diskette drives, 0 =
    the first drive, 1 = the second drive, 2 = the third drive, and so
    on.  For hard disk drives, 0x80 = the first physical hard drive, 0x81
    = the second physical hard drive, 0x82 = the third physical hard
    drive, and so on.  Notice that only the physical drive is specified
    with hard disks; using the partition table information is the task of
    the application program itself.

    'cmd' specifies the disk operation and may or may not require other
    parameters. The possible values for 'cmd' for IBM personal computers
    are:

           0    Forces the drive controller to perform a hard reset of a
                diskette system. Other parameters are disregarded.

           1    Reports on the status of the last disk operation. Other
                parameters are disregarded.

           2    Reads 512 bytes per sector from disk into the memory
                specified by 'buffer'. The starting sector is defined by
                the values of 'head', 'track', and 'sector', and the
                number of sectors to be read is specified by 'nsects'.

           3    Writes 512 bytes per sector to disk from the memory
                specified by 'buffer'. The starting sector is defined by
                the values of 'head', 'track', and 'sector', and the
                number of sectors to be written is specified by 'nsects'.

           4    Verifies sectors, starting with the sector indicated by
                'head', 'track' and 'sector'and continuing for the number
                of sectors indicated by  'nsects'.

           5    Formats the track specified by 'head' and 'track'. A
                table of sector headers to be written on 'track' is
                pointed to by 'buffer'.

    Certain other 'cmd' values are allowed only for an XT, AT, or PS/2:

           6    Formats a track and sets flags for bad sectors
           7    Begins at a specified track in formatting the drive
           8    Reports the current drive parameters in the first four
                bytes of 'buffer'
           9    Initializes drive-pair characteristics
          10    Performs a long read of 512 plus 4 bytes per sector
          11    Performs a long write of 512 plus 4 bytes per sector
          12    Performs a disk seek
          13    Alternates disk reset
          14    Reads sector buffer
          15    Writes sector buffer
          16    Determines whether 'drive' is ready
          17    Recalibrates the drive
          18    Controller RAM diagnostic
          19    Drive diagnostic
          20    Controller internal diagnostic

    Returns:    A status byte with the following bit values:

                0x00     Success
                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. The data is correct,
                so
                         this is not an error; the application program
                can
                         use the value however it wants.
                0x20     Controller has failed
                0x40     Seek operation failed
                0x80     Attachment failed to respond
                0xBB     Undefined error occurred
                0xFF     Sense operation failed


   Portability:     IBM PC and compatibles only.

   -------------------------------- Example ---------------------------------

    The following statements read sectors 2 and 4 from side 0, track 17
    of the floppy in drive A: into buf.

           #include <stdio.h>      /* for printf */
           #include <bios.h>       /* for biosdisk */

           main()
           {
               int result;
               char buf[1024];

               result = biosdisk(2,0,0,17,3,2,buf);
               if (result != 0 && result != 0x11)
                   printf("error (%x) reading drive A:\n",result);
           }



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