[solved] Buggy ATA PIO read

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
iProgramInCpp
Member
Member
Posts: 81
Joined: Sun Apr 21, 2019 7:39 am

[solved] Buggy ATA PIO read

Post by iProgramInCpp »

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
Last edited by iProgramInCpp on Mon Apr 20, 2020 6:33 am, edited 1 time in total.
Hey! I'm developing two operating systems:

NanoShell --- A 32-bit operating system whose GUI takes inspiration from Windows 9x and early UNIX desktop managers.
Boron --- A portable SMP operating system taking inspiration from the design of the Windows NT kernel.
iProgramInCpp
Member
Member
Posts: 81
Joined: Sun Apr 21, 2019 7:39 am

Re: Buggy ATA PIO read

Post by iProgramInCpp »

Fixed it, was a bug totally outside this function :P
Hey! I'm developing two operating systems:

NanoShell --- A 32-bit operating system whose GUI takes inspiration from Windows 9x and early UNIX desktop managers.
Boron --- A portable SMP operating system taking inspiration from the design of the Windows NT kernel.
Octocontrabass
Member
Member
Posts: 5578
Joined: Mon Mar 25, 2013 7:01 pm

Re: Buggy ATA PIO read

Post by Octocontrabass »

I found a different bug:

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;
	}
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.)
iProgramInCpp
Member
Member
Posts: 81
Joined: Sun Apr 21, 2019 7:39 am

Re: Buggy ATA PIO read

Post by iProgramInCpp »

thanks for the info :)
Hey! I'm developing two operating systems:

NanoShell --- A 32-bit operating system whose GUI takes inspiration from Windows 9x and early UNIX desktop managers.
Boron --- A portable SMP operating system taking inspiration from the design of the Windows NT kernel.
Post Reply