Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jul 2012 10:15:22 -0700
From:      Artem Belevich <artemb@gmail.com>
To:        Venkat Duvvuru <venkatduvvuru.ml@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: PCI BAR mmap
Message-ID:  <CAFqOu6g%2BTypQngY6tyeFigPZahixL1QGTiwaEwABqDyMWA-3uw@mail.gmail.com>
In-Reply-To: <CAGdae7a0xuKnFaeOTUykLcUKuCf17TTuYD_MuG4t7FKbHNoqAg@mail.gmail.com>
References:  <CAGdae7a0xuKnFaeOTUykLcUKuCf17TTuYD_MuG4t7FKbHNoqAg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFqOu6g%2BTypQngY6tyeFigPZahixL1QGTiwaEwABqDyMWA-3uw>