summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--libldetect.h1
-rw-r--r--pci.c20
3 files changed, 22 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 93f386d..e14a5d4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- add new API for drakx's stage1 in order to find unknown PCI devices
- don't exit(1) on systems without pci (eg: ARM) (rtp)
Version 0.11.1 - 1 December 2009, Thierry Vignaud
diff --git a/libldetect.h b/libldetect.h
index 7c02ae2..339e422 100644
--- a/libldetect.h
+++ b/libldetect.h
@@ -43,6 +43,7 @@ extern void pciusb_free(struct pciusb_entries *entries);
extern struct pciusb_entries pci_probe(void);
extern const char *pci_class2text(unsigned long class_id);
extern char *proc_pci_path;
+extern char *get_pci_description(int vendor_id, int device_id);
/******************************************************************************/
/* usb ************************************************************************/
diff --git a/pci.c b/pci.c
index dda2866..370cb9c 100644
--- a/pci.c
+++ b/pci.c
@@ -29,6 +29,26 @@ static void __attribute__((noreturn)) error_and_die(char *msg, ...)
exit(1);
}
+static struct pci_access *pacc;
+char* get_pci_description(int vendor_id, int device_id) {
+ char vendorbuf[128], devbuf[128];
+ char *buf = malloc(256);
+
+ if (!pacc) {
+ pacc = pci_alloc();
+ pci_init(pacc); /* Initialize the PCI library */
+ pacc->numeric_ids = 0;
+ pci_init(pacc);
+ }
+
+ asprintf(&buf, "%s|%s",
+ pci_lookup_name(pacc, vendorbuf, sizeof(vendorbuf), PCI_LOOKUP_VENDOR | PCI_LOOKUP_NO_NUMBERS, vendor_id, device_id),
+ pci_lookup_name(pacc, devbuf, sizeof(devbuf), PCI_LOOKUP_DEVICE, vendor_id, device_id)
+ );
+ //pci_cleanup(pacc); // only used by stage1's merge-pcitable.pl that doesn't care about leaking _one_ struct
+ return buf;
+}
+
extern struct pciusb_entries pci_probe(void) {
u8 buf[CONFIG_SPACE_SIZE];
struct pciusb_entries r;