home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / tools / fips12 / source / fipsspec.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-13  |  4.6 KB  |  131 lines

  1. /*
  2.     FIPS - the First nondestructive Interactive Partition Splitting program
  3.  
  4.     Module fipsspec.cpp
  5.  
  6.     RCS - Header:
  7.     $Header: c:/daten/fips/source/main/RCS/fipsspec.cpp 1.1.1.1 1994/10/13 01:53:35 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. #include "fipsspec.h"
  32. #include "global.h"
  33. #include <dos.h>
  34.  
  35. #define DISK_INT 0x13
  36.  
  37. #define RESET_DISK 0
  38. #define GET_DRIVE_PARAMS 8
  39.  
  40. void fips_bpb::print (void)
  41. {
  42.     printx ("Bytes per sector: %u\n",bytes_per_sector);
  43.     printx ("Sectors per cluster: %u\n",sectors_per_cluster);
  44.     printx ("Reserved sectors: %u\n",reserved_sectors);
  45.     printx ("Number of FATs: %u\n",no_of_fats);
  46.     printx ("Number of rootdirectory entries: %u\n",no_of_rootdir_entries);
  47.     printx ("Number of sectors (short): %u\n",no_of_sectors);
  48.     printx ("Media descriptor byte: %02Xh\n",media_descriptor);
  49.     printx ("Sectors per FAT: %u\n",sectors_per_fat);
  50.     printx ("Sectors per track: %u\n",sectors_per_track);
  51.     printx ("Drive heads: %u\n",drive_heads);
  52.     printx ("Hidden sectors: %lu\n",hidden_sectors);
  53.     printx ("Number of sectors (long): %lu\n",no_of_sectors_long);
  54.     printx ("Physical drive number: %02Xh\n",phys_drive_no);
  55.     printx ("Signature: %02Xh\n\n",signature);
  56. }
  57.  
  58. void fips_partition_table::print (void)
  59. {
  60.     printx ("     |        |     Start      |      |      End       | Start  |Number of|\n");
  61.     printx ("Part.|bootable|Head Cyl. Sector|System|Head Cyl. Sector| Sector |Sectors  |  MB\n");
  62.     printx ("-----+--------+----------------+------+----------------+--------+---------+----\n");
  63.     for (int i=0;i<4;i++)
  64.     {
  65.         printx ("%u    |    %s |%4u %4u   %4u|   %02Xh|%4u %4u   %4u|%8lu| %8lu|%4lu\n",i+1,
  66.         partition_info[i].bootable ? "yes" : " no",
  67.         partition_info[i].start_head,partition_info[i].start_cylinder,partition_info[i].start_sector,
  68.         partition_info[i].system,partition_info[i].end_head,partition_info[i].end_cylinder,partition_info[i].end_sector,
  69.         partition_info[i].start_sector_abs,partition_info[i].no_of_sectors_abs,partition_info[i].no_of_sectors_abs / 2048);
  70.     }
  71. }
  72.  
  73. void fips_harddrive::get_geometry (void)
  74. {
  75.     union REGS regs;
  76.  
  77.     regs.h.ah = GET_DRIVE_PARAMS;
  78.     regs.h.dl = number;
  79.     int86 (DISK_INT,®s,®s);
  80.     if (global.debug_mode)
  81.     {
  82.         fprintf (global.debugfile,"\nRegisters after call to int 13h 08h (drive %02Xh):\n\n",number);
  83.         fprintf (global.debugfile,"   00       sc/cl    hd\n");
  84.         fprintf (global.debugfile,"al ah bl bh cl ch dl dh   si    di    cflgs flags\n");
  85.         hexwrite ((byte *) ®s,16,global.debugfile);
  86.     }
  87.     if ((errorcode = regs.h.ah) != 0) return;
  88.     geometry.heads = (dword) regs.h.dh + 1;
  89.     geometry.sectors = (dword) regs.h.cl & 0x3f;
  90.     geometry.cylinders = ((dword) regs.h.ch | (((dword) regs.h.cl << 2) & 0x300)) + 1;
  91.  
  92.     if (global.debug_mode)
  93.     {
  94.         fprintf (global.debugfile, "\nGeometry reported by BIOS:\n");
  95.         fprintf
  96.         (
  97.             global.debugfile,
  98.             "%ld cylinders, %ld heads, %ld sectors\n",
  99.             geometry.cylinders,
  100.             geometry.heads,
  101.             geometry.sectors
  102.         );
  103.     }
  104. }
  105.  
  106. void fips_harddrive::reset (void)
  107. {
  108.     union REGS regs;
  109.  
  110.     regs.h.ah = RESET_DISK;
  111.     regs.h.dl = number;
  112.     int86 (DISK_INT,®s,®s);
  113.     if (global.debug_mode)
  114.     {
  115.         fprintf (global.debugfile,"\nRegisters after call to int 13h 00h (drive %02Xh):\n\n",number);
  116.         fprintf (global.debugfile,"al ah bl bh cl ch dl dh   si    di    cflgs flags\n");
  117.         hexwrite ((byte *) ®s,16,global.debugfile);
  118.     }
  119.     errorcode = regs.h.ah;
  120. }
  121.  
  122. void fips_logdrive_info::put_debug_info (void)
  123. {
  124.     fprintf (global.debugfile,"Calculated Partition Characteristica:\n\n");
  125.     fprintf (global.debugfile,"Start of FAT 1: %lu\n",start_fat1);
  126.     fprintf (global.debugfile,"Start of FAT 2: %lu\n",start_fat2);
  127.     fprintf (global.debugfile,"Start of Rootdirectory: %lu\n",start_rootdir);
  128.     fprintf (global.debugfile,"Start of Data: %lu\n",start_data);
  129.     fprintf (global.debugfile,"Number of Clusters: %lu\n",no_of_clusters);
  130. }
  131.