|
|
ff36e7 |
From 2c84941819da11626ecaee1d2a10abc852cfff3d Mon Sep 17 00:00:00 2001
|
|
|
ff36e7 |
From: Lyonel Vincent <lyonel@ezix.org>
|
|
|
ff36e7 |
Date: Sat, 9 May 2015 10:18:17 +0000
|
|
|
ff36e7 |
Subject: [PATCH 1/1] update PowerPC device-tree memory detection (cf. #686)
|
|
|
ff36e7 |
|
|
|
ff36e7 |
git-svn-id: http://ezix.org/source/packages/lshw/development@2576 811e2811-9fd9-0310-a116-b6e8ac943c8b
|
|
|
ff36e7 |
---
|
|
|
ff36e7 |
src/core/device-tree.cc | 90 ++++++++++++++++++++++++++++++++++---------------
|
|
|
ff36e7 |
1 file changed, 63 insertions(+), 27 deletions(-)
|
|
|
ff36e7 |
|
|
|
ff36e7 |
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
|
|
|
ff36e7 |
index 6d93ab8..0b3d814 100644
|
|
|
ff36e7 |
--- a/src/core/device-tree.cc
|
|
|
ff36e7 |
+++ b/src/core/device-tree.cc
|
|
|
ff36e7 |
@@ -9,6 +9,7 @@
|
|
|
ff36e7 |
*
|
|
|
ff36e7 |
*/
|
|
|
ff36e7 |
|
|
|
ff36e7 |
+#include <algorithm>
|
|
|
ff36e7 |
#include <errno.h>
|
|
|
ff36e7 |
#include "version.h"
|
|
|
ff36e7 |
#include "device-tree.h"
|
|
|
ff36e7 |
@@ -35,6 +36,7 @@ struct dimminfo
|
|
|
ff36e7 |
};
|
|
|
ff36e7 |
|
|
|
ff36e7 |
#define DEVICETREE "/proc/device-tree"
|
|
|
ff36e7 |
+#define DEVICETREEVPD "/proc/device-tree/vpd/"
|
|
|
ff36e7 |
|
|
|
ff36e7 |
static unsigned long get_long(const string & path)
|
|
|
ff36e7 |
{
|
|
|
ff36e7 |
@@ -284,46 +286,80 @@ static void scan_devtree_cpu(hwNode & core)
|
|
|
ff36e7 |
}
|
|
|
ff36e7 |
}
|
|
|
ff36e7 |
|
|
|
ff36e7 |
+void add_memory_bank(string name, string path, hwNode & core)
|
|
|
ff36e7 |
+{
|
|
|
ff36e7 |
+ struct dirent **dirlist;
|
|
|
ff36e7 |
+ string product;
|
|
|
ff36e7 |
+ int n;
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ pushd(path + name);
|
|
|
ff36e7 |
+ if(name.substr(0, 7) == "ms-dimm")
|
|
|
ff36e7 |
+ {
|
|
|
ff36e7 |
+ replace(name.begin(), name.end(), '@', ':');
|
|
|
ff36e7 |
+ hwNode *memory = core.getChild("memory");
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ hwNode bank("bank", hw::memory);
|
|
|
ff36e7 |
+ bank.claim(true);
|
|
|
ff36e7 |
+ bank.addHint("icon", string("memory"));
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ if(!memory)
|
|
|
ff36e7 |
+ memory = core.addChild(hwNode("memory", hw::memory));
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ if(exists("serial-number"))
|
|
|
ff36e7 |
+ bank.setSerial(get_string("serial-number"));
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ product = get_string("part-number");
|
|
|
ff36e7 |
+ if(exists("fru-number"))
|
|
|
ff36e7 |
+ {
|
|
|
ff36e7 |
+ product += " FRU#" + get_string("fru-number");
|
|
|
ff36e7 |
+ }
|
|
|
ff36e7 |
+ if(product != "")
|
|
|
ff36e7 |
+ bank.setProduct(product);
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ if(exists("description"))
|
|
|
ff36e7 |
+ bank.setDescription(get_string("description"));
|
|
|
ff36e7 |
+ if(exists("ibm,loc-code"))
|
|
|
ff36e7 |
+ bank.setSlot(get_string("ibm,loc-code"));
|
|
|
ff36e7 |
+ if(unsigned long size = get_number("size"))
|
|
|
ff36e7 |
+ bank.setSize(size*1024*1024);
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ memory->addChild(bank);
|
|
|
ff36e7 |
+ }
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ n = scandir(".", &dirlist, selectdir, alphasort);
|
|
|
ff36e7 |
+ popd();
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ if (n < 0)
|
|
|
ff36e7 |
+ return;
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+ for (int i = 0; i < n; i++)
|
|
|
ff36e7 |
+ {
|
|
|
ff36e7 |
+ add_memory_bank(dirlist[i]->d_name, path + name + "/", core);
|
|
|
ff36e7 |
+ free(dirlist[i]);
|
|
|
ff36e7 |
+ }
|
|
|
ff36e7 |
+ free(dirlist);
|
|
|
ff36e7 |
+}
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
static void scan_devtree_memory_powernv(hwNode & core)
|
|
|
ff36e7 |
{
|
|
|
ff36e7 |
struct dirent **namelist;
|
|
|
ff36e7 |
- hwNode *memory = core.getChild("memory");
|
|
|
ff36e7 |
int n;
|
|
|
ff36e7 |
+ string path = DEVICETREEVPD;
|
|
|
ff36e7 |
|
|
|
ff36e7 |
- pushd(DEVICETREE "/vpd");
|
|
|
ff36e7 |
+ pushd(DEVICETREEVPD);
|
|
|
ff36e7 |
n = scandir(".", &namelist, selectdir, alphasort);
|
|
|
ff36e7 |
popd();
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
if (n < 0)
|
|
|
ff36e7 |
return;
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
for (int i = 0; i < n; i++)
|
|
|
ff36e7 |
{
|
|
|
ff36e7 |
- string basepath;
|
|
|
ff36e7 |
- unsigned long size = 0;
|
|
|
ff36e7 |
- string sizestr;
|
|
|
ff36e7 |
-
|
|
|
ff36e7 |
- if (strncmp(namelist[i]->d_name, "ms-dimm@", 8) == 0)
|
|
|
ff36e7 |
- {
|
|
|
ff36e7 |
- hwNode bank("bank", hw::memory);
|
|
|
ff36e7 |
-
|
|
|
ff36e7 |
- if (!memory)
|
|
|
ff36e7 |
- memory = core.addChild(hwNode("memory", hw::memory));
|
|
|
ff36e7 |
-
|
|
|
ff36e7 |
- basepath = string(DEVICETREE "/vpd/") + string(namelist[i]->d_name);
|
|
|
ff36e7 |
- bank.setSerial(get_string(basepath + string("/serial-number")));
|
|
|
ff36e7 |
- bank.setProduct(get_string(basepath + string("/part-number")) + " FRU#" + get_string(basepath + string("/fru-number")));
|
|
|
ff36e7 |
- bank.setDescription(get_string(basepath + string("/description")));
|
|
|
ff36e7 |
- bank.setSlot(get_string(basepath + string("/ibm,loc-code")));
|
|
|
ff36e7 |
- sizestr = get_string(basepath + string("/size"));
|
|
|
ff36e7 |
- errno = 0;
|
|
|
ff36e7 |
- size = strtoul(sizestr.c_str(), NULL, 10);
|
|
|
ff36e7 |
- if (!errno)
|
|
|
ff36e7 |
- bank.setSize(size*1024*1024);
|
|
|
ff36e7 |
- bank.addHint("icon", string("memory"));
|
|
|
ff36e7 |
-
|
|
|
ff36e7 |
- memory->addChild(bank);
|
|
|
ff36e7 |
- }
|
|
|
ff36e7 |
+ add_memory_bank(namelist[i]->d_name, path, core);
|
|
|
ff36e7 |
free(namelist[i]);
|
|
|
ff36e7 |
}
|
|
|
ff36e7 |
+
|
|
|
ff36e7 |
free(namelist);
|
|
|
ff36e7 |
}
|
|
|
ff36e7 |
|
|
|
ff36e7 |
--
|
|
|
ff36e7 |
2.4.3
|
|
|
ff36e7 |
|