Satish wrote:
U wanted actual size of HDD, I mean in ur case u should get 15GB right ?
Yes!
how are u reading the size to detrmine the HDD size ?
driver.c
=== cut here ===
#define ATA_PRI_M 0x1f0 // base address of primary controller
#define ATA_SEC_M 0x170 // base address of secondary controller
#define ATA_REG_DATA 0 // data register
#define ATA_REG_DEV 6 // device register
#define ATA_REG_CMD 7 // command register
#define ATA_REG_STATUS 7 // status register
#define DEV_OFF 4
#define ATA_DEV_NUM(dev) (0xA0 + ((dev)<<dev_off>
#define ATA_CMD_GETP 0xec // get drive parameters
#define DEVICE ATA_DEV_NUM(0) // <<< Set IDE to read here >>>
#define ADAPTER ATA_PRI_M // <<< Set IDE to read here >>>
#define DRQ 8 // DRQ status mask
union idbuf {
ID_PARMS parms;
USHORT data[256];
};
/* […] /
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath) {
UCHAR sreg;
int i;
/ […] /
//
// Select the adapter
//
WRITE_PORT_UCHAR((PUCHAR)(ADAPTER + ATA_REG_DEV), DEVICE);
Wait400ns();
//
// The Identify Device Command
//
WRITE_PORT_UCHAR((PUCHAR)(ADAPTER + ATA_REG_CMD), ATA_CMD_GETP);
Wait400ns();
//
// Read status register
//
sreg = READ_PORT_UCHAR((PUCHAR)(ADAPTER + ATA_REG_STATUS));
if (!(sreg & DRQ)) {
DbgPrint((“%s: Data not ready! Status= %#x\n”, DEVICE_NAME, sreg));
IoDeleteSymbolicLink(&uniWin32NameString);
IoDeleteDevice(DriverObject->DeviceObject);
return STATUS_UNSUCCESSFUL;
}
//
// Read Identify Device data
//
for (i = 0; i < 256; i++)
iddata.data[i] = (USHORT)READ_PORT_USHORT((PUSHORT)(ADAPTER + ATA_REG_DATA));
/ […] */
return STATUS_SUCCESS;
}
VOID Wait400ns(VOID){
LARGE_INTEGER start, current;
ULONG k = KeQueryTimeIncrement();
KeQuerySystemTime(&start);
do {
KeQuerySystemTime(¤t);
} while((current.QuadPart - start.QuadPart) < 4 * k);
}
=== cut here ===
test.c
=== cut here ===
cyl = id_params.fcyl; // 1 offset at id_params(IDENTIFY DATA)
heads = id_params.hds; // 3
sects = id_params.spt; // 6 sectors/track
// id_params.tsecs // 60 total number of user addressable sectors (LBA mode)
total_secs = cyl * heads * sects;
if (cyl == 16383 && total_secs < id_params.tsecs)
total_secs = id_params.tsecs;
printf(“HDD C/H/S : %lu/%lu/%lu [%luMB]\n\n”,
total_secs / (heads * sects), heads, sects,
total_secs / (1024L * 1024L / 512));
=== cut here ===
>
> Regards,
> Satish K.S
>
> ----- Original Message -----
> From: “D. K.”
> To: “NT Developers Interest List”
> Sent: Thursday, March 29, 2001 2:50 PM
> Subject: [ntdev] QESTION For Real Kernel Hackers. ATA IDENTIFY DATA & NT/2K
>
> > Hi, dear all!
> >
> > I have written the device driver which reads
> > the ATA Identify Device Data through ports(on Windows NT/2k).
> >
> > I have looked as my FreeBSD 4.2 determines real size HDD in
> > her ATA dev(ice) driver at boot time:
> >
> > ==cut here==
> > total_secs = cylinders * heads * sectors;
> > if (cylinders == 16383 && total_secs < lbasize)
> > total_secs = lbasize;
> > ==cut here==
> >
> > Where: ATA offset ATA description
> > cylinders - // 1 number of fixed cyls
> > heads - // 3 number of heads
> > sectors - // 4 bytes/track
> > lbasize - // 60 total number of user addressable sectors
> (LBA mode)
> >
> > At booting FreeBSD correctly determines HDD size.
> > For my 15GB HDD lbasize(at boot time)= 30021632
> >
> > But! When i read lbasize at Windows NT(SP6a)/ Windows 2000
> > it always = 0x70000 ~ 224 MB.
> > On any HDD…
> >
> > Why?
> >
> > Best Reards,
> > Dmitry Koptelov
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@aalayance.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntdev as: xxxxx@homepage.ru
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</dev_off>