Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - _bios_disk http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   _bios_disk

   Usage
   #include <bios.h>
   int _bios_disk(unsigned service, struct diskinfo_t *info);

   Description
   _bios_disk  is a direct interface to the bios disk  control  interrupt
   0x13.

   Six services are available on a basic IBM PC. They are selected by the
   value given to service as follows:

   reset0
   Causes  a  hard reset of the floppy disk controller.  This  is  useful
   after  an error has occurred. For this service the info  parameter  is
   ignored.

   status1
   Obtains  the status of the last disk operation. For this  service  the
   info parameter is ignored.

   read2
   Reads  one or more disk sectors into the memory buffer pointed  to  by
   buffer  in the diskinfo structure. This service requires that all  the
   fields  in the diskinfo structure, pointed to by info,  are  correctly
   set up.

   write3
   Writes  one  or  more disk sectors with data from  the  memory  buffer
   pointed to by buffer in the diskinfo structure. This service  requires
   that all the fields in the diskinfo structure, pointed to by info, are
   correctly set up.

   verify4
   Verifies  one  or more disk sectors to ensure that it  exists  and  is
   readable.  It also does a CRC (cyclic redundancy check). This  service
   requires that all the fields in the diskinfo structure, pointed to  by
   info, are correctly set up.

   format5
   Formats  the  track  specified in the head and  track  fields  of  the
   diskinfo structure pointed to by info. Only one track can be formatted
   in  each call. The buffer field contains a set of sector markers,  the
   format  of which depends on the type of disk drive. Refer to  the  IBM
   Technical Reference Manual for more information on marker formats.

   The format of struct diskinfo is as follows:
   struct diskinfo_t {
   unsigned drive;/* drive number*/
   unsigned head;/* head number*/
   unsigned track;/* track number*/
   unsigned sector;/* start sector no.*/
   unsigned nsectors;/* sectors to process */
   void far *buffer; /* Memory buffer to use*/
   };
   Example
   #include <stdio.h>
   #include <bios.h>

   main()
   {
   int status;
   struct diskinfo disk;

        if((status = _bios_disk(1,disk)) != 0)
             printf("Last disk operation had error %d\n",status);
        else
             printf("Last disk operation completed OK\n");
   }

   Return Value
   The  value  returned depends of the service requested. The  reset  and
   format  services do not return meaningful values. The read, write  and
   verify  services  return the number of sectors processed  in  the  low
   byte, and the high byte is 0. The status service and, if an error  has
   occurred, the read, write or verify service, places a code in the high
   byte of the return value.

   The status codes are as follows:
   0x01 Invalid request / bad command
   0x02 Address mark not found
   0x04 Sector not found
   0x05 Reset failure
   0x07 Drive parameter activity failure
   0x09 DMA overrun
   0x0a Bad sector flag detected
   0x10 Data read (ECC) error
   0x11 Corrected data read (ECC) error
   0x20 Controller failure
   0x40 Seek error
   0x80 Disk timed out / not responding
   0xaa Drive not ready
   0xbb Undefined error
   0xcc Write fault
   0xe0 Status error


See Also: BIOS_package

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