summaryrefslogtreecommitdiffstats
path: root/src/import/chips
diff options
context:
space:
mode:
authorClaus Michael Olsen <cmolsen@us.ibm.com>2017-03-30 20:20:23 -0500
committerSachin Gupta <sgupta2m@in.ibm.com>2017-05-12 22:27:58 -0400
commit8fb3f52276fd37466afb34b85a1dbda3c8ee3e9f (patch)
treeff056cec9819cca8d29ffd98c6b341eae770ad4f /src/import/chips
parent618c88eba551a9a971b8873a3ec1e9a13230f93e (diff)
downloadtalos-sbe-8fb3f52276fd37466afb34b85a1dbda3c8ee3e9f.tar.gz
talos-sbe-8fb3f52276fd37466afb34b85a1dbda3c8ee3e9f.zip
H-code ddLevel support - Front-end hooks for user and back-end codes.
xip_image.c has been renamed to xip_image.C to take advantage of C++ ability to overload function call arg list to avoid having to introduce additional skinny "xip_dd_get_section" and "xip_dd_append" functions. p9_xip_get_section() and p9_xip_append() APIs have been updated with an additional DD support arg as their last parm. P9XipSection.iv_reserved8[0] converted to iv_ddSupport to enable XIP level knowledge about ddSupport capability of XIP sections. Introduced p9_xip_dd_section_support() that queries a section's iv_ddSupport flag to tell caller true/false about a sections ddLevel support status. Added support in xip_tool.C as follows: - Updated "append" command to accept an optional arg, ddSupport, if section has ddLevel support or not. - Updated "extract" command to accept an optional arg, ddLevel, specifying which ddLevel to extract. - Updated "report" command's listing to show ddLevel support status of sections. Change-Id: I17e1e09d63e894d4f26cb7b324cf10ab784d78a4 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38666 Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38667 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'src/import/chips')
-rw-r--r--src/import/chips/p9/xip/p9_xip_image.C (renamed from src/import/chips/p9/xip/p9_xip_image.c)67
-rw-r--r--src/import/chips/p9/xip/p9_xip_image.h52
-rw-r--r--src/import/chips/p9/xip/p9_xip_tool.C205
3 files changed, 272 insertions, 52 deletions
diff --git a/src/import/chips/p9/xip/p9_xip_image.c b/src/import/chips/p9/xip/p9_xip_image.C
index c97a3d02..96e83c67 100644
--- a/src/import/chips/p9/xip/p9_xip_image.c
+++ b/src/import/chips/p9/xip/p9_xip_image.C
@@ -1,11 +1,11 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: src/import/chips/p9/xip/p9_xip_image.c $ */
+/* $Source: src/import/chips/p9/xip/p9_xip_image.C $ */
/* */
/* OpenPOWER sbe Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2017 */
+/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -49,7 +49,6 @@
#include <string.h>
#include "p9_xip_image.h"
-
////////////////////////////////////////////////////////////////////////////
// Local Functions
////////////////////////////////////////////////////////////////////////////
@@ -391,9 +390,9 @@ xipTranslateSection(P9XipSection* o_dest, const P9XipSection* i_src)
o_dest->iv_offset = htobe32(i_src->iv_offset);
o_dest->iv_size = htobe32(i_src->iv_size);
o_dest->iv_alignment = i_src->iv_alignment;
+ o_dest->iv_ddSupport = i_src->iv_ddSupport;
o_dest->iv_reserved8[0] = 0;
o_dest->iv_reserved8[1] = 0;
- o_dest->iv_reserved8[2] = 0;
#else
if (o_dest != i_src)
@@ -2005,6 +2004,7 @@ p9_xip_image_size(void* io_image, uint32_t* o_size)
}
+#ifdef __PPE__
int
p9_xip_get_section(const void* i_image,
const int i_sectionId,
@@ -2023,6 +2023,33 @@ p9_xip_get_section(const void* i_image,
return rc;
}
+#else
+
+int
+p9_xip_get_section(const void* i_image,
+ const int i_sectionId,
+ P9XipSection* o_hostSection,
+ const uint8_t i_ddLevel)
+{
+ int rc;
+ P9XipSection* imageSection;
+
+ if (i_ddLevel != P9_XIP_UNDEFINED_DDLEVEL)
+ {
+ return P9_XIP_NO_DDLEVEL_SUPPORT;
+ }
+
+ rc = xipGetSectionPointer(i_image, i_sectionId, &imageSection);
+
+ if (!rc)
+ {
+ xipTranslateSection(o_hostSection, imageSection);
+ }
+
+ return rc;
+}
+#endif
+
// If the 'big' TOC is not present, search the mini-TOCs that only index the
// .fixed and .header sections.
@@ -2638,7 +2665,8 @@ p9_xip_delete_section(void* io_image,
(void*)(((uint8_t*)o_imageBuf) + section.iv_offset),
(const uint32_t)section.iv_size,
(const uint32_t)imageSize,
- NULL );
+ NULL,
+ section.iv_ddSupport );
if (rc)
{
@@ -2749,7 +2777,8 @@ p9_xip_append(void* io_image,
const void* i_data,
const uint32_t i_size,
const uint32_t i_allocation,
- uint32_t* o_sectionOffset)
+ uint32_t* o_sectionOffset,
+ uint8_t i_ddSupport)
{
P9XipSection section, initialSection;
int rc, final, restoreOnError;
@@ -2799,7 +2828,6 @@ p9_xip_append(void* io_image,
}
section.iv_offset = xipImageSize(io_image);
-
}
else
{
@@ -2868,6 +2896,8 @@ p9_xip_append(void* io_image,
section.iv_size += i_size;
+ section.iv_ddSupport = i_ddSupport;
+
if (xipPutSection(io_image, i_sectionId, &section) != 0)
{
rc = TRACE_ERROR(P9_XIP_BUG); /* Can't happen */
@@ -3156,3 +3186,26 @@ p9_xip_map_toc(void* io_image,
return rc;
}
+
+
+#ifndef __PPE__
+//
+// Inform caller if specified sectionId has DD support
+//
+int p9_xip_dd_section_support(const void* i_image,
+ const int i_sectionId,
+ bool& o_bDdSupport)
+{
+ int rc;
+ P9XipSection section;
+
+ rc = p9_xip_get_section(i_image, i_sectionId, &section);
+
+ if (!rc)
+ {
+ o_bDdSupport = (bool)section.iv_ddSupport;
+ }
+
+ return rc;
+}
+#endif
diff --git a/src/import/chips/p9/xip/p9_xip_image.h b/src/import/chips/p9/xip/p9_xip_image.h
index 3961478d..484ce5a8 100644
--- a/src/import/chips/p9/xip/p9_xip_image.h
+++ b/src/import/chips/p9/xip/p9_xip_image.h
@@ -238,6 +238,9 @@ typedef enum {
/// gaurantee that the something will be able to complete any 8-byte load/store.
#define P9_XIP_FINAL_ALIGNMENT 8
+/// Local undefined DD level value.
+#define P9_XIP_UNDEFINED_DDLEVEL (uint8_t)0xff
+
////////////////////////////////////////////////////////////////////////////
// C Definitions
@@ -306,8 +309,12 @@ typedef struct
/// address. Alignment specifications are required to be a power-of-2.
uint8_t iv_alignment;
+ /// Indicate if section has DD-level support. This value must be set
+ /// to either 1 for true or 0 for false (default).
+ uint8_t iv_ddSupport;
+
/// Reserved structure alignment padding; Pad to 12 bytes
- uint8_t iv_reserved8[3];
+ uint8_t iv_reserved8[2];
} P9XipSection;
@@ -683,13 +690,21 @@ p9_xip_image_size(void* i_image, uint32_t* o_size);
/// \param[out] o_hostSection Updated to contain the section table entry
/// translated to host byte order.
///
+/// \param[in] i_ddLevel Specified the DD level of the sub-section within
+/// the XIP section to be extracted.
+///
/// \retval 0 Success
///
/// \retval non-0 See \ref p9_xip_image_errors
int
p9_xip_get_section(const void* i_image,
const int i_sectionId,
+#ifdef __PPE__
P9XipSection* o_hostSection);
+#else
+ P9XipSection* o_hostSection,
+ uint8_t i_ddLevel=P9_XIP_UNDEFINED_DDLEVEL);
+#endif
/// Endian translation of a P9XipHeader object
@@ -1150,6 +1165,9 @@ p9_xip_duplicate_section(const void* i_image,
/// byte of the appended data within the indicated section. This return value
/// is invalid in the event of a non-0 return code.
///
+/// \param[in] i_ddSupport Specifies if the section contains ddLevel sub-
+/// sections (=1) or if it does not have ddLevel support (=0).
+///
/// This API copies data from \a i_data to the end of the indicated \a
/// i_section. The section \a i_section must either be empty, or must be the
/// final (highest address) section in the image. If the section is initially
@@ -1200,7 +1218,8 @@ p9_xip_append(void* io_image,
const void* i_data,
const uint32_t i_size,
const uint32_t i_allocation,
- uint32_t* o_sectionOffset);
+ uint32_t* o_sectionOffset,
+ uint8_t i_ddSupport);
/// Convert a P9-XIP section offset to a relocatable IMAGE address
@@ -1348,6 +1367,27 @@ p9_xip_get_toc(void* i_image,
char** o_strings);
+/// Inform caller if specified sectionId has DD support
+///
+/// \param[in] i_image A pointer to a P9-XIP image in host memory.
+///
+/// \param[in] i_sectionId Identifies the section to be queried. See \ref
+/// p9_xip_sections.
+///
+/// \param[out] o_bDdSupport Updated to contain true or false whether
+/// sectionId has DD support or not.
+///
+/// \retval 0 Success
+///
+/// \retval non-0 See \ref p9_xip_image_errors
+#ifndef __PPE__
+int
+p9_xip_dd_section_support(const void* i_image,
+ const int i_sectionId,
+ bool& o_bDdSupport);
+#endif
+
+
/// \brief Decode a TOC entry from dump file
///
///\param[in] - i_image - seeprom image
@@ -1458,6 +1498,12 @@ p9_xip_decode_toc_dump(void* i_image, void* i_dump,
/// .rings seciton for specific dd level is larger than the allowable size
#define P9_XIP_SBE_DD_SIZE_ERR 19
+/// Specified section has no ddLevel support
+#define P9_XIP_NO_DDLEVEL_SUPPORT 20
+
+/// Specified ddLevel was not found in section
+#define P9_XIP_DDLEVEL_NOT_FOUND 21
+
/// Applications can expand this macro to declare an array of string forms of
/// the error codes if desired.
#define P9_XIP_ERROR_STRINGS(var) \
@@ -1482,6 +1528,8 @@ p9_xip_decode_toc_dump(void* i_image, void* i_dump,
"P9_XIP_NULL_BUFFER", \
"P9_XIP_CANT_RESTORE_IMAGE", \
"P9_XIP_SBE_DD_SIZE_ERR", \
+ "P9_XIP_NO_DDLEVEL_SUPPORT", \
+ "P9_XIP_DDLEVEL_NOT_FOUND", \
}
/// Applications can use this macro to safely index the array of error
diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C
index ab109c87..e6fe0793 100644
--- a/src/import/chips/p9/xip/p9_xip_tool.C
+++ b/src/import/chips/p9/xip/p9_xip_tool.C
@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <string>
#undef P9_XIP_TOOL_VERBOSE
@@ -72,10 +73,10 @@ enum LISTING_MODE_ID
// p9_xip_tool <image> [-<flag> ...] setv <item> <index> <value> [ <item1> <index1> <value1> ... ]
// p9_xip_tool <image> [-<flag> ...] report [<regex>]
// p9_xip_tool <image> [-<flag> ...] attrdump <attr dump file>
-// p9_xip_tool <image> [-<flag> ...] append <section> <file>
-// p9_xip_tool <image> [-<flag> ...] extract <section> <file>
+// p9_xip_tool <image> [-<flag> ...] append <section> <file> [ <ddSupport> ]
+// p9_xip_tool <image> [-<flag> ...] extract <section> <file> [ <ddLevel> ]
// p9_xip_tool <image> [-<flag> ...] delete <section> [ <section1> ... <sectionN> ]
-// p9_xip_tool <image> [-<flag> ...] dissect <ring section> [table,short,normal(default),long,raw]
+// p9_xip_tool <image> [-<flag> ...] dissect <ring section> [ table,short,normal(default),long,raw ]
// p9_xip_tool <image> [-<flag> ...] disasm <text section>
//
// This simple application uses the P9-XIP image APIs to normalize, search
@@ -127,9 +128,18 @@ enum LISTING_MODE_ID
// Currently the section must either be the final (highest address) section of
// the image, or must be empty, in which case the append command creates the
// section as the final section of the image. The 'append' command writes the
-// relocatable image address where the input file was loaded to stdout.
+// relocatable image address where the input file was loaded to stdout. The
+// last argument, ddSupport, indicates if the section being added has ddLevel
+// metadata support (=1) or not (=0). If this arg is omitted it's assumed
+// to be false (=0).
//
-// The 'extract' command extracts a sections from the binary image.
+// The 'extract' command extracts a section from the binary image. The last
+// argument, ddLevel, indicates [in hex] the DD level to be extracted. If
+// the section doesn't have DD level support, a message is returned stating
+// that and to reissue the command w/o the ddLevel arg. If the section does
+// have DD support but the specified ddLevel cannot be found, a message is
+// returned stating that and no section is returned. If the arg is omitted,
+// the entire XIP section is returned
//
// The 'delete' command deletes 0 or more sections, starting with <section0>.
// Each section to be deleted must either be the final (highest address)
@@ -165,11 +175,11 @@ const char* g_usage =
" p9_xip_tool <image> [-i<flag> ...] setv <item> <index> <value> [ <item1> <index1> <value1> ... ]\n"
" p9_xip_tool <image> [-i<flag> ...] report [<regex>]\n"
" p9_xip_tool <image> [-i<flag> ...] attrdump <attr dump file>\n"
- " p9_xip_tool <image> [-i<flag> ...] append <section> <file>\n"
- " p9_xip_tool <image> [-i<flag> ...] extract <section> <file>\n"
+ " p9_xip_tool <image> [-i<flag> ...] append <section> <file> [ <ddSupport> ]\n"
+ " p9_xip_tool <image> [-i<flag> ...] extract <section> <file> [ <ddLevel> ]\n"
" p9_xip_tool <image> [-i<flag> ...] delete <section> [ <section1> ... <sectionN> ]\n"
" p9_xip_tool <image> [-i<flag> ...] dis <section>\n"
- " p9_xip_tool <image> [-i<flag> ...] dissect <ring section> [table,short,normal(default),long,raw]\n"
+ " p9_xip_tool <image> [-i<flag> ...] dissect <ring section> [ table,short,normal(default),long,raw ]\n"
" p9_xip_tool <image> [-i<flag> ...] disasm <text section>\n"
" p9_xip_tool <image> [-i<flag> ...] check-sbe-ring-section <dd level> <maximum size>\n"
"\n"
@@ -222,9 +232,18 @@ const char* g_usage =
"Currently the section must either be the final (highest address) section of\n"
"the image, or must be empty, in which case the append command creates the\n"
"section as the final section of the image. The 'append' command writes the\n"
- "relocatable image address where the input file was loaded to stdout.\n"
+ "relocatable image address where the input file was loaded to stdout. The\n"
+ "last argument, ddSupport, indicates if the section being added has ddLevel\n"
+ "metadata support (=1) or not (=0). If this arg is omitted, it's assumed\n"
+ "to be false (=0).\n"
"\n"
- "The 'extract' command extracs a sections from a binary image.\n"
+ "The 'extract' command extracts a section from the binary image. The last\n"
+ "argument, ddLevel, indicates [in hex] the DD level to be extracted. If\n"
+ "the section doesn't have DD level support, a message is returned stating\n"
+ "that and to reissue the command w/o the ddLevel arg. If the section does\n"
+ "have DD support but the specified ddLevel cannot be found, a message is\n"
+ "returned stating that and no section is returned. If the arg is omitted,\n"
+ "the entire XIP section is returned."
"\n"
"The 'delete' command deletes 0 or more sections, starting with <section0>.\n"
"Each section to be deleted must either be the final (highest address)\n"
@@ -322,12 +341,12 @@ static inline const char* get_sectionName(uint64_t magic, int index)
// Determine index of section given by its name in section table
-static inline int get_sectionId(uint64_t i_magic, const char* i_section)
+static inline int get_sectionId(uint64_t i_magic, const char* i_sectionName)
{
int i;
for (i = 0; i < P9_XIP_SECTIONS; i++)
- if (strcmp(i_section, get_sectionName(i_magic, i)) == 0)
+ if (strcmp(i_sectionName, get_sectionName(i_magic, i)) == 0)
{
return i;
}
@@ -566,15 +585,16 @@ dumpHeader(void* i_image)
printf("\n");
printf("Section Table :\n\n");
- printf(" Name Alignment Start End Size\n");
+ printf(" Name Align DD Start End Size\n");
printf("\n");
for (i = 0; i < P9_XIP_SECTIONS; i++)
{
section = &(header.iv_section[i]);
- printf(" %-16s %d 0x%08x ",
+ printf(" %-16s %d %d 0x%08x ",
get_sectionName(header.iv_magic, i),
section->iv_alignment,
+ section->iv_ddSupport,
section->iv_offset);
if (section->iv_size == 0)
@@ -1090,6 +1110,7 @@ static int
append(const char* i_imageFile, const int i_imageFd, void* io_image,
int i_argc, const char** i_argv)
{
+ uint8_t i_ddSupport = 0;
int fileFd, newImageFd, sectionId, rc;
struct stat buf;
const char* section;
@@ -1105,7 +1126,7 @@ append(const char* i_imageFile, const int i_imageFd, void* io_image,
// Basic syntax check: <section> <file>
- if (i_argc != 2)
+ if (i_argc != 2 && i_argc != 3)
{
fprintf(stderr, g_usage);
exit(1);
@@ -1114,6 +1135,23 @@ append(const char* i_imageFile, const int i_imageFd, void* io_image,
section = i_argv[0];
file = i_argv[1];
+ if (i_argc == 3)
+ {
+ if (strcmp(i_argv[2], "1") == 0)
+ {
+ i_ddSupport = 1;
+ }
+ else if (strcmp(i_argv[2], "0") == 0)
+ {
+ i_ddSupport = 0;
+ }
+ else
+ {
+ fprintf(stderr, g_usage);
+ exit(1);
+ }
+ }
+
p9_xip_translate_header(&header, (P9XipHeader*)io_image);
// Translate the section name to a section Id
@@ -1190,9 +1228,13 @@ append(const char* i_imageFile, const int i_imageFd, void* io_image,
// We will not fail for unaligned addresses, as we have no knowledge
// of whether or why the user wants the final image address.
- rc = p9_xip_append(newImage, sectionId,
- appendImage, buf.st_size,
- newSize, &sectionOffset);
+ rc = p9_xip_append(newImage,
+ sectionId,
+ appendImage,
+ buf.st_size,
+ newSize,
+ &sectionOffset,
+ i_ddSupport);
if (rc)
{
@@ -1248,63 +1290,140 @@ append(const char* i_imageFile, const int i_imageFd, void* io_image,
return rc;
}
-// Extract section from a file
+// Extract section from an image incl a DD-specific sub-section within an XIP section.
static int
extract(const char* i_imageFile, const int i_imageFd, void* io_image,
int i_argc, const char** i_argv)
{
- int fileFd, sectionId, rc;
+ int rc = 0;
+ const char* i_sectionName; //Direct copy of input arg, thus i_
+ const char* i_fileName; //Same
+ std::string i_ddLevelStr; //Same
+ uint8_t ddLevel = P9_XIP_UNDEFINED_DDLEVEL;
+ bool bDdSuppExpected = false;
+ int fileFd, sectionId;
void* newImage;
- const char* section;
- const char* file;
P9XipHeader header;
- P9XipSection* xSection;
- uint32_t size;
- uint32_t offset;
+ P9XipSection* xSection; // XIP section of i_section
+ P9XipSection xDdSection; // Extracted XIP (self) or Dd section of i_section
do
{
- if (i_argc != 2)
+ if (i_argc != 2 && i_argc != 3)
{
fprintf(stderr, g_usage);
exit(1);
}
- section = i_argv[0];
- file = i_argv[1];
-
- printf("%s %s\n", section , file);
+ i_sectionName = i_argv[0];
+ i_fileName = i_argv[1];
p9_xip_translate_header(&header, (P9XipHeader*)io_image);
-
- sectionId = get_sectionId(header.iv_magic, section);
+ sectionId = get_sectionId(header.iv_magic, i_sectionName);
if (sectionId < 0)
{
- fprintf(stderr, "Unrecognized section name : '%s;\n", section);
+ fprintf(stderr, "\nUnrecognized section name : '%s;\n", i_sectionName);
exit(1);
}
xSection = &(header.iv_section[sectionId]);
- size = xSection->iv_size;
- offset = xSection->iv_offset;
+ printf("\nInput parms to the \"extract\" command:\n"\
+ " Section: %s\n"\
+ " Output file: %s\n",
+ i_sectionName, i_fileName);
- printf("%-16s 0x%08x 0x%08x (%d)\n",
- section, offset, size, size);
+ ddLevel = P9_XIP_UNDEFINED_DDLEVEL;
+ bDdSuppExpected = false;
- newImage = malloc(size);
+ if (i_argc == 3)
+ {
+ i_ddLevelStr = i_argv[2];
+
+ bDdSuppExpected = true;
+
+ printf(" DD level (input): %s\n",
+ i_ddLevelStr.c_str());
+ }
+
+ if (bDdSuppExpected)
+ {
+ if (xSection->iv_ddSupport)
+ {
+ if (i_ddLevelStr.size() != 2 && i_ddLevelStr.size() != 4)
+ {
+ fprintf(stderr, "\nThe specified ddLevel \"%s\" has an unsupported format.\n",
+ i_ddLevelStr.c_str());
+ fprintf(stderr, "Specify ddLevel in hex format, e.g. \"0x10\" or \"10\"\n\n");
+ exit(1);
+ }
+
+ ddLevel = strtol(i_ddLevelStr.c_str(), NULL, 16);
+
+ printf(" DD level (hex converted): 0x%x\n",
+ ddLevel);
+ }
+ else
+ {
+ fprintf(stderr, "\nThe section \"%s\" has no DD level support.\n", i_sectionName);
+ fprintf(stderr, "To extract the entire section, omit the \"ddLevel\" arg.\n\n");
+ exit(1);
+ }
+ }
+
+ printf("\nThe specified XIP section has the following attributes:\n"\
+ " Offset: 0x%08x\n"\
+ " Size (size): 0x%08x (%d)\n"\
+ " DD support: %d\n",
+ xSection->iv_offset, xSection->iv_size, xSection->iv_size, xSection->iv_ddSupport);
+
+ if (ddLevel == 0)
+ {
+ ddLevel = P9_XIP_UNDEFINED_DDLEVEL;
+ // Even though this may seem like we should just exit here, we'll leave it up
+ // to xip_get_section what to do in this case. Who knows, maybe it'll eventually
+ // return a list of supported DD levels.
+ }
+
+#ifdef __PPE__
+ rc = p9_xip_get_section( io_image, sectionId, &xDdSection);
+#else
+ rc = p9_xip_get_section( io_image, sectionId, &xDdSection, ddLevel);
+#endif
+
+ switch (rc)
+ {
+ case 0:
+ break;
+
+ case P9_XIP_NO_DDLEVEL_SUPPORT:
+ fprintf(stderr, "\nThere is no support for DD level extraction yet.\n");
+ fprintf(stderr, "To extract the entire section, omit the \"ddLevel\" arg.\n\n");
+ exit(1);
+
+ case P9_XIP_DDLEVEL_NOT_FOUND:
+ fprintf(stderr, "\nA sub-section w/the specified ddLevel (=0x%x) was not found.\n", ddLevel);
+ fprintf(stderr, "To extract the entire section, omit the \"ddLevel\" arg.\n\n");
+ exit(1);
+
+ default:
+ fprintf(stderr, "\np9_xip_get_section() failed w/rc = %d\n\n", rc);
+ exit(1);
+ }
+
+ newImage = malloc(xSection->iv_size);
if (newImage == 0)
{
- fprintf(stderr, "Can't malloc() a buffer for the new image\n");
+ fprintf(stderr, "\nCan't malloc() a buffer for the new image\n");
exit(1);
}
- memcpy(newImage, (void*)((uint64_t)io_image + offset), size);
+ memcpy( newImage, (void*)((uint64_t)io_image + xDdSection.iv_offset), xDdSection.iv_size);
- fileFd = open(file, O_CREAT | O_WRONLY | O_TRUNC, 0755);
+ fileFd = open(i_fileName, O_CREAT | O_WRONLY | O_TRUNC, 0755);
if (fileFd < 0)
{
@@ -1312,9 +1431,9 @@ extract(const char* i_imageFile, const int i_imageFd, void* io_image,
exit(1);
}
- rc = write(fileFd, newImage, size);
+ rc = write(fileFd, newImage, xDdSection.iv_size);
- if ((rc < 0) || ((uint32_t)rc != size))
+ if ((rc < 0) || ((uint32_t)rc != xDdSection.iv_size))
{
perror("write() of fixed section : ");
exit(1);
OpenPOWER on IntegriCloud