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

  1. /* 
  2.     FIPS - the First nondestructive Interactive Partition Splitting program 
  3.  
  4.     Module logdr_st.h 
  5.  
  6.     RCS - Header: 
  7.     $Header: c:/daten/fips/source/main/RCS/logdr_st.h 1.1 1994/05/25 22:20:31 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 LOGDR_ST_H 
  32. #define LOGDR_ST_H 
  33.  
  34. #include "types.h" 
  35. #include "disk_io.h" 
  36.  
  37. /* ----------------------------------------------------------------------- */ 
  38. /* Class bootsector - derived from structure sector                        */ 
  39. /* Must be initialized with pointer to logical drive object                */ 
  40. /* Read() and write() read/write sector 0 of logical drive                 */ 
  41. /* ----------------------------------------------------------------------- */ 
  42.  
  43. class bootsector:public sector 
  44.     class logical_drive *logical_drive; 
  45. public: 
  46.     int read (void); 
  47.     int write (void); 
  48.  
  49.     bootsector (class logical_drive *logical_drive) { bootsector::logical_drive = logical_drive; } 
  50. }; 
  51.  
  52. /* ----------------------------------------------------------------------- */ 
  53. /* Bios Parameter Block structure                                          */ 
  54. /* This is not exactly the BPB as understood by DOS, because it contains   */ 
  55. /* the additional fields that are in the bootsector like jump_instruction, */ 
  56. /* oem_name etc. Get() extracts info from the bootsector, put() writes the */ 
  57. /* info back into the bootsector buffer.                                   */ 
  58. /* ----------------------------------------------------------------------- */ 
  59.  
  60. struct bios_parameter_block 
  61.     byte jump_instruction[3];        // EB xx 90 or E9 xx xx 
  62.     char oem_name[9]; 
  63.     word bytes_per_sector;          // usually 512 
  64.     byte sectors_per_cluster;       // may differ 
  65.     word reserved_sectors;          // usually 1 (bootsector) 
  66.     byte no_of_fats;                // usually 2 
  67.     word no_of_rootdir_entries;     // usually 512 for HDs (?), 224 for HD-Floppies, 112 for DD-Floppies 
  68.     word no_of_sectors;             // 0 on BIGDOS partitions 
  69.     byte media_descriptor;          // usually F8h 
  70.     word sectors_per_fat;           // depends on partition size 
  71.     word sectors_per_track;         // depends on drive 
  72.     word drive_heads;               // dto. 
  73.     dword hidden_sectors;           // first sector of partition or 0 for FDs 
  74.     dword no_of_sectors_long;       // number of sectors on BIGDOS partitions 
  75.     byte phys_drive_no;             // 80h or 81h 
  76.     byte signature;                 // usually 29h 
  77.     dword serial_number;            // random 
  78.     char volume_label[12]; 
  79.     char file_system_id[9]; 
  80.  
  81.     void get (bootsector *bootsector); 
  82.     void put (bootsector *bootsector); 
  83. }; 
  84.  
  85. /* ----------------------------------------------------------------------- */ 
  86. /* Some miscellaneous figures about the drive                              */ 
  87. /* Get() extracts this info from the BPB                                   */ 
  88. /* ----------------------------------------------------------------------- */ 
  89.  
  90. struct logical_drive_info 
  91.     dword start_fat1; 
  92.     dword start_fat2; 
  93.     dword start_rootdir; 
  94.     dword start_data; 
  95.     dword no_of_clusters; 
  96.  
  97.     virtual void get (const bios_parameter_block &bpb); 
  98. }; 
  99.  
  100. /* ----------------------------------------------------------------------- */ 
  101. /* Abstract Class logical_drive. This can be any DOS drive that allows     */ 
  102. /* direct reading and writing of sectors, like Harddisk Partitions, Floppy */ 
  103. /* disks or Ramdisks                                                       */ 
  104. /* ----------------------------------------------------------------------- */ 
  105.  
  106. class logical_drive 
  107.     struct bios_parameter_block pr_bpb; 
  108.     struct logical_drive_info pr_info; 
  109. public: 
  110.     class bootsector *bootsector; 
  111.     virtual bios_parameter_block &bpb() { return pr_bpb; } 
  112.     virtual logical_drive_info &info() { return pr_info; } 
  113.  
  114.     virtual int read_sector (dword number,sector *sector) = 0; 
  115.     virtual int write_sector (dword number,sector *sector) = 0; 
  116. }; 
  117.  
  118. /* ----------------------------------------------------------------------- */ 
  119. /* Function to read bootsector from logical drive                          */ 
  120. /* It must be in the header file because it is inline                      */ 
  121. /* ----------------------------------------------------------------------- */ 
  122.  
  123. inline int bootsector::read (void) 
  124.     return logical_drive->read_sector (0,this); 
  125.  
  126. /* ----------------------------------------------------------------------- */ 
  127. /* Function to write bootsector to logical drive                           */ 
  128. /* ----------------------------------------------------------------------- */ 
  129.  
  130. inline int bootsector::write (void) 
  131.     return logical_drive->write_sector (0,this); 
  132.  
  133. #endif 
  134.