OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: ATA/PIO not working stuck on infinite loop waiting for RDY
PostPosted: Tue Mar 07, 2023 8:49 am 
Offline

Joined: Mon Mar 06, 2023 10:25 am
Posts: 4
i have written a super simple os and i decided to start using grub to boot it, so i started a new projected and im getting my old kernel functions to the new kernel and the ATA driver is not working stuck when i wait for RDY

Code:
void ATA_wait_BSY() // Wait for bsy to be 0
{
   while (insb(0x1F7) & STATUS_BSY)
      ;
}

void ATA_wait_DRQ() // Wait fot drq to be 1
{
   while (!(insb(0x1F7) & STATUS_RDY))
      ;
}

i have this 2 functions

and
Code:
int disk_read_sector(int lba, void *buf)
{
   ATA_wait_BSY();
   print("1");

   outb(0x1F6, 0xE0 | ((lba >> 24) & 0xF));
   outb(0x1F2, 1);
   outb(0x1F3, (uint8_t)lba);
   outb(0x1F4, (uint8_t)(lba >> 8));
   outb(0x1F5, (uint8_t)(lba >> 16));
   outb(0x1F7, 0x20); // Send the read command

   uint16_t *ptr = (uint16_t *)buf;

   ATA_wait_BSY();
   print("2");
   ATA_wait_DRQ();
   print("3");
   for (int i = 0; i < 256; i++)
   {
      *ptr = insw(0x1F0);
      ptr++;
   }

   return 0;
}

i only get printed 1 and 2 so i presume it is stuck on ATA_wait_DRQ();
this used to work on my old bootloader so i think is something related to it the idt is also from the old bootloader and de gdt is the same as nanobyte used.
so im really lost... the interrupts are working fine, div 0 is good... keyboard input also, my unique current problem is this


Top
 Profile  
 
 Post subject: Re: ATA/PIO not working stuck on infinite loop waiting for R
PostPosted: Mon Apr 03, 2023 5:55 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Marques wrote:
Code:
   while (!(insb(0x1F7) & STATUS_RDY))

Is that "inb" or "insb"? Is that DRQ or DRDY?

Marques wrote:
i only get printed 1 and 2 so i presume it is stuck on ATA_wait_DRQ();

If it is stuck there, you should print the status register to see if the drive is reporting an error of some kind.

Marques wrote:
the interrupts are working fine

If you have interrupts, why are you polling?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 56 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group