Problem with 0x1F0 and disk size..
Posted: Wed Dec 02, 2009 3:59 pm
Hi people
I am using the port 0x1F0 for get features of hard disk's, but as everyone knows the bios only supports 8gb and returns max 8063 mb.
How can I fix it?
My calc: size = (sectors per track * cylinders * heads) * 0.5) / 1024;
My code..
Thanks
I am using the port 0x1F0 for get features of hard disk's, but as everyone knows the bios only supports 8gb and returns max 8063 mb.
How can I fix it?
My calc: size = (sectors per track * cylinders * heads) * 0.5) / 1024;
My code..
Code: Select all
int buscar_dispositivos_ata()
{
printf("[SISTEMA] Buscando dispositivos ATA...\n");
int ndispositivos = 0;
unsigned int dados [256];
unsigned int dados_off;
unsigned int loop, size;
ndispositivos = peekb(0x40, 0x75); // Byte at Segment 40H Offset 75H
for (loop = 0; loop < ndispositivos; loop++)
{
while (inportb(0x1F7) != 0x50); // Wait for controller not busy
outportb(0x1F6, (loop == 0 ? 0xA0 : 0xB0)); // Get first/second drive
outportb(0x1F7, 0xEC); // Get drive info data
while (inportb(0x1F7) != 0x58); // Wait for data ready
for (dados_off = 0; dados_off != 256; dados_off++) // Read "sector"
dados[dados_off] = inportbw(0x1F0);
hard_disks[loop].Modelo = getascii(dados, 27, 46);
hard_disks[loop].Serial = getascii(dados, 10, 19);
size = 0;
size = ((dados[1] * dados[3] * dados[6]) * 0.5) / 1024;
hard_disks[loop].Tamanho = tamanho;
hard_disks[loop].Canal = (loop == 0 || loop == 1) ? 0 : 1;
hard_disks[loop].Drive = (loop == 0 || loop == 2) ? 0 : 1;
printf("DRIVE %d:\n", loop);
printf("Modelo____________________: %s\n", getascii(dados, 27, 46));
printf("Serial____________________: %s\n", getascii(dados, 10, 19));
printf("Dados do HD:\n");
printf("Tamanho___________________: %d\n", tamanho);
printf("Cilindros_________________: %d\n", dados[1]);
printf("Cabeças___________________: %d\n", dados[3]);
printf("Setores por Trilha________: %d\n\n", dados[6]);
}
if (ndispositivos == 0)
{
printf("[SISTEMA] Nenhum dispositivo ATA encontrado...\n");
return 0;
}
else printf("[SISTEMA] %d dispositivo(s) ATA encontrado(s)...\n", ndispositivos);
return 1;
}