From 9ff67879d0d4f2421c376825bf0aa3d7ff924e78 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 12 Feb 2008 10:19:19 +0100 Subject: [PATCH] Introduced API for selection of access methods. Access method names were normalized (they so far served only informational purposes). Each access method gained a help text. --- lib/aix-device.c | 3 ++- lib/dump.c | 1 + lib/fbsd-device.c | 3 ++- lib/i386-ports.c | 6 ++++-- lib/init.c | 22 ++++++++++++++++++++++ lib/internal.h | 1 + lib/nbsd-libpci.c | 3 ++- lib/obsd-device.c | 3 ++- lib/pci.h | 4 ++++ lib/proc.c | 3 ++- lib/sysfs.c | 3 ++- 11 files changed, 44 insertions(+), 8 deletions(-) diff --git a/lib/aix-device.c b/lib/aix-device.c index 2febd79..cb0a974 100644 --- a/lib/aix-device.c +++ b/lib/aix-device.c @@ -259,7 +259,8 @@ aix_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_aix_device = { - "AIX-device", + "aix-device", + "AIX /dev/pci[0-n]", NULL, aix_detect, aix_init, diff --git a/lib/dump.c b/lib/dump.c index 9bf50af..69a99c8 100644 --- a/lib/dump.c +++ b/lib/dump.c @@ -164,6 +164,7 @@ dump_cleanup_dev(struct pci_dev *d) struct pci_methods pm_dump = { "dump", + "Reading of register dumps (set the `dump.name' parameter)", dump_config, dump_detect, dump_init, diff --git a/lib/fbsd-device.c b/lib/fbsd-device.c index 3281906..742c641 100644 --- a/lib/fbsd-device.c +++ b/lib/fbsd-device.c @@ -154,7 +154,8 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_fbsd_device = { - "FreeBSD-device", + "fbsd-device", + "FreeBSD /dev/pci device", fbsd_config, fbsd_detect, fbsd_init, diff --git a/lib/i386-ports.c b/lib/i386-ports.c index 4b51c88..041e47f 100644 --- a/lib/i386-ports.c +++ b/lib/i386-ports.c @@ -253,7 +253,8 @@ conf2_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_intel_conf1 = { - "Intel-conf1", + "intel-conf1", + "Raw I/O port access using Intel conf1 interface", NULL, /* config */ conf1_detect, conf12_init, @@ -267,7 +268,8 @@ struct pci_methods pm_intel_conf1 = { }; struct pci_methods pm_intel_conf2 = { - "Intel-conf2", + "intel-conf2", + "Raw I/O port access using Intel conf2 interface", NULL, /* config */ conf2_detect, conf12_init, diff --git a/lib/init.c b/lib/init.c index 59cb706..be45f81 100644 --- a/lib/init.c +++ b/lib/init.c @@ -123,6 +123,28 @@ pci_null_debug(char *msg UNUSED, ...) { } +int +pci_lookup_method(char *name) +{ + int i; + + for (i=0; iname, name)) + return i; + return -1; +} + +char * +pci_get_method_name(int index) +{ + if (index < 0 || index >= PCI_ACCESS_MAX) + return NULL; + else if (!pci_methods[index]) + return ""; + else + return pci_methods[index]->name; +} + struct pci_access * pci_alloc(void) { diff --git a/lib/internal.h b/lib/internal.h index fea3978..a1dc16f 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -11,6 +11,7 @@ struct pci_methods { char *name; + char *help; void (*config)(struct pci_access *); int (*detect)(struct pci_access *); void (*init)(struct pci_access *); diff --git a/lib/nbsd-libpci.c b/lib/nbsd-libpci.c index 7955570..2d24c4c 100644 --- a/lib/nbsd-libpci.c +++ b/lib/nbsd-libpci.c @@ -141,7 +141,8 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_nbsd_libpci = { - "NetBSD-libpci", + "nbsd-libpci", + "NetBSD libpci", nbsd_config, nbsd_detect, nbsd_init, diff --git a/lib/obsd-device.c b/lib/obsd-device.c index 217e787..62395b3 100644 --- a/lib/obsd-device.c +++ b/lib/obsd-device.c @@ -136,7 +136,8 @@ obsd_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_obsd_device = { - "OpenBSD-device", + "obsd-device", + "/dev/pci on OpenBSD", obsd_config, obsd_detect, obsd_init, diff --git a/lib/pci.h b/lib/pci.h index ce42deb..d2c9ab6 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -81,6 +81,10 @@ void pci_scan_bus(struct pci_access *acc); struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func); /* Raw access to specified device */ void pci_free_dev(struct pci_dev *); +/* Names of access methods */ +int pci_lookup_method(char *name); /* Returns -1 if not found */ +char *pci_get_method_name(int index); /* Returns "" if unavailable, NULL if index out of range */ + /* * Named parameters */ diff --git a/lib/proc.c b/lib/proc.c index 20f5790..1b44b4e 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -187,7 +187,8 @@ proc_cleanup_dev(struct pci_dev *d) } struct pci_methods pm_linux_proc = { - "Linux-proc", + "linux-proc", + "The proc file system on Linux", proc_config, proc_detect, proc_init, diff --git a/lib/sysfs.c b/lib/sysfs.c index 581bedb..ea386fa 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -250,7 +250,8 @@ static void sysfs_cleanup_dev(struct pci_dev *d) } struct pci_methods pm_linux_sysfs = { - "Linux-sysfs", + "linux-sysfs", + "The sys filesystem on Linux", sysfs_config, sysfs_detect, sysfs_init, -- 2.39.2