[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading a device's BAR



Noam Efrati <noam@genie.terra.co.il> writes...

> As I understand the way a PCI driver should be written, the BAR register 
> should be read from the device for each access of the application to
> the PCI target, in order to know its location in the PCI address space.
> 
> Synce this is done by calling the BIOS interrupt routine (Read 
> Configuration Dword), it takes about 10 microseconds (I checked it on 
> a pentium machine, I don't know the time it would take in other systems
> like ALPHA-PC or alike).
> 
> This means a latency of 10 microseconds for reading/writing a PCI device 
> !!!

No, no, NO.   (phew.  that would be DREADFUL).

You usually just read the BAR once during device driver initialization to get
the base address.  Some operating systems do this for you or have routines you
can call to do this (BIOS calls aren't of much use in a protected mode
environment such as Unix).  Further, in a virtual storage environment such as
Windows, NT, Unix, or OS/2, you need to make additional memory mapping calls to
convert this physical address into a 'linear' address that the device driver
can use.  If your environment is 'segmented', you'll also need to allocate a
selector and set this up with the linear address.  Once the address is mapped
and locked, you can then use this base pointer for direct access to the
peripheral memory and/or registers.

-jrp
ìÈ	¸