Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In my previous question, I established that the memory address used by PCI/PCIe devices does not have to mapped to system RAM, but could also refer to "on device" memory, e.g. RAM or registers.

But how are the BARs set up in this case?

Is it simply a case (that during configuration):

  • the device advertises that it wishes to expose, for example 16MB of memory,
  • BAR gets assigned a base address,
  • Thereafter the device maps the offsets to its internal memory?

How does this differ from when the device wishes to access 16MB of system memory (i.e. the device has no memory of its own?)

Thanks!

EDIT: How does the addressing differ between:
A: The device has no memory of its own, e.g. a Video Adapter using shared memory.
B: The device has memory, and shares it with the system (e.g. hypothetical HDD adapter with RAM buffers).

In both cases, are the BARs assigned by the OS and occupy addressable memory?

This distinction is important in a system fully-occupied with RAM (e.g. a 32-bit system with 4 GB RAM installed would be able to support a Video Adapter with 2 GB shared RAM [situation (A)]. But the same system has no address space left over for a hypothetical HDD adapter with onboard 2 GB RAM cache [situation (B)]?

share|improve this question
    
How do I get this question migrated to StackOverflow? Perhaps that's a better home for it. I don't want to just re-ask the same question there... –  KevinM Oct 24 '12 at 14:58

2 Answers 2

Your interpretation of the BAR setup is correct.

Then how does it differ.

The device's on board memory/registers usually is a special RAM, it may be bi-port RAM (when each cell has two ports one is connected to the host bus, another to the device's internal bus, this allows faster and concurrent access from both sides), it may be a registers or even directly some inputs or outputs of some FPGA - Field-Programmable Gate Array that controls some logic of the device.

The main system RAM that a device may access by means of the DMA most often has a completely different designation. In most common case it is used as data source or data destination for the device. For example in case of disk drive that memory will be accessed by the device to read the data in or to write this data onto media. The location of such sources and destinations is not limited by system buffers. For example the paging (swapping in and out of the virtual memory) is performed directly to/from the physical page address of the page in question.

The other possible kind of the DMA access is when the device requests from the system some memory area for its own needs. One of the examples is an Integrated Video Adapter that usually has no its own RAM to keep the binary representation of the image to display on the screen. However this case is very much like disk write operation. The only difference is that it is continuous.

share|improve this answer
    
Thanks - but I am still not 100% sure I understand how the addressing is set up for a device that uses system RAM vs one with its own memory/storage (e.g. your bi-port RAM or FPGA examples). I've edited the question, asking for more clarification. –  KevinM Oct 22 '12 at 12:40

PCI(e) devices can not request a dedicated system memory buffer, at least not by using standard PCI(e) configuration methods ( BARs ). The only devices that generally do this are integrated GPUs, and they have special support in the motherboard chipset that reserves the memory buffer, but these are only understood and set by the system BIOS.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.