[flashrom] [PATCH RFC] Access PCI BARs through sysfs

Ed Swierk eswierk at skyportsystems.com
Thu Feb 26 22:53:13 CET 2015


On Thu, Feb 26, 2015 at 4:10 AM, Patrick Georgi <pgeorgi at google.com> wrote:
> 2015-02-26 1:57 GMT+01:00 Ed Swierk <eswierk at skyportsystems.com>:
>> Running flashrom on a Linux system with CONFIG_STRICT_DEVMEM=y, I can now
>> successfully program the SPI flash on an Intel 10G NIC using the
>
>> +#if !defined(__DJGPP__) && !defined(__LIBPAYLOAD__)
>> +static void *pcidev_mapbar_sysfs(struct pci_dev *dev, const char *descr, int bar, off_t offset, size_t length)
> Isn't that actually Linux specific, instead of non-djgpp-or-libpayload specific?

I suppose that's a safe assumption, though I don't know much about any
of the other platforms flashrom supports. libpci already figures out
whether the platform supports sysfs. I piggyback off that logic by
checking pacc->method.

Here we're just deciding whether the platform uses mmap() to access
physical address space. I followed the same approach used in
physmap.c, since pcidev_mapbar_sysfs() is doing the same thing as
sys_physmap_rw_uncached(), just with a PCI resource file instead of
/dev/mem.

But I can switch to #if IS_LINUX if you think that's clearer. We can
revisit that if and when some other sprouts a similar mmapped sysfs
interface to PCI resources.

--Ed




More information about the flashrom mailing list