Date: Tue, 31 Jul 2012 20:41:01 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Artem Belevich <artemb@gmail.com> Cc: freebsd-net@freebsd.org, Venkat Duvvuru <venkatduvvuru.ml@gmail.com> Subject: Re: PCI BAR mmap Message-ID: <20120731174101.GE2676@deviant.kiev.zoral.com.ua> In-Reply-To: <CAFqOu6g%2BTypQngY6tyeFigPZahixL1QGTiwaEwABqDyMWA-3uw@mail.gmail.com> References: <CAGdae7a0xuKnFaeOTUykLcUKuCf17TTuYD_MuG4t7FKbHNoqAg@mail.gmail.com> <CAFqOu6g%2BTypQngY6tyeFigPZahixL1QGTiwaEwABqDyMWA-3uw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Lf5N93S3uGY/b6lN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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@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 ca= n I > > access PCI BAR as a file in freebsd to mmap it? >=20 > It's a bit of a hack, but if you are root, you can access physical > memory via /dev/mem. >=20 > memfd =3D open(/dev/mem) > ptr =3D mmap(NULL, bar_size, PROT_READ, 0, memfd, bar_address); >=20 > You can even use dd: >=20 > dd if=3D/dev/mem bs=3D4k skip=3D<BAR_ADDRESS/4k> count=3D<BAR_SIZE/4k> of= =3Dbar.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. --Lf5N93S3uGY/b6lN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlAYGK0ACgkQC3+MBN1Mb4iH9ACgoTJJhSV/GWg6sFqtIoSNlWU8 7MYAoJ0M0yK2K2how1jdmkO8O16lqfbH =LpXT -----END PGP SIGNATURE----- --Lf5N93S3uGY/b6lN--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120731174101.GE2676>