Ticket #6503: scsi-device-patch-r1.diff

File scsi-device-patch-r1.diff, 6.1 KB (added by kallisti5, 14 years ago)

scsi device patch hrev1

  • src/apps/devices/Device.cpp

     
    1212#include <iostream>
    1313
    1414
    15 // This list comes from the pciid list, except for the last one
     15// This list comes from the pciid list, except for the last few that don't rely on PCIid numbers
    1616const char* kCategoryString[] = {
    17     "Unclassified device",                  // 0x00
     17    "Unclassified device",                  // 0x00
    1818    "Mass storage controller",              // 0x01
    1919    "Network controller",                   // 0x02
    2020    "Display controller",                   // 0x03
     
    2626    "Input device controller",              // 0x09
    2727    "Docking station",                      // 0x0a
    2828    "Processor",                            // 0x0b
    29     "Serial bus controller",                // 0x0c
     29    "Serial bus controller",                // 0x0c
    3030    "Wireless controller",                  // 0x0d
    3131    "Intelligent controller",               // 0x0e
    3232    "Satellite communications controller",  // 0x0f
    3333    "Encryption controller",                // 0x10
    3434    "Signal processing controller",         // 0x11
    3535    "Computer",                             // 0x12 (added later)
    36     "ACPI controller"           // 0x13 (added later)
     36    "ACPI controller"                       // 0x13 (added later)
    3737};
    3838
    3939
  • src/apps/devices/Device.h

     
    4444
    4545
    4646typedef enum {
    47     CAT_NONE = 0,
    48     CAT_BUS = 6,
    49     CAT_COMPUTER = 0x12,
    50     CAT_ACPI = 0x13
     47    CAT_NONE = 0x00,        // Unknown / Other
     48    CAT_BUS = 0x06,         // Bus Device
     49    CAT_COMPUTER = 0x12,    // Generic computer related
     50    CAT_ACPI = 0x13         // ACPI Related
    5151} Category;
    5252
    5353
  • src/apps/devices/DevicesView.cpp

     
    318318            newDevice = new DeviceACPI(parent);
    319319            break;
    320320        }
     321
     322        // SCSI device (or an ATA device playing SCSI?)
     323        if (attributes[i].fName == B_DEVICE_BUS
     324                && attributes[i].fValue == "scsi") {
     325            newDevice = new DeviceSCSI(parent);
     326            break;
     327        }
    321328    }
    322329
    323330    if (newDevice == NULL) {
  • src/apps/devices/DeviceSCSI.cpp

     
     1/*
     2 * Copyright 2008-2010 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Handle SCSI devices and show them in a clean way
     6 *
     7 * Authors:
     8 *      Alexander von Gluck (kallisti5)
     9 */
     10
     11
     12#include <sstream>
     13#include <stdlib.h>
     14
     15#include "DeviceSCSI.h"
     16
     17// Standard SCSI device types
     18const char* SCSITypeMap[] = {
     19    "Disk Drive",           // 0x00
     20    "Tape Drive",           // 0x01
     21    "Printer",              // 0x02
     22    "Processor",            // 0x03
     23    "Worm",                 // 0x04
     24    "CD-ROM",               // 0x05
     25    "Scanner",              // 0x06
     26    "Optical",              // 0x07
     27    "Changer",              // 0x08
     28    "Communications",       // 0x09
     29    "Graphics Peripheral",  // 0x0A
     30    "Graphics Peripheral",  // 0x0B
     31    "Array",                // 0x0C
     32    "Enclosure",            // 0x0D
     33    "RBC",                  // 0x0E
     34    "Card Reader",          // 0x0F
     35    "Bridge",               // 0x10
     36    "Other"                 // 0x11
     37};
     38
     39DeviceSCSI::DeviceSCSI(Device* parent)
     40    :
     41    Device(parent)
     42{
     43}
     44
     45
     46DeviceSCSI::~DeviceSCSI()
     47{
     48}
     49
     50
     51void
     52DeviceSCSI::InitFromAttributes()
     53{
     54    BString outlineName;
     55    BString nodeProduct;
     56    BString nodeVendor;
     57    BString nodeType;
     58    int nodeTypeID;
     59
     60    nodeProduct = GetAttribute("scsi/product").fValue;
     61    nodeVendor = GetAttribute("scsi/vendor").fValue;
     62    nodeType = GetAttribute("scsi/type").fValue;
     63
     64    nodeTypeID = atoi (nodeType.String());
     65
     66    fCategory = (Category)CAT_COMPUTER;
     67
     68    outlineName << "SCSI " << SCSITypeMap[nodeTypeID] << " (" << nodeProduct << ")";
     69
     70    SetAttribute("Device name", outlineName.String());
     71    SetAttribute("Manufacturer", nodeVendor.String());
     72    SetAttribute("Device class", SCSITypeMap[nodeTypeID]);
     73
     74    SetText(outlineName.String());
     75}
     76
     77
     78Attributes
     79DeviceSCSI::GetBusAttributes()
     80{
     81    // Push back things that matter for SCSI devices
     82    Attributes attributes;
     83    attributes.push_back(GetAttribute("device/bus"));
     84    attributes.push_back(GetAttribute("scsi/product"));
     85    attributes.push_back(GetAttribute("scsi/vendor"));
     86    attributes.push_back(GetAttribute("scsi/revision"));
     87    attributes.push_back(GetAttribute("scsi/target_id"));
     88    attributes.push_back(GetAttribute("scsi/target_lun"));
     89    attributes.push_back(GetAttribute("dma/max_transfer_blocks"));
     90    attributes.push_back(GetAttribute("Device class"));
     91    return attributes;
     92}
     93
     94
     95BString
     96DeviceSCSI::GetBusStrings()
     97{
     98    BString str;
     99    str << "Class Info:\t\t\t\t: " << fAttributeMap["Class Info"];
     100    return str;
     101}
  • src/apps/devices/DevicesView.h

     
    2727#include "Device.h"
    2828#include "DevicePCI.h"
    2929#include "DeviceACPI.h"
     30#include "DeviceSCSI.h"
    3031#include "PropertyList.h"
    3132#include "PropertyListPlain.h"
    3233
  • src/apps/devices/Jamfile

     
    6666    dm_wrapper.c
    6767    DevicePCI.cpp
    6868    DeviceACPI.cpp
     69    DeviceSCSI.cpp
    6970    Device.cpp
    7071    PropertyList.cpp
    7172    PropertyListPlain.cpp
  • src/apps/devices/DeviceSCSI.h

     
     1/*
     2 * Copyright 2008-2010 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Authors:
     6 *      Alexander von Gluck (kallisti5)
     7 */
     8#ifndef DEVICESCSI_H
     9#define DEVICESCSI_H
     10
     11#include "Device.h"
     12
     13class DeviceSCSI : public Device {
     14public:
     15                        DeviceSCSI(Device* parent);
     16    virtual             ~DeviceSCSI();
     17    virtual Attributes  GetBusAttributes();
     18    virtual BString     GetBusStrings();
     19    virtual void        InitFromAttributes();
     20   
     21    virtual BString     GetBusTabName()
     22                            { return "SCSI Information"; }
     23
     24};
     25
     26#endif /* DEVICESCSI_H */