RE: Help with understanding PCI

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

 



>Hi,
>I am trying to understand PCI unsuccessfully. 
>Let's say i have 4 GB of RAM and x86 32bit.
>Now, i have 1 PCI card with a device on it. It has 4gb worth of
registers.
I.e. memory. So, it sits on bus:0, device:1 function:2.

>1) If i wish to address just two words (to be set to 0xffee) (32 bits) 
>register on address 0xe0000000. What will be the hardware steps to
take?
>My guess work (and please CMIIW): The address bus register on the cpu
is >set 
>to 0xe0000000, the CPU data bus is switched to PCI bus 0 and somewhere
on the 
>bus 0 controller we set a register to 0x110 to represent device:1
>function:2.
>The CPU then writes to it's data bus 0xffee and we are done.

>Also, i would appreciate to have the actual commands in linux to do the
above.

>2) The PCI device now wants it's memory to be i/o memory mapped to ram 
(probably at boottime) so i can write *my_memmaped_pointer=0xffee; What
are 
the steps to do that in linux?

>Btw, i am in serious doubt that there are devices on a PC x86 that
allows a 
>PCI to directly connect it's data bus and address bus to the RAM
address and 
>data bus like handheld computers does etc... instead of working like a
port 
on ISA (i.e. a separate bus).


First have a look at the /proc/pci. It gives good amount of information
on PCI devices connected. Once you find the device you are looking for,.
u can get the Pci_dev reference with vendor id and device id.

pci_dev = pci_find_device(Vendor, devid, NULL/*First reference*/); 

PCI Device can support 6 IO regions, and the address of the these
regions will be stored in Configuration space of the pci device, Exact
location where these address will be stored is referred as BAR(Base
address register), there are 6 BARs ranged from 0-5.

Start_add = Pci_resource_start(pci_dev, bar_no); 
End_addr = pci_resource_end(pci_dev, bar_no);

Now with these you can make a request for ioremap.

ioremap(start, size /*end - start +1*/);

now you can use read and write functions to access the pci memory
region...

CMIIW...

-Vamsi

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux