continue fucking with disk system

This commit is contained in:
2025-03-15 17:29:27 +03:00
parent a7a7121812
commit 526a1a07dd
3 changed files with 31 additions and 26 deletions
+24 -19
View File
@@ -57,35 +57,40 @@ void get_disk_info(disk_info *info) {
// Send the identify command
ide_send_command(IDE_CMD_IDENTIFY);//0xEC
uint8_t huy = inportb(0x1F7);
printf("huy is %X\n", huy);
uint8_t status = inportb(0x1F7);
printf("status is %X\n", status);
if(huy == 0)
return;
if(!status)
{
printf("!status\n");
return;
}
while((inportb(0x1F7) & STATUS_BUSY) != 0);
// Wait for the data to be ready
while (ide_read_status() & STATUS_BUSY);
while(1){
status = inportb(0x1F7);
if(status & STATUS_ERR)
{
printf("ERROR! drive has err set. returning...\n");
return;
}
if(status & STATUS_DRQ)
break;
}
printf("disk is online\n");
uint8_t lbaMID, lbaHI;
lbaMID = inportb(0x1F4);
lbaHI = inportb(0x1F5);
//TODO: FIX THIS FUCKERY
if(lbaMID != 0 || lbaHI != 0)
{
printf("ERROR! lbaMID: %X, lbaHI: %X\n", lbaMID, lbaHI);
printf("The drive is not ATA\n");
return;
}
//while(!(ide_read_status() & STATUS_DRQ));//wait for the DRQ bit to be set
while(1)
{
uint8_t status = ide_read_status();
if(status & STATUS_DRQ || status & STATUS_ERR)
break;
}
// Read the data
unsigned short data[256];
for (int i = 0; i < 256; i++) {
@@ -93,9 +98,9 @@ void get_disk_info(disk_info *info) {
}
// Extract the disk information
info->cylinders = (data[1] >> 8) | (data[2] << 8);
info->heads = data[3];
info->sectors = data[6];
info->cylinders = (data[1] >> 8) | (data[2] << 8); // Cylinder count
info->heads = data[6]; // Heads per cylinder
info->sectors = data[3]; // Sectors per track
}
// Function to check if a disk is present