Reading ATA status port always gives 0xFF (IDENTIFY command)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Reading ATA status port always gives 0xFF (IDENTIFY command)

Post by Cyao »

Hello,

Im tring to read from my boot cdrom, but its always responding 0xFF :( , and I've checked and i think that all the logic is right, can anyone help me have a look? thanks!

https://github.com/cheyao/AchiveOS/blob ... b/cd.c#L33
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Octocontrabass »

Does your virtual machine's debug log show that you're accessing the hardware? Bochs is very talkative if you enable debug messages.
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Cyao »

Octocontrabass wrote:Does your virtual machine's debug log show that you're accessing the hardware? Bochs is very talkative if you enable debug messages.
Nope, no messages after the 00035981151i[BIOS ] Booting from 07c0:0000 message
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by nullplan »

0xFF is the open bus value. You seem to think it was 0, but no, if no hardware is there, you get all 1-bits. Unfortunately, for some hardware ports, 0xFF is also a valid register value. Anyway, you do not seem to be detecting ATA, but are just assuming an ATA controller to be at a predetermined address.

0xFF being the open-bus value is also why most A20 enabling code using the keyboard controller is wrong on systems that don't have a keyboard controller. But that is a question for another time.
Carpe diem!
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Cyao »

nullplan wrote:0xFF is the open bus value. You seem to think it was 0, but no, if no hardware is there, you get all 1-bits. Unfortunately, for some hardware ports, 0xFF is also a valid register value. Anyway, you do not seem to be detecting ATA, but are just assuming an ATA controller to be at a predetermined address.

0xFF being the open-bus value is also why most A20 enabling code using the keyboard controller is wrong on systems that don't have a keyboard controller. But that is a question for another time.
I think that shouldn't be the case, it reports 0xff for all 4 ports, but atleast one should have something since i've got a cdrom connected
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Cyao »

And now I just used changed it to use a pointer, but now it gets 0 out of the pointer when using -O2, but -O1 and -O0 works. Is there some kind of UB that im overlooking?
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Cyao »

Octocontrabass wrote:How big is your kernel binary?
Its only 19 sectors, enough for now.

And I found the problem, some how i needed a delay after the inb, dunno why, but its fixed :D

but thanks for the help!
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Octocontrabass »

cyao1234 wrote:Its only 19 sectors, enough for now.
Are you sure? I checked a recently-generated disk image and the kernel binary in that one is at least 30 sectors...
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Cyao »

Octocontrabass wrote:
cyao1234 wrote:Its only 19 sectors, enough for now.
Are you sure? I checked a recently-generated disk image and the kernel binary in that one is at least 30 sectors...
That's weird, on my pc it's only 19 sectors, anywas im going to increase it a little bit
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Reading ATA status port always gives 0xFF (IDENTIFY comm

Post by Octocontrabass »

You should figure out a way to automatically load the correct number of sectors. Otherwise, you'll keep running into problems whenever your kernel outgrows your bootloader.
Post Reply