On Tue, Apr 7, 2009 at 9:21 AM, John Baldwin <j...@freebsd.org> wrote: > On Monday 06 April 2009 11:12:33 pm Sergey Babkin wrote: >> John Baldwin wrote: >> > >> > On Monday 06 April 2009 1:07:38 pm Ivan Voras wrote: >> > > 2009/4/6 John Baldwin <j...@freebsd.org>: >> > > > On Sunday 05 April 2009 12:23:39 pm Sergey Babkin wrote: >> > > >> > > > Hmm, the problem is we need to be able to write to BARs to size them. > б Any >> > OS >> > > > needs to be able to do this to know what address space regions are > being >> > > > decoded by devices. б We can't avoid writing to BARs. >> > > >> > > I have only vague idea what BARs are and if it's the correct diagnosis >> > > in this case, but the fact is that other operating systems (Windows, >> > > Linux tested) work, so either there is a way around it or the original >> > > premise is wrong-ish. >> > >> > Every OS writes to BARs to size them during boot. It's the defined > procedure >> > for sizing them. A BAR is a base address register, and it is how a PCI >> > device gets memory and I/O port resources. OS (or BIOS) writes a starting >> > address into the register to tell the PCI device where a given >> > resource "starts". >> >> The OS doesn't have to write to the BAR if BIOS has already >> done it. And the BIOS in the Hyper-V VM is obviously special, >> so it doesn't trip on iself. > > Yes it does because we don't know how _big_ the BAR is. The OS has to know if > the device is decoding 1MB or 64KB because we need to reserve the entire > window to prevent any other devices from using it. We don't just write the > existing value, we write all 1's to it and read it back. The lower N > bits "stick" at zero and we use that to figure out the BAR's size. See > pci_add_map() in sys/dev/pci/pci.c
John is 100% correct. Every kernel PCI driver has to figure out how big the BAR is and IN FACT typically the BIOS assigns more address space than the register set you are mapping. This is straight out of the PCI spec. -aps _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"