C library to extract the Linux system filehandle paths of PCI device BARs based on vendor and device id.
git clone https://github.com/andkae/pciinfo.git
The Makefile builds the repository:
$ make
gcc -c -O -Wall -Wextra -Wimplicit -Wconversion -I . ./pciinfo_main.c -o ./bin/pciinfo_main.o
gcc -c -O -Wall -Wextra -Wimplicit -Wconversion -I . ./pciinfo.c -o ./bin/pciinfo.o
gcc ./bin/pciinfo_main.o ./bin/pciinfo.o -Wall -Wextra -I. -lm -o ./bin/pciinfo_main
The library part itself can be built with:
gcc -c -O -Wall -Wextra -Wimplicit -Wconversion -I . ./pciinfo.c -o ./bin/pciinfo.o
To enable the debug printf
add the compile switch -DPCIINFO_PRINTF_EN
to the gcc call.
Finds the PCI device memory mapped file paths based on a given vendor and device id.
int pciinfoFind(const char vendorID[], const char deviceID[], char devicePath[], uint32_t devicePathMax)
Acquires bar sizes from os.
int pciinfoBarSize(const char sysPathPciDev[], uint32_t byteSize[]);
Extracts from Linux path to memory mapped file of PCI bar.
int pciinfoBarPath(const char vendorID[], const char deviceID[], uint8_t bar, char devicePath[], uint32_t devicePathMax);
Gets the PCI bar assigned physical addresses.
int pciinfoBarPhyAddr(const char sysPathPciDev[], uint8_t barNo, uint32_t *barPhyAddr);