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