OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:05 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Reading ATA status port always gives 0xFF (IDENTIFY command)
PostPosted: Sun Nov 20, 2022 2:19 am 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
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

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Sun Nov 20, 2022 3:03 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Does your virtual machine's debug log show that you're accessing the hardware? Bochs is very talkative if you enable debug messages.


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Sun Nov 20, 2022 3:07 am 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
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

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Sun Nov 20, 2022 4:24 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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!


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Sun Nov 20, 2022 4:59 am 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
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

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Sun Nov 20, 2022 8:37 am 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
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?

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Sun Nov 20, 2022 3:00 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
How big is your kernel binary?


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Mon Nov 21, 2022 11:11 am 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
Octocontrabass wrote:


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!

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Mon Nov 21, 2022 11:59 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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...


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Mon Nov 21, 2022 1:01 pm 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
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

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: Reading ATA status port always gives 0xFF (IDENTIFY comm
PostPosted: Mon Nov 21, 2022 1:32 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 57 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