Back to index

lshw  02.16
Functions
pcmcia-legacy.h File Reference
#include "hw.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool scan_pcmcialegacy (hwNode &n)

Function Documentation

bool scan_pcmcialegacy ( hwNode n)

Definition at line 1050 of file pcmcia-legacy.cc.

{
  int fd[MAX_SOCK];
  int major = lookup_dev("pcmcia");
  unsigned int sockets = 0;
  unsigned int i;
  vector < string > stab;

  if (major < 0)                                  // pcmcia support not loaded, there isn't much
    return false;                                 // we can do

  memset(fd, 0, sizeof(fd));
  for (i = 0; i < MAX_SOCK; i++)
  {
    fd[i] = open_dev((dev_t) ((major << 8) + i));

    if (fd[i] >= 0)
    {
      hwNode *parent = find_pcmciaparent(i, n);
      cs_status_t status;
      if (i >= sockets)
        sockets = i + 1;

// check that slot is populated
      memset(&status, 0, sizeof(status));
      status.Function = 0;

      ioctl(fd[i], DS_GET_STATUS, &status);
      if (status.CardState & CS_EVENT_CARD_DETECT)
      {
        if (parent)
          pcmcia_ident(i, fd[i], parent);
        else
          pcmcia_ident(i, fd[i], &n);
      }
    }
    else
      break;
  }

  for (unsigned int j = 0; j < sockets; j++)
  {
    close(fd[j]);
  }

  if (loadfile(VARLIBPCMCIASTAB, stab))
  {
    string socketname = "";
    string carddescription = "";

    for (i = 0; i < stab.size(); i++)
    {
      if (stab[i][0] == 'S')
      {
        string::size_type pos = stab[i].find(':');

        socketname = "";
        carddescription = "";

        if (pos != string::npos)
        {
          socketname = stab[i].substr(0, pos);
          carddescription = stab[i].substr(pos + 1);
        }
        else
        {
          carddescription = stab[i];
          socketname = "";
        }
      }
      else
      {
        int cnt = 0;
        int unused = 0;
        int socket = -1, devmajor = 0, devminor = 0;
        char devclass[20], driver[20], logicalname[20];

        memset(devclass, 0, sizeof(devclass));
        memset(driver, 0, sizeof(driver));
        memset(logicalname, 0, sizeof(logicalname));

        cnt = sscanf(stab[i].c_str(),
          "%d %s %s %d %s %d %d",
          &socket, devclass, driver, &unused, logicalname,
          &devmajor, &devminor);

        if ((cnt == 7) || (cnt == 5))             // we found a correct entry
        {
          string devclassstr = string(devclass);
          hwNode *parent = n.findChildByHandle(pcmcia_handle(socket));

          if (socket >= (int) sockets)
            sockets = socket + 1;

          hwNode device = hwNode(devclass, hw::generic);

          if (devclassstr == "serial")
            device = hwNode(devclass, hw::communication);
          else if (devclassstr == "ide")
            device = hwNode(devclass, hw::storage);
          else if (devclassstr == "memory")
            device = hwNode(devclass, hw::memory);
          else if (devclassstr == "network")
            device = hwNode(devclass, hw::network);

          device.setLogicalName(logicalname);
          device.setConfig("driver", driver);
          device.claim();

          if (!parent)
          {
            parent = find_pcmciaparent(socket, n);

            if (parent)
            {
              hwNode *realparent = parent->getChild(0);
              if (!realparent)
              {
                parent = parent->addChild(hwNode("pccard"));
                parent->setHandle(pcmcia_handle(socket));
              }
              else
                parent = realparent;
            }
          }

          if (parent)
          {
            parent->setSlot(socketname);
            if (parent->getDescription() == "")
              parent->setDescription(carddescription);
            parent->addChild(device);
          }
          else
            n.addChild(device);
        }
      }
    }
  }

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function: