Lately I keep stumbling upon the same ATA error:
Code: Select all
00015145707e[HD ] calc_log_addr: out of bounds (0/20160)
00015145707e[HD ] ide_read_sector() reached invalid sector 0, aborting
It occurs only when I try to read/write in LBA28 (PIO) mode. When I use CHS, everything works like a charm. I've looked through my code over and over, but can't seem to find anything that's wrong. A quick glance at the Bochs code indicates that it calculates logical_sector (which is 0, as I'm trying to read LBA 0, I also tried calculating the address myself) and then compares it with the size of the drive (maximum LBA). The values printed by the error (calc_log_addr) are as seen above: 0/20160. The Bochs source does the following (found
here):
Code: Select all
if (logical_sector >= sector_count) {
BX_ERROR (("calc_log_addr: out of bounds (%d/%d)", (Bit32u)logical_sector, sector_count));
Where logical_sector is a 64-bit signed integer and sector_count a 32-bit unsigned integer. The values printed are correct, but how can 0 >= 20160? The most reasonable explanation to me would be some kind of wrong signed/unsigned cast, but shouldn't a 64-bit signed value 1 be casted to a 32-bit unsigned value of 0 as well? Seeing as the Bochs code being faulty is rare, I've come to the conclusion that my code probably is faulty (I'm following the ATA/IDE page on the wiki), but I can't seem to figure out what's wrong. All my ATA code can be found
in my SVN repository.
Has anyone had any similar issues? Any idea how to solve them? Sorry if my post sounds a bit hasty, I'm pretty tired (mostly of trying to figure out what's wrong).
PS: The wiki page switches selectors all the time, is this really necessary (or only when one needs to read/write from e.g. usermode, should one then switch to the usermode segment)?
Thanks in advance,
Creature
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.