/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/usr/diag/prdf/common/framework/register/iipCaptureData.h $ */ /* */ /* IBM CONFIDENTIAL */ /* */ /* COPYRIGHT International Business Machines Corp. 1996,2012 */ /* */ /* 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 otherwise */ /* divested of its trade secrets, irrespective of what has been */ /* deposited with the U.S. Copyright Office. */ /* */ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ #ifndef iipCaptureData_h #define iipCaptureData_h // Class Specification ************************************************* // // Class name: CaptureData // Parent class: None. // // Summary: This class provides a queue-like buffer for recording Scan // Comm Register data. // // When this class is constructed or the Clear() member // function is called, the buffer is empty. The Add() // function adds data to the front or back of this buffer. // The data is ordered according to the sequence of Add() // calls and the Place parameter (FRONT or BACK). A Scan // Comm Register is passed to the Add() function and the // register is read during the Add() function. The data is // then stored internally. Whenever the Copy() member // function is called, the current internal data is copied to // the specified buffer with respect to the current ordering. // Only the number of bytes specified are copied. Therefore, // any data that MUST be copied should be added using the // FRONT placement. // // Cardinality: N // // Performance/Implementation: // Space Complexity: Linear based on the number of Add() calls // Time Complexity: All member functions constant unless otherwise // stated. // // Usage Examples: // // BIT8 data[BUFFER_SIZE]; // // void foo(TARGETING::TargetHandle_t chipId, ScanCommRegisterAccess & scr) // { // CaptureData captureData; // // captureData.Add(chipId, scr, CaptureData::FRONT); // captureData.Add(chipId, scr, CaptureData::BACK); // // int bytesCopied = captureData.Copy(data, BUFFER_SIZE); // } // // End Class Specification ********************************************* /*--------------------------------------------------------------------*/ /* Reference the virtual function tables and inline function defintions in another translation unit. */ /*--------------------------------------------------------------------*/ #include #ifndef IIPCONST_H #include #endif #include #include // @jl04 a Needed for the unary function in new predicate. // Forward Declarations class SCAN_COMM_REGISTER_CLASS; class ScanCommRegisterAccess; class BIT_STRING_CLASS; // @jl04 a start // @jl04 a Added this enumeration for error log compression, elimination of secondary regs. enum RegType { PRIMARY = 1, SECONDARY = 2 }; // @jl04 a Stop /** Capture data class @author Doug Gilbert @version V5R2 */ class CaptureData { public: enum Place { FRONT, BACK }; enum { INITIAL_DATA_COUNT = 80, ENTRY_FIXED_SIZE = 8, MAX_ENTRY_SIZE = 128 }; /** Constructor */ CaptureData(void); /* Copy constructor - default is ok */ // CaptureData(const CaptureData & c); /* Assignment operator - default is ok */ // CaptureData & operator=(const CaptureData & c); /** Destructor */ // dg05d ~CaptureData(void); // compiler default is ok /** Clear out capture data

    Paramters:None
    Returns:Nothing
    Requirments:None.
    Promises: All capture data cleared ( copy(...) == 0 )

*/ void Clear(void); // dg00 start /** Add scr & data to capture log

    Paramter: chipHandle target handle of chip object
    Paramter: scan comm id (unique one btye code representing scan comm address)
    Paramter: Scan comm register object
    Paramter: Optional location in capure vector [FRONT | BACK] def = BACK
    Returns: Nothing
    Requires: Nothing
    Promises: scr.Read()
    Notes: This is the required Add() method for Regatta and beyond

*/ void Add( TARGETING::TargetHandle_t i_pchipHandle, int scomId, SCAN_COMM_REGISTER_CLASS & scr, Place place = BACK, RegType type = PRIMARY); // @jl04 c. Changed this to add the type to the end of the parms. // dg00 end /* REMOVE for FSP Add scr & data to capture log

    Paramter: chipHandle target handle of chip object
    Paramter: Scan comm register object
    Paramter: Optional location in capure vector [FRONT | BACK] def = BACK
    Returns: Nothing
    Requires: Nothing
    Promises: scr.Read()
    Notes: This is the required Add() method for pre-Regatta

void Add(TARGETING::TargetHandle_t chipId, SCAN_COMM_REGISTER_CLASS & scr, Place place = BACK); */ /** Add scr & data to capture log (defunct)

    Paramter: chipid (or chip enum)
    Paramter: Scan comm register object
    Paramter: Optional location in capure vector [FRONT | BACK] def = BACK
    Returns: Nothing
    Requires: Nothing
    Promises: scr.Read()
    Notes: This method is no longer implemented

*/ void Add(ScanCommRegisterAccess & scr, Place place = BACK); // dg02 start /** Add scr & data to capture log

    Paramter: i_pchipHandle Handle of chip object
    Paramter: scan comm id (unique one btye code representing scan comm address)
    Paramter: BIT_STRING_CLASS
    Paramter: Optional location in capure vector [FRONT | BACK] def = BACK
    Returns: Nothing
    Requires: Nothing
    Promises:
    Notes: This is available for Regatta and beyond. Not implemented on Condor

*/ void Add( TARGETING::TargetHandle_t i_pchipHandle, int scomId, BIT_STRING_CLASS & bs, Place place = BACK); // dg02 end // dg06a start /** Add scr & data to capture log

    Paramter: i_pTargetHandle Handle of chip object
    Paramter: scan comm id (unique code representing scan comm address)
    Paramter: Scan comm register address
    Paramter: Scan comm register bit length length
    Paramter: Optional location in capure vector [FRONT | BACK] def = BACK
    Returns: Nothing
    Requires: Nothing
    Promises:
    Notes: This is available for Regatta and beyond. Not implemented on Condor

*/ void Add( TARGETING::TargetHandle_t i_pTargetHandle , int iScomId, uint64_t iScomAddress, uint32_t iScomBitLength , Place iplace = BACK); // dg06a end // start @jl04a /** Drop scr & data from capture log

    Paramter: Type of capture vector [PRIMARY | SECONDARY] def = PRIMARY. SECONDARIES dropped on connected.
    Returns: Nothing
    Requires: Nothing
    Promises:

*/ void Drop(RegType type); //@jl04a // end @jl04a /** Copy caputre data to buffer

    Paramter: ptr to buffer to place capture data
    Paramter: maxsize of buffer area
    Returns: Returns the number of bytes copied
    Requirements: None
    Promises: bytes copied <= bufferSize
    Notes: Caputure data is placed in the buffer in the order it exists in the vector until done or buffer is full

      */ unsigned int Copy(uint8_t * buffer, unsigned int bufferSize) const; // dg08a --> /** Reconstruct data from flat data

        Paramter: i_flatdata ptr to flat data
        Returns: reference to the new capture data
        Requirements: None
        Promises: CaptureData created form flatdata
        Note: i_flatdata -> (uin32_t)size + data created by Copy() data is network ordered bytes.

          */ CaptureData & operator=(const uint8_t *i_flatdata); // <-- dg08a private: // Notes ************************************************************* // // Instead of maintaining an actual data buffer, an auxilliary data // structure is used to maintain data in a specific order. The main // reason for this is that since data can be entered in the front or // back of the buffer, the data must be copied to maintain the order. // It is more efficient to copy a number of pointers than a large // data buffer. However, there is added complexity since the data // structure contains a pointer to dynamic data that must be // allocated/deallocated properly. // // A vector of data structures is maintained that is given an initial // size. The vector can grow dynamically, but this can be expensive // in terms of copying and memory fragmentation. To prevent this, the // number of calls to Add() between calls to Clear() should not exceed // the enum INITIAL_DATA_COUNT. // // End Notes ********************************************************* class Data { public: // Ctor Data(TARGETING::TargetHandle_t i_pchipHandle= NULL, // dg01 uint16_t a = 0, uint16_t dbl = 0, uint8_t * dPtr = NULL) : chipHandle(i_pchipHandle), address(a), dataByteLength(dbl), dataPtr(dPtr) {} ~Data(void) // dg05a { // dg05a if(dataPtr != NULL) // dg05a { // dg05a delete [] dataPtr; // pw01 } // dg05a } // dg05a // Data TARGETING::TargetHandle_t chipHandle; uint16_t address; uint16_t dataByteLength; uint8_t * dataPtr; RegType registerType; // @jl04a Data(const Data & d); Data & operator=(const Data & d); }; // We should probably use a link list instead of a vector typedef std::list DataContainerType; typedef DataContainerType::iterator DataIterator; typedef DataContainerType::const_iterator ConstDataIterator; DataContainerType data; /** Private function to facilitate the adding of caputre data to the internal vector */ void AddDataElement(Data &dataElement, SCAN_COMM_REGISTER_CLASS & scr, Place place, RegType type); //$TEMP @jl04 Changed AddDataElement to include a Register type. // Predicate for deciding to delete an element of data from a Capture Data list. class prdfCompareCaptureDataType : public std::unary_function { public: prdfCompareCaptureDataType(RegType i_ctor_input) : __private_storage(i_ctor_input){}; bool operator() (Data &i) { return (i.registerType == __private_storage); }; private: //Private storage for value passed in. RegType __private_storage; //Constructor allows a value to be passed in to compare against. }; }; #endif