I'm trying to get right status of Hard disk registers before read or write the hard disk using LBA equations.
So there is the little code:
0x8392 <waitdisk+7> mov eax,0x1f7 │
│ 0x8397 <waitdisk+12> mov edx,eax │
│ 0x8399 <waitdisk+14> in al,dx │
│ 0x839a <waitdisk+15> mov WORD PTR [ebp-0x2],ax │
│ 0x839e <waitdisk+19> movzx eax,WORD PTR [ebp-0x2] │
│ 0x83a2 <waitdisk+23> cmp ax,0x40 │
│ 0x83a6 <waitdisk+27> jne 0x8392 <waitdisk+7>
So you can see that i'm waiting for right status ( 0x40
) to end into the loop.
There is the info registers before taking harddisk/floppy status :
eax 0x1f7 503
ecx 0x40 64
edx 0x1f7 503
ebx 0x0 0
esp 0xff88 0xff88
ebp 0xff98 0xff98
esi 0x0 0
edi 0x8548 34120
eip 0x8399 0x8399 <waitdisk+14>
eflags 0x6 [ IOPL=0 PF ]
And there is after taking status :
eax 0x100 256
ecx 0x40 64
edx 0x1f7 503
ebx 0x0 0
esp 0xff88 0xff88
ebp 0xff98 0xff98
esi 0x0 0
edi 0x8548 34120
eip 0x839a 0x839a <waitdisk+15>
eflags 0x6 [ IOPL=0 PF ]
0x100
taken by ax
means nothing , ...
i'm using qemu emulator , so i think that maybe i have mistaken when i have created disk image or i have gived bad parameters for qemu-system-x86_64
, but nothing :
dd if=/dev/zero of=disk.img bs=512 count=2880
dd if=bin/boot1.img of=disk.img bs=512 conv=notrunc
dd if=bin/boot2.img of=disk.img seek=1 bs=512 conv=notrunc
dd if=bin/kernel.elf of=disk.img bs=512 seek=5 conv=notrunc
qemu-system-x86_64 -fda disk.img -no-shutdown -no-reboot -d cpu_reset -d int file:serial.log
So where i have done mistake ?? Is it the bad code or i should not use inline assembly ??