From mboxrd@z Thu Jan 1 00:00:00 1970 From: bjorn@mork.no (=?utf-8?Q?Bj=C3=B8rn_Mork?=) Date: Fri, 24 Apr 2015 10:45:00 +0200 Subject: How to read write PCI BAR memory address In-Reply-To: (Anil Joshi's message of "Fri, 24 Apr 2015 11:32:56 +0530") References: Message-ID: <87wq11lxtf.fsf@nemi.mork.no> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Anil Joshi writes: > My PCI device information is as follows: > > Print Begin Configuration space... > BAR 0 start address: f6000000 > BAR 0 end address: f6ffffff > BAR 0 flags: 140204 > BAR 0 IO / MEM: MEM > BAR 0 PREFETCH NON PREFETCH: NON-PREFETCH > BAR 1 start address: 0 > BAR 1 end address: 0 > BAR 1 flags: 0 > BAR 1 IO / MEM: MEM > BAR 1 PREFETCH NON PREFETCH: NON-PREFETCH > BAR 2 start address: f0000000 > BAR 2 end address: f3ffffff > BAR 2 flags: 14220c > BAR 2 IO / MEM: MEM > BAR 2 PREFETCH NON PREFETCH: PREFETCH > > I want to write a byte and read it back to BAR2 for a test simple . Is it > possible to write a byte to BAR2 start address > > > Sample code is welcomed. Linux export these resourses in sysfs. See See https://www.kernel.org/doc/Documentation/filesystems/sysfs-pci.txt Googling for these will get you some usage examples, like this one: http://billfarrow.blogspot.com/2010/09/userspace-access-to-pci-memory.html Bj?rn