pci util cpp library
Patrick Venture
venture at google.com
Tue May 7 00:58:07 AEST 2019
On Mon, May 6, 2019 at 7:35 AM Patrick Venture <venture at google.com> wrote:
>
> 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.
This is the code I wrote leveraging this library:
https://gerrit.openbmc-project.xyz/21158
https://gerrit.openbmc-project.xyz/21168
Not perfect, but it's nice enough and does exactly what I want without
really much overhead. So, I'm happy with the outcome.
I hadn't seen a write-up the of the x-y problem before. That's neat
to see like a formal description. So often, the first question I ask
of someone is -- "what is your end goal?"
>
> > >
> > > 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