How PCI BAR is assigned in Linux?
Answer:
Find free space from PCI bus resource in __find_resource, in which resource start and end are allocated ( from the bus IO memory region? )
__pci_assign_resource
pci_bus_alloc_resource
pci_bus_alloc_from_region
allocate_resource
reallocate_resource
__find_resource
In below function, parameter resno is the BAR number.
static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, int resno, resource_size_t size, resource_size_t align)
PCI BAR address points device IO. The value of the BAR address is just mapped by OS, not in range of the host physical memory.
To update the BAR to PCI device.
pci_assign_resource // from the res->start ...
pci_update_resource
pcibios_resource_to_bus(dev->bus, ®ion, res);
region->start = res->start - offset;
new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
reg = pci_resource_bar(dev, resno, &type);
pci_write_config_dword(dev, reg, new);
Reference:
http://www.linux-mips.org/wiki/PCI_Subsystem
http://wiki.osdev.org/PCI
No comments:
Post a Comment