Page 1 of 1

PCI, UDMA - simplification.

Posted: Sat Apr 24, 2010 3:52 am
by Zerith
Hello.

I am planning on adding an Hard Disk driver for my os, using UDMA.
although, i have not quite understood the structure of PCI devices or UDMA.

As i understand,
The bios already configures the hard disk as an PCI device, and all that is needed to do is to place my PRD Table in the Bus Master Register in the disk controller, and (somehow) place the LBA ..somewhere. (I have read "ATA/ATAPI" using DMA" but i didn't understand this part).

First, how would i know the "index" of the disk controller in the PCI Configuration spac so i can manipulate the Bus Master Register?
And where should the LBA be placed?

I would be very thankful if you could provide me with some text on this matter.

Re: PCI, UDMA - simplification.

Posted: Sat Apr 24, 2010 8:33 am
by bewing
The PRD table is somewhere in memory. You get to choose the location. You put the pointer to the PRD table in the Busmaster register.

The LBA is sent to the disk drive in the process of sending the "read DMA" command -- using the standard IO ports for sending commands to disk drives. Typically IO ports 0x1f0 to 0x1f7. See the http://wiki.osdev.org/ATA_PIO_Mode article for details on how to send a generic command to a disk.

All of the rest of what you are asking involves a careful enumeration of the PCI bus to find the controller for the disk drives. You need to read the wiki article on the PCI bus several times, spend a day writing code to do the enumeration, and spend another few days going through that enumeration to figure out exactly what it means. http://wiki.osdev.org/PCI