diff options
| author | Jason Albert <albertj@us.ibm.com> | 2015-03-04 17:06:15 -0600 |
|---|---|---|
| committer | Jason Albert <albertj@us.ibm.com> | 2015-03-04 17:06:15 -0600 |
| commit | 2866c5c781f46f2afb866580d4eaa48a627edf2a (patch) | |
| tree | 3467250b6d09146346d43268999172f0b5282187 | |
| parent | 159a1bd43b6bd1105bcdf65c2697b3700f9b7c9c (diff) | |
| download | vpdtools-2866c5c781f46f2afb866580d4eaa48a627edf2a.tar.gz vpdtools-2866c5c781f46f2afb866580d4eaa48a627edf2a.zip | |
Added support for writing ECC. Now the code needs a good scrubbing for clarity, duplication and the addition of useful debug messages
| -rwxr-xr-x | createVpd.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/createVpd.py b/createVpd.py index 8ef05dc..69fff0e 100755 --- a/createVpd.py +++ b/createVpd.py @@ -394,7 +394,6 @@ vpdFile = open(vpdFileName, "wb") # Instead, I purpose creating the images for each record first and storing them in memory # Then we can go through and create the full VPD image in sequence and be able to write the VTOC properly the first time recordImages = dict() -tocOffset = dict() imageLength = 0 recordName = "VHDR" @@ -546,6 +545,29 @@ for record in manifest.iter("record"): print(recordImages[recordName].record) +# Done creating the records, now create their ECC data +# Not supported at present, so allocate the space, zero it out and update the TOC +recordName = "VTOC" +print("len: ", len(recordImages[recordName].record)) +recordImages[recordName].ecc = bytearray(("\0" * (int(len(recordImages[recordName].record) / 4))).encode()) +tocName = recordImages[recordName].tocName +tocEccOffset = recordImages[recordName].tocEccOffset +recordImages[tocName].record[tocEccOffset:(tocEccOffset + 2)] = struct.pack('>H', imageLength) +tocEccLength = recordImages[recordName].tocEccLength +recordImages[tocName].record[tocEccLength:(tocEccLength + 2)] = struct.pack('>H', len(recordImages[recordName].ecc)) +imageLength += len(recordImages[recordName].ecc) + +for record in manifest.iter("record"): + recordName = record.attrib.get("name") + recordImages[recordName].ecc = bytearray(("\0" * (int(len(recordImages[recordName].record) / 4))).encode()) + tocName = recordImages[recordName].tocName + tocEccOffset = recordImages[recordName].tocEccOffset + recordImages[tocName].record[tocEccOffset:(tocEccOffset + 2)] = struct.pack('>H', imageLength) + tocEccLength = recordImages[recordName].tocEccLength + recordImages[tocName].record[tocEccLength:(tocEccLength + 2)] = struct.pack('>H', len(recordImages[recordName].ecc)) + imageLength += len(recordImages[recordName].ecc) + +# Write the files writeDataToVPD(vpdFile, recordImages["VHDR"].record) writeDataToVPD(vpdFile, recordImages["VTOC"].record) @@ -553,6 +575,12 @@ for record in manifest.iter("record"): recordName = record.attrib.get("name") writeDataToVPD(vpdFile, recordImages[recordName].record) +writeDataToVPD(vpdFile, recordImages["VTOC"].ecc) + +for record in manifest.iter("record"): + recordName = record.attrib.get("name") + writeDataToVPD(vpdFile, recordImages[recordName].ecc) + # Done with the file vpdFile.close() print(" Wrote vpd file: %s" % vpdFileName) |

