diff options
| author | Martin Peschke <mpeschke@de.ibm.com> | 2016-06-17 15:34:25 +0200 |
|---|---|---|
| committer | Joshua Hunsberger <jahunsbe@us.ibm.com> | 2017-10-23 16:12:12 -0500 |
| commit | 1438069e87e5abbd63301e1faf2414fcb542fb46 (patch) | |
| tree | 786b68b18e9508958f65e746544ecac4d76d3a34 | |
| parent | 4eb6d046cda4b7e4686f935ff53c05ebe4f4e4f1 (diff) | |
| download | talos-hcode-1438069e87e5abbd63301e1faf2414fcb542fb46.tar.gz talos-hcode-1438069e87e5abbd63301e1faf2414fcb542fb46.zip | |
p9_scan_compression: RS4v2 decompression
This adds RS4v2 support to decompression.
Compression was already RS4v2-ready.
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>
| -rw-r--r-- | import/chips/p9/utils/imageProcs/p9_scan_compression.C | 40 | ||||
| -rw-r--r-- | import/chips/p9/utils/imageProcs/p9_scan_compression.H | 20 |
2 files changed, 43 insertions, 17 deletions
diff --git a/import/chips/p9/utils/imageProcs/p9_scan_compression.C b/import/chips/p9/utils/imageProcs/p9_scan_compression.C index 1c0bf146..a02b0238 100644 --- a/import/chips/p9/utils/imageProcs/p9_scan_compression.C +++ b/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); diff --git a/import/chips/p9/utils/imageProcs/p9_scan_compression.H b/import/chips/p9/utils/imageProcs/p9_scan_compression.H index 7e4505bf..1ffce772 100644 --- a/import/chips/p9/utils/imageProcs/p9_scan_compression.H +++ b/import/chips/p9/utils/imageProcs/p9_scan_compression.H @@ -262,7 +262,13 @@ rs4_compress(CompressedScanData** o_data, /// the decompressed string, which is the size of the original string in bits /// rounded up to the nearest byte. /// -/// \param[in] i_stringSize The size (in bytes) of \a io_data_str. +/// \param[in,out] io_care_str A caller-supplied data area to contain the +/// decompressed care mask. The \a i_stringSize must be large enough to contain +/// the decompressed care mask, which is the size of the original string in +/// bits rounded up to the nearest byte. +/// +/// \param[in] i_stringSize The size (in bytes) of \a io_data_str and +/// \a io_care_str. /// /// \param[out] o_length The length of the decompressed string in \e bits. /// @@ -276,6 +282,7 @@ rs4_compress(CompressedScanData** o_data, /// \returns See \ref scan_compression_codes 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); @@ -287,9 +294,13 @@ _rs4_decompress(uint8_t* io_data_str, /// decompressed string. After this call the caller owns \a o_data_str and is /// responsible for free()-ing this data area once it is no longer required. /// -/// \param[out] o_length The length of the decompressed string in \e bits. -/// The caller may assume that \a o_data_str contains at least -/// (\a o_length + 7) / 8 \e bytes. +/// \param[out] o_care_str The API malloc()-s this data area to contain the +/// decompressed care mask. After this call the caller owns \a o_care_str and +/// is responsible for free()-ing this data area once it is no longer required. +/// +/// \param[out] o_length The length of the decompressed string and care mask +/// in \e bits. The caller may assume that \a o_data_str and o_care_str each +/// contain at least (\a o_length + 7) / 8 \e bytes. /// /// \param[in] i_rs4 A pointer to the CompressedScanData header + data to be /// decompressed. @@ -297,6 +308,7 @@ _rs4_decompress(uint8_t* io_data_str, /// \returns See \ref scan_compression_codes int rs4_decompress(uint8_t** o_data_str, + uint8_t** o_care_str, uint32_t* o_length, const CompressedScanData* i_rs4); |

