home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 165 / HDTYPE.ZIP / HDTYPE.C next >
C/C++ Source or Header  |  1987-11-25  |  2KB  |  66 lines

  1. /* hdtype.c - by Paul Ketrick
  2.  *
  3.  *     This program prints out an AT's hard drive type table.  It is intended
  4.  * to be compiled with Microsoft C 4.0 or later; compile with /Zp option to
  5.  * pack structure members - the integer members in the hard drive table are
  6.  * not word-aligned.
  7.  *
  8.  *     This program has been tested only on a Multitech 900 AT and a Sharp AT;
  9.  * however, I assume it will work on nearly all other AT-compatible machines.
  10.  * If you have any questions regarding the program, or modify it to work on
  11.  * other systems, please leave me a message on Mike's C BBS at (619) 722-8724
  12.  * or the Programmer's Forum at (818) 701-1021.
  13.  *
  14.  * Print this file using a tabstop setting of 4.
  15.  *
  16.  */
  17.  
  18. #include <stdio.h>
  19.  
  20. #define TBL_SEG        0xF000                    /* Segment of start of hard        */
  21.                                             /* drive type table in memory    */
  22. #define TBL_OFF        0xE400                    /* Offset of start of table        */
  23.  
  24. #define NTYPES        24                        /* Total # drive types            */
  25.  
  26. struct hdtable  {                            /* Layout of AT's drive-type    */
  27.                                             /* table:                        */
  28.     char unused1;
  29.     unsigned int cyls;                        /* # cylinders on the drive        */
  30.     char heads;                                /* # heads on the drive            */
  31.     char unused2[2];
  32.     unsigned int comp_cyl;                    /* Write precomp cylinder        */
  33.     char unused3[5];
  34.     unsigned int ship_cyl;                    /* Shipping cylinder #            */
  35.     char spt;                                /* Sectors per track            */
  36. };
  37.  
  38. main()
  39. {
  40.     struct hdtable far *table;                /* Declare 32-bit pointer to    */
  41.                                             /* hdtable structure            */
  42.     unsigned int capacity;                    /* Total drive capacity in megs    */
  43.     int i;
  44.  
  45.     table = (struct hdtable far *)(((long)TBL_SEG << 16) + TBL_OFF);
  46.         /* Set hdtable pointer to address of beginning of hard drive        */
  47.         /* type table                                                        */
  48.  
  49.     printf("Type      Heads   Cyls      Comp Cyl  Park Cyl   SPT      Capacity\n");
  50.     for (i=1; i<=NTYPES; ++i)  {
  51.             /* Compute drive capacity in megs; assumes 512 bytes/sector:    */
  52.         capacity = ((long)table->heads * table->cyls * table->spt * 512) / 1048576;
  53.  
  54.         printf("%2d         %2d     %4d        ", i, table->heads, table->cyls);
  55.  
  56.         if (table->comp_cyl >= table->cyls)
  57.             printf("NONE");
  58.         else
  59.             printf("%4d", table->comp_cyl);
  60.  
  61.         printf("      %4d     %2d         %3dM\n", table->ship_cyl, table->spt,
  62.             capacity);
  63.         ++table;
  64.     }
  65. }
  66.