Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4300 | trochtova | 1 | /* |
2 | * HelenOS PCI driver. |
||
3 | * |
||
4 | * (Based on public domain libpci example.c written by Martin Mares.) |
||
5 | * Copyright (c) 2006 Jakub Jermar |
||
6 | * |
||
7 | * Can be freely distributed and used under the terms of the GNU GPL. |
||
8 | */ |
||
9 | |||
10 | /** |
||
11 | * @addtogroup pci |
||
12 | * @{ |
||
13 | */ |
||
14 | |||
15 | #include <stdio.h> |
||
16 | #include <ddi.h> |
||
17 | #include <task.h> |
||
18 | #include <stdlib.h> |
||
19 | #include <errno.h> |
||
20 | |||
21 | #include "libpci/pci.h" |
||
22 | |||
23 | #define NAME "PCI" |
||
24 | |||
25 | static struct pci_access *pacc; |
||
26 | |||
27 | int main(int argc, char *argv[]) |
||
28 | { |
||
29 | struct pci_dev *dev; |
||
30 | unsigned int c; |
||
31 | char buf[80]; |
||
32 | |||
33 | pacc = pci_alloc(); /* Get the pci_access structure */ |
||
34 | pci_init(pacc); /* Initialize the PCI library */ |
||
35 | pci_scan_bus(pacc); /* We want to get the list of devices */ |
||
36 | for(dev=pacc->devices; dev; dev=dev->next) { /* Iterate over all devices */ |
||
37 | pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_IRQ); |
||
38 | c = pci_read_word(dev, PCI_CLASS_DEVICE); /* Read config register directly */ |
||
39 | printf("%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d base0=%lx\n", |
||
40 | dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id, |
||
41 | c, dev->irq, dev->base_addr[0]); |
||
42 | printf("\t%s\n", pci_lookup_name(pacc, buf, sizeof(buf), PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, |
||
43 | dev->vendor_id, dev->device_id)); |
||
44 | } |
||
45 | |||
46 | pci_cleanup(pacc); |
||
47 | return 0; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @} |
||
52 | */ |