From 9f2e80824408a857c041acc4345784237acc1c5b Mon Sep 17 00:00:00 2001 From: Claus Michael Olsen Date: Mon, 30 Oct 2017 16:43:17 -0500 Subject: cleanup: xip_tool: Fixing two command arguments. 1) Getting rid of 'disasm' command. 2) Removing need for 1st sub-argument to 'dissect' command when supplying a stand-alone image like an overrides ring section file. Change-Id: Ibe35277dc525e6b6ccf768bf34c0fec8711f8b2a Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/49021 Tested-by: FSP CI Jenkins Tested-by: PPE CI Tested-by: Jenkins Server Tested-by: HWSV CI Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/49023 Reviewed-by: Sachin Gupta --- src/import/chips/p9/xip/p9_xip_tool.C | 103 +++++++++++++++++----------------- 1 file changed, 52 insertions(+), 51 deletions(-) (limited to 'src/import/chips/p9/xip/p9_xip_tool.C') diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C index 38f07612..a0b40b5c 100644 --- a/src/import/chips/p9/xip/p9_xip_tool.C +++ b/src/import/chips/p9/xip/p9_xip_tool.C @@ -24,10 +24,8 @@ /* IBM_PROLOG_END_TAG */ /// \file p9_xip_tool.c -/// \brief P9-XIP image search/edit tool +/// \brief P9 XIP image search and edit tool /// -/// Note: This file was originally stored under .../procedures/ipl/sbe. It -/// was moved here at version 1.19. #include #include @@ -85,8 +83,7 @@ const char* g_usage = " p9_xip_tool [-i ...] extract
[ ]\n" " p9_xip_tool [-i ...] delete
[ ... ]\n" " p9_xip_tool [-i ...] dis
\n" - " p9_xip_tool [-i ...] dissect [ table,short,normal(default),long,raw ]\n" - " p9_xip_tool [-i ...] disasm \n" + " p9_xip_tool [-i ...] dissect [ .rings(default),.overlays,.overrides,(none) ] [ table,short,normal(default),long,raw ]\n" " p9_xip_tool [-i ...] check-sbe-ring-section
\n" "\n" "This simple application uses the P9-XIP image APIs to normalize, search\n" @@ -156,27 +153,23 @@ const char* g_usage = "section of the image at the time it is deleted, or must be empty. The\n" "'delete' command writes the size of the final modified image to stdout.\n" "\n" - "The 'dissect' command dissects a ring section. It accepts two different\n" - "types of images, namely the regular XIP image and now also stand-alone\n" - "ring section images (that have the TOR header). Wrt an XIP image, the\n" - "'dissect' command dissects the ring section named by the section argument.\n" - "Wrt a stand-alone ring section image, the 'dissect' command dissects\n" - "the ring section based on the TOR magic word embedded in the top of the\n" - "image. It does so regardless of what the section argument is (so for now\n" - "pass it .rings in this argument). In both cases, 'dissect' summarizes\n" - "the content of the ring section. The second argument to 'dissect', i.e.\n" - "[table,short,normal(default),long,raw], specifies how much information\n" - "is included in the listing:\n" - " table: Tabular overview.\n" - " short: The bare necessities.\n" - " normal: Everything except a binary dump of the ring block.\n" - " long: Everything including a binary dump of the ring block.\n" - " raw: Everything including a dump of the raw decompressed ring.\n" - "Note that if the second argument is omitted, a 'normal' listing of the ring\n" - "section will occur.\n" - "\n" - "The 'disasm' command disassembles the text section named by the section\n" - "argument.\n" + "The 'dissect' command summarizes the content of a ring section. It\n" + "accepts two different types of images: 1) The regular XIP image and 2)\n" + "a stand-alone ring section image (that has the TOR header). Wrt an XIP\n" + "image, the ring section named by the ring section argument is summarized.\n" + "Wrt a stand-alone ring section image, the ring section based on the TOR\n" + "magic word in the image, is summarized. (Hint. To find out what type of\n" + "image file you're supplying, run \"p9_xip_tool.exe report\"\n" + "on it first.) Note that the first sub-argument must be PASSED for an XIP\n" + "image but must be OMITTED for a stand-alone image. For either image, the\n" + "second sub-argument is optional and offers the following listing choices:\n" + " table: Tabular overview. No dump of ring block.\n" + " short: Key header info. No dump of ring block.\n" + " normal(default): All header info. No dump of ring block.\n" + " long: All header info and binary dump of ring block.\n" + " raw: All header info and binary+raw dump of ring block.\n" + "Note that if the second sub-argument is omitted, a 'normal' listing of\n" + "the ring section is chosen.\n" "\n" "-i:\n" "\t-ifs Causes the validation step to ignore image size check against the\n" @@ -2206,27 +2199,29 @@ int dissectRingSection(void* i_image, void* ringSectionPtr; - if (i_argc != 1 && i_argc != 2) - { - fprintf(stderr, g_usage); - exit(1); - } - - if (i_argc == 1) - { - sectionName = i_argv[0]; - } - else - { - sectionName = i_argv[0]; - listingModeName = i_argv[1]; - } - // Determine whether i_image is an XIP image or an isolated TOR ring section image. // if (be64toh(((P9XipHeader*)i_image)->iv_magic) >> 32 == P9_XIP_MAGIC) { + if (i_argc == 1) + { + sectionName = i_argv[0]; + } + else if (i_argc == 2) + { + sectionName = i_argv[0]; + listingModeName = i_argv[1]; + } + else + { + fprintf(stderr, + "ERROR: The number of sub arguments (=%d) is too few or too many for the 'dissect' command for an XIP image\n\n", + i_argc); + fprintf(stderr, g_usage); + exit(EXIT_FAILURE); + } + p9_xip_translate_header(&hostHeader, (P9XipHeader*)i_image); // Determine P9-XIP ring section ID from the section name, e.g. @@ -2313,7 +2308,22 @@ int dissectRingSection(void* i_image, } else if (be32toh(((TorHeader_t*)i_image)->magic) >> 8 == TOR_MAGIC) { + + if (i_argc == 1) + { + listingModeName = i_argv[0]; + } + else + { + fprintf(stderr, + "ERROR: The number of sub arguments (=%d) is too few or too many for the 'dissect' command for a TOR section\n\n", + i_argc); + fprintf(stderr, g_usage); + exit(EXIT_FAILURE); + } + ringSectionPtr = i_image; + } else { @@ -2635,15 +2645,6 @@ command(const char* i_imageFile, const int i_argc, const char** i_argv, const ui exit(1); #endif - } - else if (strcmp(i_argv[0], "disasm") == 0) - { - - //openAndMapReadOnly(i_imageFile, &fd, &image, i_maskIgnores); - //rc = disassembleSection(image, i_argc - 1, &(i_argv[1])); - fprintf(stderr, "not supported\n"); - exit(1); - } else if (strcmp(i_argv[0], "check-sbe-ring-section") == 0) { -- cgit v1.2.1