IDE-ATA Problem

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
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

IDE-ATA Problem

Post by SanderR »

Hello everyone!

I have a problem.
I wrote a IDE driver with the tutorials found on the osdev wiki, my can be found here: https://github.com/AdeRegt/SanderOSUSB/ ... /dev/ide.c
When the driver is initialised, it does detect the filesystem on a disk, my filesystem detection code: https://github.com/AdeRegt/SanderOSUSB/ ... l/fs/mbr.c
I decided to add a custom filesystem: https://github.com/AdeRegt/SanderOSUSB/ ... l/fs/sfs.c

The IDE-ATAPI works perfectly.
The IDE-ATA doesnt:
The system initialises the IDE-ATA, this seems to go OK
The system detects the filesystem, this goes OK
The system initialises the filesystem, this goes OK
The system wants to load sectors stored in a buffer, gotten from the filesystem. this does not go OK.
The data in the buffer is OK, but it is somehow unable to read sectors. the 0x1f7 port returns a 0xff when checking the status and does not read any sector.

Does anyone knows what is wrong?
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: IDE-ATA Problem

Post by Klakap »

Emulators(especially QEMU) took really long time for reading/writing sectors with ATA (only some first sectors are faster). On real hardware is your waitng time enough, but in emulators you should wait some miliseconds.And you must acknowledge interrupt by reading from status port(0x1F7/0x177).
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: IDE-ATA Problem

Post by BenLunt »

SanderR wrote:Hello everyone!

I have a problem.
I wrote a IDE driver with the tutorials found on the osdev wiki, my can be found here: https://github.com/AdeRegt/SanderOSUSB/ ... /dev/ide.c
When the driver is initialised, it does detect the filesystem on a disk, my filesystem detection code: https://github.com/AdeRegt/SanderOSUSB/ ... l/fs/mbr.c
I decided to add a custom filesystem: https://github.com/AdeRegt/SanderOSUSB/ ... l/fs/sfs.c

The IDE-ATAPI works perfectly.
The IDE-ATA doesnt:
The system initialises the IDE-ATA, this seems to go OK
The system detects the filesystem, this goes OK
The system initialises the filesystem, this goes OK
The system wants to load sectors stored in a buffer, gotten from the filesystem. this does not go OK.
The data in the buffer is OK, but it is somehow unable to read sectors. the 0x1f7 port returns a 0xff when checking the status and does not read any sector.

Does anyone knows what is wrong?
I interpret this as your ATA code actually does read some sectors, Yes? It must read some sectors if it found the file system on the disk.
However, the last line states that it does not read any sectors at all.

Please be more specific. If the ATA driver does read sectors, which it would have to do to correctly read in the partition to detect the file system, but then it doesn't read other times?

Ben
- http://www.fysnet.net/media_storage_devices.htm
User avatar
bloodline
Member
Member
Posts: 264
Joined: Tue Sep 15, 2020 8:07 am
Location: London, UK

Re: IDE-ATA Problem

Post by bloodline »

Hi,

I’m planning to write an ATA driver sometime soon, once I get a good handle on how the hardware works I’ll look over your code and see if I can spot any issues.

But my first question is how have you created the disk with your custom FS?
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su
User avatar
bloodline
Member
Member
Posts: 264
Joined: Tue Sep 15, 2020 8:07 am
Location: London, UK

Re: IDE-ATA Problem

Post by bloodline »

I would also note that your mbr_entry type doesn’t use the __packed__ attribute which means the compiler might be adding alignment bytes to make access quicker, so the types won’t align with your on disk structures.
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Re: IDE-ATA Problem

Post by SanderR »

Hello,

Thank you for your answers.
I discovered I had a git branch with a working base so I restored parts of this file.
The old code had bugs but I was able to solve them by the advices you guys told me. Thank you.
I was not exactly sure where the bugs in the new system was comming from.

For the filesystem: I opened my virtual harddisk (VHD) with my hexeditor and in this way designed the filesystem base.
This system works well enough. This is the filesystemdriver link: https://github.com/AdeRegt/SanderOSUSB/ ... l/fs/sfs.c
This is the ide driver link: https://github.com/AdeRegt/SanderOSUSB/ ... /dev/ide.c
Post Reply