/ src / core / main.cc
main.cc
  1  /*
  2   * main.cc
  3   *
  4   * this module is shared between the command-line and graphical interfaces of
  5   * lshw (currently, only the text interface is available).
  6   *
  7   * It calls all the defined scans in a certain order that tries to ensure
  8   * that devices are only reported once and that information coming from
  9   * different sources about a given device is kept consistent.
 10   *
 11   * Individual tests can be disabled on the command-line by using the -disable
 12   * option.
 13   * Status is reported during the execution of tests.
 14   *
 15   */
 16  
 17  #include "hw.h"
 18  #include "print.h"
 19  
 20  #include "version.h"
 21  #include "options.h"
 22  #include "mem.h"
 23  #include "dmi.h"
 24  #include "cpuinfo.h"
 25  #include "cpuid.h"
 26  #include "device-tree.h"
 27  #include "pci.h"
 28  #include "pcmcia.h"
 29  #include "pcmcia-legacy.h"
 30  #include "ide.h"
 31  #include "scsi.h"
 32  #include "spd.h"
 33  #include "network.h"
 34  #include "isapnp.h"
 35  #include "pnp.h"
 36  #include "fb.h"
 37  #include "usb.h"
 38  #include "sysfs.h"
 39  #include "display.h"
 40  #include "parisc.h"
 41  #include "cpufreq.h"
 42  #include "ideraid.h"
 43  #include "mounts.h"
 44  #include "virtio.h"
 45  #include "vio.h"
 46  #include "nvme.h"
 47  #include "mmc.h"
 48  #include "input.h"
 49  #include "sound.h"
 50  #include "graphics.h"
 51  #include "smp.h"
 52  #include "abi.h"
 53  #include "s390.h"
 54  
 55  #include <unistd.h>
 56  #include <stdio.h>
 57  
 58  __ID("@(#) $Id$");
 59  
 60  bool scan_system(hwNode & system)
 61  {
 62    char hostname[80];
 63  
 64    if (gethostname(hostname, sizeof(hostname)) == 0)
 65    {
 66      hwNode computer(::enabled("output:sanitize")?"computer":hostname,
 67        hw::system);
 68  
 69      status("DMI");
 70      if (enabled("dmi"))
 71        scan_dmi(computer);
 72      status("SMP");
 73      if (enabled("smp"))
 74        scan_smp(computer);
 75      status("PA-RISC");
 76      if (enabled("parisc"))
 77        scan_parisc(computer);
 78      status("device-tree");
 79      if (enabled("device-tree"))
 80        scan_device_tree(computer);
 81      status("SPD");
 82      if (enabled("spd"))
 83        scan_spd(computer);
 84      status("memory");
 85      if (enabled("memory"))
 86        scan_memory(computer);
 87      status("/proc/cpuinfo");
 88      if (enabled("cpuinfo"))
 89        scan_cpuinfo(computer);
 90      status("CPUID");
 91      if (enabled("cpuid"))
 92        scan_cpuid(computer);
 93      status("PCI (sysfs)");
 94      if (enabled("pci"))
 95      {
 96        if(!scan_pci(computer))
 97        {
 98          if (enabled("pcilegacy"))
 99            scan_pci_legacy(computer);
100        }
101      }
102      else
103      {
104        status("PCI (legacy)");
105        if (enabled("pcilegacy"))
106          scan_pci_legacy(computer);
107      }
108      status("ISA PnP");
109      if (enabled("isapnp"))
110        scan_isapnp(computer);
111      status("PnP (sysfs)");
112      if (enabled("pnp"))
113        scan_pnp(computer);
114      status("PCMCIA");
115      if (enabled("pcmcia"))
116        scan_pcmcia(computer);
117      status("PCMCIA");
118      if (enabled("pcmcia-legacy"))
119        scan_pcmcialegacy(computer);
120      status("Virtual I/O (VIRTIO) devices");
121      if (enabled("virtio"))
122        scan_virtio(computer);
123      status("IBM Virtual I/O (VIO)");
124      if (enabled("vio"))
125        scan_vio(computer);
126      status("kernel device tree (sysfs)");
127      if (enabled("sysfs"))
128        scan_sysfs(computer);
129      status("USB");
130      if (enabled("usb"))
131        scan_usb(computer);
132      status("IDE");
133      if (enabled("ide"))
134        scan_ide(computer);
135      if (enabled("ideraid"))
136        scan_ideraid(computer);
137      status("SCSI");
138      if (enabled("scsi"))
139        scan_scsi(computer);
140      status("NVMe");
141      if (enabled("nvme"))
142        scan_nvme(computer);
143      status("MMC");
144      if (enabled("mmc"))
145        scan_mmc(computer);
146      status("sound");
147      if (enabled("sound"))
148        scan_sound(computer);
149      status("graphics");
150      if (enabled("graphics"))
151        scan_graphics(computer);
152      status("input");
153      if (enabled("input"))
154        scan_input(computer);
155      status("S/390 devices");
156      if (enabled("s390"))
157        scan_s390_devices(computer);
158      if (enabled("mounts"))
159        scan_mounts(computer);
160      status("Network interfaces");
161      if (enabled("network"))
162        scan_network(computer);
163      status("Framebuffer devices");
164      if (enabled("fb"))
165        scan_fb(computer);
166      status("Display");
167      if (enabled("display"))
168        scan_display(computer);
169      status("CPUFreq");
170      if (enabled("cpufreq"))
171        scan_cpufreq(computer);
172      status("ABI");
173      if (enabled("abi"))
174        scan_abi(computer);
175      status("");
176  
177      if (computer.getDescription() == "")
178        computer.setDescription("Computer");
179      computer.assignPhysIds();
180      computer.fixInconsistencies();
181  
182      system = computer;
183    }
184    else
185      return false;
186  
187    return true;
188  }