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++ 3.0r4 - <b>_bios_disk</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_bios_disk
   Note - This function is not available when using the DOSX extender
          (X memory model) or OS/2.

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:


   Service          Operation
   --------------------------------------------------------------------------

   0 (reset)        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.

   1 (status)       Obtains the status of the last disk operation. For this
                    service the info parameter is ignored.


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

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

   4 (verify)       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_t structure, pointed to by info, are correctly
                    set up.

   5 (format)       Formats the track specified in the head and track fields
                    of the diskinfo_t 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_t 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 <bios.h>

   #include <stdio.h>
   #include <stdlib.h>

   int main()
   {
       int status;
       struct diskinfo_t 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 EXIT_SUCCESS;
   }

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,    _bios_keybrd,    _bios_memsize,
   _bios_printer,   _bios_serialcom



See Also: _bios_keybrd _bios_memsize _bios_printer _bios_serialcom

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