#include <stdio.h> #include <sys/io.h>
#define DISKPORT 0x1f0
int main() {
unsigned int i,j; unsigned char p; unsigned int Disk_Info[513]; unsigned int cache=0; unsigned char s[21]; unsigned char v[9]; unsigned char t[41];
i = 0; j = 0; p = 0;
if (ioperm(DISKPORT, 8, 1)) {perror("ioperm"); exit(1);}
while (p != 0x40) { j++; if(j == 0xffff) break; p = inb (0x1f7); p &= 0xc0; }
for(i = 0; i < 5; i++) outb (0,0x1f1+i);
outb (0xa0,0x1f6); outb (0xec,0x1f7); i = 0; j = 0; p = 0;
while (p != 0x8) { j++; if (j == 0xffff) break; p = inb (0x1f7); p &= 0x88; }
for (i = 0; i < 512; i++) { Disk_Info[i] = inw (0x1f0); }
s[20]='\0'; v[8]='\0'; t[40]='\0'; cache = Disk_Info[21]/2;
for (i = 0; i < 10; i++) { j = Disk_Info[10+i]; s[i*2] = (unsigned char)(j>>8); s[i*2+1] = (unsigned char)j; }
for(i = 0; i < 20; i++) { j = Disk_Info[27+i]; t[i*2] = (unsigned char)(j>>8); t[i*2+1] = (unsigned char)j; }
printf ("\nPhysical Disk 0 "); printf ("\nDrive Serial Number : %-40s",t); printf ("\nDrive Model Number : %-20s",s); printf ("\nDrive Controller Revision Number : %-8s",v); printf ("\nDrive Controller Buffer Size : %u K", cache); printf ("\n");
if (t[0] == 'V' && t[1] == 'M') printf ("\nRunning in VMware Workstation!\n"); else printf("\nRunning in Real System!\n");
if (ioperm(DISKPORT, 8, 0)) {perror("ioperm"); exit(1);} exit(0); }
|