On Wed, May 7, 2014 at 3:08 PM, Ayaz Akram <aaq...@gmail.com> wrote: > So, if I have rightly understood, this means whatever address range guest > wants to use, guest should write base address registers for particular > device accordingly.
Yes. > Actually, I have made a hack [...] > wrote bar0 in emulated e1000's config space, but I am not able to understand > from e1000's code in qemu, that how does qemu get to know that this is going > to be the base adress for this device. Linux PCI drivers usually do not write a BAR address themselves. A key feature of PCI is autoconfiguration. That means the firmware or operating system can scan all PCI adapters and query how much BAR space they need. Then the firmware or operation system sets the BAR addresses to make the devices available. The actual device driver doesn't decide the specific BAR address, it usually just asks the kernel PCI layer to "map" a BAR that it wants to use. If you need more info, please see https://lwn.net/Kernel/LDD3/ and the PCI specification. Stefan