Copied latest chip data from PRD project
Change-Id: I7fcaff1fd30b725abe8905df76d91a73e4572c08
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/chip_data/pyprd/util/__init__.py b/chip_data/pyprd/util/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/chip_data/pyprd/util/__init__.py
diff --git a/chip_data/pyprd/util/hash.py b/chip_data/pyprd/util/hash.py
new file mode 100644
index 0000000..a807d0b
--- /dev/null
+++ b/chip_data/pyprd/util/hash.py
@@ -0,0 +1,42 @@
+def hash_string(num_bytes: int, string: str) -> int:
+ """
+ Converts a string into an integer hash value. This is primarily used to
+ convert register and isolation node names from the Chip and RAS Data into
+ integer values to save space in the data.
+ """
+
+ # This hash is a simple "n*s[0] + (n-1)*s[1] + ... + s[n-1]" algorithm,
+ # where s[i] is a chunk from the input string the length of i_bytes.
+
+ # Currently only supporting 1:8 byte hashes
+ assert 1 <= num_bytes and num_bytes <= 8
+
+ # Start hashing each chunk
+ sumA = 0
+ sumB = 0
+
+ # Iterate one chunk at a time
+ for i in range(0, len(string), num_bytes):
+ # Combine each chunk into a single integer value. If we reach the end
+ # of the string, pad with null characters.
+ chunk = 0
+ for j in range(0, num_bytes):
+ chunk <<= 8
+ chunk |= ord(string[i + j]) if (i + j < len(string)) else ord("\0")
+
+ # Apply the simple hash
+ sumA += chunk
+ sumB += sumA
+
+ # Mask off everything except the target number of bytes.
+ mask = 0xFFFFFFFFFFFFFFFF
+ sumB &= mask >> ((8 - num_bytes) * 8)
+
+ return sumB
+
+
+def hash_string_format(num_bytes: int, string: str) -> str:
+ """
+ Returns a formatted hex string of the given string's hash value.
+ """
+ return "{0:0{1}x}".format(hash_string(num_bytes, string), num_bytes * 2)
diff --git a/chip_data/pyprd/util/model_ec.py b/chip_data/pyprd/util/model_ec.py
new file mode 100644
index 0000000..20b3954
--- /dev/null
+++ b/chip_data/pyprd/util/model_ec.py
@@ -0,0 +1,11 @@
+from collections import namedtuple
+
+ModelEc = namedtuple("ModelEc", "id type desc")
+
+supported = {
+ "EXPLORER_11": ModelEc(0x60D20011, "ocmb", "Explorer DD1.1"),
+ "EXPLORER_20": ModelEc(0x60D20020, "ocmb", "Explorer DD2.0"),
+ "ODYSSEY_10": ModelEc(0x60C00010, "ocmb", "Odyssey DD1.0"),
+ "P10_10": ModelEc(0x20DA0010, "proc", "P10 1.0"),
+ "P10_20": ModelEc(0x20DA0020, "proc", "P10 2.0"),
+}