PCI BAR mmap
Konstantin Belousov
kostikbel at gmail.com
Tue Jul 31 17:41:05 UTC 2012
On Tue, Jul 31, 2012 at 10:15:22AM -0700, Artem Belevich wrote:
> 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
This probably only works on x86, only for memory BARs, and only if BAR
is already activated. But yes, I did grabbed scanouts (i.e. screen) on
Intel GPUs this way.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20120731/a51e9a9c/attachment.pgp
More information about the freebsd-net
mailing list