Back to index

lshw  02.16
Classes | Defines | Typedefs | Functions | Variables File Reference
#include "version.h"
#include "cpuinfo.h"
#include "osutils.h"
#include "cdrom.h"
#include "disk.h"
#include "heuristics.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <endian.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <ctype.h>
#include <vector>
#include <linux/hdreg.h>
#include <regex.h>

Go to the source code of this file.


struct  TAG_TW_Ioctl
struct  TAG_TW_SG_Entry
struct  TAG_TW_Passthru
struct  TW_Command
struct  TAG_TW_New_Ioctl
struct  TAG_TW_Passthru.byte0
struct  TAG_TW_Passthru.byte3
struct  TW_Command.byte0
struct  TW_Command.byte3
union  TW_Command.byte6
union  TW_Command.byte8
struct  TW_Command.byte8.param
struct  TW_Command.byte8.init_connection
struct  TW_Command.byte8.ioctl_miniport_version


#define DEV_TWE   "/dev/twe"
#define IORDY_SUP   0x0800 /* 1=support; 0=may be supported */
#define IORDY_OFF   0x0400 /* 1=may be disabled */
#define LBA_SUP   0x0200 /* 1=Logical Block Address support */
#define DMA_SUP   0x0100 /* 1=Direct Memory Access support */
#define DMA_IL_SUP   0x8000 /* 1=interleaved DMA support (ATAPI) */
#define CMD_Q_SUP   0x4000 /* 1=command queuing support (ATAPI) */
#define OVLP_SUP   0x2000 /* 1=overlap operation support (ATAPI) */
#define GEN_CONFIG   0 /* general configuration */
#define CD_ROM   5
#define NOT_ATA   0x8000
#define NOT_ATAPI   0x4000 /* (check only if bit 15 == 1) */
#define EQPT_TYPE   0x1f00
#define command_set_1   command_sets
#define command_set_2   word83
#define hw_config   word93
#define ATA_SMART_CMD   0xb0
#define ATA_IDENTIFY_DEVICE   0xec
#define TW_OP_ATA_PASSTHRU   0x11
#define TW_CMD_PACKET_WITH_DATA   0x1f
#define TW_MAX_SGL_LENGTH   62
#define TW_IOCTL_BUFFER_SIZE   sizeof(TW_Ioctl)
#define TW_ATA_PASS_SGL_MAX   60


typedef struct TAG_TW_Ioctl TW_Ioctl
typedef struct TAG_TW_SG_Entry TW_SG_Entry
typedef struct TAG_TW_Passthru TW_Passthru
typedef struct TW_Command TW_Command
typedef struct TAG_TW_New_Ioctl TW_New_Ioctl


 __ID ("@(#) $Id: 2433 2012-01-10 22:01:30Z lyonel $")
static void fix_string (unsigned char *s, unsigned len)
static bool guess_manufacturer (hwNode &device)
static bool probe_port (unsigned controller, unsigned disknum, hwNode &parent)
bool scan_ideraid (hwNode &n)


static const char * description []
static const char * manufacturers []

Class Documentation

struct TAG_TW_Ioctl

Definition at line 99 of file

Class Members
unsigned char cdb
unsigned char input_data
int input_length
unsigned char opcode
unsigned char output_data
int output_length
unsigned char packing
unsigned char parameter_id
unsigned char parameter_size_bytes
unsigned short table_id
unsigned char unit_index
struct TAG_TW_SG_Entry

Definition at line 127 of file

Class Members
unsigned int address
unsigned int length
struct TAG_TW_Passthru

Definition at line 140 of file

Collaboration diagram for TAG_TW_Passthru:
Class Members
struct TAG_TW_Passthru byte0
struct TAG_TW_Passthru byte3
unsigned char command
unsigned short cylinder_hi
unsigned short cylinder_lo
unsigned char drive_head
unsigned short features
unsigned char flags
unsigned char padding
unsigned short param
unsigned char request_id
unsigned short sector_count
unsigned short sector_num
TW_SG_Entry sg_list
unsigned char size
unsigned char status
struct TW_Command

Definition at line 166 of file

Class Members
struct TW_Command byte0
struct TW_Command byte3
union TW_Command byte6
union TW_Command byte8
unsigned char flags
unsigned char request_id
unsigned char size
unsigned char status
struct TAG_TW_New_Ioctl

Definition at line 206 of file

Collaboration diagram for TAG_TW_New_Ioctl:
Class Members
unsigned char data_buffer
unsigned int data_buffer_length
TW_Command firmware_command
unsigned char padding
struct TAG_TW_Passthru.byte0

Definition at line 141 of file

Class Members
unsigned char opcode:5
unsigned char sgloff:3
struct TAG_TW_Passthru.byte3

Definition at line 147 of file

Class Members
unsigned char aport:4
unsigned char host_id:4
struct TW_Command.byte0

Definition at line 168 of file

Class Members
unsigned char opcode:5
unsigned char sgl_offset:3
struct TW_Command.byte3

Definition at line 174 of file

Class Members
unsigned char host_id:4
unsigned char unit:4
union TW_Command.byte6

Definition at line 181 of file

Class Members
unsigned short block_count
unsigned short message_credits
unsigned short parameter_count
union TW_Command.byte8

Definition at line 186 of file

Class Members
byte8 init_connection
byte8 io
byte8 ioctl_miniport_version
byte8 param

Definition at line 187 of file

Class Members
uint32_t lba
uint32_t padding
TW_SG_Entry sgl
struct TW_Command.byte8.param

Definition at line 192 of file

Class Members
uint32_t padding
TW_SG_Entry sgl
struct TW_Command.byte8.init_connection

Definition at line 196 of file

Class Members
uint32_t padding
uint32_t response_queue_pointer
struct TW_Command.byte8.ioctl_miniport_version

Definition at line 200 of file

Class Members
char version

Define Documentation

#define ATA_IDENTIFY_DEVICE   0xec

Definition at line 90 of file

#define ATA_SMART_CMD   0xb0

Definition at line 89 of file

#define CD_ROM   5

Definition at line 40 of file

#define CMD_Q_SUP   0x4000 /* 1=command queuing support (ATAPI) */

Definition at line 36 of file

#define command_set_1   command_sets

Definition at line 83 of file

#define command_set_2   word83

Definition at line 84 of file

#define DEV_TWE   "/dev/twe"

Definition at line 29 of file

#define DMA_IL_SUP   0x8000 /* 1=interleaved DMA support (ATAPI) */

Definition at line 35 of file

#define DMA_SUP   0x0100 /* 1=Direct Memory Access support */

Definition at line 34 of file

#define EQPT_TYPE   0x1f00

Definition at line 43 of file

#define GEN_CONFIG   0 /* general configuration */

Definition at line 39 of file

#define hw_config   word93

Definition at line 85 of file

#define IORDY_OFF   0x0400 /* 1=may be disabled */

Definition at line 32 of file

#define IORDY_SUP   0x0800 /* 1=support; 0=may be supported */

Definition at line 31 of file

#define LBA_SUP   0x0200 /* 1=Logical Block Address support */

Definition at line 33 of file

#define NOT_ATA   0x8000

Definition at line 41 of file

#define NOT_ATAPI   0x4000 /* (check only if bit 15 == 1) */

Definition at line 42 of file

#define OVLP_SUP   0x2000 /* 1=overlap operation support (ATAPI) */

Definition at line 37 of file

#define TW_ATA_PASS_SGL_MAX   60

Definition at line 138 of file

#define TW_CMD_PACKET_WITH_DATA   0x1f

Definition at line 95 of file

#define TW_IOCTL_BUFFER_SIZE   sizeof(TW_Ioctl)

Definition at line 123 of file


Definition at line 94 of file

#define TW_MAX_SGL_LENGTH   62

Definition at line 97 of file

#define TW_OP_ATA_PASSTHRU   0x11

Definition at line 92 of file

Typedef Documentation

typedef struct TW_Command TW_Command
typedef struct TAG_TW_Ioctl TW_Ioctl
typedef struct TAG_TW_Passthru TW_Passthru
typedef struct TAG_TW_SG_Entry TW_SG_Entry

Function Documentation

__ID ( "@(#) $Id: 2433 2012-01-10 22:01:30Z lyonel $"  )
static void fix_string ( unsigned char *  s,
unsigned  len 
) [static]

Definition at line 214 of file

  unsigned char c;

    c = s[0];
    s[0] = s[1];
    s[1] = c;
    s += 2;
    len -= 2;

Here is the caller graph for this function:

static bool guess_manufacturer ( hwNode device) [static]

Definition at line 477 of file

  int i = 0;
  bool result = false;

  while (manufacturers[i])
    if (matches(device.getProduct().c_str(), manufacturers[i], REG_ICASE))
      device.setVendor(manufacturers[i + 1]);
      result = true;
    i += 2;

  return result;

Here is the call graph for this function:

Here is the caller graph for this function:

static bool probe_port ( unsigned  controller,
unsigned  disknum,
hwNode parent 
) [static]

Definition at line 230 of file

  hwNode device("member:"+tostring(disknum), hw::disk);
  struct hd_driveid id;
  const u_int8_t *id_regs = (const u_int8_t *) &id;
  string devname = string(DEV_TWE) + tostring(controller);
  int fd = open(devname.c_str(), O_RDONLY | O_NONBLOCK);
  unsigned char ioctl_buffer[2*TW_IOCTL_BUFFER_SIZE];

   // only used for 6000/7000/8000 char device interface
  TW_New_Ioctl *tw_ioctl_char=NULL;
  TW_Passthru *passthru=NULL;

  memset(ioctl_buffer, 0, sizeof(ioctl_buffer));

  tw_ioctl_char = (TW_New_Ioctl *)ioctl_buffer;
  tw_ioctl_char->data_buffer_length = 512;
  passthru = (TW_Passthru *)&(tw_ioctl_char->firmware_command);

  passthru->byte0.opcode  = TW_OP_ATA_PASSTHRU;
  passthru->request_id    = 0xFF;
  passthru->byte3.aport   = disknum;
  passthru->byte3.host_id = 0;
  passthru->status        = 0;
  passthru->flags         = 0x1;
  passthru->drive_head    = 0x0;
  passthru->sector_num    = 0;
  passthru->byte0.sgloff = 0x5;
  passthru->size         = 0x7;
  passthru->param        = 0xD;
  passthru->sector_count = 0x1;
  passthru->command       = ATA_IDENTIFY_DEVICE;
  passthru->features    = 0;
  passthru->cylinder_lo = 0;
  passthru->cylinder_hi = 0;

  if (fd < 0)
    return false;

  memset(&id, 0, sizeof(id));
  if (ioctl(fd, TW_CMD_PACKET_WITH_DATA, tw_ioctl_char) != 0)
    return false;


  device.setBusInfo("raid@c" + tostring(controller) + "/p" + tostring(disknum));
  device.setLogicalName("c" + tostring(controller) + "/p" + tostring(disknum));

  u_int16_t pidentity[256];
  for (int i = 0; i < 256; i++)
    pidentity[i] = tw_ioctl_char->data_buffer[2 * i] + (tw_ioctl_char->data_buffer[2 * i + 1] << 8);
  memcpy(&id, pidentity, sizeof(id));

  fix_string(id.model, sizeof(id.model));
  fix_string(id.fw_rev, sizeof(id.fw_rev));
  fix_string(id.serial_no, sizeof(id.serial_no));

  if (id.model[0])
    device.setProduct(hw::strip(string((char *) id.model, sizeof(id.model))));
    return false;
  if (id.fw_rev[0])
      setVersion(hw::strip(string((char *) id.fw_rev, sizeof(id.fw_rev))));
    return false;
  if (id.serial_no[0])
      strip(string((char *) id.serial_no, sizeof(id.serial_no))));
    return false;

  if (!(pidentity[GEN_CONFIG] & NOT_ATA))
    device.addCapability("ata", "ATA");
    device.setDescription("ATA Disk");
  else if (!(pidentity[GEN_CONFIG] & NOT_ATAPI))
    u_int8_t eqpt = (pidentity[GEN_CONFIG] & EQPT_TYPE) >> 8;
    device.addCapability("atapi", "ATAPI");

    if (eqpt == CD_ROM)
      device.addCapability("cdrom", "can read CD-ROMs");

    if (eqpt < 0x20)
      device.setDescription("IDE " + string(description[eqpt]));
  if (id.config & (1 << 7))
    device.addCapability("removable", "support is removable");
  if (id.config & (1 << 15))
    device.addCapability("nonmagnetic", "support is non-magnetic (optical)");
  if (id.capability & 1)
    device.addCapability("dma", "Direct Memory Access");
  if (id.capability & 2)
    device.addCapability("lba", "Large Block Addressing");
  if (id.capability & 8)
    device.addCapability("iordy", "I/O ready reporting");
  if (id.command_set_1 & 1)
      "S.M.A.R.T. (Self-Monitoring And Reporting Technology)");
  if (id.command_set_1 & 2)
    device.addCapability("security", "ATA security extensions");
  if (id.command_set_1 & 4)
    device.addCapability("removable", "support is removable");
  if (id.command_set_1 & 8)
    device.addCapability("pm", "Power Management");
  if (id.command_set_2 & 8)
    device.addCapability("apm", "Advanced Power Management");

  if ((id.capability & 8) || (id.field_valid & 2))
    if (id.field_valid & 4)
      if (id.dma_ultra & 0x100)
        device.setConfig("mode", "udma0");
      if (id.dma_ultra & 0x200)
        device.setConfig("mode", "udma1");
      if (id.dma_ultra & 0x400)
        device.setConfig("mode", "udma2");
      if (id.hw_config & 0x2000)
        if (id.dma_ultra & 0x800)
          device.setConfig("mode", "udma3");
        if (id.dma_ultra & 0x1000)
          device.setConfig("mode", "udma4");
        if (id.dma_ultra & 0x2000)
          device.setConfig("mode", "udma5");
        if (id.dma_ultra & 0x4000)
          device.setConfig("mode", "udma6");
        if (id.dma_ultra & 0x8000)
          device.setConfig("mode", "udma7");

  if (id_regs[83] & 8)
    device.addCapability("apm", "Advanced Power Management");

//if (device.isCapable("iordy") && (id.capability & 4))
//device.setConfig("iordy", "yes");

  if (device.isCapable("smart"))
    if (id.command_set_2 & (1 << 14))
      device.setConfig("smart", "on");
      device.setConfig("smart", "off");

  if (device.isCapable("apm"))
    if (!(id_regs[86] & 8))
      device.setConfig("apm", "off");
      device.setConfig("apm", "on");

  if (device.isCapable("lba"))
    device.setCapacity((unsigned long long) id.lba_capacity * 512);
  if (device.isCapable("removable"))
    device.setCapacity(0);                        // we'll first have to make sure we have a disk

  if (device.isCapable("cdrom"))

#if 0
  if (!(iddata[GEN_CONFIG] & NOT_ATA))
  else if (iddata[GEN_CONFIG] == CFA_SUPPORT_VAL)
  else if (!(iddata[GEN_CONFIG] & NOT_ATAPI))
    device.setDescription(description[(iddata[GEN_CONFIG] & EQPT_TYPE) >> 8]);

  if (iddata[START_MODEL])
    device.setProduct(print_ascii((char *) &iddata[START_MODEL],
  if (iddata[START_SERIAL])
      setSerial(print_ascii((char *) &iddata[START_SERIAL], LENGTH_SERIAL));
  if (iddata[START_FW_REV])
      setVersion(print_ascii((char *) &iddata[START_FW_REV], LENGTH_FW_REV));
  if (iddata[CAPAB_0] & LBA_SUP)
  if (iddata[CAPAB_0] & IORDY_SUP)
  if (iddata[CAPAB_0] & IORDY_OFF)
  if (iddata[CAPAB_0] & DMA_SUP)
  if (iddata[CAPAB_0] & DMA_IL_SUP)
  if (iddata[CAPAB_0] & CMD_Q_SUP)
  if (iddata[CAPAB_0] & OVLP_SUP)

  return true;

Here is the call graph for this function:

Here is the caller graph for this function:

bool scan_ideraid ( hwNode n)

Definition at line 497 of file

  unsigned c = 0;
  unsigned u = 0;

  for(c=0; c<16; c++)
    for(u=0; u<8; u++)

  return true;

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const char* description[] [static]

Definition at line 45 of file

const char* manufacturers[] [static]
Initial value:
  "^ST.+", "Seagate",
  "^D...-.+", "IBM",
  "^IBM.+", "IBM",
  "^HITACHI.+", "Hitachi",
  "^IC.+", "Hitachi",
  "^HTS.+", "Hitachi",
  "^FUJITSU.+", "Fujitsu",
  "^MP.+", "Fujitsu",
  "^TOSHIBA.+", "Toshiba",
  "^MK.+", "Toshiba",
  "^MAXTOR.+", "Maxtor",
  "^Pioneer.+", "Pioneer",
  "^PHILIPS.+", "Philips",
  "^QUANTUM.+", "Quantum",
  "FIREBALL.+", "Quantum",
  "^WDC.+", "Western Digital",
  "WD.+", "Western Digital",

Definition at line 455 of file