PCI BAR mmap

Artem Belevich artemb at gmail.com
Tue Jul 31 17:15:29 UTC 2012


On Tue, Jul 31, 2012 at 5:48 AM, Venkat Duvvuru
<venkatduvvuru.ml at gmail.com> wrote:
> Hi,
> How to mmap PCI  BARs from userland in freebsd?
> In Linux the PCI BAR appears as a file in the sysfs file system. How can I
> access PCI BAR as a file in freebsd to mmap it?

It's a bit of a hack, but if you are root, you can access physical
memory via /dev/mem.

memfd = open(/dev/mem)
ptr = mmap(NULL, bar_size, PROT_READ, 0, memfd, bar_address);

You can even use dd:

dd if=/dev/mem bs=4k skip=<BAR_ADDRESS/4k> count=<BAR_SIZE/4k> of=bar.dump

--Artem


More information about the freebsd-net mailing list