From 89dc4c2dc72a77bc278b388d66681e943fb6d539 Mon Sep 17 00:00:00 2001 From: "A. Patrick Williams III" Date: Tue, 13 Sep 2011 12:40:38 -0500 Subject: Revert "Support generating the PNOR targeting image" This reverts commit c82ba14ada9c80565b95ad9d3d05c678591ae328 Change-Id: Ifd9a62779b13d237c9e4c5d2818df6e433f17021 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/338 Reviewed-by: A. Patrick Williams III Tested-by: A. Patrick Williams III --- src/build/simics/post_model_hook.simics | 1 - src/build/tocgen/mkpnortoc.pl | 28 +- src/build/tocgen/pnortoc.xml | 26 +- src/build/tools/cpfiles.pl | 3 +- src/include/usr/targeting/attributeenums.H | 183 ++ src/include/usr/targeting/attributes.H | 8 +- src/include/usr/targeting/attributestrings.H | 88 + src/include/usr/targeting/attributestructs.H | 138 ++ src/include/usr/targeting/attributetraits.H | 190 ++ .../usr/targeting/predicates/predicatectm.H | 2 +- src/include/usr/targeting/targetservice.H | 2 +- src/usr/pnor/pnorrp.C | 2 +- src/usr/pnor/test/pnorrptest.H | 2 +- src/usr/targeting/fakepnordata.C | 545 +++++ src/usr/targeting/fakepnordata.H | 693 +++++++ src/usr/targeting/makefile | 5 +- src/usr/targeting/predicates/predicatectm.C | 2 +- src/usr/targeting/targetservice.C | 27 +- src/usr/targeting/test/attributestrings.C | 106 + src/usr/targeting/test/makefile | 3 - src/usr/targeting/xmltohb/hb.xml | 1026 ---------- src/usr/targeting/xmltohb/makefile | 51 - src/usr/targeting/xmltohb/xmltohb.pl | 2140 -------------------- 23 files changed, 1965 insertions(+), 3306 deletions(-) create mode 100644 src/include/usr/targeting/attributeenums.H create mode 100644 src/include/usr/targeting/attributestrings.H create mode 100644 src/include/usr/targeting/attributestructs.H create mode 100644 src/include/usr/targeting/attributetraits.H create mode 100644 src/usr/targeting/fakepnordata.C create mode 100644 src/usr/targeting/fakepnordata.H create mode 100644 src/usr/targeting/test/attributestrings.C delete mode 100644 src/usr/targeting/xmltohb/hb.xml delete mode 100644 src/usr/targeting/xmltohb/makefile delete mode 100755 src/usr/targeting/xmltohb/xmltohb.pl (limited to 'src') diff --git a/src/build/simics/post_model_hook.simics b/src/build/simics/post_model_hook.simics index 976cdf1dd..46bfc478d 100755 --- a/src/build/simics/post_model_hook.simics +++ b/src/build/simics/post_model_hook.simics @@ -36,4 +36,3 @@ run-python-file hb-simdebug.py #This will be merged into once the proper tools are written. phys_mem.load-file ../img/hbicore_extended.bin 0x500690 phys_mem.load-file ../img/pnor.toc 0x500000 -phys_mem.load-file ../img/targeting.bin 0x57E690 diff --git a/src/build/tocgen/mkpnortoc.pl b/src/build/tocgen/mkpnortoc.pl index 7fc263a72..f4e5464f5 100755 --- a/src/build/tocgen/mkpnortoc.pl +++ b/src/build/tocgen/mkpnortoc.pl @@ -1,26 +1,4 @@ #!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/build/tocgen/mkpnortoc.pl $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2011 -# -# p1 -# -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code -# -# The source code for this program is not published or other- -# wise divested of its trade secrets, irrespective of what has -# been deposited with the U.S. Copyright Office. -# -# Origin: 30 -# -# IBM_PROLOG_END # File mkPnorTOC.pl created by ADAM R. MUHLE at 14:39:27 on Mon Aug 1 2011. #Limitations to address later @@ -87,8 +65,8 @@ $onlytocVerNode = $tocVerNodes->pop(); writeElementToBinFile(BIN_TOC_FILE, $onlytocVerNode); -#Add the individual TOC entries; skip over the mandatory comment block -$root = $doc->firstChild->nextSibling; +#Add the individual TOC entries +$root = $doc->firstChild; $curSibling = $root->firstChild; do { @@ -107,7 +85,7 @@ do { #skip these, already inserted above } -}while($curSibling = $curSibling->nextSibling()); +}while($curSibling = $curSibling->nextSibling); close(BIN_TOC_FILE); diff --git a/src/build/tocgen/pnortoc.xml b/src/build/tocgen/pnortoc.xml index 06abc67c1..2f530bdb6 100644 --- a/src/build/tocgen/pnortoc.xml +++ b/src/build/tocgen/pnortoc.xml @@ -1,25 +1,3 @@ - 0x180 8 @@ -136,11 +114,11 @@ 8 number - 16384 + 8192 8 number - 16384 + 8192 8 number diff --git a/src/build/tools/cpfiles.pl b/src/build/tools/cpfiles.pl index 222c406d2..682a6b9f7 100755 --- a/src/build/tools/cpfiles.pl +++ b/src/build/tools/cpfiles.pl @@ -68,8 +68,7 @@ my @files = ("src/build/tools/exthbdump.pl", "img/hbicore_test.list", "img/hbicore_extended.bin", "img/hbicore_test_extended.bin", - "img/pnor.toc", - "img/targeting.bin", + "img/pnor.toc" ); #Directories in base git repository diff --git a/src/include/usr/targeting/attributeenums.H b/src/include/usr/targeting/attributeenums.H new file mode 100644 index 000000000..246f41061 --- /dev/null +++ b/src/include/usr/targeting/attributeenums.H @@ -0,0 +1,183 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/targeting/attributeenums.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END + +#ifndef TARG_ATTRIBUTEENUMS_H +#define TARG_ATTRIBUTEENUMS_H + +/** + * @file attributeenums.H + * + * @brief Defined enums for platform attributes + * + * This header file contains enumerations for supported platform attributes + * (as opposed to HWPF attributes). Eventually this file will be automatically + * generated + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +#include +#include + +//****************************************************************************** +// Enumerations +//****************************************************************************** + +namespace TARGETING +{ + +/** + * @brief Platform attribute IDs + * + * Enumeration defining every possible platform attribute that can be + * associated with a target + */ +enum ATTRIBUTE_ID +{ + ATTR_NA = 0x00, + ATTR_CLASS = 0x01, + ATTR_TYPE = 0x02, + ATTR_MODEL = 0x03, + ATTR_PHYS_PATH = 0x04, + ATTR_AFFINITY_PATH = 0x05, + ATTR_POWER_PATH = 0x06, + ATTR_PRIMARY_CAPABILITIES = 0x07, + ATTR_XSCOM_BASE_ADDRESS = 0x08, + ATTR_SCOM_SWITCHES = 0x09, + ATTR_XSCOM_CHIP_INFO = 0x0A, + ATTR_INBAND_SCOM_CHIP_INFO = 0x0B, + ATTR_FSI_SCOM_CHIP_INFO = 0x0C, + ATTR_I2C_CHIP_INFO = 0x0D, + ATTR_FSI_MASTER_INFO = 0x0E, + + ATTR_DUMMY_WO = 0xFD, + ATTR_DUMMY_RO = 0xFE, + ATTR_DUMMY_RW = 0xFF, +}; + +/** + * @brief Target Classes + * + * Enumeration which identifies the general class of a target + */ +enum CLASS +{ + CLASS_NA = 0x00, + CLASS_CARD = 0x01, + CLASS_ENC = 0x02, + CLASS_CHIP = 0x03, + CLASS_UNIT = 0x04, + CLASS_DEV = 0x05, + CLASS_SYS = 0x06, + CLASS_MAX = 0x07, + +}; + +/** + * @brief Target Types + * + * Enumeration which identifies the specific type of target + */ +enum TYPE +{ + TYPE_NA = 0x00, + + // System + TYPE_SYS, + + // Enclosures + TYPE_NODE, + + // Cards + TYPE_DIMM, + TYPE_SCM, + TYPE_DCM, + + // Chips + TYPE_MEMBUF, + TYPE_PROC, + + // Voltage Suppliers + TYPE_MEMVRM, + TYPE_PROCVRM, + + // Processor/Centaur Units + TYPE_EX, + TYPE_CORE, + TYPE_L2, + TYPE_L3, + TYPE_L4, + TYPE_MCS, + TYPE_MBS, + TYPE_MBA, + TYPE_MEM_PORT, + TYPE_PERVASIVE, + TYPE_POWERBUS, + TYPE_XBUS, + TYPE_ABUS, + TYPE_PCI, + + TYPE_LAST_IN_RANGE + +}; + +/** + * @brief Target Models + * + * Enumeration which identifies the specific model of a target + */ +enum MODEL +{ + MODEL_NA = 0x00, + + // Proc chips/proc units + MODEL_SALERNO = 0x10, + MODEL_VENICE = 0x11, + + // Memory buffers/memory buffer units + MODEL_CENTAUR = 0x30, + + // DIMMs + MODEL_JEDEC = 0x50, + MODEL_CDIMM = 0x51, + + // Systems + MODEL_POWER8 = 0x70, + +}; + +/** + * @brief FSI Engine Types + * + * Enumeration which identifies a specific FSI engine type + */ +enum ENGINE_TYPE +{ + // TBD in future sprint +}; + +} // End namespace TARGETING + +#endif // TARG_ATTRIBUTEENUMS_H diff --git a/src/include/usr/targeting/attributes.H b/src/include/usr/targeting/attributes.H index 3a69af6af..8c148a150 100644 --- a/src/include/usr/targeting/attributes.H +++ b/src/include/usr/targeting/attributes.H @@ -39,9 +39,9 @@ #include // This component -#include -#include -#include -#include +#include +#include +#include +#include #endif // TARG_ATTRIBUTES_H diff --git a/src/include/usr/targeting/attributestrings.H b/src/include/usr/targeting/attributestrings.H new file mode 100644 index 000000000..64506bdc9 --- /dev/null +++ b/src/include/usr/targeting/attributestrings.H @@ -0,0 +1,88 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/targeting/attributestrings.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END + +#ifndef TARG_ATTRIBUTESTRINGS_H +#define TARG_ATTRIBUTESTRINGS_H + +/** + * @file attributestrings.H + * + * @brief Attribute string conversion routines. This file will be auto + * generated in the future + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include +#include + +namespace TARGETING +{ + +/** + * @brief Class used to clarify compiler error when caller attempts to + * stringify an unsupported attribute + */ +class InvalidAttributeForStringification; + +/** + * @brief Return attribute as a string + * + * @param[in] i_attrValue Value of the attribute + * + * @return String which decodes the attribute value + */ +template +const char* attrToString( + typename AttributeTraits::Type const& i_attrValue) +{ + return InvalidAttributeForStringification(); //"Cannot stringify attr"; +} + +/** + * @brief See attrToString + */ +template<> +const char* attrToString( + AttributeTraits::Type const& i_attrValue); + +/** + * @brief See attrToString + */ +template<> +const char* attrToString( + AttributeTraits::Type const& i_attrValue); + +/** + * @brief See attrToString + */ +template<> +const char* attrToString( + AttributeTraits::Type const& i_attrValue); + +} // End namespace TARGETING + +#endif // TARG_ATTRIBUTESTRINGS_H diff --git a/src/include/usr/targeting/attributestructs.H b/src/include/usr/targeting/attributestructs.H new file mode 100644 index 000000000..c34c045e4 --- /dev/null +++ b/src/include/usr/targeting/attributestructs.H @@ -0,0 +1,138 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/targeting/attributestructs.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END + +#ifndef TARG_ATTRIBUTESTRUCTS_H +#define TARG_ATTRIBUTESTRUCTS_H + +/** + * @file attributestructs.H + * + * @brief Complex attribute types + * + * This header file contains definitions for complex attribute types. Note: + * in the future this file may be autogenerated + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include +#include + +// This component +#include + +//****************************************************************************** +// Complex Types +//****************************************************************************** + +namespace TARGETING +{ + +/** + * @brief Structure which defines a target's primary capabilities + * + * Structure which defines a target's primary capabilities. A target can only + * support at most FSI SCOM and one of the other two SCOM types. Applicable + * for all targets. Structure is read-only. + */ +struct PrimaryCapabilities +{ + uint8_t supportsFsiScom : 1; ///< 0b0: Target does not support FSI SCOM + ///< 0b1: Target supports FSI SCOM + uint8_t supportsXscom : 1; ///< 0b0: Target does not support XSCOM + ///< 0b1: Target supports FSI XSCOM + uint8_t supportsInbandScom : 1; ///< 0b0: Target does not support inband + ///< SCOM + ///< 0b1: Target supports inband SCOM + uint8_t reserved : 5; + +} PACKED; + +/** + * @brief Structure which defines which SCOM method to use at a point in time + * + * Structure which defines which SCOM to use at a point in time. Only + * applicable if target supports one or more SCOM types. Only one bit (of the + * first three) can ever be set at any one time. Structure is read-writeable. + */ +struct ScomSwitches +{ + uint8_t useFsiScom : 1; ///< 0b0: Do not use FSI SCOM at this time + ///< 0b1: Use FSI SCOM at this time + uint8_t useXscom : 1; ///< 0b0: Do not use XSCOM at this time + ///< 0b1: Use XSCOM at this time + uint8_t useInbandScom : 1; ///< 0b0: Do not use inband SCOM at this time + ///< 0b1: Use inband SCOM at this time + uint8_t reserved : 5; ///< Reserved bits + +} PACKED; + +/** + * @brief Structure which defines chip info necessary for XSCOM + * + * Structure which defines chip info necessary for XSCOM. Only + * applicable for chip targets which support XSCOM. Structure is read-only. + */ +struct XscomChipInfo +{ + uint8_t nodeId; // Unique ID of node containing the chip + uint8_t chipId; // Unique ID of chip, relative to node + +} PACKED; + +/** + * @brief Structure which defines chip info necessary for I2C operations + * + * Structure which defines info necessary for I2C. Only applicable for + * chip targets which support I2C. Structure is read-only. + */ +struct I2cChipInfo +{ + uint32_t busSpeed; // Slave Device bus speed + uint16_t deviceAddr; // Slave Device address + uint8_t devicePort; // Slave Device Port location + uint8_t deviceMasterEng; // Master I2C engine slave is hung off of +} PACKED; + +//@todo - NOT READY YET +/** + * @brief Structure which defines info necessary to setup a FSI master + * + * Structure which defines info necessary for a FSI master. Only applicable + * for chip targets which include MFSI of CMFSI logic. Structure is read-only. + */ +struct FsiMasterInfo +{ + uint64_t modebits; ///< TBD + uint16_t clockRatio0; ///< Clock Ratio 0 + uint16_t clockRatio1; ///< Clock Ratio 1 + + uint8_t numPorts; ///< Number of possible FSI-slave ports +} PACKED; + +} // End namespace TARGETING + +#endif // TARG_ATTRIBUTESTRUCTS_H diff --git a/src/include/usr/targeting/attributetraits.H b/src/include/usr/targeting/attributetraits.H new file mode 100644 index 000000000..fe466a5d3 --- /dev/null +++ b/src/include/usr/targeting/attributetraits.H @@ -0,0 +1,190 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/targeting/attributetraits.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END + +#ifndef TARG_ATTRIBUTETRAITS_H +#define TARG_ATTRIBUTETRAITS_H + +/** + * @file attributetraits.H + * + * @brief Templates which map attributes to their type/properties + * + * This header file contains templates which map attributes to their + * type/properties + * + * This file -will- be autogenerated in the future + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include +#include + +namespace TARGETING +{ + +//****************************************************************************** +// Attribute Property Mappings +//****************************************************************************** + +/** + * @brief Template associating a specific attribute with a type and other + * properties, such as whether it is readable/writable + * + * This will eventually be automatically generated + * + * enum { + * disabled = Special value for the basic attribute + * readable = Attribute is readable + * writable = Attribute is writable + * hasStringConversion = Attribute has debug string conversion + * } + * + * typedef TYPE // is the Attribute's valid type + */ +template +class AttributeTraits +{ + private: + enum { disabled }; + typedef void* Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable, hasStringConversion }; + typedef CLASS Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable, hasStringConversion }; + typedef TYPE Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable, hasStringConversion }; + typedef MODEL Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable, writeable }; + typedef uint8_t Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { writeable }; + typedef uint8_t Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef uint8_t Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef EntityPath Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef EntityPath Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef EntityPath Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef PrimaryCapabilities Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable, writable }; + typedef ScomSwitches Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef uint64_t Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef XscomChipInfo Type; +}; + +template<> +class AttributeTraits +{ + public: + enum { readable }; + typedef I2cChipInfo Type; +}; + +} // End namespace TARGETING + +#endif // TARG_ATTRIBUTETRAITS_H diff --git a/src/include/usr/targeting/predicates/predicatectm.H b/src/include/usr/targeting/predicates/predicatectm.H index 99fc27a78..79a374c50 100644 --- a/src/include/usr/targeting/predicates/predicatectm.H +++ b/src/include/usr/targeting/predicates/predicatectm.H @@ -41,7 +41,7 @@ // Targeting Component #include -#include +#include #include //****************************************************************************** diff --git a/src/include/usr/targeting/targetservice.H b/src/include/usr/targeting/targetservice.H index e220eafb7..bdb6abac6 100644 --- a/src/include/usr/targeting/targetservice.H +++ b/src/include/usr/targeting/targetservice.H @@ -47,7 +47,7 @@ #include // This component -#include +#include #include #include #include diff --git a/src/usr/pnor/pnorrp.C b/src/usr/pnor/pnorrp.C index de2d0a5ec..35f8c8edc 100644 --- a/src/usr/pnor/pnorrp.C +++ b/src/usr/pnor/pnorrp.C @@ -320,7 +320,7 @@ errlHndl_t PnorRP::readTOC() iv_TOC[PNOR::SIDE_A][PNOR::TOC].size = 8 + 8 + PNOR::NUM_SECTIONS*sizeof(TOCEntry_t); iv_TOC[PNOR::SIDE_A][PNOR::HB_EXT_CODE].size = 500*1024; //500K iv_TOC[PNOR::SIDE_A][PNOR::GLOBAL_DATA].size = PAGESIZE; //4K - iv_TOC[PNOR::SIDE_A][PNOR::HB_DATA].size = 4*PAGESIZE; //16K + iv_TOC[PNOR::SIDE_A][PNOR::HB_DATA].size = 2*PAGESIZE; //8K // fake PNOR will look like this: TOC::HB_EXT_CODE:GLOBAL_DATA:HB_DATA // virtual addresses diff --git a/src/usr/pnor/test/pnorrptest.H b/src/usr/pnor/test/pnorrptest.H index f3825edd5..9741b6cb0 100644 --- a/src/usr/pnor/test/pnorrptest.H +++ b/src/usr/pnor/test/pnorrptest.H @@ -67,7 +67,7 @@ class PnorRpTest : public CxxTest::TestSuite /* GLOBAL_DATA */ { PAGESIZE, 0x8007D690 }, /* SBE_IPL */ { 0, 0 }, /* HB_BASE_CODE */ { 0, 0 }, - /* HB_DATA */ { 4*PAGESIZE, 0x8007E690 }, + /* HB_DATA */ { 2*PAGESIZE, 0x8007E690 }, /* HB_ERRLOGS */ { 0, 0 }, /* HB_EXT_CODE */ { 0x7D000, 0x80000690 }, /* HB_RUNTIME */ { 0, 0 }, diff --git a/src/usr/targeting/fakepnordata.C b/src/usr/targeting/fakepnordata.C new file mode 100644 index 000000000..4d5e78306 --- /dev/null +++ b/src/usr/targeting/fakepnordata.C @@ -0,0 +1,545 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/targeting/fakepnordata.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END + +/** + * @file fakepnordata.C + * + * @brief Generates a fake PNOR image for supporting host boot while PNOR + * is not available (i.e. bringup) +*/ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include +#include +#include +#include + +// Other components +#include +#include + +// This component +#include +#include +#include "fakepnordata.H" +#include "trace.H" + +namespace TARGETING +{ + +#define TARG_NAMESPACE "TARGETING::" +#define TARG_CLASS "PnorBuilderService::" + + + +//****************************************************************************** +// PnorBuilderService::~PnorBuilderService +//****************************************************************************** + +PnorBuilderService::~PnorBuilderService() +{ + free(iv_pPnor); + free(iv_pHeap); +} + +//****************************************************************************** +// PnorBuilderService::heapBase +//****************************************************************************** + +uint8_t* PnorBuilderService::heapBase() const +{ + return reinterpret_cast(iv_pHeap); +} + +//****************************************************************************** +// PnorBuilderService::pnorBase +//****************************************************************************** + +uint8_t* PnorBuilderService::pnorBase() const +{ + return reinterpret_cast(iv_pPnor); +} + +//****************************************************************************** +// PnorBuilderService::clearPnorSection +//****************************************************************************** + +void PnorBuilderService::clearPnorSection() +{ + memset(pnorBase(),0x00,PNOR_SIZE); +} + +//****************************************************************************** +// PnorBuilderService::clearHeapSection +//****************************************************************************** + +void PnorBuilderService::clearHeapSection() +{ + memset(heapBase(),0x00,HEAP_SIZE); +} + +//****************************************************************************** +// PnorBuilderService::populateValidAttrIds +//****************************************************************************** + +void PnorBuilderService::populateValidAttrIds( + uint8_t*& i_pPnor, + const std::vector& i_attrInfo, + ATTRIBUTE_ID*& o_pAttrNames) +{ + uint32_t l_numAttr = i_attrInfo.size(); + *(reinterpret_cast(i_pPnor)) = l_numAttr; + i_pPnor+=sizeof(l_numAttr); + ATTRIBUTE_ID (*l_pAttr)[] = (ATTRIBUTE_ID (*)[])i_pPnor; + for(uint32_t i=0; i& o_targets, + const std::vector& i_attrInfo) +{ + void* (*l_pAttrValues)[] = (void* (*)[])i_pPnor; + + // Reserve space for number of pointers + i_pPnor += sizeof(void*) * i_attrInfo.size(); + + // Iterate through the data + for(uint32_t i=0; iiv_attrs = i_attrInfo.size(); + l_pTarget->iv_pAttrNames = (ATTRIBUTE_ID (*)[])i_pAttrNames; + l_pTarget->iv_pAttrValues = l_pAttrValues; + o_targets.push_back(l_pTarget); +} + +//****************************************************************************** +// PnorBuilderService::buildTargetingImage +//****************************************************************************** + +void PnorBuilderService::buildTargetingImage() +{ + #define TARG_FN "buildTargetingImage()" + + TARG_INF(">>Build targeting image"); + + clearPnorSection(); + clearHeapSection(); + + std::vector l_targets; + + uint8_t* l_pPnor = pnorBase(); + uint8_t* l_pHeap = heapBase(); + ATTRIBUTE_ID* l_pAttrNames = NULL; + + uint32_t** l_numTargets = (uint32_t**)l_pPnor; + l_pPnor+=sizeof(uint32_t*); + std::vector l_attrs; + + TARG_INF("Populate sys 0"); + + // Populate the system target + SysSysPower8 l_sysSysPower8_0; + EntityPath l_sysContainment(EntityPath::PATH_PHYSICAL); + EntityPath l_sysAffinity(EntityPath::PATH_AFFINITY); + l_sysContainment.addLast(TYPE_SYS,0); + l_sysAffinity.addLast(TYPE_SYS,0); + l_sysSysPower8_0.iv_physicalPath.set(l_sysContainment); + l_sysSysPower8_0.iv_affinityPath.set(l_sysAffinity); + l_sysSysPower8_0.iv_xscomBaseAddr.set(0x300000000000); + l_sysSysPower8_0.getAttrInfo(l_attrs); + populateValidAttrIds(l_pPnor,l_attrs,l_pAttrNames); + populateAttrs(l_pAttrNames,l_pPnor,l_pHeap,l_targets,l_attrs); + l_attrs.clear(); + + // Populate the sys0/node0 target + EncNodePower8 l_encNodePower8_0; + EntityPath l_nodeContainment = l_sysContainment; + l_nodeContainment.addLast(TYPE_NODE,0); + EntityPath l_nodeAffinity = l_sysAffinity; + l_nodeAffinity.addLast(TYPE_NODE,0); + l_encNodePower8_0.iv_physicalPath.set(l_nodeContainment); + l_encNodePower8_0.iv_affinityPath.set(l_nodeAffinity); + l_encNodePower8_0.getAttrInfo(l_attrs); + populateValidAttrIds(l_pPnor,l_attrs,l_pAttrNames); + populateAttrs(l_pAttrNames,l_pPnor,l_pHeap,l_targets,l_attrs); + l_attrs.clear(); + +// // Populate the sys0/node0/SCM0 target +// CardScmPower8 l_cardScmPower8_0; +// EntityPath l_scmContainment = l_nodeContainment; +// l_scmContainment.addLast(TYPE_SCM,0); +// EntityPath l_scmAffinity = l_nodeAffinity; +// l_scmAffinity.addLast(TYPE_SCM,0); +// l_cardScmPower8_0.iv_physicalPath.set(l_scmContainment); +// l_cardScmPower8_0.iv_affinityPath.set(l_scmAffinity); +// l_cardScmPower8_0.getAttrInfo(l_attrs); +// populateValidAttrIds(l_pPnor,l_attrs,l_pAttrNames); +// populateAttrs(l_pAttrNames,l_pPnor,l_pHeap,l_targets,l_attrs); +// l_attrs.clear(); + + TARG_INF("Populate proc 0"); + + // Populate the sys0/node0/proc0 Salerno processor chip targets + ProcChipSalerno l_procChipSalerno_0; + EntityPath l_procContainment = l_nodeContainment; + l_procContainment.addLast(TYPE_PROC,0); + EntityPath l_procAffinity = l_nodeAffinity; + l_procAffinity.addLast(TYPE_PROC,0); + l_procChipSalerno_0.iv_physicalPath.set(l_procContainment); + l_procChipSalerno_0.iv_affinityPath.set(l_procAffinity); + XscomChipInfo l_xscomChipInfo = {0,0}; + l_procChipSalerno_0.iv_xscomChipInfo.set(l_xscomChipInfo); + l_procChipSalerno_0.getAttrInfo(l_attrs); + populateValidAttrIds(l_pPnor,l_attrs,l_pAttrNames); + populateAttrs(l_pAttrNames,l_pPnor,l_pHeap,l_targets,l_attrs); + + + +#define EX_PER_SALERNO 6 + + ATTRIBUTE_ID* l_pExAttrNames = NULL; + ATTRIBUTE_ID* l_pCoreAttrNames = NULL; + ATTRIBUTE_ID* l_pL2AttrNames = NULL; + ATTRIBUTE_ID* l_pL3AttrNames = NULL; + TARG_INF("Populate EXs and sub-units"); + + for(int i=0; i l_exInstAttrs; + UnitExSalerno l_unitExSalerno; + + // Customize + EntityPath l_exContainment = l_procContainment; + l_exContainment.addLast(TYPE_EX,i); + EntityPath l_exAffinity = l_procAffinity; + l_exAffinity.addLast(TYPE_EX,i); + l_unitExSalerno.iv_physicalPath.set(l_exContainment); + l_unitExSalerno.iv_affinityPath.set(l_exAffinity); + l_unitExSalerno.getAttrInfo(l_exInstAttrs); + + // If valid attributes are empty for this class + if(l_pExAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_exInstAttrs,l_pExAttrNames); + } + + populateAttrs(l_pExAttrNames,l_pPnor,l_pHeap,l_targets,l_exInstAttrs); + + TARG_INF("Populate Core"); + + // Populate core + std::vector l_coreInstAttrs; + UnitCoreSalerno l_unitCoreSalerno; + EntityPath l_coreContainment = l_procContainment; + l_coreContainment.addLast(TYPE_CORE,i); + EntityPath l_coreAffinity = l_exAffinity; + l_coreAffinity.addLast(TYPE_CORE,0); + l_unitCoreSalerno.iv_physicalPath.set(l_coreContainment); + l_unitCoreSalerno.iv_affinityPath.set(l_coreAffinity); + l_unitCoreSalerno.getAttrInfo(l_coreInstAttrs); + if(l_pCoreAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_coreInstAttrs,l_pCoreAttrNames); + } + populateAttrs(l_pCoreAttrNames,l_pPnor,l_pHeap,l_targets,l_coreInstAttrs); + + TARG_INF("Populate L2"); + + // Populate L2 + std::vector l_l2InstAttrs; + UnitL2Salerno l_unitL2Salerno; + EntityPath l_l2Containment = l_procContainment; + l_l2Containment.addLast(TYPE_L2,i); + EntityPath l_l2Affinity = l_exAffinity; + l_l2Affinity.addLast(TYPE_L2,0); + l_unitL2Salerno.iv_physicalPath.set(l_l2Containment); + l_unitL2Salerno.iv_affinityPath.set(l_l2Affinity); + l_unitL2Salerno.getAttrInfo(l_l2InstAttrs); + if(l_pL2AttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_l2InstAttrs,l_pL2AttrNames); + } + populateAttrs(l_pL2AttrNames,l_pPnor,l_pHeap,l_targets,l_l2InstAttrs); + + TARG_INF("Populate L3"); + + // Populate L3 + std::vector l_l3InstAttrs; + UnitL3Salerno l_unitL3Salerno; + EntityPath l_l3Containment = l_procContainment; + l_l3Containment.addLast(TYPE_L3,i); + EntityPath l_l3Affinity = l_exAffinity; + l_l3Affinity.addLast(TYPE_L3,0); + l_unitL3Salerno.iv_physicalPath.set(l_l3Containment); + l_unitL3Salerno.iv_affinityPath.set(l_l3Affinity); + l_unitL3Salerno.getAttrInfo(l_l3InstAttrs); + if(l_pL3AttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_l3InstAttrs,l_pL3AttrNames); + } + populateAttrs(l_pL3AttrNames,l_pPnor,l_pHeap,l_targets,l_l3InstAttrs); + } + + + // Populate Mcs + ATTRIBUTE_ID* l_pMcsAttrNames = NULL; + + std::vector l_McsInstAttrs; + UnitMcsSalerno l_unitMcsSalerno; + EntityPath l_McsContainment = l_procContainment; + l_McsContainment.addLast(TYPE_MCS,0); + EntityPath l_McsAffinity = l_procAffinity; + l_McsAffinity.addLast(TYPE_MCS,0); + l_unitMcsSalerno.iv_physicalPath.set(l_McsContainment); + l_unitMcsSalerno.iv_affinityPath.set(l_McsAffinity); + l_unitMcsSalerno.getAttrInfo(l_McsInstAttrs); + if(l_pMcsAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_McsInstAttrs,l_pMcsAttrNames); + } + populateAttrs(l_pMcsAttrNames,l_pPnor,l_pHeap,l_targets,l_McsInstAttrs); + + ATTRIBUTE_ID* l_pMbaAttrNames = NULL; + ATTRIBUTE_ID* l_pMemPortAttrNames = NULL; + + for(int i=0; i<2; ++i) + { + // Populate MBAs + std::vector l_MbaInstAttrs; + UnitMbaSalerno l_unitMbaSalerno; + EntityPath l_mbaContainment = l_procContainment; + l_mbaContainment.addLast(TYPE_MBA,i); + EntityPath l_mbaAffinity = l_McsAffinity; + l_mbaAffinity.addLast(TYPE_MBA,i); + l_unitMbaSalerno.iv_physicalPath.set(l_mbaContainment); + l_unitMbaSalerno.iv_affinityPath.set(l_mbaAffinity); + l_unitMbaSalerno.getAttrInfo(l_MbaInstAttrs); + if(l_pMbaAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_MbaInstAttrs,l_pMbaAttrNames); + } + populateAttrs(l_pMbaAttrNames,l_pPnor,l_pHeap,l_targets,l_MbaInstAttrs); + + for(uint32_t l_ports=0; l_ports<1; ++l_ports) + { + // Populate Memory Ports + std::vector l_MemPortInstAttrs; + UnitMemPortSalerno l_unitMemPortSalerno; + EntityPath l_MemPortContainment = l_procContainment; + l_MemPortContainment.addLast(TYPE_MEM_PORT,i); + EntityPath l_MemPortAffinity = l_mbaAffinity; + l_MemPortAffinity.addLast(TYPE_MEM_PORT,l_ports); + l_unitMemPortSalerno.iv_physicalPath.set(l_MemPortContainment); + l_unitMemPortSalerno.iv_affinityPath.set(l_MemPortAffinity); + l_unitMemPortSalerno.getAttrInfo(l_MemPortInstAttrs); + if(l_pMemPortAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_MemPortInstAttrs,l_pMemPortAttrNames); + } + populateAttrs(l_pMemPortAttrNames,l_pPnor,l_pHeap,l_targets,l_MemPortInstAttrs); + + // DIMMs will get linked up later + } + } + + // Populate Pervasive Unit + ATTRIBUTE_ID* l_pPervasiveAttrNames = NULL; + std::vector l_PervasiveInstAttrs; + UnitPervasiveSalerno l_unitPervasiveSalerno; + EntityPath l_PervasiveContainment = l_procContainment; + l_PervasiveContainment.addLast(TYPE_PERVASIVE,0); + EntityPath l_PervasiveAffinity = l_procAffinity; + l_PervasiveAffinity.addLast(TYPE_PERVASIVE,0); + l_unitPervasiveSalerno.iv_physicalPath.set(l_PervasiveContainment); + l_unitPervasiveSalerno.iv_affinityPath.set(l_PervasiveAffinity); + l_unitPervasiveSalerno.getAttrInfo(l_PervasiveInstAttrs); + if(l_pPervasiveAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_PervasiveInstAttrs,l_pPervasiveAttrNames); + } + populateAttrs(l_pPervasiveAttrNames,l_pPnor,l_pHeap,l_targets,l_PervasiveInstAttrs); + + // Populate Powerbus Unit + ATTRIBUTE_ID* l_pPowerbusAttrNames = NULL; + std::vector l_PowerbusInstAttrs; + UnitPowerbusSalerno l_unitPowerbusSalerno; + EntityPath l_PowerbusContainment = l_procContainment; + l_PowerbusContainment.addLast(TYPE_POWERBUS,0); + EntityPath l_PowerbusAffinity = l_procAffinity; + l_PowerbusAffinity.addLast(TYPE_POWERBUS,0); + l_unitPowerbusSalerno.iv_physicalPath.set(l_PowerbusContainment); + l_unitPowerbusSalerno.iv_affinityPath.set(l_PowerbusAffinity); + l_unitPowerbusSalerno.getAttrInfo(l_PowerbusInstAttrs); + if(l_pPowerbusAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_PowerbusInstAttrs,l_pPowerbusAttrNames); + } + populateAttrs(l_pPowerbusAttrNames,l_pPnor,l_pHeap,l_targets,l_PowerbusInstAttrs); + + // Populate PCI Units + ATTRIBUTE_ID* l_pPciAttrNames = NULL; + + for(int i=0; i<3; ++i) + { + std::vector l_PciInstAttrs; + UnitPciSalerno l_unitPciSalerno; + EntityPath l_pciContainment = l_procContainment; + l_pciContainment.addLast(TYPE_PCI,i); + EntityPath l_pciAffinity = l_procAffinity; + l_pciAffinity.addLast(TYPE_PCI,i); + l_unitPciSalerno.iv_physicalPath.set(l_pciContainment); + l_unitPciSalerno.iv_affinityPath.set(l_pciAffinity); + l_unitPciSalerno.getAttrInfo(l_PciInstAttrs); + if(l_pPciAttrNames == NULL) + { + populateValidAttrIds(l_pPnor,l_PciInstAttrs,l_pPciAttrNames); + } + populateAttrs(l_pPciAttrNames,l_pPnor,l_pHeap,l_targets,l_PciInstAttrs); + } + + + /* + TARG_INF("Populate proc 1"); + + + // Populate the sys0/node0/DCM0/proc1 Salerno processor chip targets + ProcChipSalerno l_procChipSalerno_1; + l_containment.removeLast(); + l_affinity.removeLast(); + l_containment.addLast(TYPE_PROC,1); + l_affinity.addLast(TYPE_PROC,1); + l_procChipSalerno_1.iv_physicalPath.set(l_containment); + l_procChipSalerno_1.iv_affinityPath.set(l_affinity); + std::vector l_attrs1; + l_procChipSalerno_1.getAttrInfo(l_attrs1); + populateAttrs(l_pAttrNames,l_pPnor,l_pHeap,l_targets,l_attrs1); + l_attrs.clear(); + l_attrs1.clear(); + */ + + TARG_INF("Finalize PNOR"); + + // Populate pointer to total # of targets at beginning of + // targeting section + *l_numTargets = (uint32_t*)l_pPnor; + + // Add number of targets + uint32_t l_instance = l_targets.size(); + memcpy(l_pPnor,&l_instance,sizeof(l_instance)); + l_pPnor+= sizeof(l_instance); + + // Add actual targets + for(uint32_t i=0; i(iv_pPnor); +} + +//****************************************************************************** +// PnorBuilderService::PnorBuilderService +//****************************************************************************** + +PnorBuilderService::PnorBuilderService() +{ + TARG_INF(">>PnorBuilderService"); + + + iv_pPnor = reinterpret_cast(malloc(PNOR_SIZE)); + + TARG_INF(">>malloc(HEAP_SIZE)"); + + iv_pHeap = reinterpret_cast(malloc(HEAP_SIZE)); + + TARG_INF("Calling buildTargetingImage"); + + (void)buildTargetingImage(); + + TARG_INF("< +#include +#include + +namespace TARGETING +{ + +/** + * @brief Enum which describes where an attribute resides + */ +enum LOCATION +{ + PNOR, ///< Attribute resides in PNOR + HEAP, ///< Attribute resides in heap memory, not backed to PNOR +}; + +/** + * @brief Structure which holds attribute information for the PNOR targeting + * image generator + */ +struct AttrInfo +{ + uint32_t size; ///< Size of attribute + ATTRIBUTE_ID attrId; ///< Attribute ID + LOCATION location; ///< Location where attribute resides + const void* pData; ///< Address of attribute +}; + +/** + * @brief Property class which maintains info about a property to serialize + */ +template +class Property +{ + public: + + /** + * @brief Map the attribute's type to something more intuitive + */ + typedef typename AttributeTraits::Type _Type; + + /** + * @brief Build a property + */ + Property() + { + info.size = sizeof(_Type); + info.attrId = A; + info.location = L; + info.pData = &iv_data; + iv_initialized = false; + memset(&iv_data,0x00,sizeof(iv_data)); + } + + /** + * @brief Push attribute info to the attribute array + * + * @param[out] o_info Array of attribute structures + */ + void addAttrInfo( + std::vector& o_info) const + { + if(info.location == PNOR) + { + assert(iv_initialized); + } + o_info.push_back(info); + } + + /** + * @brief Sets the attribute value + * + * @param[in] i_value Value of the attribute to set + */ + void set( + _Type const& i_value) + { + iv_data = i_value; + iv_initialized = true; + } + + /** + * @brief Return size of the attribute + * + * @return uint32_t giving the size of the attribute in bytes + */ + uint32_t size() const + { + return sizeof(iv_data); + } + + /** + * @brief Return attribute's corresponding attribute ID + * + * @return Attribute ID of the attribute + */ + ATTRIBUTE_ID id() const + { + return info.attrId; + } + + /** + * @brief Return address of the attribute data + * + * @return Address of the attribute data + */ + const _Type* data() const + { + return &iv_data; + } + + /** + * @brief Return location where attribute resides + * + * @return Location specifier + */ + LOCATION location() const + { + return info.location; + } + + public: + + AttrInfo info; ///< Attribute information + _Type iv_data; ///< Attribute data + bool iv_initialized; ///< Whether attribute was set or not +}; + +/** + * @brief Base class describing attributes that all targets have. + * + * Note: will not repeat documentation for subclasses, since they act the same + */ +class Base +{ + public: + + /** + * @brief Build the base object for attributes + */ + Base() + { + } + + /** + * @brief Populate the list with information on all the attributes + * + * @param[out] o_info List containing all the attribute information + */ + void getAttrInfo( + std::vector& o_info) const + { + iv_class.addAttrInfo(o_info); + iv_type.addAttrInfo(o_info); + iv_model.addAttrInfo(o_info); + iv_physicalPath.addAttrInfo(o_info); + iv_affinityPath.addAttrInfo(o_info); + iv_interfaces.addAttrInfo(o_info); + } + + public: + + Property iv_class; + Property iv_type; + Property iv_model; + Property iv_physicalPath; + Property iv_affinityPath; + Property iv_interfaces; +}; + +/** + * @brief Class describing the data for all cards + */ +class Card : public Base +{ + public: + + Card() + { + iv_class.set(CLASS_CARD); + + PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo( + std::vector& o_info) const + { + Base::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for all DCM cards + */ +class CardScmPower8 : public Card +{ + public: + + CardScmPower8() + { + iv_type.set(TYPE_SCM); + iv_model.set(MODEL_POWER8); + } + + void getAttrInfo(std::vector& o_info) const + { + Card::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for the top level system + */ +class SysSysPower8 : public Base +{ + public: + + SysSysPower8() + { + iv_class.set(CLASS_SYS); + iv_type.set(TYPE_SYS); + iv_model.set(MODEL_POWER8); + + PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Base::getAttrInfo(o_info); + + iv_xscomBaseAddr.addAttrInfo(o_info); + } + + Property iv_xscomBaseAddr; +}; + +/** + * @brief Class describing the data for a chip + */ +class Chip : public Base +{ + public: + + Chip() + { + iv_class.set(CLASS_CHIP); + } + + void getAttrInfo(std::vector& o_info) const + { + Base::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for a node + */ +class EncNodePower8 : public Base +{ + public: + + EncNodePower8() + { + iv_class.set(CLASS_ENC); + iv_type.set(TYPE_NODE); + iv_model.set(MODEL_POWER8); + + PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Base::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for the Salerno chip + */ +class ProcChipSalerno : public Chip +{ + public: + + ProcChipSalerno() + { + iv_type.set(TYPE_PROC); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + l_capabilities.supportsFsiScom = true; + l_capabilities.supportsXscom = true; + iv_interfaces.set(l_capabilities); + + ScomSwitches l_switches = {0}; + l_switches.useXscom = 1; + iv_scomSwitches.set(l_switches); + + iv_dummyRw.set(0); + } + + void getAttrInfo(std::vector& o_info) const + { + Chip::getAttrInfo(o_info); + + iv_dummyRw.addAttrInfo(o_info); + iv_scomSwitches.addAttrInfo(o_info); + iv_xscomChipInfo.addAttrInfo(o_info); + } + + Property iv_dummyRw; + Property iv_scomSwitches; + Property iv_xscomChipInfo; + +}; + +/** + * @brief Class describing the data for a logical entity + */ +class Logical : public Base +{ + public: + + Logical() + { + iv_class.set(CLASS_UNIT); + } + + void getAttrInfo(std::vector& o_info) const + { + Base::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for an EX unit + */ +class UnitExSalerno : public Logical +{ + public: + + UnitExSalerno() + { + iv_type.set(TYPE_EX); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for a core unit + */ +class UnitCoreSalerno : public Logical +{ + public: + + UnitCoreSalerno() + { + iv_type.set(TYPE_CORE); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for an L3 unit + */ +class UnitL3Salerno : public Logical +{ + public: + + UnitL3Salerno() + { + iv_type.set(TYPE_L3); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } + +}; + +/** + * @brief Class describing the data for an L2 unit + */ +class UnitL2Salerno : public Logical +{ + public: + + UnitL2Salerno() + { + iv_type.set(TYPE_L2); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for an MCA unit + */ +class UnitMcsSalerno : public Logical +{ + public: + + UnitMcsSalerno() + { + iv_type.set(TYPE_MCS); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } + + Property iv_scomSwitches; +}; + +/** + * @brief Class describing the data for an MCA unit + */ +class UnitMbaSalerno : public Logical +{ + public: + + UnitMbaSalerno() + { + iv_type.set(TYPE_MBA); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +/** + * @brief Class describing the data for the pervasive unit + */ +class UnitPervasiveSalerno : public Logical +{ + public: + + UnitPervasiveSalerno() + { + iv_type.set(TYPE_PERVASIVE); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } + +}; + +class UnitPciSalerno : public Logical +{ + public: + + UnitPciSalerno() + { + iv_type.set(TYPE_PCI); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +class UnitPowerbusSalerno : public Logical +{ + public: + + UnitPowerbusSalerno() + { + iv_type.set(TYPE_POWERBUS); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +class UnitMemPortSalerno : public Logical +{ + public: + + UnitMemPortSalerno() + { + iv_type.set(TYPE_MEM_PORT); + iv_model.set(MODEL_SALERNO); + + TARGETING::PrimaryCapabilities l_capabilities = {0}; + iv_interfaces.set(l_capabilities); + } + + void getAttrInfo(std::vector& o_info) const + { + Logical::getAttrInfo(o_info); + } +}; + +//****************************************************************************** +// PNOR Builder Service +//****************************************************************************** + +/** + * @brief Class which builds fake PNOR image for bringup + */ +class PnorBuilderService +{ + public: + + /** + * @brief Initial PNOR sizes + */ + static const uint32_t PNOR_SIZE = 8000; + static const uint32_t HEAP_SIZE = 8000; + + /** + * @brief Constructs the PnorBuilderService + */ + PnorBuilderService(); + + /** + * @brief Destructs the PnorBuilderService + */ + ~PnorBuilderService(); + + /** + * @brief Returns pointer to the start of the heap section + */ + uint8_t* heapBase() const; + + /** + * @brief Returns pointer to the start of the PNOR section + */ + uint8_t* pnorBase() const; + + /** + * @brief Clears the PNOR section + */ + void clearPnorSection(); + + /** + * @brief Clears the PNOR section + */ + void clearHeapSection(); + + /** + * @brief Populates attributes valid attributes for a class/type/model + * into the targeting image + * + * @param[in] i_pPnor On input and output, pointer to next valid + * location to write to in PNOR + * @param[in] i_attrInfo List of attributes to process + * @param[in] o_pAttrNames Pointer to where the list was stored + */ + void populateValidAttrIds( + uint8_t*& io_pPnor, + const std::vector& i_attrInfo, + ATTRIBUTE_ID*& o_pAttrNames); + + /** + * @brief Populates attributes into the targeting image + * + * @param[in] i_pAttrNames Pointer to array of valid attributes for + * the class/type/model in question + * @param[in/out] io_pPnor On both input and output, a pointer to the + * next free position in PNOR to populate. + * @param[in/out] io_pHeap On both input and output, a pointer to the + * next free position on the heap to populate. + * @param[out] o_targets List of targets to serialize + * @param[in] i_attrInfo List of attribute infor structures + */ + void populateAttrs( + const ATTRIBUTE_ID* i_pAttrNames, + uint8_t*& io_pPnor, + uint8_t*& io_pHeap, + std::vector< Target* >& o_targets, + const std::vector& i_attrInfo); + + /** + * @brief Builds the targeting image + */ + void buildTargetingImage(); + + /** + * @brief Updates caller's pointer with the address of the targeting + * layout + * + * @param[out] o_pTargetsArea Pointer to the address of the targeting + * layout + */ + void getTargetingImageBaseAddress( + const void*& o_pTargetsArea); + + uint8_t* iv_pPnor; + uint8_t* iv_pHeap; + +} PACKED; + +typedef Singleton thePnorBuilderService; + +} // End namespace TARGETING + +#endif // TARG_FAKEPNORDATA_H diff --git a/src/usr/targeting/makefile b/src/usr/targeting/makefile index 1c26396f6..d335c2d93 100644 --- a/src/usr/targeting/makefile +++ b/src/usr/targeting/makefile @@ -39,10 +39,11 @@ ITERATORS_OBJS = \ TARGET_OBJS = \ target.o \ targetservice.o \ - entitypath.o + entitypath.o \ + fakepnordata.o OBJS = ${TARGET_OBJS} ${PREDICATES_OBJS} ${ITERATORS_OBJS} -SUBDIRS = test.d xmltohb.d +SUBDIRS = test.d include ${ROOTPATH}/config.mk diff --git a/src/usr/targeting/predicates/predicatectm.C b/src/usr/targeting/predicates/predicatectm.C index cb3275c19..79de118ea 100644 --- a/src/usr/targeting/predicates/predicatectm.C +++ b/src/usr/targeting/predicates/predicatectm.C @@ -38,7 +38,7 @@ // Targeting Component #include -#include +#include #include //****************************************************************************** diff --git a/src/usr/targeting/targetservice.C b/src/usr/targeting/targetservice.C index c7513f014..f9b32e962 100644 --- a/src/usr/targeting/targetservice.C +++ b/src/usr/targeting/targetservice.C @@ -40,13 +40,12 @@ #include #include #include -#include // This component #include #include "trace.H" +#include "fakepnordata.H" #include -#include //****************************************************************************** // targetService @@ -172,24 +171,9 @@ void TargetService::init() iv_associationMappings.push_back(a6); // Get+save pointer to beginning of targeting's swappable config in - // PNOR. - //@TODO Fully account for the attribute resource provider - PNOR::SectionInfo_t l_sectionInfo; - errlHndl_t l_pElog = PNOR::getSectionInfo( - PNOR::HB_DATA, PNOR::SIDE_A, l_sectionInfo ); - if(l_pElog) - { - l_pElog->setSev(ERRORLOG::ERRL_SEV_UNRECOVERABLE); - errlCommit(l_pElog); - assert("Failed to get handle to targeting data"); - } - - TargetingHeader* l_pHdr = reinterpret_cast( - l_sectionInfo.vaddr); - assert(l_pHdr->eyeCatcher == PNOR_TARG_EYE_CATCHER); - - iv_pPnor = reinterpret_cast( - (reinterpret_cast(l_pHdr) + l_pHdr->headerSize)); + // PNOR. Note that this will change once PNOR is accessible + (void)thePnorBuilderService::instance() + .getTargetingImageBaseAddress(iv_pPnor); (void)_configureTargetPool(); @@ -605,9 +589,6 @@ uint32_t TargetService::_maxTargets() // Target count found by following the pointer pointed to by the iv_pPnor // pointer. iv_maxTargets = *(*(reinterpret_cast(iv_pPnor))); - - TARG_INF("Max targets = %d",iv_maxTargets); - return iv_maxTargets; #undef TARG_FN diff --git a/src/usr/targeting/test/attributestrings.C b/src/usr/targeting/test/attributestrings.C new file mode 100644 index 000000000..9cfa61d53 --- /dev/null +++ b/src/usr/targeting/test/attributestrings.C @@ -0,0 +1,106 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/targeting/test/attributestrings.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END +/** + * @file attributestrings.C + * + * @brief Attribute string implementation. This file will be autogenerated in + * the future + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include +#include + +// This component +#include +#include +#include + +namespace TARGETING { + +//****************************************************************************** +// attrToString +//****************************************************************************** + +template<> +const char* attrToString ( + AttributeTraits::Type const& i_attrValue) +{ + switch (i_attrValue) + { + case CLASS_CARD: + return "Card"; + case CLASS_ENC: + return "Enclosure"; + case CLASS_CHIP: + return "Chip"; + case CLASS_UNIT: + return "Unit"; + case CLASS_DEV: + return "Device"; + default: + return "Cannot decode class"; + } +} + +//****************************************************************************** +// attrToString +//****************************************************************************** + +template<> +const char* attrToString ( + AttributeTraits::Type const& i_attrValue) +{ + switch (i_attrValue) + { + case TYPE_PROC: + return "Processor"; + case TYPE_EX: + return "EX chiplet"; + default: + return "Cannot decode type"; + } +} + +//****************************************************************************** +// attrToString +//****************************************************************************** + +template<> +const char* attrToString ( + AttributeTraits::Type const& i_attrValue) +{ + switch (i_attrValue) + { + case MODEL_SALERNO: + return "Salerno"; + default: + return "Cannot decode model"; + } +} + +} // End namespace TARGETING diff --git a/src/usr/targeting/test/makefile b/src/usr/targeting/test/makefile index e8b48222b..1e3d79623 100644 --- a/src/usr/targeting/test/makefile +++ b/src/usr/targeting/test/makefile @@ -28,6 +28,3 @@ TESTS = *.H OBJS = attributestrings.o include ${ROOTPATH}/config.mk - -vpath %.C ${GENDIR} - diff --git a/src/usr/targeting/xmltohb/hb.xml b/src/usr/targeting/xmltohb/hb.xml deleted file mode 100644 index 871a7847e..000000000 --- a/src/usr/targeting/xmltohb/hb.xml +++ /dev/null @@ -1,1026 +0,0 @@ - - - - - - - CLASS - Attribute indicating the target's class - - - Enumeration indicating the target's class - - NA - 0 - - - CARD - 1 - - - ENC - 2 - - - CHIP - 3 - - - UNIT - 4 - - - DEV - 5 - - - SYS - 6 - - - MAX - 7 - - NA - - - non-volatile - - - - - - TYPE - Attribute indicating the target's type - - - Attribute indicating the target's type - - NA - 0 - - - SYS - - - NODE - - - DIMM - - - SCM - - - DCM - - - MEMBUF - - - PROC - - - MEMVRM - - - PROCVRM - - - EX - - - CORE - - - L2 - - - L3 - - - L4 - - - MCS - - - MBS - - - MBA - - - MEM_PORT - - - PERVASIVE - - - POWERBUS - - - XBUS - - - ABUS - - - PCI - - - LAST_IN_RANGE - - NA - - - non-volatile - - - - - - MODEL - Attribute indicating the target's model - - - Enumeration indicating the target's model - - NA - 0 - - - SALERNO - 16 - - - VENICE - - - CENTAUR - 48 - - - JEDEC - 80 - - - CDIMM - - - POWER8 - 112 - - NA - - - non-volatile - - - - - - ENGINE_TYPE - Attribute indicating the target's model - - - Enumeration indicating the target's model - - NA - 0 - - - ENGINE_IIC - 1 - - - ENIGNE_SCOM - 2 - - NA - - - non-volatile - - - - - - DUMMY_RW - Dummy attribute with read/write permissions - - - 0 - - - non-volatile - - - - - - DUMMY_WO - Dummy attribute with write-only permissions - - - 0 - - - non-volatile - - - - - DUMMY_RO - Dummy attribute with read-only permissions - - - 0 - - - non-volatile - - - - - DUMMY_HEAP_ZERO_DEFAULT - Dummy attribute on the heap with zero initialization - - - 5 - - - volatile-zeroed - - - - - PHYS_PATH - Physical hierarchical path to the target - - EntityPath - - non-volatile - - - - - AFFINITY_PATH - Hierarchical path to the target with respect to logical affinity - - EntityPath - - non-volatile - - - - - POWER_PATH - Hierarchical path to the target with respect to power - - EntityPath - - non-volatile - - - - - PRIMARY_CAPABILITIES - Attribute which describes capabilities of a target - - Structure which defines a target's primary capabilities. - A target can only support at most FSI SCOM and one of the other two SCOM - types. Applicable for all targets. Structure is read-only. - - - supportsFsiScom - 0b0: Target does not support FSI SCOM; - 0b1: Target supports FSI SCOM - - uint8_t - 1 - 0 - - - supportsXscom - 0b0: Target does not support XSCOM; - 0b1: Target supports FSI XSCOM - uint8_t - 1 - 0 - - - supportsInbandScom - 0b0: Target does not support inband SCOM - uint8_t - 1 - 0 - - - reserved - Reserved for future use - uint8_t - 5 - 0 - - - non-volatile - - - - - SCOM_SWITCHES - Attribute storing information about which SCOM path to use - - Structure which defines which SCOM to use at a point in - time. Only applicable if target supports one or more SCOM types. Only - one bit (of the first three) can ever be set at any one time. - - - useFsiScom - 0b0: Do not use FSI SCOM at this time. 0b1: Use FSI - SCOM at this time - uint8_t - 1 - 0 - - - useXscom - 0b0: Do not use XSCOM at this time. 0b1: Use XSCOM at - this time - uint8_t - 1 - 0 - - - useInbandScom - 0b0: Do not use inband SCOM at this time. 0b1: Use - inband SCOM at this time - uint8_t - 1 - 0 - - - reserved - Reserved for future expansion - uint8_t - 5 - 0 - - - volatile - - - - - XSCOM_BASE_ADDRESS - System XSCOM base address - - - 0x300000000000 - - - non-volatile - - - - - XSCOM_CHIP_INFO - Attribute which describes XSCOM chip info - - Structure which defines chip info necessary for XSCOM. - Only applicable for chip targets which support XSCOM. Structure is - read-only - - nodeId - Unique ID of node containing the chip - uint8_t - 0 - - - chipId - Unique ID of chip, relative to node - uint8_t - 0 - - - non-volatile - - - - - I2C_CHIP_INFO - Attribute which describes I2C chip info - - Structure which defines info necessary for I2C. Only - applicable for chip targets which support I2C. Structure is - read-only. - - busSpeed - Slave device bus speed - uint32_t - 0 - - - deviceAddr - Slave device address - uint32_t - 0 - - - devicePort - Slave device port location - uint32_t - 0 - - - deviceMasterEng - Master I2C engine slave is hung off of - uint32_t - 0 - - - non-volatile - - - - - - - base - CLASS - TYPE - MODEL - PHYS_PATH - AFFINITY_PATH - - PRIMARY_CAPABILITIES - - - - - sys-sys-power8 - base - CLASSSYS - TYPESYS - MODELPOWER8 - - XSCOM_BASE_ADDRESS - - - PHYS_PATH - physical:sys-0 - - - AFFINITY_PATH - affinity:sys-0 - - - - - chip - base - - CLASS - CHIP - - - - - chip-processor - chip - - TYPE - PROC - - - PRIMARY_CAPABILITIES - - supportsFsiScom1 - supportsXscom1 - supportsInbandScom0 - reserved0 - - - - SCOM_SWITCHES - - - - - chip-processor-salerno - chip-processor - - MODEL - SALERNO - - - XSCOM_CHIP_INFO - - DUMMY_RW - DUMMY_HEAP_ZERO_DEFAULT - - - - unit - base - - CLASS - UNIT - - - PRIMARY_CAPABILITIES - - supportsFsiScom1 - supportsXscom1 - supportsInbandScom0 - reserved0 - - - - - - unit-ex-salerno - unit - - TYPE - EX - - - MODEL - SALERNO - - - - - unit-core-salerno - unit - - TYPE - CORE - - - MODEL - SALERNO - - - - - unit-mba-salerno - unit - - TYPE - MBA - - - MODEL - SALERNO - - - - - unit-pervasive-salerno - unit - - TYPE - PERVASIVE - - - MODEL - SALERNO - - - - - unit-pci-salerno - unit - - TYPE - PCI - - - MODEL - SALERNO - - - - - unit-powerbus-salerno - unit - - TYPE - POWERBUS - - - MODEL - SALERNO - - - - - unit-memport-salerno - unit - - TYPE - MEM_PORT - - - MODEL - SALERNO - - - - - unit-mcs-salerno - unit - - TYPE - MCS - - - MODEL - SALERNO - - - - - enc-node-power8 - base - - CLASS - ENC - - - TYPE - NODE - - - MODEL - POWER8 - - - - - - - sys0 - sys-sys-power8 - - PHYS_PATH - physical:sys-0 - - - AFFINITY_PATH - affinity:sys-0 - - - - - sys0node0 - enc-node-power8 - - PHYS_PATH - physical:sys-0/node-0 - - - AFFINITY_PATH - affinity:sys-0/node-0 - - - - - sys0node0proc0 - chip-processor-salerno - SCOM_SWITCHES - - useFsiScom0 - useXscom1 - useInbandScom0 - reserved0 - - - - XSCOM_CHIP_INFO - - nodeId0 - chipId0 - - - - PHYS_PATH - physical:sys-0/node-0/proc-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0 - - - - - sys0node0proc0ex0 - unit-ex-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-0 - - - - - sys0node0proc0ex1 - unit-ex-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-1 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-1 - - - - - sys0node0proc0ex2 - unit-ex-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-2 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-2 - - - - - sys0node0proc0ex3 - unit-ex-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-3 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-3 - - - - - sys0node0proc0ex4 - unit-ex-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-4 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-4 - - - - - sys0node0proc0ex5 - unit-ex-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-5 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-5 - - - - - sys0node0proc0ex0core0 - unit-core-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-0/core-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-0/core-0 - - - - - sys0node0proc0ex1core0 - unit-core-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-1/core-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-1/core-0 - - - - - sys0node0proc0ex2core0 - unit-core-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-2/core-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-2/core-0 - - - - - sys0node0proc0ex3core0 - unit-core-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-3/core-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-3/core-0 - - - - - sys0node0proc0ex4core0 - unit-core-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-4/core-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-4/core-0 - - - - - sys0node0proc0ex5core0 - unit-core-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/ex-5/core-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/ex-5/core-0 - - - - - sys0node0proc0mcs0 - unit-mcs-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/mcs-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/mcs-0 - - - - - sys0node0proc0mcs0mba0 - unit-mba-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/mcs-0/mba-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/mcs-0/mba-0 - - - - - sys0node0proc0mcs0mba1 - unit-mba-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/mcs-0/mba-1 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/mcs-0/mba-1 - - - - - sys0node0proc0mcs0mba0port0 - unit-memport-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/mcs-0/mba-0/mem_port-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/mcs-0/mba-0/mem_port-0 - - - - - sys0node0proc0mcs0mba1port0 - unit-memport-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/mcs-0/mba-1/mem_port-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/mcs-0/mba-1/mem_port-0 - - - - - sys0node0proc0pervasive0 - unit-pervasive-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/pervasive-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/pervasive-0 - - - - - sys0node0proc0powerbus0 - unit-powerbus-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/powerbus-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/powerbus-0 - - - - - sys0node0proc0pci0 - unit-pci-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/pci-0 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/pci-0 - - - - - sys0node0proc0pci1 - unit-pci-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/pci-1 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/pci-1 - - - - - sys0node0proc0pci2 - unit-pci-salerno - - PHYS_PATH - physical:sys-0/node-0/proc-0/pci-2 - - - AFFINITY_PATH - affinity:sys-0/node-0/proc-0/pci-2 - - - - diff --git a/src/usr/targeting/xmltohb/makefile b/src/usr/targeting/xmltohb/makefile deleted file mode 100644 index 2bcf51a5c..000000000 --- a/src/usr/targeting/xmltohb/makefile +++ /dev/null @@ -1,51 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/targeting/makefile $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2011 -# -# p1 -# -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code -# -# The source code for this program is not published or other- -# wise divested of its trade secrets, irrespective of what has -# been deposited with the U.S. Copyright Office. -# -# Origin: 30 -# -# IBM_PROLOG_END - -ROOTPATH = ../../../.. - -XMLTOHB_HEADER_TARGETS = \ - attributeenums.H \ - attributestrings.H \ - attributetraits.H \ - attributestructs.H \ - pnortargeting.H - -XMLTOHB_SOURCE_TARGETS = \ - attributestrings.C - -XMLTOHB_BINARY_TARGETS = \ - targeting.bin - -GENFILES = \ - ${XMLTOHB_HEADER_TARGETS} \ - ${XMLTOHB_SOURCE_TARGETS} \ - ${XMLTOHB_BINARY_TARGETS} - -# Delete any generated file on error -.DELETE_ON_ERROR: - -$(addprefix %/,$(GENFILES)) : xmltohb.pl hb.xml - ./$< --hb-xml-file ./hb.xml --src-output-dir=$(dir $@) --img-output-dir=$(dir $@) $(filter-out $<,$^) - cp -f $(dir $@)/targeting.bin $(IMGDIR) - -include ${ROOTPATH}/config.mk diff --git a/src/usr/targeting/xmltohb/xmltohb.pl b/src/usr/targeting/xmltohb/xmltohb.pl deleted file mode 100755 index 711bef874..000000000 --- a/src/usr/targeting/xmltohb/xmltohb.pl +++ /dev/null @@ -1,2140 +0,0 @@ -#!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/targeting/xmltohb/xmltohb.pl $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2011 -# -# p1 -# -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code -# -# The source code for this program is not published or other- -# wise divested of its trade secrets, irrespective of what has -# been deposited with the U.S. Copyright Office. -# -# Origin: 30 -# -# IBM_PROLOG_END - -# -# Purpose: -# Author: Nick Bofferding -# Last Updated: 09/09/2011 -# -# Version: 1.0 -# -# Change Log ********************************************************** -# -# End Change Log ****************************************************** - -use strict; - -################################################################################ -# Use of the following packages -################################################################################ - -use Getopt::Long; -use Pod::Usage; -use XML::Simple; -use Text::Wrap; -use Data::Dumper; -use POSIX; - -################################################################################ -# Process command line parameters, issue help text if needed -################################################################################ - -sub main{ } -my $cfgSrcOutputDir = "."; -my $cfgImgOutputDir = "."; -my $cfgHbXmlFile = "./hb.xml"; -my $cfgHelp = 0; -my $cfgMan = 0; -my $cfgVerbose = 0; - -GetOptions("hb-xml-file:s" => \$cfgHbXmlFile, - "src-output-dir:s" => \$cfgSrcOutputDir, - "img-output-dir:s" => \$cfgImgOutputDir, - "help" => \$cfgHelp, - "man" => \$cfgMan, - "verbose" => \$cfgVerbose ) || pod2usage(-verbose => 0); - -pod2usage(-verbose => 1) if $cfgHelp; -pod2usage(-verbose => 2) if $cfgMan; - -# Remove extraneous '/' from end of path names; use temporary version of $/ for -# the chomp -{ - local $/ = '/'; - chomp($cfgSrcOutputDir); - $cfgSrcOutputDir .= "/"; - - chomp($cfgImgOutputDir); - $cfgImgOutputDir .= "/"; -} - -if($cfgVerbose) -{ - print STDOUT "Host boot intemediate XML model = $cfgHbXmlFile\n"; - print STDOUT "Source output dir = $cfgSrcOutputDir\n"; - print STDOUT "Image output dir = $cfgImgOutputDir\n"; -} - -################################################################################ -# Initialize some globals -################################################################################ - -my $xml = new XML::Simple (KeyAttr=>[]); - -# Until full machine parseable workbook parsing splits out all the input files, -# use the intermediate representation containing the full host boot model. -# Aborts application if file name not found. -my $attributes = $xml->XMLin($cfgHbXmlFile, forcearray => ['attribute']); - -# Perform some sanity validation of the model (so we don't have to later) -validateAttributes($attributes); -validateTargetInstances($attributes); -validateTargetInstances($attributes); - -# Open the output files and write them -open(TRAIT_FILE,">$cfgSrcOutputDir"."attributetraits.H") - or fatal ("Trait file: \"$cfgSrcOutputDir" - . "attributetraits.H\" could not be opened."); -my $traitFile = *TRAIT_FILE; -writeTraitFileHeader($traitFile); -writeTraitFileTraits($attributes,$traitFile); -writeTraitFileFooter($traitFile); -close $traitFile; - -open(ATTR_FILE,">$cfgSrcOutputDir"."attributeenums.H") - or fatal ("Attribute enum file: \"$cfgSrcOutputDir" - . "attributeenums.H\" could not be opened."); -my $enumFile = *ATTR_FILE; -writeEnumFileHeader($enumFile); -writeEnumFileAttrIdEnum($attributes,$enumFile); -writeEnumFileAttrEnums($attributes,$enumFile); -writeEnumFileFooter($enumFile); -close $enumFile; - -open(STRING_HEADER_FILE,">$cfgSrcOutputDir"."attributestrings.H") - or fatal ("Attribute string header file: \"$cfgSrcOutputDir" - . "attributestrings.H\" could not be opened."); -my $stringHeaderFile = *STRING_HEADER_FILE; -writeStringHeaderFileHeader($stringHeaderFile); -writeStringHeaderFileStrings($attributes,$stringHeaderFile); -writeStringHeaderFileFooter($stringHeaderFile); -close $stringHeaderFile; - -open(STRING_IMPLEMENTATION_FILE,">$cfgSrcOutputDir"."attributestrings.C") - or fatal ("Attribute string source file: \"$cfgSrcOutputDir" - . "attributestrings.C\" could not be opened."); -my $stringImplementationFile = *STRING_IMPLEMENTATION_FILE; -writeStringImplementationFileHeader($stringImplementationFile); -writeStringImplementationFileStrings($attributes,$stringImplementationFile); -writeStringImplementationFileFooter($stringImplementationFile); -close $stringImplementationFile; - -open(STRUCTS_HEADER_FILE,">$cfgSrcOutputDir"."attributestructs.H") - or fatal ("Attribute struct file: \"$cfgSrcOutputDir" - . "attributestructs.H\" could not be opened."); -my $structFile = *STRUCTS_HEADER_FILE; -writeStructFileHeader($structFile); -writeStructFileStructs($attributes,$structFile); -writeStructFileFooter($structFile); -close $structFile; - -open(PNOR_HEADER_DEF_FILE,">$cfgSrcOutputDir"."pnortargeting.H") - or fatal ("Targeting header definition header file: \"$cfgSrcOutputDir" - . "pnortargeting.H\" could not be opened."); -my $pnorHeaderDefFile = *PNOR_HEADER_DEF_FILE; -writeHeaderFormatHeaderFile($pnorHeaderDefFile); -close $pnorHeaderDefFile; - -open(PNOR_TARGETING_FILE,">$cfgImgOutputDir"."targeting.bin") - or fatal ("Targeting image file: \"$cfgSrcOutputDir" - . "targeting.bin\" could not be opened."); -my $pnorFile = *PNOR_TARGETING_FILE; -writeTargetingImage($pnorFile,$attributes); -close $pnorFile; - -exit(0); - -################################################################################ -# Report a fatal error and quit -################################################################################ - -sub DEBUG_FUNCTIONS { } -sub fatal { - my($msg) = @_; - - print STDERR "[FATAL!] $msg\n"; - - for(my $caller = 1; ; $caller++) - { - my ($package, $filename, $callerLine, - $subr, $has_args, $wantarray )= caller($caller); - my $line = (caller($caller-1))[2]; - if(!$line) { last; } - - print STDERR " $caller: $subr" . "(". $line . ")\n"; - } - - exit(1); -} - -sub VALIDATION_FUNCTIONS { } - -################################################################################ -# Validates sub-elements of an element against criteria -################################################################################ - -sub validateSubElements { - my($name,$mustBeHash,$element,$criteria) = @_; - - if($mustBeHash && (ref($element) ne "HASH")) - { - fatal("$name must be in the form of a hash."); - } - - # print keys %{$element} . "\n"; - - for my $subElementName (keys %{$element}) - { - if(!exists $criteria->{$subElementName}) - { - fatal("$name element cannot have child element of type " - . "\"$subElementName\"."); - } - } - - for my $subElementName (keys %{$criteria}) - { - if( ($criteria->{$subElementName}{required} == 1) - && (!exists $element->{$subElementName})) - { - fatal("$name element missing required child element " - . "\"$subElementName\"."); - } - - if(exists $element->{$subElementName} - && ($criteria->{$subElementName}{isscalar} == 1) - && (ref ($element->{$subElementName}) eq "HASH")) - { - fatal("$name element child element \"$subElementName\" should be " - . "scalar, but is a hash."); - } - } -} - -################################################################################ -# Validates attribute element for correctness -################################################################################ - -sub validateAttributes { - my($attributes) = @_; - - my %elements = ( ); - $elements{"id"} = { required => 1, isscalar => 1}; - $elements{"description"} = { required => 1, isscalar => 1}; - $elements{"persistency"} = { required => 1, isscalar => 1}; - $elements{"readable"} = { required => 0, isscalar => 0}; - $elements{"simpleType"} = { required => 0, isscalar => 0}; - $elements{"complexType"} = { required => 0, isscalar => 0}; - $elements{"nativeType"} = { required => 0, isscalar => 0}; - $elements{"writeable"} = { required => 0, isscalar => 0}; - $elements{"hasStringConversion"} - = { required => 0, isscalar => 0}; - - foreach my $attribute (@{$attributes->{attribute}}) - { - validateSubElements("attribute",1,$attribute,\%elements); - } -} - -################################################################################ -# Validates field element for correctness -################################################################################ - -sub validateFieldElement { - my($field) = @_; - - my %elements = ( ); - $elements{"type"} = { required => 1, isscalar => 1}; - $elements{"name"} = { required => 1, isscalar => 1}; - $elements{"description"} = { required => 1, isscalar => 1}; - $elements{"default"} = { required => 1, isscalar => 1}; - $elements{"bits"} = { required => 0, isscalar => 1}; - - validateSubElements("field",1,$field,\%elements); -} - -################################################################################ -# Validates target instance elements for correctness -################################################################################ - -sub validateTargetInstances { - my($attributes) = @_; - - my %elements = ( ); - $elements{"id"} = { required => 1, isscalar => 1}; - $elements{"parent"} = { required => 0, isscalar => 1}; - $elements{"attribute"} = { required => 0, isscalar => 0}; - - foreach my $targetType (@{$attributes->{targetType}}) - { - validateSubElements("targetType",1,$targetType,\%elements); - } -} - -################################################################################ -# Validates target type elements for correctness -################################################################################ - -sub validateTargetInstances { - my($attributes) = @_; - - my %elements = ( ); - $elements{"id"} = { required => 1, isscalar => 1}; - $elements{"type"} = { required => 1, isscalar => 1}; - $elements{"attribute"} = { required => 0, isscalar => 0}; - - foreach my $targetInstance (@{$attributes->{targetInstance}}) - { - validateSubElements("targetInstance",1,$targetInstance,\%elements); - } -} - -sub SOURCE_FILE_GENERATION_FUNCTIONS { } - -################################################################################ -# Writes the pnor targeting header format file -################################################################################ - -sub writeHeaderFormatHeaderFile { - my($outFile) = @_; - - print $outFile < - -// Targeting component - -//****************************************************************************** -// Complex Types -//****************************************************************************** - -namespace TARGETING -{ - const uint32_t PNOR_TARG_EYE_CATCHER = 0x54415247; - - enum SECTION_TYPE - { - // Targeting read-only section backed to PNOR. Always the 0th section. - SECTION_TYPE_PNOR_RO = 0x00, - - // Targeting read-write section backed to PNOR - SECTION_TYPE_PNOR_RW = 0x01, - - // Targeting heap section initialized out of PNOR - SECTION_TYPE_HEAP_PNOR_INIT = 0x02, - - // Targeting heap section intialized to zero - SECTION_TYPE_HEAP_ZERO_INIT = 0x03, - }; - - struct TargetingSection - { - // Type of targeting section - const SECTION_TYPE sectionType; - - // Offset of the section within the PNOR targeting image from byte zero - // of the targeting header - const uint32_t sectionOffset; - - // Size of the section within the PNOR targeting image - const uint32_t sectionSize; - - } PACKED; - - struct TargetingHeader - { - // Eyecatcher to quickly verify correct population of targeting PNOR - // data - const uint32_t eyeCatcher; - - // Major version of the PNOR targeting image - const uint16_t majorVersion; - - // Minor version of the PNOR targeting image - const uint16_t minorVersion; - - // Total size of the targeting header (from beginning of header). The - // PNOR RO targeting data is located immediately following the header - const uint32_t headerSize; - - // Virtual memory offset from the virtual memory address of the previous - // section where the attribute resource provider must load the next - // section. If there is no previous section, it will represent the - // offset from the virtual memory base address (typically 0) - const uint32_t vmmSectionOffset; - - // Virtual memory base address where the attribute resource provider - // must load the 0th (PNOR RO) section - void* const vmmBaseAddress; - - // Size of each TargetingSection record - const uint32_t sizeOfSection; - - // Number of TargetingSection records - const uint32_t numSections; - - // Offset to the first TargetingSection record, from the end of this - // field - const uint32_t offsetToSections; - - // Pad, in bytes, given by "offsetToSections" - - // const TargetingSection sections[numSections]; - - } PACKED; - -} // End namespace TARGETING - -#endif // TARG_PNORHEADER_H - -VERBATIM - -} - -################################################################################ -# Writes the string implementation file header -################################################################################ - -sub writeStringImplementationFileHeader { - my($outFile) = @_; - - print $outFile < -#include - -// Targeting component -#include - -namespace TARGETING { - -VERBATIM - -} - -################################################################################ -# Writes string implementation -################################################################################ - -sub writeStringImplementationFileStrings { - my($attributes,$outFile) = @_; - - foreach my $attribute (@{$attributes->{attribute}}) - { - if(exists $attribute->{simpleType}) - { - my $simpleType = $attribute->{simpleType}; - if(exists $simpleType->{enumeration}) - { - my $enumeration = $simpleType->{enumeration}; - - print $outFile "//*********************************************" - . "*********************************\n"; - print $outFile "// attrToString{id}, ">\n"; - print $outFile "//*********************************************" - . "*********************************\n\n"; - print $outFile "template<>\n"; - print $outFile "const char* attrToString{id},"> (\n"; - print $outFile " AttributeTraits{id}, - ">::Type const& i_attrValue)\n"; - print $outFile "{\n"; - print $outFile " switch(i_attrValue)\n"; - print $outFile " {\n"; - - foreach my $enumerator (@{$enumeration->{enumerator}}) - { - print $outFile " case ", $attribute->{id}, "_", - $enumerator->{name},":\n"; - print $outFile " return \"", - $enumerator->{name},"\";\n"; - } - - print $outFile " default:\n"; - print $outFile " return \"Cannot decode ", - $attribute->{id}, "\";\n"; - print $outFile " }\n"; - print $outFile "}\n\n"; - } - } - } -} - -################################################################################ -# Writes the string implementation file footer -################################################################################ - -sub writeStringImplementationFileFooter { - my($outFile) = @_; - -print $outFile < -#include - -// Targeting component -#include - -//****************************************************************************** -// Complex Types -//****************************************************************************** - -namespace TARGETING -{ - -VERBATIM - -} - -################################################################################ -# Writes struct header file structs -################################################################################ - -sub writeStructFileStructs { - my($attributes,$outFile) = @_; - - foreach my $attribute (@{$attributes->{attribute}}) - { - if(exists $attribute->{complexType}) - { - my $complexType = $attribute->{complexType}; - if(!exists $complexType->{description}) - { - fatal("ERROR: Complex type requires a 'description'."); - } - - print $outFile "/**\n"; - print $outFile wrapBrief($complexType->{description}); - print $outFile " */\n"; - - print $outFile "struct ", - calculateStructName($attribute->{id}), "\n"; - print $outFile "{\n"; - - my $complex = $attribute->{complexType}; - foreach my $field (@{$complex->{field}}) - { - validateFieldElement($field); - - my $bits = ""; - if($field->{bits}) - { - $bits = " : " . $field->{bits}; - } - - print $outFile wrapComment($field->{description}); - print $outFile " ", $field->{type}, " ", $field->{name}, - $bits, "; \n\n"; - } - - print $outFile "} PACKED;\n\n"; - } - } -} - -################################################################################ -# Writes the struct file footer -################################################################################ - -sub writeStructFileFooter { - my($outFile) = @_; - -print $outFile < -#include - -namespace TARGETING -{ - -/** - * \@brief Class used to clarify compiler error when caller attempts to - * stringify an unsupported attribute - */ -class InvalidAttributeForStringification; - -/** - * \@brief Return attribute as a string - * - * \@param[in] i_attrValue Value of the attribute - * - * \@return String which decodes the attribute value - */ -template -const char* attrToString( - typename AttributeTraits::Type const& i_attrValue) -{ - // Default behavior is to fail the compile if caller attempt to print an - // unsupported string - return InvalidAttributeForStringification(); -} - -VERBATIM - -} - -################################################################################ -# Writes string interfaces -################################################################################ - -sub writeStringHeaderFileStrings { - my($attributes,$outFile) = @_; - - foreach my $attribute (@{$attributes->{attribute}}) - { - if(exists $attribute->{simpleType}) - { - my $simpleType = $attribute->{simpleType}; - if(exists $simpleType->{enumeration}) - { - my $enumeration = $simpleType->{enumeration}; - print $outFile "/**\n"; - print $outFile " * \@brief See " - . "attrToString\n"; - print $outFile " */\n"; - print $outFile "template<>\n"; - print $outFile "const char* attrToString{id},">(\n"; - print $outFile " AttributeTraits{id}, - ">::Type const& i_attrValue);\n"; - print $outFile "\n"; - } - } - } -} - -################################################################################ -# Writes the string header file footer -################################################################################ - -sub writeStringHeaderFileFooter { - my($outFile) = @_; - -print $outFile < -#include - -//****************************************************************************** -// Enumerations -//****************************************************************************** - -namespace TARGETING -{ - -VERBATIM - -} - -################################################################################ -# Writes the enum file attribute enumeration -################################################################################ - -sub writeEnumFileAttrIdEnum { - my($attributes,$outFile) = @_; - - print $outFile <{enumerator}}) - { - $hexVal = sprintf "0x%08X", $enumerator->{value}; - $attrId = $enumerator->{name}; - write; - } - - print $outFile "};\n\n"; -} - -################################################################################ -# Writes other enumerations to enumeration file -################################################################################ - -sub writeEnumFileAttrEnums { - my($attributes,$outFile) = @_; - - my $enumName = ""; - my $enumHex = ""; - - format ENUMFORMAT = - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< = @<<<<<<<<<< - $enumName $enumHex ."," -. - select($outFile); - $~ = 'ENUMFORMAT'; - - foreach my $attribute (@{$attributes->{attribute}}) - { - if(exists $attribute->{simpleType}) - { - my $simpleType = $attribute->{simpleType}; - if(exists $simpleType->{enumeration}) - { - my $enumeration = $simpleType->{enumeration}; - print $outFile "/**\n"; - print $outFile wrapBrief( $enumeration->{description} ); - print $outFile " */\n"; - print $outFile "enum ", $attribute->{id}, "\n"; - print $outFile "{\n"; - - foreach my $enumerator (@{$enumeration->{enumerator}}) - { - $enumHex = sprintf "0x%08X", - enumNameToValue($enumeration,$enumerator->{name}); - $enumName = $attribute->{id} . "_" . $enumerator->{name}; - write; - } - - print $outFile "};\n\n"; - } - } - } -} - -################################################################################ -# Writes the enum file footer -################################################################################ - -sub writeEnumFileFooter { - my($outFile) = @_; - -print $outFile < -#include - -namespace TARGETING -{ - -//****************************************************************************** -// Attribute Property Mappings -//****************************************************************************** - -/** - * \@brief Template associating a specific attribute with a type and other - * properties, such as whether it is readable/writable - * - * This is automatically generated - * - * enum { - * disabled = Special value for the basic, unused wildcard attribute - * readable = Attribute is readable - * writable = Attribute is writable - * hasStringConversion = Attribute has debug string conversion - * } - * - * typedef TYPE // is the Attribute's valid type - */ -template -class AttributeTraits -{ - private: - enum { disabled }; - typedef void* Type; -}; - -VERBATIM - -} - -################################################################################ -# Writes computed traits to trait file -################################################################################ - -sub writeTraitFileTraits { - my($attributes,$outFile) = @_; - - foreach my $attribute (@{$attributes->{attribute}}) - { - # Build boolean traits - - my $traits = ""; - foreach my $trait ("writeable","readable","hasStringConversion") - { - if(exists $attribute->{$trait}) - { - $traits .= " $trait,"; - } - } - chop($traits); - - # Build value type - - my $type = ""; - if(exists $attribute->{simpleType}) - { - my $simpleType = $attribute->{simpleType}; - my $simpleTypeProperties = simpleTypeProperties(); - my $typeName = (keys %{$simpleType})[0]; - if(exists $simpleTypeProperties->{$typeName}) - { - if( $simpleTypeProperties->{$typeName}{typeName} - eq "XMLTOHB_USE_PARENT_ATTR_ID") - { - $type = $attribute->{id}; - } - else - { - $type = $simpleTypeProperties->{$typeName}{typeName}; - } - } - - if($type eq "") - { - fatal("Unsupported simpleType child element \"$typeName\" for " - . "attribute $attribute->{id}."); - } - } - elsif(exists $attribute->{nativeType}) - { - $type = $attribute->{nativeType}->{name}; - } - elsif(exists $attribute->{complexType}) - { - $type = calculateStructName($attribute->{id}); - } - else - { - fatal("Could not determine attribute data type for attribute " - . "$attribute->{id}."); - } - - # Add traits definition to output - - print $outFile "template<>\n"; - print $outFile "class AttributeTraits{id},">\n"; - print $outFile "{\n"; - print $outFile " public:\n"; - print $outFile " enum {",$traits," };\n"; - print $outFile " typedef ", $type, " Type;\n"; - print $outFile "};\n\n"; - }; -} - -################################################################################ -# Writes the trait file footer -################################################################################ - -sub writeTraitFileFooter { - my($outFile) = @_; - - print $outFile <{description} = "Internal enum for attribute IDs\n"; - $enumeration->{default} = "NA"; - $enumeration->{enumerator}->[0]->{name} = "NA"; - $enumeration->{enumerator}->[0]->{value} = 0; - - foreach my $attribute (@{$attributes->{attribute}}) - { - $attributeValue++; - $enumeration->{enumerator}->[$attributeValue]->{name} - = $attribute->{id}; - $enumeration->{enumerator}->[$attributeValue]->{value} - = sprintf "%u",$attributeValue; - } - - return $enumeration; -} - -################################################################################ -# Pack uint64_t into a buffer in big-endian format -################################################################################ - -sub packQuad{ - my($quad) = @_; - - return pack("NN" , $quad >> 32, $quad); -} - -################################################################################ -# Get space required to store an enum, based on the max value -################################################################################ - -sub enumSpace { - my($maxEnumVal) = @_; - if($maxEnumVal == 0) - { - # Enum needs at least one byte - $maxEnumVal++; - } - my $space = ceil(log($maxEnumVal+1) / (8 * log(2))); - return $space; -} - -################################################################################ -# Get mininum # of bytes, in block size chunks, able to contain the input data -################################################################################ - -sub sizeBlockAligned { - my ($size,$blockSize,$oneBlockMinimum) = @_; - - if( (!defined $size) - || (!defined $blockSize) - || (!defined $oneBlockMinimum) ) - { - fatal("Caller must specify 'size', 'blockSize', 'oneBlockMinimum' " - . "args."); - } - - if(!$blockSize) - { - fatal("'blockSize' arg must be > 0."); - } - - if(($size % $blockSize) || (($size==0) && $oneBlockMinimum) ) - { - $size += ($blockSize - ($size % $blockSize)); - } - - return $size; -} - -################################################################################ -# Optimize white space for C++/doxygen documentation -################################################################################ - -sub optWhiteSpace { - my($text) = @_; - - # Remove leading, trailing white space, then collapse excess internal - # whitespace - $text =~ s/^\s+|\s+$//g; - $text =~ s/\s+/ /g; - - return $text; -} - -################################################################################ -# Wrap text into a C++/doxygen brief description -################################################################################ - -sub wrapBrief { - my($text) = @_; - - my $brief_start = " * \@brief "; - my $brief_continue = " * "; - - return wrap($brief_start,$brief_continue, optWhiteSpace($text))."\n"; -} - -################################################################################ -# Wrap text into a C++ style comment -################################################################################ - -sub wrapComment { - my($text) = @_; - - my $comment_start = " // "; - my $comment_continue = " // "; - - return wrap($comment_start,$comment_continue,optWhiteSpace($text))."\n"; -} - -################################################################################ -# Calculate struct type name for a header file, based on its ID -################################################################################ - -sub calculateStructName { - my($id) = @_; - - my $type = ""; - - # Struct name is original ID with underscores removed and first letter of - # each word capitalized - my @words = split(/_/,$id); - foreach my $word (@words) - { - $type .= ucfirst( lc($word) ); - } - - return $type; -} - -################################################################################ -# Return array containing only distinct target types that are actally in use -################################################################################ - -sub getInstantiatedTargetTypes { - my($attributes) = @_; - - my %seen = (); - my @uniqueTargetTypes = (); - - foreach my $targetInstance (@{$attributes->{targetInstance}}) - { - push (@uniqueTargetTypes, $targetInstance->{type}) - unless $seen{$targetInstance->{type}}++; - } - - return @uniqueTargetTypes; -} - -################################################################################ -# Get hash ref to supported simple types and their properties -################################################################################ - -sub simpleTypeProperties { - - my %typesHoH = (); - - # Intentionally didn't wrap these to 80 columns to keep them lined up and - # more readable - $typesHoH{"uint8_t"} = { complexTypeSupport => 1, typeName => "uint8_t" , bytes => 1, bits => 8 , packfmt => "C" }; - $typesHoH{"uint16_t"} = { complexTypeSupport => 1, typeName => "uint16t" , bytes => 2, bits => 16, packfmt => "S" }; - $typesHoH{"uint32_t"} = { complexTypeSupport => 1, typeName => "uint32_t" , bytes => 4, bits => 32, packfmt => "L" }; - $typesHoH{"uint64_t"} = { complexTypeSupport => 1, typeName => "uint64_t" , bytes => 8, bits => 64, packfmt =>\&packQuad }; - $typesHoH{"enumeration"} = { complexTypeSupport => 0, typeName => "XMLTOHB_USE_PARENT_ATTR_ID" , bytes => 0, bits => 0 , packfmt => "packEnumeration" }; - - return \%typesHoH; -} - -################################################################################ -# Get attribute default -################################################################################ - -sub getAttributeDefault { - my($attributeId,$attributes) = @_; - - my $default = ""; - my $simpleTypeProperties = simpleTypeProperties(); - - foreach my $attribute (@{$attributes->{attribute}}) - { - if ($attribute->{id} eq $attributeId) - { - if(exists $attribute->{simpleType}) - { - for my $type (keys %{$simpleTypeProperties}) - { - # Note: must check for 'type' before 'default', otherwise - # might add value to the hash - if( exists $attribute->{simpleType}->{$type} - && exists $attribute->{simpleType}->{$type}->{default}) - { - $default = $attribute->{simpleType}->{$type}->{default}; - last; - } - } - } - elsif(exists $attribute->{complexType}) - { - my $cplxDefault = { } ; - my $i = 0; - foreach my $field (@{$attribute->{complexType}->{field}}) - { - $cplxDefault->{field}->[$i]->{id} = $field->{name}; - $cplxDefault->{field}->[$i]->{value} = $field->{default}; - $i++; - } - return $cplxDefault->{field}; - } - elsif(exists $attribute->{nativeType}) - { - if( exists $attribute->{nativeType}->{name} - && ($attribute->{nativeType}->{name} eq "EntityPath")) - { - $default = "MustBeOverriddenByTargetInstance"; - } - else - { - fatal("Cannot provide default for unsupported nativeType."); - } - } - else - { - fatal("Unrecognized value type."); - } - - last; - } - } - - return $default; -} - -################################################################################ -# Get target attributes -################################################################################ - -sub getTargetAttributes { - my($type,$attributes,$attrhasha) = @_; - - foreach my $targetType (@{$attributes->{targetType}}) - { - if($targetType->{id} eq $type) - { - if(exists $targetType->{parent}) - { - getTargetAttributes($targetType->{parent}, - $attributes,$attrhasha); - } - - foreach my $attr (@{$targetType->{attribute}}) - { - $attrhasha->{ $attr->{id} } = $attr; - - if(!exists $attrhasha->{ $attr->{id}}->{default}) - { - my $default = getAttributeDefault($attr->{id},$attributes); - $attrhasha->{ $attr->{id}}->{default}->{field} = $default; - } - } - - last; - } - } -} - -################################################################################ -# Compute maximum enumerator value for a given enumeration -################################################################################ - -sub maxEnumValue { - my($enumeration) = @_; - - my $max = 0; - my $candidateMax = 0; - foreach my $enumerator (@{$enumeration->{enumerator}}) - { - $candidateMax = enumNameToValue($enumeration,$enumerator->{name}); - if($candidateMax > $max) - { - $max = $candidateMax; - } - } - - return $max; -} - -################################################################################ -# Serialize an enumeration to data buffer -################################################################################ - -sub packEnumeration { - my($enumeration,$value) = @_; - - my $binaryData; - - # Determine space required for max enum - my $bytes = enumSpace( maxEnumValue($enumeration) ); - - # Encode the value - for (my $count=$bytes-1; $count >= 0; $count--) - { - $binaryData .= pack("C", (0xFF & ($value >> (8*$count))) ); - } - - if(length $binaryData < 1) - { - fatal("Failed to write binary data for enumeration."); - } - - #print " Enum description: ", $enumeration->{description}, "\n"; - #print "Enum storage space required: ", $bytes, "\n"; - #print " Value encoded: ", $value, "\n"; - #print " Final length of encode: ", length $binaryData, "\n"; - - return $binaryData; -} - -################################################################################ -# Convert enumerator name into equivalent enumerator value for given enumeration -################################################################################ - -sub enumNameToValue { - my ($enumeration,$enumeratorName) = @_; - - my $nextEnumeratorValue = 0; - my $found = 0; - my $enumeratorValue; - - foreach my $enumerator (@{$enumeration->{enumerator}}) - { - my $currentEnumeratorValue; - if(exists $enumerator->{value} ) - { - $nextEnumeratorValue = $enumerator->{value} + 1; - $currentEnumeratorValue = $enumerator->{value}; - } - else - { - $currentEnumeratorValue = $nextEnumeratorValue; - $nextEnumeratorValue += 1; - } - - if($enumerator->{name} eq $enumeratorName) - { - $found = 1; - $enumeratorValue = $currentEnumeratorValue; - last; - } - } - - if(!$found) - { - fatal("Could not convert enumerator name \"$enumeratorName\"into " - . "enumerator value."); - } - - return $enumeratorValue; -} - -################################################################################ -# Object which accumulates/flushes bit field data -################################################################################ - -{ - -package Accumulator; - -################################################################################ -# Constructor; create a new Accumulator object -################################################################################ - -sub new { - my ($class) = @_; - my $self = { _currentType => "", _accumulator => "", _bits => 0 }; - - bless $self, $class; - return $self; -} - -################################################################################ -# Accumulate a new bit field -################################################################################ - -sub accumulate { - my($self,$type,$bits,$value) = @_; - - my $binaryData; - my $simpleTypeProperties = main::simpleTypeProperties(); - - if($bits > $simpleTypeProperties->{$type}{bits}) - { - main::fatal("Too many bits ($bits) for type ($type)."); - } - - if($self->{_currentType} eq "") - { - $self->{_currentType} = $type; - $self->{_bits} = $bits; - } - elsif($self->{_currentType} eq $type) - { - if($self->{_bits} + $bits > - $simpleTypeProperties->{$self->{_currentType}}{bits}) - { - $binaryData .= $self->releaseAndClear(); - $self->{_currentType} = $type; - $self->{_bits} = $bits; - } - else - { - $self->{_bits} += $bits; - } - } - else - { - $binaryData .= $self->releaseAndClear(); - $self->{_currentType} = $type; - $self->{_bits} = $bits; - } - - for(my $count = 0; $count < $bits; $count++) - { - if( 1 & ($value >> $bits - $count - 1)) - { - $self->{_accumulator} .= "1"; - } - else - { - $self->{_accumulator} .= "0"; - } - } - - return $binaryData; -} - -################################################################################ -# Release the accumulator (if non-empty) to the caller and clear -################################################################################ - -sub releaseAndClear { - my($self) = @_; - - my $binaryData; - - if($self->{_currentType} ne "") - { - my $simpleTypeProperties = main::simpleTypeProperties(); - - $binaryData .= pack - ("B".$main::simpleTypeProperties->{$self->{_currentType}}{bits}, - $self->{_accumulator}); - - $self->{_accumulator} = ""; - $self->{_currentType} = ""; - $self->{_bits} = 0; - } - - return $binaryData; -} - -1; - -} - -################################################################################ -# Pack a complex type into a binary data stream -################################################################################ - -sub packComplexType { - my ($complexType,$attributeDefault) = @_; - - my $binaryData; - my $simpleTypeProperties = simpleTypeProperties(); - - my $accumulator = new Accumulator(); - - # Build using each field - - foreach my $field (@{$complexType->{field}}) - { - # print "Field = ", $field->{name}, "\n"; - # print "Default = ", $field->{default}, "\n"; - # print "Bits = ", $field->{bits}, "\n"; - # print "Type = ", $field->{type}, "\n"; - - my $found = 0; - foreach my $default (@{$attributeDefault->{field}}) - { - if($default->{id} eq $field->{name}) - { - $found = 1; - if(exists $field->{bits}) - { - $binaryData .= $accumulator->accumulate( - $field->{type},$field->{bits},$default->{value}); - } - # If non-bitfield - else - { - $binaryData .= $accumulator->releaseAndClear(); - - # Pack easy types using 'pack', otherwise invoke appropriate - # (possibly workaround) callback function - if(exists $simpleTypeProperties->{$field->{type}} - && $simpleTypeProperties->{$field->{type}} - {complexTypeSupport}) - { - if(ref ($simpleTypeProperties->{$field->{type}} - {packfmt}) eq "CODE") - { - $binaryData .= - $simpleTypeProperties->{$field->{type}} - {packfmt}->($default->{value}); - } - else - { - $binaryData .= pack( - $simpleTypeProperties->{$field->{type}} - {packfmt},$default->{value}); - } - } - else - { - fatal("Field type $field->{type} not supported in " - . "complex type."); - } - } - - last; - } - } - - if(!$found) - { - fatal("Could not find value for field."); - } - } - - $binaryData .= $accumulator->releaseAndClear(); - - return $binaryData; -} - -################################################################################ -# Pack an attribute into a binary data stream -################################################################################ - -sub packAttribute { - my($attributes,$attribute,$value) = @_; - - my $binaryData; - - if(exists $attribute->{simpleType}) - { - my $simpleType = $attribute->{simpleType}; - my $simpleTypeProperties = simpleTypeProperties(); - - my $typeName = (keys %{$simpleType})[0]; - if(exists $simpleTypeProperties->{$typeName}) - { - if($typeName eq "enumeration") - { - my $enumeration = $simpleType->{enumeration}; - - # Here $value is the enumerator name - my $enumeratorValue = enumNameToValue($enumeration,$value); - $binaryData = packEnumeration($enumeration,$enumeratorValue); - } - else - { - if(ref ($simpleTypeProperties->{$typeName}{packfmt}) eq "CODE") - { - $binaryData .= - $simpleTypeProperties->{$typeName}{packfmt}->($value); - } - else - { - $binaryData .= - pack($simpleTypeProperties->{$typeName}{packfmt}, - $value); - } - } - } - else - { - fatal("Error simple type $typeName not supported."); - } - } - elsif(exists $attribute->{complexType}) - { - if(ref ($value) eq "HASH" ) - { - $binaryData = packComplexType($attribute->{complexType},$value); - } - else - { - fatal("Warning cannot serialize non-hash complex type."); - } - } - elsif(exists $attribute->{nativeType}) - { - if($attribute->{nativeType}->{name} eq "EntityPath") - { - my $maxPathElements = 8; - my ($typeStr,$path) = split(/:/,$value); - my (@paths) = split(/\//,$path); - - my $type = 0; - if($typeStr eq "physical") - { - $type = 2; - } - elsif($typeStr eq "affinity") - { - $type = 1; - } - else - { - fatal("Unsupported enity path type."); - } - - if( (scalar @paths) > $maxPathElements) - { - fatal("Path elements cannot be greater than $maxPathElements."); - } - - $binaryData .= pack("C", (0xF0 & ($type << 4)) + - (0x0F & (scalar @paths))); - - foreach my $pathElement (@paths) - { - my ($pathType,$pathInstance) = split(/-/,$pathElement); - $pathType = uc($pathType); - - foreach my $attr (@{$attributes->{attribute}}) - { - if($attr->{id} eq "TYPE") - { - $pathType = - enumNameToValue( - $attr->{simpleType}->{enumeration},$pathType); - $binaryData .= pack ("CC", $pathType, $pathInstance); - last; - } - } - } - - if($maxPathElements > (scalar @paths)) - { - $binaryData .= pack("C".(($maxPathElements - scalar @paths)*2)); - } - } - else - { - fatal("Error nativeType not supported on attribute ID = " - . "$attribute->{id}."); - } - } - else - { - fatal("Unsupported attribute type on attribute ID = $attribute->{id}."); - } - - if(length $binaryData < 1) - { - fatal("Serialization failed for attribute ID = $attribute->{id}."); - } - - return $binaryData; -} - -################################################################################ -# Write the PNOR targeting image -################################################################################ - -sub writeTargetingImage { - my($outFile, $attributes) = @_; - - # 128 MB virtual memory offset between sections - #@TODO Need the final value after full host boot support is implemented. - # For now assume 4k since we're mapping directly to physical targeting image - my $vmmSectionOffset = 4 * 1024; - - # Virtual memory addresses corresponding to the start of the targeting image - # PNOR/heap sections - #@TODO Need the final value of the base address after full host boot support - # is implemented. - my $pnorRoBaseAddress = 0x8007E690; - my $pnorRwBaseAddress = $pnorRoBaseAddress + $vmmSectionOffset; - my $heapPnorInitBaseAddr = $pnorRwBaseAddress + $vmmSectionOffset; - my $heapZeroInitBaseAddr = $heapPnorInitBaseAddr + $vmmSectionOffset; - - # Reserve 256 bytes for the header, then keep track of PNOR RO offset - my $headerSize = 256; - my $offset = $headerSize; - - # Reserve space for the pointer to the # of targets, update later; - my $numTargetsPointer = 0; - my $numTargetsPointerBinData = packQuad($numTargetsPointer); - $offset += (length $numTargetsPointerBinData); - - ############################################################################ - # Build the attribute list for each unique CTM - ############################################################################ - - # Get an array of only the unique types of targets actually used by the - # aggregation of target instances. - my @targetTypes = getInstantiatedTargetTypes($attributes); - - my $attributeIdEnumeration = getAttributeIdEnumeration($attributes); - - my %attributeListTypeHoH = (); - my $attributeListBinData; - - # For each unique type of target modeled, create the attribute list - foreach my $targetType (@targetTypes) - { - # Create the attribute list associated with each target type - #@TODO Eventually we'll need criteria to order the attributes - # for code update - my %attrhash = (); - getTargetAttributes($targetType, $attributes,\%attrhash); - - # Serialize per target type attribute list - my $perTargetTypeAttrBinData; - for my $attributeId (keys %attrhash) - { - $perTargetTypeAttrBinData .= packEnumeration( - $attributeIdEnumeration, - enumNameToValue($attributeIdEnumeration,$attributeId)); - } - - # Save offset of the attribute list, tied to the type - $attributeListTypeHoH{$targetType}{offset} = $offset; - $attributeListTypeHoH{$targetType}{elements} = scalar keys %attrhash; - $attributeListTypeHoH{$targetType}{size} = - length $perTargetTypeAttrBinData; - - #print "Target type: $targetType\n"; - #print " elements: $attributeListTypeHoH{$targetType}{elements}\n"; - #print " offset: $attributeListTypeHoH{$targetType}{offset}\n"; - #print " size: $attributeListTypeHoH{$targetType}{size}\n"; - - # Append attribute data for this part to the attribute list subsection - $attributeListBinData .= $perTargetTypeAttrBinData; - - # Increment the offset - $offset += (length $perTargetTypeAttrBinData); - } - - # For each target instance ... - - #@TODO Eventually we'll need criteria to order the attributes - # for code update. At minimum, ensure that we always process at this level - # in the given order - my @targetsAoH = (); - my $numTargets = 0; - foreach my $targetInstance (@{$attributes->{targetInstance}}) - { - push(@targetsAoH, $targetInstance); - $numTargets++; - } - - my $numAttributes = 0; - foreach my $targetInstance (@targetsAoH) - { - my %attrhash = (); - getTargetAttributes($targetInstance->{type}, $attributes,\%attrhash); - $numAttributes += keys %attrhash; - } - - # Reserve # pointers * sizeof(pointer) - my $startOfAttributePointers = $offset; - print "Total attributes = $numAttributes\n"; - $offset += ($numAttributes * (length packQuad(0) )); - - # Now we can determine the pointer to the number of targets - # Don't increment the offset; already accounted for - $numTargetsPointer = $pnorRoBaseAddress + $offset; - $numTargetsPointerBinData = packQuad($numTargetsPointer); - - my $numTargetsBinData = pack("N",$numTargets); - $offset += length $numTargetsBinData; - - my $roAttrBinData; - my $heapZeroInitOffset = 0; - my $heapZeroInitBinData; - my $heapPnorInitOffset = 0; - my $heapPnorInitBinData; - my $rwAttrBinData; - my $rwOffset = 0; - my $attributePointerBinData; - my $targetsBinData; - - # Ensure consistent ordering of target instances - my $attrAddr = $pnorRoBaseAddress + $startOfAttributePointers; - - foreach my $targetInstance (@targetsAoH) - { - my $data; - - # print "TargetInstance: $targetInstance->{id}\n"; - # print " Attributes: ", - # $attributeListTypeHoH{$targetInstance->{type}}{elements}, "\n" ; - # print " offset: ", - # $attributeListTypeHoH{$targetInstance->{type}}{offset}, "\n" ; - - # Create target record - $data .= pack('N', - $attributeListTypeHoH{$targetInstance->{type}}{elements}); - $data .= packQuad( - $attributeListTypeHoH{$targetInstance->{type}}{offset} - + $pnorRoBaseAddress); - my $ptrToAttrPtrs = 0; - $data .= packQuad($attrAddr); - $attrAddr += $attributeListTypeHoH{$targetInstance->{type}}{elements} - * (length packQuad(0)); - - # Increment the offset - $offset += length $data; - - # Add it to the target sub-section - $targetsBinData .= $data; - } - - my $pnorRoOffset = $offset; - my $attributesWritten = 0; - - foreach my $targetInstance (@targetsAoH) - { - my $data; - my %attrhash = (); - my @AoH = (); - - # Ensure consistent ordering of attributes for each target type - # Get the attribute list associated with each target type - #@TODO Attributes must eventually be ordered correctly for code update - getTargetAttributes($targetInstance->{type}, $attributes,\%attrhash); - - # Update hash with any per-instance overrides, but only if that - # attribute has already been defined - foreach my $attr (@{$targetInstance->{attribute}}) - { - if(exists $attrhash{$attr->{id}}) - { - $attrhash{ $attr->{id} } = $attr; - } - else - { - fatal("Target instance \"$targetInstance->{id}\" cannot " - . "override attribute \"$attr->{id}\" unless " - . "the attribute has already been defined in the target " - . "type inheritance chain."); - } - } - - for my $attributeId (keys %attrhash) - { - # Search each attribute definition - - foreach my $attributeDef (@{$attributes->{attribute}}) - { - my $section; - if( $attributeDef->{id} eq $attributeId ) - { - if( exists $attributeDef->{writeable} - && $attributeDef->{persistency} eq "non-volatile" ) - { - $section = "pnor-rw"; - } - elsif ( !exists $attributeDef->{writeable} - && $attributeDef->{persistency} eq "non-volatile") - { - $section = "pnor-ro"; - } - elsif ($attributeDef->{persistency} eq "volatile" ) - { - $section = "heap-pnor-initialized"; - } - elsif($attributeDef->{persistency} eq "volatile-zeroed") - { - $section = "heap-zero-initialized"; - } - else - { - fatal("Persistency not supported."); - } - - if($section eq "pnor-ro") - { - my $rodata = packAttribute($attributes,$attributeDef, - $attrhash{$attributeId}->{default}); - - $attributePointerBinData .= packQuad( - $offset + $pnorRoBaseAddress); - - $offset += length $rodata; - - $roAttrBinData .= $rodata; - } - elsif($section eq "pnor-rw") - { - my $rwdata = packAttribute($attributes,$attributeDef, - $attrhash{$attributeId}->{default}); - - print "Wrote to pnor-rw value ",$attributeDef->{id}, ", - ", $attrhash{$attributeId}->{default}," \n"; - $attributePointerBinData .= packQuad( - $rwOffset + $pnorRwBaseAddress); - - $rwOffset += length $rwdata; - - $rwAttrBinData .= $rwdata; - - } - elsif($section eq "heap-zero-initialized") - { - my $heapZeroInitData = packAttribute($attributes, - $attributeDef,$attrhash{$attributeId}->{default}); - - $attributePointerBinData .= packQuad( - $heapZeroInitOffset + $heapZeroInitBaseAddr); - - $heapZeroInitOffset += length $heapZeroInitData; - - $heapZeroInitBinData .= $heapZeroInitData; - - } - elsif($section eq "heap-pnor-initialized") - { - my $heapPnorInitData = packAttribute($attributes, - $attributeDef,$attrhash{$attributeId}->{default}); - - $attributePointerBinData .= packQuad( - $heapPnorInitOffset + $heapPnorInitBaseAddr); - - $heapPnorInitOffset += length $heapPnorInitData; - - $heapPnorInitBinData .= $heapPnorInitData; - } - else - { - fatal("Could not find a suitable section."); - } - - $attributesWritten++; - - last; - } - } - - - } # End attribute loop - - } # End target instance loop - - if($numAttributes != $attributesWritten) - { - fatal("Number of attributes expected, $numAttributes, does not match " - . "what was written to PNOR, $attributesWritten."); - } - - # Build header data - #@TODO Need header file for host boot which lays out the header - - my $headerBinData; - my $blockSize = 4*1024; - - my %sectionHoH = (); - $sectionHoH{ pnorRo }{ offset } = 0; - $sectionHoH{ pnorRo }{ type } = 0; - $sectionHoH{ pnorRo }{ size } = sizeBlockAligned($offset,$blockSize,1); - - $sectionHoH{ pnorRw }{ offset } = - $sectionHoH{pnorRo}{offset} + $sectionHoH{pnorRo}{size}; - $sectionHoH{ pnorRw }{ type } = 1; - $sectionHoH{ pnorRw }{ size } = sizeBlockAligned($rwOffset,$blockSize,1); - - $sectionHoH{ heapPnorInit }{ offset } = - $sectionHoH{pnorRw}{offset} + $sectionHoH{pnorRw}{size}; - $sectionHoH{ heapPnorInit }{ type } = 2; - $sectionHoH{ heapPnorInit }{ size } = - sizeBlockAligned($heapPnorInitOffset,$blockSize,1); - - $sectionHoH{ heapZeroInit }{ offset } = - $sectionHoH{heapPnorInit}{offset} + $sectionHoH{heapPnorInit}{size}; - $sectionHoH{ heapZeroInit }{ type } = 3; - $sectionHoH{ heapZeroInit }{ size } = - sizeBlockAligned($heapZeroInitOffset,$blockSize,1); - - my $numSections = keys %sectionHoH; - - # Version 1.0 to start with - my $headerMajorMinorVersion = 0x00010000; - my $eyeCatcher = 0x54415247; # TARG - my $sizeOfSection = 9; - my $offsetToSections = 0; - - $headerBinData .= pack("N",$eyeCatcher); - $headerBinData .= pack("N",$headerMajorMinorVersion); - $headerBinData .= pack("N",$headerSize); - $headerBinData .= pack("N",$vmmSectionOffset); - $headerBinData .= packQuad($pnorRoBaseAddress); - $headerBinData .= pack("N",$sizeOfSection); - $headerBinData .= pack("N",$numSections); - $headerBinData .= pack("N",$offsetToSections); - - foreach my $section ("pnorRo","pnorRw","heapPnorInit","heapZeroInit") - { - $headerBinData .= pack("C" , $sectionHoH{$section}{type}); - $headerBinData .= pack("N" , $sectionHoH{$section}{offset}); - $headerBinData .= pack("N" , $sectionHoH{$section}{size}); - } - - # Serialize PNOR RO section to multiple of 4k page size (pad if necessary) - - # First 256 bytes is RO header (pad if necessary) - if((length $headerBinData) > $headerSize) - { - fatal("Header data of length " . length $headerBinData . " is larger " - . "than allocated amount of $headerSize."); - } - print $outFile $headerBinData; - my $padSize = sizeBlockAligned(length $headerBinData,$headerSize,1) - - length $headerBinData; - print $outFile pack ("@".$padSize); - - # Remaining data belongs to targeting - print $outFile $numTargetsPointerBinData; - print $outFile $attributeListBinData; - print $outFile $attributePointerBinData; - print $outFile $numTargetsBinData; - print $outFile $targetsBinData; - print $outFile $roAttrBinData; - print $outFile pack ("@".($sectionHoH{pnorRo}{size} - $offset)); - - # Serialize PNOR RW section to multiple of 4k page size (pad if necessary) - print $outFile $rwAttrBinData; - print $outFile pack("@".($sectionHoH{pnorRw}{size} - $rwOffset)); - - # Serialize PNOR initiated heap section to multiple of 4k page size (pad if - # necessary) - print $outFile $heapPnorInitBinData; - print $outFile pack("@".($sectionHoH{heapPnorInit}{size} - - $heapPnorInitOffset)); - - # Serialize 0 initiated heap section to multiple of 4k page size (pad if - # necessary) - #@TODO: Once host boot support 0 initialization of heap pages for targeting, - # remove the contents of this section, since it will be a "virtual" section. - # Until then, zero out the section and map it into memory - print $outFile pack("@".(length $heapZeroInitBinData)); - print $outFile pack("@".($sectionHoH{heapZeroInit}{size} - - $heapZeroInitOffset)); -} - -__END__ - -=head1 NAME - -xmltohb.pl - -=head1 SYNOPSIS - -xmltohb.pl [options] [file ...] - -=head1 OPTIONS - -=over 8 - -=item B<--help> - -Print a brief help message and exits. - -=item B<--man> - -Prints the manual page and exits. - -=item B<--hb-xml-file> - -File containing the intermediate representation of the host boot XML just prior -to compilation down to images and source files (Default is ./hb.xml) - -=item B<--src-output-dir>=DIRECTORY - -Sets the output directory for generated source files (default is the current -directory) - -=item B<--img-output-dir>=DIRECTORY - -Sets the output directory for generated binary files -(default is the current directory) - -=item B<--verbose> - -Prints out some internal workings - -=back - -=head1 DESCRIPTION - -B will process a set of input .xml files and emit source files and -a PNOR targeting image binary to facilitate compiling and configuring host boot -respectively. - -=cut - - -- cgit v1.2.1