Weired first sector

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
stones3000
Posts: 7
Joined: Thu Aug 09, 2007 5:08 am

Weired first sector

Post 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!!!
Avarok
Member
Member
Posts: 102
Joined: Thu Aug 30, 2007 9:09 pm

Post 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.
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.
- C. A. R. Hoare
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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 :twisted:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

my favourite sentinel is 0xdeadbaba. Dead baby jokes ftw :P
stones3000
Posts: 7
Joined: Thu Aug 09, 2007 5:08 am

Post 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'?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
stones3000
Posts: 7
Joined: Thu Aug 09, 2007 5:08 am

Post 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 :-)
Post Reply