summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/utils
diff options
context:
space:
mode:
authorMartin Peschke <mpeschke@de.ibm.com>2016-06-17 15:34:25 +0200
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-09-02 17:15:27 -0400
commit7f66d4a106a5f2b6097dee197cff262c4b561185 (patch)
tree4265be2619c7fe7966b9a4853df2c0faf40544a3 /src/import/chips/p9/utils
parent1c77420c47edc754fe1ed87cd7650c9203ab7009 (diff)
downloadtalos-hostboot-7f66d4a106a5f2b6097dee197cff262c4b561185.tar.gz
talos-hostboot-7f66d4a106a5f2b6097dee197cff262c4b561185.zip
p9_scan_compression: RS4v2 decompression
This adds RS4v2 support to decompression. Compression was already RS4v2-ready. Change-Id: If9df068740451adb72244053db258084795b7c7d Original-Change-Id: I9621b0f72827924734953fd7fd98f861506bd8e0 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25984 Tested-by: Jenkins Server <pfd-jenkins+hostboot@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/29118 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.C40
1 files changed, 27 insertions, 13 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 da6e907b1..f397edc08 100644
--- a/src/import/chips/p9/utils/imageProcs/p9_scan_compression.C
+++ b/src/import/chips/p9/utils/imageProcs/p9_scan_compression.C
@@ -719,18 +719,20 @@ rs4_compress(CompressedScanData** o_data,
static int
__rs4_decompress(uint8_t* io_data_str,
+ uint8_t* io_care_str,
const uint8_t* i_rs4_str,
const uint32_t i_length)
{
int rc;
int state; /* 0 : Rotate, 1 : Scan */
uint32_t i; /* Nibble index in i_rs4_str */
- uint32_t j; /* Nibble index in io_data_str */
+ uint32_t j; /* Nibble index in io_data_str/io_care_str */
uint32_t k; /* Loop index */
uint32_t bits; /* Number of output bits decoded so far */
uint32_t count; /* Count of rotate nibbles */
uint32_t nibbles; /* Rotate encoding or scan nibbles to process */
int r; /* Remainder bits */
+ int masked; /* if a care mask is available */
rc = 0;
i = 0;
@@ -755,11 +757,9 @@ __rs4_decompress(uint8_t* io_data_str,
i += nibbles;
bits += (4 * count);
- for (k = 0; k < count; k++)
- {
- rs4_set_nibble(io_data_str, j, 0);
- j++;
- }
+ // keep 'count' zero care and data nibbles
+ // as initialised by memset in calling function
+ j += count;
state = 1;
}
@@ -773,16 +773,20 @@ __rs4_decompress(uint8_t* io_data_str,
break;
}
- if ((bits + (4 * nibbles)) > i_length)
+ masked = (nibbles == 15 ? 1 : 0);
+ nibbles = (masked ? 1 : nibbles);
+ bits += 4 * nibbles;
+
+ if (bits > i_length)
{
rc = BUG(SCAN_DECOMPRESSION_SIZE_ERROR);
break;
}
- bits += (4 * nibbles);
-
for (k = 0; k < nibbles; k++)
{
+ rs4_set_nibble(io_care_str, j, rs4_get_nibble(i_rs4_str, i));
+ i = (masked ? i + 1 : i);
rs4_set_nibble(io_data_str, j, rs4_get_nibble(i_rs4_str, i));
i++;
j++;
@@ -797,9 +801,12 @@ __rs4_decompress(uint8_t* io_data_str,
if (!rc)
{
- r = rs4_get_nibble(i_rs4_str, i);
+ nibbles = rs4_get_nibble(i_rs4_str, i);
i++;
+ masked = nibbles & 0x8;
+ r = nibbles & 0x3;
+
if (r != 0)
{
if ((bits + r) > i_length)
@@ -809,6 +816,8 @@ __rs4_decompress(uint8_t* io_data_str,
else
{
bits += r;
+ rs4_set_nibble(io_care_str, j, rs4_get_nibble(i_rs4_str, i));
+ i = (masked ? i + 1 : i);
rs4_set_nibble(io_data_str, j, rs4_get_nibble(i_rs4_str, i));
}
}
@@ -832,6 +841,7 @@ __rs4_decompress(uint8_t* io_data_str,
int
_rs4_decompress(uint8_t* io_data_str,
+ uint8_t* io_care_str,
uint32_t i_stringSize,
uint32_t* o_length,
const CompressedScanData* i_rs4)
@@ -857,8 +867,9 @@ _rs4_decompress(uint8_t* io_data_str,
}
memset(io_data_str, 0, bytes);
+ memset(io_care_str, 0, bytes);
- rc = __rs4_decompress(io_data_str,
+ rc = __rs4_decompress(io_data_str, io_care_str,
(uint8_t*)i_rs4 + sizeof(CompressedScanData),
*o_length);
}
@@ -870,6 +881,7 @@ _rs4_decompress(uint8_t* io_data_str,
int
rs4_decompress(uint8_t** o_data_str,
+ uint8_t** o_care_str,
uint32_t* o_length,
const CompressedScanData* i_rs4)
{
@@ -886,15 +898,17 @@ rs4_decompress(uint8_t** o_data_str,
length = htobe32(i_rs4->iv_length);
bytes = (length + 7) / 8;
+
*o_data_str = (uint8_t*)malloc(bytes);
+ *o_care_str = (uint8_t*)malloc(bytes);
- if (*o_data_str == 0)
+ if (*o_data_str == 0 || *o_care_str == 0)
{
rc = BUG(SCAN_COMPRESSION_NO_MEMORY);
break;
}
- rc = _rs4_decompress(*o_data_str, bytes, o_length, i_rs4);
+ rc = _rs4_decompress(*o_data_str, *o_care_str, bytes, o_length, i_rs4);
}
while (0);
OpenPOWER on IntegriCloud