Bochs HDD serial number?
Posted: Tue Oct 25, 2005 2:18 pm
I print the hard drive serial number for the master primary IDE device, just for shits and grins. The only thing is that when I do a command 0xEC (identify drive) to get information on it, there are some problems...
First of all, the drive's first 16bits returned are all 1s which seems to conflict. Second the serial is reported as:
XXXXXXXZXXXXXXXXXZXX
I'm not sure if Bochs is just weird when it comes to giving virtual drives serials, or what. Here's the read code:
Note that the read on the error register is there to clear the error bit from something that bochs did. The idedrivewait just waits for the device's status register to be of a known value.
So does anyone see a problem with this code, or is Bochs just unreliable/strange in it's reporting of serials?
I'm getting all of my information from http://www.nondot.org/sabre/os/files/Disk/IDE-tech.html and http://www.nondot.org/sabre/os/files/Di ... rogate.zip
First of all, the drive's first 16bits returned are all 1s which seems to conflict. Second the serial is reported as:
XXXXXXXZXXXXXXXXXZXX
I'm not sure if Bochs is just weird when it comes to giving virtual drives serials, or what. Here's the read code:
Code: Select all
void idedriveinfo(ushort device)
{
inportb(device + IDEERROR); //0x1F1
idedrivewait(device, IDESTATUSREADY + IDESTATUSSEEKCOMPLETE); //0x1F0, 01010000b
outportb(device + IDEDRIVEHEAD, IDEDRIVEHEADRESERVED + IDEDRIVEHEADPRIMARY); //0x1F6, 0xA0
outportb(device + IDECOMMAND, IDECOMMANDIDENT); //0x1F7, 0xEC
idedrivewait(device, IDESTATUSREADY + IDESTATUSSEEKCOMPLETE + IDESTATUSDRQ); //0x1F0, 01011000b
kprintf("IDE Probe of Device at: 0x%h\n", device);
kprintf("Flags: %b%b \n", inportb(device), inportb(device));
uint i = 0;
for(i = 10; i>0;i--)
{
inportb(device);
inportb(device);
}
char serial[21];
serial[20] = 0;
for(i=20;i>0;i--)
serial[i-1] = inportb(device);
kprintf(serial);
}
So does anyone see a problem with this code, or is Bochs just unreliable/strange in it's reporting of serials?
I'm getting all of my information from http://www.nondot.org/sabre/os/files/Disk/IDE-tech.html and http://www.nondot.org/sabre/os/files/Di ... rogate.zip