As far as I understand, (which could very well be wrong,) each PCI device knows how much(size) iomem/ioport address space it wants to claim, but it does not know where(offset). Only the BIOS or OS can tell the device where that place should be, because somebody has to talk to all PCI devices and coordinate their iomem/ioport address alloc requests so that the allocated addresses don't overlap, and this coordination happens at boot time, or a hotplug event, or during a pci rescan. However, in Linux kernel code, I only find a function (pci_read_bases
) that reads out the BAR information, and sets pci_dev
& iomem_resource
/ioport_resource
accordingly, not changing the BARs. So the questions are:
- Can OS(Linux kernel) change BAR? Or only BIOS can do that before loading OS?
- If kernel can change BAR, where does the logic for coordinating address allocation live? (I did see functions like
pbus_assign_resources_sorted
, but it seems to me that that function only maps the existing BARs to kernel objects likeiomem_resource
, not changing BARs)