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...@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.
pgpbgXWizbU8G.pgp
Description: PGP signature