diff --git a/src/apps/devices/Device.cpp b/src/apps/devices/Device.cpp index 6e5b394c5c..2a328b4d1b 100644 --- a/src/apps/devices/Device.cpp +++ b/src/apps/devices/Device.cpp @@ -32,7 +32,8 @@ const char* kCategoryString[] = { "Satellite communications controller", // 0x0f "Encryption controller", // 0x10 "Signal processing controller", // 0x11 - "Computer" // 0x12 (added later) + "Computer", // 0x12 (added later) + "ACPI controller" // 0x13 (added later) }; diff --git a/src/apps/devices/Device.h b/src/apps/devices/Device.h index ab8fe40662..2c53811701 100644 --- a/src/apps/devices/Device.h +++ b/src/apps/devices/Device.h @@ -24,6 +24,7 @@ typedef enum { BUS_ISA = 1, BUS_PCI, BUS_SCSI, + BUS_ACPI, BUS_NONE } BusType; @@ -45,7 +46,8 @@ typedef std::vector Attributes; typedef enum { CAT_NONE = 0, CAT_BUS = 6, - CAT_COMPUTER = 0x12 + CAT_COMPUTER = 0x12, + CAT_ACPI = 0x13 } Category; diff --git a/src/apps/devices/DeviceACPI.cpp b/src/apps/devices/DeviceACPI.cpp new file mode 100644 index 0000000000..3d58f8ab8e --- /dev/null +++ b/src/apps/devices/DeviceACPI.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2008-2010 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck (kallisti5) + */ + + +#include +#include + +#include "DeviceACPI.h" + + +DeviceACPI::DeviceACPI(Device* parent) + : + Device(parent) +{ +} + + +DeviceACPI::~DeviceACPI() +{ +} + + +void +DeviceACPI::InitFromAttributes() +{ + BString outlineName; + BString nodeACPIPath; + BString rootACPIPath; + + rootACPIPath = nodeACPIPath = GetAttribute("acpi/path").fValue; + + // Grab just the root node info + // We grab 6 characters to not identify sub nodes of root node + rootACPIPath.Truncate(6); + // Grab node leaf name + nodeACPIPath.Remove(0, nodeACPIPath.FindLast(".") + 1); + + fCategory = (Category)CAT_ACPI; + + // Identify Predefined root namespaces (ACPI Spec 4.0a, p162) + if (rootACPIPath == "\\_SB_") { + outlineName = "ACPI System Bus"; + } else if (rootACPIPath == "\\_TZ_") { + outlineName = "ACPI Thermal Zone"; + } else if (rootACPIPath == "\\_PR_.") { + // each CPU node is considered a root node + outlineName << "ACPI Processor Namespace '" << nodeACPIPath << "'"; + } else if (rootACPIPath == "\\_SI_") { + outlineName = "ACPI System Indicator"; + } else { + outlineName << "ACPI node '" << nodeACPIPath << "'"; + } + + SetAttribute("Device name", outlineName.String()); + SetAttribute("Manufacturer", "Not implimented"); + + SetText(outlineName.String()); +} + + +Attributes +DeviceACPI::GetBusAttributes() +{ + // Push back things that matter for ACPI + Attributes attributes; + attributes.push_back(GetAttribute("device/bus")); + attributes.push_back(GetAttribute("acpi/path")); + attributes.push_back(GetAttribute("acpi/type")); + return attributes; +} + + +BString +DeviceACPI::GetBusStrings() +{ + BString str; + str << "Class Info:\t\t\t\t: " << fAttributeMap["Class Info"]; + return str; +} diff --git a/src/apps/devices/DeviceACPI.h b/src/apps/devices/DeviceACPI.h new file mode 100644 index 0000000000..11349913e9 --- /dev/null +++ b/src/apps/devices/DeviceACPI.h @@ -0,0 +1,27 @@ +/* + * Copyright 2008-2010 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck (kallisti5) + */ +#ifndef DEVICEACPI_H +#define DEVICEACPI_H + + +#include "Device.h" + + +class DeviceACPI : public Device { +public: + DeviceACPI(Device* parent); + virtual ~DeviceACPI(); + virtual Attributes GetBusAttributes(); + virtual BString GetBusStrings(); + virtual void InitFromAttributes(); + + virtual BString GetBusTabName() + { return "ACPI Information"; } +}; + +#endif /* DEVICEACPI_H */ diff --git a/src/apps/devices/DevicesView.cpp b/src/apps/devices/DevicesView.cpp index 1aeb2881a5..de96cd0b8e 100644 --- a/src/apps/devices/DevicesView.cpp +++ b/src/apps/devices/DevicesView.cpp @@ -277,21 +277,28 @@ DevicesView::AddDeviceAndChildren(device_node_cookie *node, Device* parent) // Determine what type of device it is and create it for (unsigned int i = 0; i < attributes.size(); i++) { // Devices Root - if (attributes[i].fName == "device/pretty name" + if (attributes[i].fName == B_DEVICE_PRETTY_NAME && attributes[i].fValue == "Devices Root") { newDevice = new Device(parent, BUS_NONE, CAT_COMPUTER, "Computer"); break; } + // ACPI Controller + if (attributes[i].fName == B_DEVICE_PRETTY_NAME + && attributes[i].fValue == "ACPI") { + newDevice = new Device(parent, BUS_ACPI, CAT_BUS, "ACPI bus"); + break; + } + // PCI bus - if (attributes[i].fName == "device/pretty name" + if (attributes[i].fName == B_DEVICE_PRETTY_NAME && attributes[i].fValue == "PCI") { newDevice = new Device(parent, BUS_PCI, CAT_BUS, "PCI bus"); break; } // ISA bus - if (attributes[i].fName == "device/bus" + if (attributes[i].fName == B_DEVICE_BUS && attributes[i].fValue == "isa") { newDevice = new Device(parent, BUS_ISA, CAT_BUS, "ISA bus"); break; @@ -303,6 +310,13 @@ DevicesView::AddDeviceAndChildren(device_node_cookie *node, Device* parent) newDevice = new DevicePCI(parent); break; } + + // ACPI device + if (attributes[i].fName == B_DEVICE_BUS + && attributes[i].fValue == "acpi") { + newDevice = new DeviceACPI(parent); + break; + } } if (newDevice == NULL) { diff --git a/src/apps/devices/DevicesView.h b/src/apps/devices/DevicesView.h index 56f2fbd55a..4730e1cfe4 100644 --- a/src/apps/devices/DevicesView.h +++ b/src/apps/devices/DevicesView.h @@ -26,6 +26,7 @@ #include "Device.h" #include "DevicePCI.h" +#include "DeviceACPI.h" #include "PropertyList.h" #include "PropertyListPlain.h" diff --git a/src/apps/devices/Jamfile b/src/apps/devices/Jamfile index 60a7054681..3820516dee 100644 --- a/src/apps/devices/Jamfile +++ b/src/apps/devices/Jamfile @@ -65,6 +65,7 @@ Application Devices : DevicesView.cpp dm_wrapper.c DevicePCI.cpp + DeviceACPI.cpp Device.cpp PropertyList.cpp PropertyListPlain.cpp