Sebastian Herbszt wrote:
> The following disk description is used to trigger this bug:
> ata0-master: type=disk, path=fdtest.img, mode=flat, cylinders=1, heads=150, spt=63
>
> The current BIOS returns CX=0xFFFF. This value is wrong.
>
> rombios.c got
>
> nlc = nlc - 2; /* 0 based, last sector not used */
> SET_AL(0);
> SET_CH(nlc & 0xff);
> SET_CL(((nlc >> 2) & 0xc0) | (nlspt & 0x3f));
> SET_DH(nlh - 1);
>
> with BX_USE_ATADRV and without it's
>
> max_cylinder = hd_cylinders - 2; /* 0 based */
> SET_AL(0);
> SET_CH(max_cylinder & 0xff);
> SET_CL(((max_cylinder >> 2) & 0xc0) | (hd_sectors & 0x3f));
> SET_DH(hd_heads - 1);
>
> nlc and max_cylinder are Bit16u so substracting 2 from 1 gets us the wrong value.
>
> Section "INT 13 - DISK - GET DRIVE PARAMETERS (PC,XT286,CONV,PS,ESDI,SCSI)"
> from Ralf Browns "Interrupt List, part 2 of 18" got
>
> "the maximum cylinder number reported in CX is usually two less than
> the total cylinder count reported in the fixed disk parameter table
> (see INT 41h,INT 46h) because early hard disks used the last cylinder
> for testing purposes; however, on some Zenith machines, the maximum
> cylinder number reportedly is three less than the count in the fixed
> disk parameter table.
> for BIOSes which reserve the last cylinder for testing purposes, the
> cylinder count is automatically decremented"
>
> I don't think Bochs BIOS uses "the last cylinder for testing purpose" so i would suggest
> decrementing by 1 not 2. This should also fix the reported problem.
>
> Thoughts?
>
> - Sebastian
SeaBIOS has the same problem and similar wrong comment about last sector when
decrementing the cylinder count:
} else if (regs->dl < EXTSTART_CD) {
// Hard drive
count = GET_BDA(hdcount);
nlc--; // last sector reserved
} else {
- Sebastian