Update chip data peltool parsing to handle extra signatures
Signed-off-by: Caleb Palmer <cnpalmer@us.ibm.com>
Change-Id: Id6665526d9b66490f34fe42e761559283eaa08ab
diff --git a/README.md b/README.md
index 447ed88..3b7b014 100644
--- a/README.md
+++ b/README.md
@@ -21,14 +21,14 @@
## User Application Requirements and APIs
- The process to access hardware register data will vary per user application.
- Therefore, this library will declare the hardware access [user APIs][], but each
- user application must implement the APIs for their own environment.
+ Therefore, this library will declare the hardware access [user APIs][], but
+ each user application must implement the APIs for their own environment.
- This library will not contain data regarding hardware specific information.
Instead, that information will be provided by the user application in the form
of the [Chip Data Files][].
- Tracing, or logging, methods will vary per user application. Therefore, this
- library will declare the tracing/logging [user APIs][], but each user application
- must implement the APIs for their own environment.
+ library will declare the tracing/logging [user APIs][], but each user
+ application must implement the APIs for their own environment.
## Environment configuration
diff --git a/chip_data/parse_chip_data.py b/chip_data/parse_chip_data.py
index e000d5d..7de4d14 100755
--- a/chip_data/parse_chip_data.py
+++ b/chip_data/parse_chip_data.py
@@ -40,11 +40,11 @@
binary_encode(model_ec, base, fp)
-def gen_peltool_json(indir: str, outdir: str) -> None:
- for model_ec, base in _import_chip_data(indir).items():
+def gen_peltool_json(cdIndir: str, outdir: str, exSigPath=None) -> None:
+ for model_ec, base in _import_chip_data(cdIndir).items():
file = f"pel_parser_data_{model_ec.lower()}.json"
with open(os.path.join(outdir, file), "w") as fp:
- peltool_encode(model_ec, base, fp)
+ peltool_encode(model_ec, base, fp, exSigPath)
if __name__ == "__main__":
diff --git a/chip_data/pyprd/chip_data/peltool.py b/chip_data/pyprd/chip_data/peltool.py
index f1939cc..4428b46 100644
--- a/chip_data/pyprd/chip_data/peltool.py
+++ b/chip_data/pyprd/chip_data/peltool.py
@@ -1,4 +1,6 @@
import json
+import os.path
+import re
from collections import namedtuple
from pyprd.chip_data import chip_data as cd
@@ -25,7 +27,7 @@
# Public functions
-def peltool_encode(model_ec: str, base: cd.Base, fp: object):
+def peltool_encode(model_ec: str, base: cd.Base, fp: object, exSigPath: str):
"""
Pulls the necessary information from the Chip Data object and writes the
eBMC PEL parser (peltool) JSON data to the given file pointer. Note that
@@ -45,6 +47,7 @@
"attn_types": {},
"registers": {},
"signatures": {},
+ "extra_signatures": {},
}
for attn_type in base.root_nodes.keys():
@@ -74,5 +77,20 @@
for pos, bit in iso_node.bits.items():
node[1][pos] = bit.desc
+ # If the input extra signature file exists, add those to the data.
+ if os.path.isfile(exSigPath):
+ with open(exSigPath, "r") as sigFp:
+ fileData = sigFp.read()
+ sigPattern = r'PRD_EXTRA_SIG\s*\(\s*([^"]*)\s*,\s*(0x[0-9A-Fa-f]{8})\s*,\s*"([^"]*)"'
+
+ sigs = re.findall(sigPattern, fileData)
+ for sig in sigs:
+ hexValue = sig[1].lower()
+ # Remove the 0x prefix from the hex string for consistency with
+ # other hex IDs used.
+ hexValue = hexValue[2:]
+ desc = sig[2]
+ data["extra_signatures"][hexValue] = desc
+
json.dump(data, fp, indent=4, sort_keys=True)
fp.write("\n")