[Solved]Unable to obtain disk identify info on qemu
Posted: Thu Dec 23, 2021 5:24 pm
First, I use to create a 80m img file as hard disk. Then I use to plug in the disk and start the qemu.
And here is my full command to start qemu:
I want to get the identify information of my disk, and here is my code to do that:
Definition of all macros used above
But the data I've got from the port is nothing but 0. Here is the code I've used to get return data from port:
Here is the definition of port_insw:
Structure "Disk_Identify_Info" is nothing but a 256 bits struct to store disk identify info. It is kind of long so I cannot post it on this quote.
(Definition of Disk_Identify_Info: https://github.com/bigjr-mkkong/OStest/blob/main/disk.h)
However, I want to know how can I fix this problem or it is normal to get a full 0 identify info in qemu.
Code: Select all
qemu-img create -f qcow2 80m.img 80m
Code: Select all
-hdb 80m.img
And here is my full command to start qemu:
Code: Select all
qemu-system-x86_64 -cpu Nehalem,+x2apic -m 512 -enable-kvm -s -S -fda a.img -hdb 80m.img
Code: Select all
//send command to the primary disk of slave controller to get identify info
io_out8(PORT_DISK1_ALT_STA_CTL,0);
io_out8(PORT_DISK1_ERR_FEATURE,0);
io_out8(PORT_DISK1_SECTOR_CNT,0);
io_out8(PORT_DISK1_SECTOR_LOW,0);
io_out8(PORT_DISK1_SECTOR_MID,0);
io_out8(PORT_DISK1_SECTOR_HIGH,0);
io_out8(PORT_DISK1_DEVICE,0xe0);
io_out8(PORT_DISK1_STATUS_CMD,0xec);
Code: Select all
#define PORT_DISK1_DATA 0x170
#define PORT_DISK1_ERR_FEATURE 0x171
#define PORT_DISK1_SECTOR_CNT 0x172
#define PORT_DISK1_SECTOR_LOW 0x173
#define PORT_DISK1_SECTOR_MID 0x174
#define PORT_DISK1_SECTOR_HIGH 0x175
#define PORT_DISK1_DEVICE 0x176
#define PORT_DISK1_STATUS_CMD 0x177
#define PORT_DISK1_ALT_STA_CTL 0x376
Code: Select all
struct Disk_Identify_Info a;
unsigned short *p = NULL;
port_insw(PORT_DISK1_DATA,&a,256);
p = (unsigned short *)&a;
for(int i = 0;i<256;i++){
printk(ORANGE,WHITE,"%x ",*(p+i));
}
Code: Select all
#define port_insw(port,buffer,nr) \
__asm__ __volatile__("rep;insw;mfence;"::"d"(port),"D"(buffer),"c"(nr):"memory")
(Definition of Disk_Identify_Info: https://github.com/bigjr-mkkong/OStest/blob/main/disk.h)
However, I want to know how can I fix this problem or it is normal to get a full 0 identify info in qemu.