pci util cpp library

Patrick Venture venture at google.com
Tue May 7 00:35:44 AEST 2019


On Sun, May 5, 2019 at 10:02 PM William Kennington <wak at google.com> wrote:
>
> Worth noting that lspci just uses the libpci library provided by
> pciutils. I would try and use that before parsing lspci.
> https://github.com/pciutils/pciutils/blob/master/example.c

I ended up building in libpci and just calling the C methods from c++.
I preferred a single linking/calling environment, hence, cpp, but it
works fine so far.  Sorry, forgot to reply to this call-for-help.

>
> On Sun, May 5, 2019 at 8:32 PM Andrew Jeffery <andrew at aj.id.au> wrote:
> >
> >
> >
> > On Sat, 4 May 2019, at 02:28, Patrick Venture wrote:
> > > Does anyone have a favorite CPP library for talking to PCI?  I don't
> > > think parsing lspci output is as clean.
> >
> > This feels a lot like the X-Y problem:
> >
> > https://mywiki.wooledge.org/XyProblem
> >
> > What are you actually trying to do?

Parse the PCI devices on a system to find a PCI device and then read
its configuration space, and write to a memory-mapped region. -- Which
is exactly what a library talking to PCI would do.  In this case,
there is a C one that works perfectly well for what I need.

> >
> > Maybe poking at sysfs directly might help?

No need, libpci (pciutils) handles the poking and provides convenient
methods for reading the information required.

> >
> > Andrew
> >
> > >
> > > Patrick
> > >


More information about the openbmc mailing list