source: mainline/uspace/app/lspci/pci.c@ 892e4e1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 892e4e1 was cb0ea39, checked in by Lenka Trochtova <trochtova.lenka@…>, 16 years ago

dd: initial import of the original svn branch

  • Property mode set to 100644
File size: 1.3 KB
Line 
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
25static struct pci_access *pacc;
26
27int 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 */
Note: See TracBrowser for help on using the repository browser.