Ticket #6350: early-acpi-support.r3.diff

File early-acpi-support.r3.diff, 5.7 KB (added by kallisti5, 14 years ago)

revision 3, now identifies important ACPI root nodes.

  • src/apps/devices/Device.cpp

     
    3232    "Satellite communications controller",  // 0x0f
    3333    "Encryption controller",                // 0x10
    3434    "Signal processing controller",         // 0x11
    35     "Computer"                              // 0x12 (added later)
     35    "Computer",                             // 0x12 (added later)
     36    "ACPI controller"           // 0x13 (added later)
    3637};
    3738
    3839
  • src/apps/devices/DeviceACPI.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 DEVICEACPI_H
     9#define DEVICEACPI_H
     10
     11
     12#include "Device.h"
     13
     14
     15class DeviceACPI : public Device {
     16public:
     17                        DeviceACPI(Device* parent);
     18    virtual             ~DeviceACPI();
     19    virtual Attributes  GetBusAttributes();
     20    virtual BString     GetBusStrings();
     21    virtual void        InitFromAttributes();
     22   
     23    virtual BString     GetBusTabName()
     24                            { return "ACPI Information"; }
     25};
     26
     27#endif /* DEVICEACPI_H */
  • src/apps/devices/Device.h

     
    2424    BUS_ISA = 1,
    2525    BUS_PCI,
    2626    BUS_SCSI,
     27    BUS_ACPI,
    2728    BUS_NONE
    2829} BusType;
    2930
     
    4546typedef enum {
    4647    CAT_NONE = 0,
    4748    CAT_BUS = 6,
    48     CAT_COMPUTER = 0x12
     49    CAT_COMPUTER = 0x12,
     50    CAT_ACPI = 0x13
    4951} Category;
    5052
    5153
  • src/apps/devices/DevicesView.cpp

     
    277277    // Determine what type of device it is and create it
    278278    for (unsigned int i = 0; i < attributes.size(); i++) {
    279279        // Devices Root
    280         if (attributes[i].fName == "device/pretty name"
     280        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
    281281                && attributes[i].fValue == "Devices Root") {
    282282            newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, "Computer");
    283283            break;
    284284        }
    285285
     286        // ACPI Controller
     287        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
     288                && attributes[i].fValue == "ACPI") {
     289            newDevice = new Device(parent, BUS_ACPI, CAT_BUS, "ACPI Controller");
     290            break;
     291        }
     292
    286293        // PCI bus
    287         if (attributes[i].fName == "device/pretty name"
     294        if (attributes[i].fName == B_DEVICE_PRETTY_NAME
    288295                && attributes[i].fValue == "PCI") {
    289296            newDevice = new Device(parent, BUS_PCI, CAT_BUS, "PCI bus");
    290297            break;
    291298        }
    292299
    293300        // ISA bus
    294         if (attributes[i].fName == "device/bus"
     301        if (attributes[i].fName == B_DEVICE_BUS
    295302                && attributes[i].fValue == "isa") {
    296303            newDevice = new Device(parent, BUS_ISA, CAT_BUS, "ISA bus");
    297304            break;
     
    303310            newDevice = new DevicePCI(parent);
    304311            break;
    305312        }
     313
     314        // ACPI device
     315        if (attributes[i].fName == B_DEVICE_BUS
     316                && attributes[i].fValue == "acpi") {
     317            newDevice = new DeviceACPI(parent);
     318            break;
     319        }
    306320    }
    307321
    308322    if (newDevice == NULL) {
  • src/apps/devices/DevicesView.h

     
    2626
    2727#include "Device.h"
    2828#include "DevicePCI.h"
     29#include "DeviceACPI.h"
    2930#include "PropertyList.h"
    3031#include "PropertyListPlain.h"
    3132
  • src/apps/devices/Jamfile

     
    6565    DevicesView.cpp
    6666    dm_wrapper.c
    6767    DevicePCI.cpp
     68    DeviceACPI.cpp
    6869    Device.cpp
    6970    PropertyList.cpp
    7071    PropertyListPlain.cpp
  • src/apps/devices/DeviceACPI.cpp

     
     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
     9
     10#include <sstream>
     11#include <stdlib.h>
     12
     13#include "DeviceACPI.h"
     14
     15
     16DeviceACPI::DeviceACPI(Device* parent)
     17    :
     18    Device(parent)
     19{
     20}
     21
     22
     23DeviceACPI::~DeviceACPI()
     24{
     25}
     26
     27
     28void
     29DeviceACPI::InitFromAttributes()
     30{
     31    BString outlineName;
     32    BString ACPIPath;
     33
     34    ACPIPath = GetAttribute("acpi/path").fValue;
     35
     36    // Grab just the root node info
     37    // We grab 6 characters to not identify sub nodes of root node
     38    ACPIPath.Truncate(6);
     39
     40    fCategory = (Category)CAT_ACPI;
     41
     42    // Identify Predefined root namespaces (ACPI Spec 4.0a, p162)
     43    if (ACPIPath == "\\_SB_") {
     44        outlineName = "ACPI System Bus";
     45    } else if (ACPIPath == "\\_TZ_") {
     46        outlineName = "ACPI Thermal Zone";
     47    } else if (ACPIPath == "\\_PR_.") {
     48        // each CPU node is considered a root node
     49        outlineName = "ACPI Processor Namespace";
     50    } else if (ACPIPath == "\\_SI_") {
     51        outlineName = "ACPI System Indicator";
     52    } else {
     53        outlineName = "ACPI node";
     54    }
     55
     56    SetAttribute("Device name", outlineName.String());
     57    SetAttribute("Manufacturer", "Not implimented");
     58
     59    SetText(outlineName.String());
     60}
     61
     62
     63Attributes
     64DeviceACPI::GetBusAttributes()
     65{
     66    // Push back things that matter for ACPI
     67    Attributes attributes;
     68    attributes.push_back(GetAttribute("device/bus"));
     69    attributes.push_back(GetAttribute("acpi/path"));
     70    attributes.push_back(GetAttribute("acpi/type"));
     71    return attributes;
     72}
     73
     74
     75BString
     76DeviceACPI::GetBusStrings()
     77{
     78    BString str;
     79    str << "Class Info:\t\t\t\t: " << fAttributeMap["Class Info"];
     80    return str;
     81}