home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / install / fips / source / disk_io.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-11  |  4.1 KB  |  119 lines

  1. /* 
  2.     FIPS - the First nondestructive Interactive Partition Splitting program 
  3.  
  4.     Module disk_io.h 
  5.  
  6.     RCS - Header: 
  7.     $Header: c:/daten/fips/source/main/RCS/disk_io.h 1.1 1994/05/25 22:20:19 schaefer Exp schaefer $ 
  8.  
  9.     Copyright (C) 1993 Arno Schaefer 
  10.  
  11.     This program is free software; you can redistribute it and/or modify 
  12.     it under the terms of the GNU General Public License as published by 
  13.     the Free Software Foundation; either version 2 of the License, or 
  14.     (at your option) any later version. 
  15.  
  16.     This program is distributed in the hope that it will be useful, 
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of 
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  19.     GNU General Public License for more details. 
  20.  
  21.     You should have received a copy of the GNU General Public License 
  22.     along with this program; if not, write to the Free Software 
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  24.  
  25.  
  26.     Report problems and direct all questions to: 
  27.  
  28.     schaefer@rbg.informatik.th-darmstadt.de 
  29. */ 
  30.  
  31. #ifndef DISK_IO_H 
  32. #define DISK_IO_H 
  33.  
  34. #include "types.h" 
  35.  
  36. /* ----------------------------------------------------------------------- */ 
  37. /* Structure to hold information about the drive geometry                  */ 
  38. /* ----------------------------------------------------------------------- */ 
  39.  
  40. struct drive_geometry 
  41.     dword heads; 
  42.     dword cylinders; 
  43.     dword sectors; 
  44. }; 
  45.  
  46. /* ----------------------------------------------------------------------- */ 
  47. /* Physical_sector_no holds and calculates physical sector number (Head,   */ 
  48. /* Cylinder, Sector). Number is calculated on initialization. Log_sector   */ 
  49. /* is absolute logical sector number (0 = master boot record). Usage:      */ 
  50. /* physical_sector_no mbr (0,geometry);                                    */ 
  51. /* physical_sector_no mbr (0,0,1);                                         */ 
  52. /* ----------------------------------------------------------------------- */ 
  53.  
  54. struct physical_sector_no 
  55.     dword head; 
  56.     dword cylinder; 
  57.     dword sector; 
  58.  
  59.     physical_sector_no (dword log_sector,const drive_geometry &geometry); 
  60.     physical_sector_no (dword head,dword cylinder,dword sector) 
  61.     { 
  62.         physical_sector_no::head = head; 
  63.         physical_sector_no::cylinder = cylinder; 
  64.         physical_sector_no::sector = sector; 
  65.     } 
  66. }; 
  67.  
  68. /* ----------------------------------------------------------------------- */ 
  69. /* Low level structure physical_drive, contains drive number and geometry. */ 
  70. /* Geometry is determined on initialization, errorcode contains error      */ 
  71. /* number after call to get_geometry() and reset().                        */ 
  72. /* Initialization requires number (ex.: physical_drive c(0x80);).          */ 
  73. /* ----------------------------------------------------------------------- */ 
  74.  
  75. class physical_drive 
  76. protected: 
  77.     virtual void get_geometry (void); 
  78. public: 
  79.     int number; 
  80.     int errorcode; 
  81.     drive_geometry geometry; 
  82.     virtual void reset (void); 
  83.  
  84.     physical_drive (int number); 
  85.     physical_drive (physical_drive &pd); 
  86.     void operator= (physical_drive &pd); 
  87. }; 
  88.  
  89. /* ----------------------------------------------------------------------- */ 
  90. /* Structure sector - contains data and low level read/write routines.     */ 
  91. /* Read and write are called max. 3 times in case of failure, return code  */ 
  92. /* contains 0 if successful. Sector CRC is verified after write.           */ 
  93. /* Sector is absolute logical sector number (0 = master boot record).      */ 
  94. /* ----------------------------------------------------------------------- */ 
  95.  
  96. struct sector 
  97.     byte data[512]; 
  98.     int read (physical_drive *drive,dword sector); 
  99.     int write (physical_drive *drive,dword sector); 
  100. }; 
  101.  
  102. /* ----------------------------------------------------------------------- */ 
  103. /* Prototype for bios call get_disk_type - returns 0 if drive not present. */ 
  104. /* Valid drive numbers: 0 - 255, result: 1 - floppy without disk change    */ 
  105. /* detection, 2 - floppy with disk change detection, 3 - harddisk          */ 
  106. /* ----------------------------------------------------------------------- */ 
  107.  
  108. int get_disk_type (int drive_number); 
  109.  
  110. /* Bios call get_no_of_drives */ 
  111.  
  112. int get_no_of_drives (void); 
  113.  
  114. #endif 
  115.