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
+1 -1
View File
@@ -23,7 +23,7 @@ image:
grub-mkrescue -o boot.iso grubshit
test:
qemu-system-i386 -hda boot.iso -m 512M
qemu-system-i386 -drive file=boot.iso,media=disk,format=raw -m 512M
$(OUTPUT): $(OBJS)
$(CC) -T $(LDSCRIPT) -o $@ $(OBJS) $(LDFLAGS)
+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
+6 -6
View File
@@ -18,13 +18,13 @@ void kmain()
char yooo[256] = "heheh";
printf("test string: %s\n", yooo);
printf("checking for disk...\n");
int disk_present = ide_check_disk_present();
printf("we got the result, it's %X\n", disk_present);
//printf("checking for disk...\n");
//int disk_present = ide_check_disk_present();
//printf("we got the result, it's %X\n", disk_present);
disk_info *info;
get_disk_info(info);
printf("CYL HEAD SECT: %X %X %X\n", info->cylinders, info->heads, info->sectors);
disk_info info;
get_disk_info(&info);
printf("CYL HEAD SECT: %X %X %X\n", info.cylinders, info.heads, info.sectors);
while(1)
{