home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
beehive
/
zcat
/
dstat01.lbr
/
DSTAT.C
next >
Wrap
Text File
|
1991-01-30
|
3KB
|
126 lines
/* DSTAT : Disk Stat: the Whole Shebang
* Wilson H. Bent, Jr. : RCP/M: Lillipute: (312) 649-1730 Chicago
* Version 0.1 : Last Mod 06/02/86
*
* A Thorough Dump of the Disk Parameters as known by the BIOS.
* Written for Aztec C : uses functions bioshl() and bdos()
*/
/* BDOS Defines */
#define SELDISK 14
#define CRNTDSK 25
/* BIOS Defines */
#define SELDSK 9
/* The structure member names are those used in
* the CP/M 2.2 Operating System Manual
*/
/* Disk Parameter Header */
struct dph {
char *xlt; /* Logical-Physical Translation pointer */
int xxx[3];/* (used by BDOS) */
char *dbuf; /* Directory Buffer pointer */
struct dpb *dpb; /* Disk Parameter Block pointer */
int *csv; /* Scratch Pad pointer */
int *alv; /* Allocation Vector pointer */
} *dphp;
/* Disk Parameter Block */
struct dpb {
int spt; /* Sectors per Track */
char bsh; /* Block Shift */
char blm; /* Block Mask */
char exm; /* Extent Mask */
int dsm; /* Max. Block Number */
int drm; /* No. of Dir Entries - 1 */
char al0, al1; /* Dir Block Bitmap */
int cks; /* Dir Check Vector Size */
int off; /* Reserved Tracks Offset */
} *dpbp;
int currdisk; /* Current Disk */
int seldisk; /* Selected Disk */
unsigned int bls; /* Block Size */
long dcap; /* Disk Capacity */
main (argc, argv)
char *argv[];
{
register int i;
/* preserve the current disk */
currdisk = bdos (CRNTDSK, 0);
/* get the argument disk, if one is asked for */
if (argc > 1)
seldisk = *argv[1] - 'A';
/* ..otherwise, use the current disk */
else
seldisk = currdisk;
/* use the BIOS call to get a pointer to the DPH */
dphp = bioshl (SELDSK, seldisk, 0);
printf ("Disk %c:\n DPH: 0%04x\n", seldisk + 'A', dphp);
if (dphp == 0) {
printf ("No such disk!\n");
goto away;
}
/* The DPH Stats! */
printf ("Log-Phys Trans:\t0%04x\n", dphp -> xlt);
printf ("Dir Buff:\t0%04x\n", dphp -> dbuf);
printf ("Scratch Pad:\t0%04x\n", dphp -> csv);
printf ("Alloc Vector:\t0%04x\n", dphp -> alv);
/* the DPH has the pointer to the DPB */
dpbp = dphp -> dpb;
/* The DPB Stats! */
printf ("\n DPB Addr: 0%04x\n", dpbp);
printf ("Sect per Track:\t%5d\n", dpbp -> spt);
printf ("Block Shift:\t %2d\n", (int)dpbp -> bsh);
printf ("Block Mask:\t %2d\n", (int)dpbp -> blm);
printf ("Extent Mask:\t %2d\n", (int)dpbp -> exm);
/* Block Size is a computed value, not in the DPB */
for (i = dpbp -> bsh, bls = 1; i > 0; --i)
bls <<= 1;
bls *= 0x80;
printf ("Block Size: %u bytes\n", bls);
/* the Disk Capacity is also a computed value */
printf ("Max Block:\t %4xh\n", dpbp -> dsm + 1);
dcap = (long) bls * (long) (dpbp -> dsm + 1);
printf ("DISK CAPACITY (incl. Directory): %ld (0%lx) Bytes\n",
dcap, dcap);
printf ("Dir Entries:\t%5d\n", dpbp -> drm);
printf ("Dir Bitmap: ");
pbits (dpbp -> al0, 8);
pbits (dpbp -> al1, 8);
putchar ('\n');
printf ("DSV Size:\t%5d\n", dpbp -> cks);
printf ("Sys Tracks:\t%5d\n", dpbp -> off);
/* back to the proper disk! */
away:
bdos (SELDISK, currdisk);
}
/* print NUM in binary, which is of size BITS */
pbits(num,bits)
int num;
int bits;
{
unsigned mask;
for (mask = 1 << (bits - 1); mask; mask >>= 1)
putchar ((num & mask) ? '1' : '0');
}
m;
int bits;
{
unsigned mask;
for (mask = 1 << (bits - 1); mask; mask >>= 1)
putchar ((num & mask) ? '1'