OSDev.org
https://forum.osdev.org/

OSDev Wiki ATA read/write sectors code not working right
https://forum.osdev.org/viewtopic.php?f=1&t=33657
Page 1 of 1

Author:  iProgramInCpp [ Wed Apr 24, 2019 10:48 am ]
Post subject:  OSDev Wiki ATA read/write sectors code not working right

https://wiki.osdev.org/ATA_read/write_sectors
Some of the time, it does work, some of the time it does not.
I can only read and write in one function, then the code quits working.

https://gist.github.com/iProgramMC/8328 ... 9bdfd6909f
https://gist.github.com/iProgramMC/8d92 ... 52e7b76b31

The basic code required to test the functions is here.
The code returns zeros from the FileOpen function, even though the InitFilesystem function worked beforehand and made a full tree of the filesystem.

File system is very simple, you've got the classical BPB boot-sector, then 16 sectors' worth of root directory files, and data area.
All other FAT features were stripped down as this is planned to be a read-only file system.
Its main purpose is to load other programs into memory.

I'm not sure what causes the random halt of the functioning of AtaLbaRead and AtaLbaWrite, but I have a suspicion it may be in regards to the drive not being initialized and such, even though the file system was loaded successfully.

Please help?

Author:  iProgramInCpp [ Wed Apr 24, 2019 12:55 pm ]
Post subject:  Re: OSDev Wiki ATA read/write sectors code not working right

Please help!

Author:  alberinfo [ Wed Apr 24, 2019 3:49 pm ]
Post subject:  Re: OSDev Wiki ATA read/write sectors code not working right

i think that you're messing up some code.
in the wiki says:
Code:
mov edx, 0x1f4
mov eax, ebx
shr eax, 8
out dx, al


and then

Code:
mov edx, 0x1f4
mov eax, ebx
shr eax, 16
out dx, al


but instead in your code you're doing:
Code:
mov edx, 0x1f4
mov eax, ebx
shr eax, 16
out dx, al


correct me if i'm wrong

Author:  iProgramInCpp [ Thu Apr 25, 2019 6:09 am ]
Post subject:  Re: OSDev Wiki ATA read/write sectors code not working right

I've fixed it.
The resulting array is still inconsistent even if I read the same sector over and over.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/