PCI, UDMA - simplification.

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
Zerith
Posts: 14
Joined: Sun Jul 05, 2009 4:01 pm

PCI, UDMA - simplification.

Post 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.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: PCI, UDMA - simplification.

Post 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
Post Reply