summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/utils
diff options
context:
space:
mode:
authorMartin Peschke <mpeschke@de.ibm.com>2016-07-01 12:00:27 +0200
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-09-02 17:12:44 -0400
commite874bc0f5e92a442a95b7c771d2aa14df3387855 (patch)
tree1eaacd32dcaf99ffa8d2e2fdf12550e5d4eb14dd /src/import/chips/p9/utils
parent0db0e4cef023653ce7aaf9a436e517cf88554ed5 (diff)
downloadtalos-hostboot-e874bc0f5e92a442a95b7c771d2aa14df3387855.tar.gz
talos-hostboot-e874bc0f5e92a442a95b7c771d2aa14df3387855.zip
p9_scan_compression: RS4v2 compression error return fix
Instead of calling exit() on errors and instead of terminating a calling binary, it's better to return a defined RS4 return code. This allows calling code to handle these errors, e.g. by dumping debug information. Change-Id: Ia38d18a6e2fcd64374a4d7fae96214a8cf7b01d8 Original-Change-Id: I49242b6fe880dc8f5adbc0951a1667b891c8cf22 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/26528 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Prachi Gupta <pragupta@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: Claus M. Olsen <cmolsen@us.ibm.com> Reviewed-by: Martin Peschke <mpeschke@de.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29113 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/import/chips/p9/utils')
-rw-r--r--src/import/chips/p9/utils/imageProcs/p9_scan_compression.C38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/import/chips/p9/utils/imageProcs/p9_scan_compression.C b/src/import/chips/p9/utils/imageProcs/p9_scan_compression.C
index 9e8db05ce..4ec3acc78 100644
--- a/src/import/chips/p9/utils/imageProcs/p9_scan_compression.C
+++ b/src/import/chips/p9/utils/imageProcs/p9_scan_compression.C
@@ -303,10 +303,11 @@ stop_decode(uint32_t* o_count, const uint8_t* i_string, const uint32_t i_i)
// to the rotate state. Runs of more than 15 scans will always include a
// 0-length rotate between the scan sequences.
//
-// Returns the number of nibbles in the compressed string.
+// Returns a scan compression return code.
-static uint32_t
+static int
__rs4_compress(CompressedScanData* o_data,
+ uint32_t* o_nibbles,
const uint8_t* i_data_str,
const uint8_t* i_care_str,
const uint32_t i_length)
@@ -343,8 +344,8 @@ __rs4_compress(CompressedScanData* o_data,
if (~care_nibble & data_nibble)
{
- printf("__rs4_compress(): Data error in nibble[%d]: We can't have '1' in data where care has '0'\n", i);
- exit(1);
+ return BUGX(SCAN_COMPRESSION_INPUT_ERROR,
+ "Conflicting data and mask bits in nibble %d\n", i);
}
if (state == 0)
@@ -457,8 +458,8 @@ __rs4_compress(CompressedScanData* o_data,
}
else
{
- printf("__rs4_compress(): Code error: state==2 not allowed at this point\n");
- exit(1);
+ return BUGX(SCAN_COMPRESSION_STATE_ERROR,
+ "Termination can not immediately follow masked data\n");
}
// Indicate termination start
@@ -479,8 +480,8 @@ __rs4_compress(CompressedScanData* o_data,
if (~care_nibble & data_nibble)
{
- printf("__rs4_compress(): Data error in nibble[%d]: We can't have '1' in data where care has '0'\n", n);
- exit(1);
+ return BUGX(SCAN_COMPRESSION_INPUT_ERROR,
+ "Conflicting data and mask bits in nibble %d\n", i);
}
if ((care_nibble ^ data_nibble) == 0)
@@ -503,8 +504,9 @@ __rs4_compress(CompressedScanData* o_data,
}
}
- // Return the number of nibbles in the compressed string.
- return j;
+ *o_nibbles = j;
+
+ return SCAN_COMPRESSION_OK;
}
@@ -572,6 +574,8 @@ rs4_max_compressed_bytes(uint32_t nibbles)
// We always require the worst-case amount of memory including the header and
// any rounding required to guarantee that the data size is a multiple of 8
// bytes. The final image size is also rounded up to a multiple of 8 bytes.
+//
+// Returns a scan compression return code.
int
_rs4_compress(CompressedScanData* io_data,
@@ -591,7 +595,6 @@ _rs4_compress(CompressedScanData* io_data,
do
{
-
if (i_dataSize < bytes)
{
rc = BUG(SCAN_COMPRESSION_BUFFER_OVERFLOW);
@@ -600,7 +603,13 @@ _rs4_compress(CompressedScanData* io_data,
memset(io_data, 0, bytes);
- nibbles = __rs4_compress(io_data, i_data_str, i_care_str, i_length);
+ rc = __rs4_compress(io_data, &nibbles, i_data_str, i_care_str, i_length);
+
+ if (rc != SCAN_COMPRESSION_OK)
+ {
+ break;
+ }
+
bytes = rs4_max_compressed_bytes(nibbles);
io_data->iv_magic = htobe32(RS4_MAGIC);
@@ -614,9 +623,6 @@ _rs4_compress(CompressedScanData* io_data,
io_data->iv_chipletId = i_chipletId;
*o_imageSize = bytes;
-
- rc = SCAN_COMPRESSION_OK;
-
}
while (0);
@@ -628,6 +634,8 @@ _rs4_compress(CompressedScanData* io_data,
// and any rounding required to guarantee that the allocated length is a
// multiple of 8 bytes. The final size is also rounded up to a multiple of 8
// bytes.
+//
+// Returns a scan compression return code.
int
rs4_compress(CompressedScanData** o_data,
OpenPOWER on IntegriCloud