Thread: How to access a PCIe device's BAR from user space?

  1. #1
    Registered User
    Join Date
    May 2013

    How to access a PCIe device's BAR from user space?

    I have a PCIe device and I read its BAR through setpci. Now suppose I want to access this address space.
    To my best understanding, this address space is a physical address space, and thus can not be accessed through user-space processes (having the ability to read/write from/to virtual addresses).
    Is there an easy way in which I can read/write from/to a device's BAR?
    Either by using a tool or by writing a simple C program.


  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    This link may be of use to you:
    Access physical memory in Linux | FalsinSoft
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Apr 2015
    Bangalore, Karnataka, India
    I really don't think that any user application will be allowed to WRITE into PCI address space.
    If you want to do so, then you have to add IOCTL functionalities in the particular device's driver.

    Meanwhile I guess lspci(8) will help you out READING PCI BAR details for you:
    lspci(8): all PCI devices - Linux man page
    Last edited by; 02-19-2016 at 11:13 AM. Reason: Better look

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. user space control for device driver
    By itisravi in forum Linux Programming
    Replies: 5
    Last Post: 03-02-2010, 02:17 PM
  2. free space on unknow device
    By hallo007 in forum C Programming
    Replies: 1
    Last Post: 12-27-2009, 07:16 PM
  3. Replies: 8
    Last Post: 07-03-2009, 11:20 AM
  4. Fatal error: No space left on device
    By Queatrix in forum C++ Programming
    Replies: 1
    Last Post: 07-03-2006, 08:54 AM