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 "DeviceACPI.h" 11 12 #include <sstream> 13 #include <stdlib.h> 14 15 #include <Catalog.h> 16 17 #undef B_TRANSLATION_CONTEXT 18 #define B_TRANSLATION_CONTEXT "DeviceACPI" 19 20 21 DeviceACPI::DeviceACPI(Device* parent) 22 : 23 Device(parent) 24 { 25 } 26 27 28 DeviceACPI::~DeviceACPI() 29 { 30 } 31 32 33 void 34 DeviceACPI::InitFromAttributes() 35 { 36 BString outlineName; 37 BString nodeACPIPath; 38 BString rootACPIPath; 39 40 rootACPIPath = nodeACPIPath = GetAttribute("acpi/path").fValue; 41 42 // Grab just the root node info 43 // We grab 6 characters to not identify sub nodes of root node 44 rootACPIPath.Truncate(6); 45 // Grab node leaf name 46 nodeACPIPath.Remove(0, nodeACPIPath.FindLast(".") + 1); 47 48 fCategory = (Category)CAT_ACPI; 49 50 // Identify Predefined root namespaces (ACPI Spec 4.0a, p162) 51 if (rootACPIPath == "\\_SB_") { 52 outlineName = B_TRANSLATE("ACPI System Bus"); 53 } else if (rootACPIPath == "\\_TZ_") { 54 outlineName = B_TRANSLATE("ACPI Thermal Zone"); 55 } else if (rootACPIPath == "\\_PR_.") { 56 // This allows to localize apostrophes, too 57 BString string(B_TRANSLATE("ACPI Processor Namespace '%2'")); 58 string.ReplaceFirst("%2", nodeACPIPath); 59 // each CPU node is considered a root node 60 outlineName << string.String(); 61 } else if (rootACPIPath == "\\_SI_") { 62 outlineName = B_TRANSLATE("ACPI System Indicator"); 63 } else { 64 // This allows to localize apostrophes, too 65 BString string(B_TRANSLATE("ACPI node '%1'")); 66 string.ReplaceFirst("%1", nodeACPIPath); 67 outlineName << string.String(); 68 } 69 70 SetAttribute(B_TRANSLATE("Device name"), outlineName.String()); 71 SetAttribute(B_TRANSLATE("Manufacturer"), B_TRANSLATE("Not implemented")); 72 73 SetText(outlineName.String()); 74 } 75 76 77 Attributes 78 DeviceACPI::GetBusAttributes() 79 { 80 // Push back things that matter for ACPI 81 Attributes attributes; 82 attributes.push_back(GetAttribute("device/bus")); 83 attributes.push_back(GetAttribute("acpi/path")); 84 attributes.push_back(GetAttribute("acpi/type")); 85 return attributes; 86 } 87 88 89 BString 90 DeviceACPI::GetBusStrings() 91 { 92 BString str(B_TRANSLATE("Class Info:\t\t\t\t: %classInfo%")); 93 str.ReplaceFirst("%classInfo%", fAttributeMap["Class Info"]); 94 95 return str; 96 } 97 98 99 BString 100 DeviceACPI::GetBusTabName() 101 { 102 return B_TRANSLATE("ACPI Information"); 103 } 104 105