export
-all: lib/$(PCILIB) lspci setpci lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
+all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
lib/$(PCILIB): $(PCIINC) force
$(MAKE) -C lib all
sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
chmod +x $@
+# The example of use of libpci
+example: example.o lib/$(PCILIB)
+example.o: example.c $(PCIINC)
+
%: %.o
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
clean:
rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
- rm -f update-pciids lspci setpci lib/config.* lib/example *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
+ rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
rm -rf maint/dist
distclean: clean
So far, there is only a little documentation for the library except for the
general introduction in the pcilib(7) man page. If you want to use the
library in your programs, please follow the comments in lib/pci.h and in
-the example program lib/example.c.
+the example program example.c.
6. Feedback
--- /dev/null
+/*
+ * The PCI Library -- Example of use (simplistic lister of PCI devices)
+ *
+ * Written by Martin Mares and put to public domain. You can do
+ * with it anything you want, but I don't give you any warranty.
+ */
+
+#include <stdio.h>
+
+#include "lib/pci.h"
+
+int main(void)
+{
+ struct pci_access *pacc;
+ struct pci_dev *dev;
+ unsigned int c;
+
+ pacc = pci_alloc(); /* Get the pci_access structure */
+ /* Set all options you want -- here we stick with the defaults */
+ pci_init(pacc); /* Initialize the PCI library */
+ pci_scan_bus(pacc); /* We want to get the list of devices */
+ for(dev=pacc->devices; dev; dev=dev->next) /* Iterate over all devices */
+ {
+ pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS); /* Fill in header info we need */
+ c = pci_read_byte(dev, PCI_INTERRUPT_PIN); /* Read config register directly */
+ printf("%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d (pin %d) base0=%lx\n",
+ dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id,
+ dev->device_class, dev->irq, c, dev->base_addr[0]);
+ }
+ pci_cleanup(pacc); /* Close everything */
+ return 0;
+}
names-parse.o: names-parse.c $(INCL) names.h
filter.o: filter.c $(INCL)
nbsd-libpci.o: nbsd-libpci.c $(INCL)
-
-example: example.c $(PCILIB)
+++ /dev/null
-/*
- * The PCI Library -- Example of use (simplistic lister of PCI devices)
- *
- * Written by Martin Mares and put to public domain. You can do
- * with it anything you want, but I don't give you any warranty.
- */
-
-#include <stdio.h>
-
-#include "pci.h"
-
-int main(void)
-{
- struct pci_access *pacc;
- struct pci_dev *dev;
- unsigned int c;
-
- pacc = pci_alloc(); /* Get the pci_access structure */
- /* Set all options you want -- here we stick with the defaults */
- pci_init(pacc); /* Initialize the PCI library */
- pci_scan_bus(pacc); /* We want to get the list of devices */
- for(dev=pacc->devices; dev; dev=dev->next) /* Iterate over all devices */
- {
- pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS); /* Fill in header info we need */
- c = pci_read_byte(dev, PCI_INTERRUPT_PIN); /* Read config register directly */
- printf("%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d (pin %d) base0=%lx\n",
- dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id,
- dev->device_class, dev->irq, c, dev->base_addr[0]);
- }
- pci_cleanup(pacc); /* Close everything */
- return 0;
-}