Here's my ATA PIO read code: https://gist.github.com/iProgramMC/a02c ... fff0189b31
I am wondering if what I'm doing is right. Reading the boot sector works just fine, however, reading the FAT (in my case at sector 0x20FE, for some reason) does not work. It skips two bytes. I've tried this code in qemu, not sure about VirtualBox and others.
I've checked that the FAT actually exists at the address - it does.
I've compressed the hard drive image so that you can see if it works. (Warning: it is 256 MB.) Here it is. (the domain is weird because I couldn't be bothered to upload anywhere else)
update: ReadPort is inportb, ReadPortW is inportw, WritePort is outportb and WritePortW is outportw.
Thanks
[solved] Buggy ATA PIO read
-
- Member
- Posts: 81
- Joined: Sun Apr 21, 2019 7:39 am
[solved] Buggy ATA PIO read
Last edited by iProgramInCpp on Mon Apr 20, 2020 6:33 am, edited 1 time in total.
-
- Member
- Posts: 81
- Joined: Sun Apr 21, 2019 7:39 am
Re: Buggy ATA PIO read
Fixed it, was a bug totally outside this function
-
- Member
- Posts: 5575
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Buggy ATA PIO read
I found a different bug:
There can be up to two drives on each channel, but this code can only work with one drive on each channel. (Also, these are the legacy I/O ports, but PCI IDE controllers may be using ports set in their BARs instead of the legacy ports.)
Code: Select all
switch(drive_num)
{
case 0: base = 0x01f0; break;
case 1: base = 0x0170; break;
case 2: base = 0x01e8; break;
case 3: base = 0x0168; break;
default: return -1;
}
-
- Member
- Posts: 81
- Joined: Sun Apr 21, 2019 7:39 am
Re: Buggy ATA PIO read
thanks for the info