home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
165
/
HDTYPE.ZIP
/
HDTYPE.C
next >
Wrap
C/C++ Source or Header
|
1987-11-25
|
2KB
|
66 lines
/* hdtype.c - by Paul Ketrick
*
* This program prints out an AT's hard drive type table. It is intended
* to be compiled with Microsoft C 4.0 or later; compile with /Zp option to
* pack structure members - the integer members in the hard drive table are
* not word-aligned.
*
* This program has been tested only on a Multitech 900 AT and a Sharp AT;
* however, I assume it will work on nearly all other AT-compatible machines.
* If you have any questions regarding the program, or modify it to work on
* other systems, please leave me a message on Mike's C BBS at (619) 722-8724
* or the Programmer's Forum at (818) 701-1021.
*
* Print this file using a tabstop setting of 4.
*
*/
#include <stdio.h>
#define TBL_SEG 0xF000 /* Segment of start of hard */
/* drive type table in memory */
#define TBL_OFF 0xE400 /* Offset of start of table */
#define NTYPES 24 /* Total # drive types */
struct hdtable { /* Layout of AT's drive-type */
/* table: */
char unused1;
unsigned int cyls; /* # cylinders on the drive */
char heads; /* # heads on the drive */
char unused2[2];
unsigned int comp_cyl; /* Write precomp cylinder */
char unused3[5];
unsigned int ship_cyl; /* Shipping cylinder # */
char spt; /* Sectors per track */
};
main()
{
struct hdtable far *table; /* Declare 32-bit pointer to */
/* hdtable structure */
unsigned int capacity; /* Total drive capacity in megs */
int i;
table = (struct hdtable far *)(((long)TBL_SEG << 16) + TBL_OFF);
/* Set hdtable pointer to address of beginning of hard drive */
/* type table */
printf("Type Heads Cyls Comp Cyl Park Cyl SPT Capacity\n");
for (i=1; i<=NTYPES; ++i) {
/* Compute drive capacity in megs; assumes 512 bytes/sector: */
capacity = ((long)table->heads * table->cyls * table->spt * 512) / 1048576;
printf("%2d %2d %4d ", i, table->heads, table->cyls);
if (table->comp_cyl >= table->cyls)
printf("NONE");
else
printf("%4d", table->comp_cyl);
printf(" %4d %2d %3dM\n", table->ship_cyl, table->spt,
capacity);
++table;
}
}