Results 1 to 7 of 7
Hello,
I'm not sure is it right place for this kind of questions but I try.
Some time ago I wrote a module driver for my PCI card. It works ...
- 08-31-2007 #1Just Joined!
- Join Date
- Jun 2006
- Location
- Krakow, Poland
- Posts
- 5
pci_resource_start
Hello,
I'm not sure is it right place for this kind of questions but I try.
Some time ago I wrote a module driver for my PCI card. It works perfectly: I communicate with my hardware through card IO space with inb, outb, inw, outw ... but first I have to get base address with pci_resource_start function. In LDD book I have found that it is possible to do the same from user space with the same inb, outb, inw, outw ... functions but I couldn't find any information who to get this base address. Since now I send this base address from module in kernel space via char device interface to user space and then I can use it in my user space version of driver but this is very annoying as you may imagine. Could you help me with this??
- 08-31-2007 #2Just Joined!
- Join Date
- Apr 2007
- Posts
- 32
re
Is Your PCI card is auto detected while booting? What pci card you are using find it using command lspci
which list all the pci devices connecte to your system.
based on that you can see the location of memry, which is mapped to your PCI device.
- 08-31-2007 #3Just Joined!
- Join Date
- Jun 2006
- Location
- Krakow, Poland
- Posts
- 5
Yes, I see my device when I use lspci and I can find there address of its memory resources/IO ports. In my case there are: Region 0: memory, Region 1: IO ports, Region 2: IO ports (this is what I'm actualy looking for). These addresses are set by BIOS and I'm looking for some way of getting this number from user space but not with 'lspci' but from code.
This is what lspci shows:
BTW: It is my own card means it was developed by some of my friends. I am responsible for driver and some other software.Code:00:09.0 Bridge: PLX Technology, Inc. Unknown device 2497 (rev 01) Subsystem: Unknown device 2497:0107 Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- Interrupt: pin A routed to IRQ 5 Region 0: Memory at d8001000 (32-bit, non-prefetchable) [size=128] Region 1: I/O ports at dc00 [size=128] Region 2: I/O ports at e000 [size=256] Capabilities: [40] Power Management version 1 Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold-) Status: D0 PME-Enable- DSel=0 DScale=0 PME- Capabilities: [48] #06 [0000] Capabilities: [4c] Vital Product Data
- 08-31-2007 #4Just Joined!
- Join Date
- Apr 2007
- Posts
- 32
You can get these all details in below mentioned directory:
/sys/bus/pci/devices/aaaa:bb:cc.d
in the above aaaa( 16 bits for domain ) :bb( 8 bit bus): cc( 5+3 device and function bits)
lspci output first field is bb:cc.d generally domain is always 0000
I hope it may helps you
Regards
Ravime
- 08-31-2007 #5Just Joined!
- Join Date
- Jun 2006
- Location
- Krakow, Poland
- Posts
- 5
But this number is changing means it depends where I plug this in (which slot) and it is changing when I change the computer. I am rather looking for a way to get this address with VENDOR_ID and DEVICE_ID like in kernel space.
- 08-31-2007 #6Just Joined!
- Join Date
- Apr 2007
- Posts
- 32
Do you need the address of Vendor ID and device ID why?
yes correct. In the above mentioned directory has many files. They are vendor, device class, irq subdevice, subvendor. open these file look those. the vendor ID sub vendor ID, system ID, subsystem ID and interrupt allotted..
- 06-02-2009 #7Just Joined!
- Join Date
- Apr 2009
- Location
- Chennai
- Posts
- 15
This outb() etc... functions are kernel level function. If u want to use in application, should call ioperm(). This function is used for giving access permission for I/O port from user space.




