diff options
author | Shakeeb <shakeebbk@in.ibm.com> | 2016-06-13 02:07:20 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2016-06-23 15:45:49 -0400 |
commit | 68d68bb83bb1a6f1e29615978feb9861b836b14c (patch) | |
tree | f10ba75b8baa68fdea63afd20dc8c09581ba342c /src/import/chips/p9/xip | |
parent | 45c6a566f49ea3223492e35e21abc7fa9a058970 (diff) | |
download | talos-hostboot-68d68bb83bb1a6f1e29615978feb9861b836b14c.tar.gz talos-hostboot-68d68bb83bb1a6f1e29615978feb9861b836b14c.zip |
p9_xip_tool: Attribute dump parser command
Implementation of 'attrdump' command in xip tool to parse
SBE dump for attributes
Change-Id: I64049b24d4548af494450065bb6d7ab5e9ea2d8e
RTC:134294
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25540
Tested-by: Jenkins Server
Tested-by: PPE CI
Tested-by: Hostboot CI
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Reviewed-by: Martin Peschke <mpeschke@de.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25541
Tested-by: FSP CI Jenkins
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/import/chips/p9/xip')
-rw-r--r-- | src/import/chips/p9/xip/p9_xip_image.c | 158 | ||||
-rw-r--r-- | src/import/chips/p9/xip/p9_xip_image.h | 52 |
2 files changed, 156 insertions, 54 deletions
diff --git a/src/import/chips/p9/xip/p9_xip_image.c b/src/import/chips/p9/xip/p9_xip_image.c index 67e2650c5..b29e929a4 100644 --- a/src/import/chips/p9/xip/p9_xip_image.c +++ b/src/import/chips/p9/xip/p9_xip_image.c @@ -638,12 +638,12 @@ xipImage2Section(const void* i_image, /// /// All return values are optional. -XIP_STATIC int -xipGetToc(void* i_image, - P9XipToc** o_toc, - size_t* o_entries, - int* o_sorted, - char** o_strings) +int +p9_xip_get_toc(void* i_image, + P9XipToc** o_toc, + size_t* o_entries, + int* o_sorted, + char** o_strings) { int rc; P9XipSection tocSection, stringsSection; @@ -777,7 +777,7 @@ xipLinearSearch(void* i_image, const char* i_id, P9XipToc** o_entry) char* strings; *o_entry = 0; - rc = xipGetToc(i_image, &imageToc, &entries, 0, &strings); + rc = p9_xip_get_toc(i_image, &imageToc, &entries, 0, &strings); if (!rc) { @@ -822,7 +822,7 @@ xipBinarySearch(void* i_image, const char* i_id, P9XipToc** o_entry) { *o_entry = 0; - rc = xipGetToc(i_image, &imageToc, &entries, &sorted, &strings); + rc = p9_xip_get_toc(i_image, &imageToc, &entries, &sorted, &strings); if (rc) { @@ -1142,6 +1142,50 @@ xipDecodeToc(void* i_image, return rc; } +int +p9_xip_decode_toc_dump(void* i_image, void* i_dump, + P9XipToc* i_imageToc, + P9XipItem* o_item) +{ + int rc = 0; + P9XipToc hostToc = {0}; + P9XipSection stringsSection = {0}; + + if (!xipNormalized(i_image)) + { + rc = TRACE_ERROR(P9_XIP_NOT_NORMALIZED); + return rc; + } + + // Translate the TOC entry and set the TOC pointer, data type and + // number of elements in the outgoing structure. The Id string is + // always located in the TOC_STRINGS section. + + xipTranslateToc(&hostToc, i_imageToc); + + o_item->iv_toc = i_imageToc; + o_item->iv_type = hostToc.iv_type; + o_item->iv_elements = hostToc.iv_elements; + + p9_xip_get_section(i_image, P9_XIP_SECTION_STRINGS, &stringsSection); + o_item->iv_id = + (char*)i_image + stringsSection.iv_offset + hostToc.iv_id; + + //Print only the attributes present in fixed section of SEEPROM image + if (hostToc.iv_section == P9_XIP_SECTION_FIXED) + { + //get the attribute value from dump file + o_item->iv_imageData = (void*)((uint8_t*)i_dump + hostToc.iv_data); + o_item->iv_address = xipLinkAddress(i_image) + hostToc.iv_data; + o_item->iv_partial = 0; + } + else + { + o_item->iv_address = 0; + } + + return rc; +} /// Sort the TOC @@ -1167,7 +1211,7 @@ xipSortToc(void* io_image) break; } - rc = xipGetToc(io_image, &hostToc, &entries, 0, &strings); + rc = p9_xip_get_toc(io_image, &hostToc, &entries, 0, &strings); if (rc) { @@ -1807,7 +1851,7 @@ p9_xip_normalize(void* io_image) if (!xipNormalized(io_image)) { - rc = xipGetToc(io_image, &imageToc, &tocEntries, 0, 0); + rc = p9_xip_get_toc(io_image, &imageToc, &tocEntries, 0, 0); if (rc) { @@ -2006,67 +2050,75 @@ p9_xip_find(void* i_image, return rc; } +int +p9_xip_get_item(const P9XipItem* i_item, uint64_t* o_data) +{ + switch (i_item->iv_type) + { + case P9_XIP_UINT8: + *o_data = *((uint8_t*)(i_item->iv_imageData)); + break; + case P9_XIP_UINT16: + *o_data = htobe16(*((uint16_t*)(i_item->iv_imageData))); + break; + case P9_XIP_UINT32: + *o_data = htobe32(*((uint32_t*)(i_item->iv_imageData))); + break; -int -p9_xip_get_scalar(void* i_image, const char* i_id, uint64_t* o_data) -{ - int rc; - P9XipItem item; + case P9_XIP_UINT64: + *o_data = htobe64(*((uint64_t*)(i_item->iv_imageData))); + break; - rc = p9_xip_find(i_image, i_id, &item); + case P9_XIP_INT8: + *o_data = *((int8_t*)(i_item->iv_imageData)); + break; - if (!rc) - { - switch (item.iv_type) - { - case P9_XIP_UINT8: - *o_data = *((uint8_t*)(item.iv_imageData)); - break; + case P9_XIP_INT16: + *o_data = htobe16(*((int16_t*)(i_item->iv_imageData))); + break; - case P9_XIP_UINT16: - *o_data = htobe16(*((uint16_t*)(item.iv_imageData))); - break; + case P9_XIP_INT32: + *o_data = htobe32(*((int32_t*)(i_item->iv_imageData))); + break; - case P9_XIP_UINT32: - *o_data = htobe32(*((uint32_t*)(item.iv_imageData))); - break; + case P9_XIP_INT64: + *o_data = htobe64(*((int64_t*)(i_item->iv_imageData))); + break; - case P9_XIP_UINT64: - *o_data = htobe64(*((uint64_t*)(item.iv_imageData))); - break; + case P9_XIP_ADDRESS: + *o_data = i_item->iv_address; + break; - case P9_XIP_INT8: - *o_data = *((int8_t*)(item.iv_imageData)); - break; + case P9_XIP_STRING: + //Nothing to do in case of string, but making sure rc is valid + break; - case P9_XIP_INT16: - *o_data = htobe16(*((int16_t*)(item.iv_imageData))); - break; + default: + return TRACE_ERROR(P9_XIP_TYPE_ERROR); + break; + } - case P9_XIP_INT32: - *o_data = htobe32(*((int32_t*)(item.iv_imageData))); - break; + return 0; +} - case P9_XIP_INT64: - *o_data = htobe64(*((int64_t*)(item.iv_imageData))); - break; +int +p9_xip_get_scalar(void* i_image, const char* i_id, uint64_t* o_data) +{ + int rc; + P9XipItem item; - case P9_XIP_ADDRESS: - *o_data = item.iv_address; - break; + rc = p9_xip_find(i_image, i_id, &item); - default: - rc = TRACE_ERROR(P9_XIP_TYPE_ERROR); - break; - } + if (!rc) + { + rc = p9_xip_get_item(&item, o_data); } return rc; } - int p9_xip_get_element(void* i_image, const char* i_id, @@ -2972,7 +3024,7 @@ p9_xip_map_toc(void* io_image, break; } - rc = xipGetToc(io_image, &imageToc, &entries, 0, 0); + rc = p9_xip_get_toc(io_image, &imageToc, &entries, 0, 0); if (rc) { diff --git a/src/import/chips/p9/xip/p9_xip_image.h b/src/import/chips/p9/xip/p9_xip_image.h index 979e58c7d..ed000488f 100644 --- a/src/import/chips/p9/xip/p9_xip_image.h +++ b/src/import/chips/p9/xip/p9_xip_image.h @@ -238,7 +238,7 @@ typedef enum { //////////////////////////////////////////////////////////////////////////// #ifndef __ASSEMBLER__ - +#include <stddef.h> #include <stdint.h> #ifdef __cplusplus @@ -725,6 +725,21 @@ int p9_xip_get_scalar(void* i_image, const char* i_id, uint64_t* o_data); +/// Get endianness converted value from the P9-XIP image toc data +/// +/// \param[in] i_item - decoded toc entry + +/// \param[out] o_data A pointer to an 8-byte integer to receive the scalar +/// data. Assuming the item is located this variable is assigned by the call. +/// In the event of an error the final state of \a o_data is not specified. +/// +/// \retval 0 Success +/// +/// \retval non-0 See \ref p9_xip_image_errors +int +p9_xip_get_item(const P9XipItem *i_item, uint64_t* o_data); + + /// Get an integral element from a vector held in a P9-XIP image /// /// \param[in] i_image A pointer to a P9-XIP image in host memory. The @@ -1279,7 +1294,42 @@ p9_xip_host2image(const void* i_image, void* i_hostAddress, uint64_t* o_imageAddress); +/// Get all the information required to search and find the TOC +/// +/// \param[in] i_image A pointer to a P9-XIP image in host memory +/// +/// \param[out][optional] o_toc A pointer to TOC listing +/// +/// \param[out][optional] o_entries Number of TOC entries located +/// +/// \param[out][optional] o_sorted Indication if the TOC is sorted +/// +/// \param[out][optional] o_strings A pointer to String section containing TOC +/// names +/// +/// \retval 0 Success +/// +/// \retval non-0 See \ref p9_xip_image_errors +int +p9_xip_get_toc(void* i_image, + P9XipToc** o_toc, + size_t* o_entries, + int* o_sorted, + char** o_strings); + +/// \brief Decode a TOC entry from dump file +/// +///\param[in] - i_image - seeprom image +///\param[in] - i_dump - dump file +///\param[in] - i_imageToc - TOC entry +///\param[out] - o_item - decoded toc entry +/// +///\return - 0 Success; non-0 See \ref p9_xip_image_errors +int +p9_xip_decode_toc_dump(void* i_image, void* i_dump, + P9XipToc* i_imageToc, + P9XipItem* o_item); // PHYP has their own way of implementing the <string.h> functions. PHYP also // does not allow static functions or data, so all of the XIP_STATIC functions |