Blame view

RIOT/sys/shell/commands/sc_x86_lspci.c 2.08 KB
fb11e647   vrobic   reseau statique a...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  /*
   * Copyright (C) 2014  René Kijewski  <rene.kijewski@fu-berlin.de>
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   */
  
  /**
   * @ingroup     sys_shell_commands
   * @{
   *
   * @file
   * @brief       List PCI devices
   *
   * @author      René Kijewski <rene.kijewski@fu-berlin.de>
   *
   * @}
   */
  
  #include "x86_pci.h"
  #include "x86_pci_strings.h"
  
  #include <stdio.h>
  
  extern int _x86_lspci(int argc, char **argv)
  {
      (void) argc;
      (void) argv;
  
      unsigned index = 0;
      while (1) {
          const char *baseclass_name, *subclass_name, *vendor_name, *device_name;
  
          const x86_known_pci_device_t *d = x86_enumerate_pci_devices(&index);
          if (!d) {
              break;
          }
  
          subclass_name = x86_pci_subclass_to_string(d->class.baseclass,
                                                     d->class.subclass,
                                                     d->class.programming_interface,
                                                     &baseclass_name);
          vendor_name = x86_pci_device_id_to_string(d->vendor.vendor_id,
                                                    d->vendor.device_id,
                                                    &device_name);
          printf("%02x:%02x.%x \"%s\": \"%s\" (%s: %s, rev: %02hhx)\n",
                 d->bus, d->dev, d->fun,
                 vendor_name, device_name,
                 baseclass_name, subclass_name, d->class.revision_id);
      }
  
      return 0;
  }