summaryrefslogtreecommitdiffstats
path: root/import/chips/p9/utils/imageProcs
diff options
context:
space:
mode:
authorRichard J. Knight <rjknight@us.ibm.com>2017-06-27 12:16:16 -0500
committerJoshua Hunsberger <jahunsbe@us.ibm.com>2018-02-05 15:17:18 -0600
commit92034916221c7e416081447f47c86aebe5130897 (patch)
treeab5c1333a8ac763bb554da8f08882087f87ef7a6 /import/chips/p9/utils/imageProcs
parentd0dd236cb23bae5f617faba9dced27a3ae3f085b (diff)
downloadtalos-hcode-92034916221c7e416081447f47c86aebe5130897.tar.gz
talos-hcode-92034916221c7e416081447f47c86aebe5130897.zip
p9_xip_tool support for DD level section parsing
- Currently supports only .overlays section. - Fixed an heap problem causing segmentation fault after repetitive use of malloc in rs4_decompress() and rs4_extract_cmsk(). Now allocating buffers locally and calling _rs4_decompress() and _rs4_extract_cmsk() instead so only have to use malloc once. - Fixed a bug in the usage of the ringBlockPtr which got moved away from pointing to its initially allocated buffer after the first CMSK ring is processed. - Even though malloc() can be used in a C++ context, we really should be using the new() operator. So, I replaced all malloc() and free() with new() and delete() instead in both p9_xip_tool.C and p9_scan_compression.C. Change-Id: Iccef1ae8491d66fc3021a8f6e851768fd19da92b Original-Change-Id: I2da7509ed7aaa13345185dc07bce57f71c3740fd Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/42531 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com> Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: Richard J. Knight <rjknight@us.ibm.com> Reviewed-by: Sumit Kumar <sumit_kumar@in.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Diffstat (limited to 'import/chips/p9/utils/imageProcs')
-rw-r--r--import/chips/p9/utils/imageProcs/p9_scan_compression.H65
1 files changed, 46 insertions, 19 deletions
diff --git a/import/chips/p9/utils/imageProcs/p9_scan_compression.H b/import/chips/p9/utils/imageProcs/p9_scan_compression.H
index 33aa8a1d..fe38dfe4 100644
--- a/import/chips/p9/utils/imageProcs/p9_scan_compression.H
+++ b/import/chips/p9/utils/imageProcs/p9_scan_compression.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HCODE Project */
/* */
-/* COPYRIGHT 2016,2017 */
+/* COPYRIGHT 2016,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -123,8 +123,9 @@ compressed_scan_data_translate(CompressedScanData* o_data,
/// <ChipType> ring ID header files for more info.)
///
/// This API is required for integration with PHYP which does not support
-/// malloc(). Applications in environments supporting malloc() can use
-/// rs4_compress() instead.
+/// local memory allocation, like malloc() and new(). Applications in
+/// environments supporting local memory allocation can use rs4_compress()
+/// instead.
///
/// 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
@@ -145,7 +146,7 @@ _rs4_compress(CompressedScanData* io_rs4,
/// Compress a scan string using the RS4 compression algorithm
///
-/// \param[out] o_rs4 This algorithm uses malloc() to allocate memory for the
+/// \param[out] o_rs4 This algorithm uses new() to allocate memory for the
/// compressed data, and returns a pointer to this memory in \a o_rs4. After
/// the call this memory is owned by the caller who is responsible for
/// free()-ing the data area once it is no longer required. Note that the
@@ -189,7 +190,9 @@ rs4_compress(CompressedScanData** o_rs4,
/// the decompressed care mask, which is the size of the original string in
/// bits rounded up to the nearest byte.
///
-/// \param[in] i_size The size in \e bytes of \a io_data_str and \a io_care_str.
+/// \param[in] i_size The size in \e bytes of \a o_data_str and \a o_care_str
+/// buffers and which represents the max number of raw ring bits x 8 that may
+/// fit into the two raw ring buffers.
///
/// \param[out] o_length The length of the decompressed string in \e bits.
///
@@ -197,13 +200,14 @@ rs4_compress(CompressedScanData** o_rs4,
/// decompressed.
///
/// This API is required for integration with PHYP which does not support
-/// malloc(). Applications in environments supporting malloc() can use
-/// rs4_decompress() instead.
+/// local memory allocation, such as malloc() and new(). Applications in
+/// environments supporting local memory allocation can use rs4_decompress()
+/// instead.
///
/// \returns See \ref scan_compression_codes
int
-_rs4_decompress(uint8_t* io_data_str,
- uint8_t* io_care_str,
+_rs4_decompress(uint8_t* o_data_str,
+ uint8_t* o_care_str,
uint32_t i_size,
uint32_t* o_length,
const CompressedScanData* i_rs4);
@@ -211,11 +215,11 @@ _rs4_decompress(uint8_t* io_data_str,
/// Decompress a scan string compressed using the RS4 compression algorithm
///
-/// \param[out] o_data_str The API malloc()-s this data area to contain the
+/// \param[out] o_data_str The API new() allocs this data area to contain the
/// 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_care_str The API malloc()-s this data area to contain the
+/// \param[out] o_care_str The API new() allocs 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.
///
@@ -251,7 +255,7 @@ rs4_redundant(const CompressedScanData* i_data, int* o_redundant);
/// \param[in] i_rs4 A pointer to the RS4 CompressedScanData [header + data]
///
/// \returns 1 if CMSK ring found, 0 otherwise
-int rs4_is_cmsk(CompressedScanData* i_rs4);
+int rs4_is_cmsk(const CompressedScanData* i_rs4);
/// Embed CMSK ring into an RS4 ring
@@ -265,18 +269,41 @@ int rs4_embed_cmsk(CompressedScanData** io_rs4,
CompressedScanData* i_rs4_cmsk);
-/// Extract Stump & CMSK rings from an RS4 ring
+/// Extract Stump & CMSK rings from an RS4 ring (assumes pre-allocated ring buffers)
///
-/// \param[in] i_rs4 A pointer to the CompressedScanData [header + data]
+/// \param[in] i_rs4 A pointer to the input hybrid CMSK RS4 ring and which must contain
+/// boto CompressedScanData header + RS4 encoded data string.
///
-/// \param[inout] i_rs4_stump A pointer to the Stump CompressedScanData [header + data]
+/// \param[in] i_size Size of buffers to hold the output Stump and CMSK RS4 rings.
///
-/// \param[inout] i_rs4_cmsk A pointer to the Cmsk CompressedScanData [header + data]
+/// \param[out] o_rs4_stump A pointer to a pre-allocated buffer that must be big
+/// enough to hold the Stump CompressedScanData [header + data].
+///
+/// \param[out] o_rs4_cmsk A pointer to a pre-allocated buffer that must be big
+/// enough to hold the Cmsk CompressedScanData [header + data].
+///
+/// \returns See \ref scan_compression_codes
+int _rs4_extract_cmsk( const CompressedScanData* i_rs4,
+ size_t i_size,
+ CompressedScanData* o_rs4_stump,
+ CompressedScanData* o_rs4_cmsk );
+
+
+/// Extract Stump & CMSK rings from an RS4 ring (local allocation of ring buffers)
+///
+/// \param[in] i_rs4 A pointer to the input hybrid CMSK RS4 ring and which must contain
+/// boto CompressedScanData header + RS4 encoded data string.
+///
+/// \param[out] o_rs4_stump A pointer to a locally allocated buffer that holds the
+/// Stump CompressedScanData [header + data]. The calling code must free the buffer.
+///
+/// \param[out] o_rs4_cmsk A pointer to a locally allocated buffer that holds the
+/// Cmsk CompressedScanData [header + data]. The calling code must free the buffer.
///
/// \returns See \ref scan_compression_codes
-int rs4_extract_cmsk(CompressedScanData* i_rs4,
- CompressedScanData** io_rs4_stump,
- CompressedScanData** io_rs4_cmsk);
+int rs4_extract_cmsk( const CompressedScanData* i_rs4,
+ CompressedScanData** o_rs4_stump,
+ CompressedScanData** o_rs4_cmsk );
#endif // __ASSEMBLER__
OpenPOWER on IntegriCloud