diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | vbetool.c | 42 |
2 files changed, 22 insertions, 22 deletions
diff --git a/Makefile.am b/Makefile.am index 7060c25..4d7c949 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ sbin_PROGRAMS = vbetool -vbetool_LDADD = $(libdir)/libpci.a $(LIBX86_LIBS) -lz +vbetool_LDADD = $(LIBX86_LIBS) -lpciaccess -lz vbetool_CFLAGS = $(LIBX86_CFLAGS) vbetool_SOURCES = vbetool.c noinst_HEADERS = vbetool.h @@ -11,7 +11,7 @@ version 2 #include <sys/mman.h> #include <libx86.h> -#include <pci/pci.h> +#include <pciaccess.h> #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -38,8 +38,6 @@ version 2 #define DPMS_STATE_OFF 0x0400 #define DPMS_STATE_LOW 0x0800 -static struct pci_access *pacc; - int vbetool_init (void) { if (!LRMI_init()) { fprintf(stderr, "Failed to initialise LRMI (Linux Real-Mode Interface).\n"); @@ -48,9 +46,7 @@ int vbetool_init (void) { iopl(3); - pacc = pci_alloc(); - pacc->numeric_ids = 1; - pci_init(pacc); + pci_system_init(); return 0; } @@ -222,25 +218,29 @@ int do_real_post(unsigned pci_device) int do_post(void) { - struct pci_dev *p; - unsigned int c; - unsigned int pci_id; int error; + struct pci_id_match dev_match = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + (0x03 << 16), 0xff000, 0 }; + struct pci_device *dev; + struct pci_device_iterator *iter; + unsigned pci_id; + + iter = pci_id_match_iterator_create(&dev_match); + if (iter == NULL) { + return 1; + } - pci_scan_bus(pacc); - - for (p = pacc->devices; p; p = p->next) { - c = pci_read_word(p, PCI_CLASS_DEVICE); - if (c == 0x300) { - pci_id = - (p->bus << 8) + (p->dev << 3) + - (p->func & 0x7); - error = do_real_post(pci_id); - if (error != 0) { - return error; - } + while ((dev = pci_device_next(iter)) != NULL) { + pci_id = (dev->bus << 8) + (dev->dev << 3) + + (dev->func & 0x7); + + error = do_real_post(pci_id); + if (error != 0) { + return error; } } + pci_iterator_destroy(iter); return 0; } |