Re: [hatari-devel] Small IDE drive image, wrong physical parameters?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Am Sun, 29 May 2016 19:13:16 +0200
schrieb Uwe Seimet <Uwe.Seimet@xxxxxxxxx>:

> Hi,
> 
> I wonder whether Hatari correctly sets the physical drive parameters
> of small IDE drives. With an IDE image file size of 524288 bytes the
> result according to my calculation is 2016 sectors. This is how I
> calculate: In case LBA is supported I just use the LBA sector count,
> if LBA is not supported (LBA sector count is 0) I multiply the nubmer
> of heads, sectors per track and cylinders.
> 
> For an image file size of 410009600 bytes the values appear to be
> correct. Can it be that the values are wrong for the non-LBA case?

Have a look at the following code in ide.c:

	/* if no geometry, use a standard physical disk geometry */
	cylinders = nb_sectors / (16 * 63);
	if (cylinders > 16383)
		cylinders = 16383;
	else if (cylinders < 2)
		cylinders = 2;
	s->cylinders = cylinders;
	s->heads = 16;
	s->sectors = 63;

For a file with 524288 bytes, nb_sectors is 524288 / 512 = 1024, so
cylinders are first calculated to 1. Since 1 is < 2, it is set to 2
instead. Then you get 2 * 16 * 63 = 2016 sectors instead.

Not sure why there is a limitation to 2 cylinders, but I guess there is
a reason for this, current QEMU also still has this code.

So I think the it likely simply does not make sense to use IDE hard
disks with a size less than 1 MB ... even the very first IDE hard disk
already had 10 MB, so this interface was likely never invented for
something smaller...

 Thomas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/