|
Message
From: Mark McDougall<markm@v...>
Date: Sat Oct 27 04:14:14 CEST 2007
Subject: [pci] Rookie questions about PCI
make_u_play@y... wrote:> Ok I was having a look at http://www.fpga4fun.com/PCI2.html. It says > "The disadvantage of the IO space is that it's small (limited to 64KBs > on PCs, even if PCI supports 4GBs) and pretty crowded. " I also had a > look at the I/O space addresses on my PC and it is crowded and limited > to a max address of xxxxx....FFFF. Can you explain the difference > between I/O space and memory space from a hardware and software point > of view. Basically what I want to know is from the computers > perspective what is so different between I/O space and memory space? > From what I can see they are pretty much the same sort of thing i.e. I > access both by an address and read or write data to both. What are the > unique aspects of each that make them special and different?
>From a software POV, you use different CPU instructions to access memory and IO space. IO space has more limitations as well, such as not being prefetchable. I think the legacy of IO space was to reduce the decode logic required by IO peripherals, and perhaps optimise IO performace in the CPU?!?
These days, just use PCI memory space.
> But to clarify the base address register is the > register(s) in the config space that is updated by the host pc telling > the card where the assigned memory space has been mapped to correct? > Also how does the card know how much memory space has been assigned to > it?
Yes. In the case of the opencores PCI controller, you set the size of each memory or IO space image in a header file before you build the FPGA. The PC BIOS must assign a memory range that is the requested size. The way it's actually done is the BIOS writes 1's to the BAR and reads it back - the unimplemented low-order bits determine the size of the image.
> Now say infact that I wanted to have 4GB of RAM on my PCI card. I > choose 4GB since its well over the direct addressing limit for a 32 bit > system. So if I want to access all of the 4GB in which there is data > how will I go about this? There is a limit to how much memory space I > can be assigned am I correct? and beyond this I will have to impliment > some type of indirect addressing or paging scheme where I tell my PCI > card to switch between two 2GB ram sections?
You won't get anywhere *near* 2GB successfully assigned to your card, and nor should you attempt it. You'll have to choose something a *lot* smaller, and implement a bank-switch register in your device. Note that if you're using a DMA engine on your card, then it's likely you won't need to make the memory space visible at all to the PCI (though you probably should implement a small window, even for debug).
> What exactly is a user-mode buffer? Also by application buffer do you > just mean an array in my program and nothing special right? When you > say the DMA's registers are mapped to memory or I/O space that is > simply so I can update the destination address for the transfer right? > (The only DMA I have delt with is on an MSP430 microcontroller where > you supply a source address, dest address and #bytes or words + trigger > source etc... and it finishes the transaction and calls an interrupt is > it exactly the same thing with a PC?)
Yes. A user-mode buffer is a buffer that you can access from a normal application. If you're doing DMA, you'll need some mechanism to allocate or find the *physical* address of such a buffer. Here's where you might need a generic driver like TVPICPCI.
Regards,
-- Mark McDougall, Engineer Virtual Logic Pty Ltd, <http://www.vl.com.au> 21-25 King St, Rockdale, 2216 Ph: +612-9599-3255 Fax: +612-9599-3266
|
 |