Page 1 of 1
Weired first sector
Posted: Sun Sep 02, 2007 11:02 pm
by stones3000
I was doing a checksum of all sectors read from a virtual disk using qemu. I used the MINDRVR driver sample code from
http://www.ata-atapi.com/products.htm.
I initialised the virtual disk with all '0's (charater 0). when I read first sector, there is a 'P' character appeared in it, located at the 279th byte. I tried both DMA and PIO, both has 'P' in the first sector. I also wrote a very simple PIO driver myself and it doesn't have the 'P' appeared when reading the first sector.
I can't understand why. Can anyone help? Is it something wrong with the driver or qemu?
Thanks!!!
Posted: Mon Sep 03, 2007 2:38 am
by Avarok
It's a bad idea to test for a single byte located in the first sector. If you hand program by PIO to do something, you're using different instructions than the bios method or whatnot. One of those instructions may be the 'P' you're looking at, since all ascii characters translate to numbers, as does machine code. The first sector is also your bootloader. The code there may or may not be shifting your sentinel out of place.
My favorite sentinel has always been 0xbabe, 'cause it makes me cooler than 0xaa55.
Seriously though, if that's not the problem, and indeed it's not finding your sentinel I'd guess your PIO driver is broken.
There's almost never something wrong with Qemu at this point.
Posted: Mon Sep 03, 2007 3:06 am
by Combuster
Avarok wrote:My favorite sentinel has always been 0xbabe, 'cause it makes me cooler than 0xaa55.
It does make some bioses think you are a femme fatale instead of a coding guru and consequently refuse to boot for that reason
Posted: Mon Sep 03, 2007 3:51 am
by JamesM
my favourite sentinel is 0xdeadbaba. Dead baby jokes ftw
Posted: Tue Sep 04, 2007 11:30 pm
by stones3000
So, I should start to read from the second sector on disks for checksum.
What really happens when reading the first sector (the MBR)? Why only the MBR gives me the weired "p" character, even though I memset the whole sector to '0'?
Posted: Wed Sep 05, 2007 8:10 am
by Combuster
Seriously though, if that's not the problem, and indeed it's not finding your sentinel I'd guess your PIO driver is broken.
What really happens when reading the first sector (the MBR)? Why only the MBR gives me the weired "p" character, even though I memset the whole sector to '0'?
We have
nothing to diagnose your problem, we have barely anything to base guesses on. We need to see code.
Posted: Wed Sep 05, 2007 4:34 pm
by stones3000
Combuster wrote:
We have nothing to diagnose your problem, we have barely anything to base guesses on. We need to see code.
I'm just wandering if anyone has the same problem with me. My code is too lengthy to read. Let's see what I can do myself. Thanks for your help