summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Muhle <armuhle@us.ibm.com>2013-01-21 16:52:43 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-02-14 15:38:34 -0600
commita753459c20affff821477924808ea5b9412504c5 (patch)
tree32bc3f2581564f53167440b76cb7ad1db3a8fe58
parent5f5ecb46d1838847dedd33791d4da86d3df39638 (diff)
downloadblackbird-hostboot-a753459c20affff821477924808ea5b9412504c5.tar.gz
blackbird-hostboot-a753459c20affff821477924808ea5b9412504c5.zip
CVPD Device Driver updates.
Implemented Device Driver support for Centaur VPD. Since CVPD is almost identical to MVPD, I moved the MVPD code to a base class so the actual logic is now common between the two. To support CVPD in the standalone configs, the hb-preload script was updated to populate the CVPD partition as well. I also started migrating the VPD code to a common trace buffer. RTC: 44009 Change-Id: I6e96d5e993d6d74d40df3d296cdcf8f34e4b5cc5 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3029 Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
-rw-r--r--src/build/mkrules/dist_targets.mk2
-rwxr-xr-xsrc/build/simics/hb-pnor-vpd-preload.pl180
-rwxr-xr-xsrc/build/simics/standalone.simics1
-rw-r--r--src/include/usr/devicefw/userif.H13
-rw-r--r--src/include/usr/vpd/cvpdenums.H62
-rw-r--r--src/include/usr/vpd/vpdreasoncodes.H31
-rw-r--r--src/usr/vpd/cvpd.C199
-rw-r--r--src/usr/vpd/cvpd.H105
-rw-r--r--src/usr/vpd/ipvpd.C923
-rw-r--r--src/usr/vpd/ipvpd.H454
-rw-r--r--src/usr/vpd/makefile4
-rw-r--r--[-rwxr-xr-x]src/usr/vpd/mvpd.C1189
-rw-r--r--[-rwxr-xr-x]src/usr/vpd/mvpd.H537
-rwxr-xr-xsrc/usr/vpd/test/cvpdtest.H744
-rwxr-xr-xsrc/usr/vpd/test/mvpdtest.H739
-rw-r--r--src/usr/vpd/vpd.C23
-rw-r--r--src/usr/vpd/vpd.H7
17 files changed, 3214 insertions, 1999 deletions
diff --git a/src/build/mkrules/dist_targets.mk b/src/build/mkrules/dist_targets.mk
index 0f9bbc761..dc76378d3 100644
--- a/src/build/mkrules/dist_targets.mk
+++ b/src/build/mkrules/dist_targets.mk
@@ -60,6 +60,7 @@ COPY_FILES = \
img/isteplist.csv:tools,vpo \
img/dimmspd.dat:vpo \
img/procmvpd.dat:vpo \
+ img/cvpd.dat:vpo \
obj/genfiles/fapiAttributeIds.txt:vpo \
obj/genfiles/fapiAttributeEnums.txt:vpo \
src/build/hwpf/prcd_compile.tcl:tools \
@@ -150,6 +151,7 @@ simics.tar_CONTENTS = \
src/build/simics/hb-pnor-vpd-preload.pl \
img/dimmspd.dat \
img/procmvpd.dat \
+ img/cvpd.dat \
obj/genfiles/fapiAttributeIds.txt \
obj/genfiles/fapiAttributeEnums.txt \
diff --git a/src/build/simics/hb-pnor-vpd-preload.pl b/src/build/simics/hb-pnor-vpd-preload.pl
index d99516fc2..262379212 100755
--- a/src/build/simics/hb-pnor-vpd-preload.pl
+++ b/src/build/simics/hb-pnor-vpd-preload.pl
@@ -1,26 +1,26 @@
#!/usr/bin/perl
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
#
-# $Source: src/build/simics/hb-pnor-mvpd-preload.pl $
+# $Source: src/build/simics/hb-pnor-vpd-preload.pl $
#
-# IBM CONFIDENTIAL
+# IBM CONFIDENTIAL
#
-# COPYRIGHT International Business Machines Corp. 2012
+# COPYRIGHT International Business Machines Corp. 2012,2013
#
-# p1
+# p1
#
-# Object Code Only (OCO) source materials
-# Licensed Internal Code Source Materials
-# IBM HostBoot Licensed Internal Code
+# 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.
+# 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
+# Origin: 30
#
-# IBM_PROLOG_END_TAG
+# IBM_PROLOG_END_TAG
use strict;
use File::Temp qw/ tempfile tempdir /;
@@ -44,15 +44,24 @@ my $emptySPDfh;
my $emptySPD;
($emptySPDfh, $emptySPD) = tempfile();
+# Create temp file for CVPD
+my $emptyCVPDfh;
+my $emptyCVPD;
+($emptyCVPDfh, $emptyCVPD) = tempfile();
+
my $mvpdFile = "procmvpd.dat";
+my $cvpdFile = "cvpd.dat";
my $spdFile = "dimmspd.dat";
my $sysMVPD = "sysmvpd.dat";
+my $sysCVPD = "syscvpd.dat";
my $sysSPD = "sysspd.dat";
my $MAX_CENT_PER_PROC = 8;
my $MAX_DIMMS_PER_CENT = 8;
my $MAX_MCS = 8;
+my @mcsArray = ( 0,0,0,0,0,0,0,0 );
+
while( $ARGV = shift )
{
@@ -124,7 +133,9 @@ elsif(length($procConfig) != $maxProcs)
exit 1;
}
+getCentaurConfig();
createMVPDData();
+createCVPDData();
createSPDData();
cleanup();
@@ -238,6 +249,68 @@ sub createMVPDData
}
#====================================================================
+# Create the CVPD data for PNOR
+#====================================================================
+sub createCVPDData
+{
+ print "Creating CVPD Data...\n";
+
+ my $cmd;
+ my $result;
+ my $sourceFile;
+ my $sysCVPDFile = "$outputPath/$sysCVPD";
+
+ if( -e $sysCVPDFile )
+ {
+ # Cleanup any existing files
+ system( "rm -rf $sysCVPDFile" );
+ }
+
+ #Centaurs are populated based on populated Processors and special
+ #MCS plugging rules. We can look at $procConfig and $maxProcs
+ #to determine processor config. Centaur plugging is contained
+ #in $mcsArray, populated by getCentaurConfig()
+
+ # Create empty CVPD data chunk
+ $cmd = " echo \"000FFF: 00\" \| xxd -r \> $emptyCVPD";
+ system( $cmd ) == 0 or die "Creating $emptyCVPD failed!";
+
+ for( my $proc = 0; $proc < $maxProcs; $proc++ )
+ {
+ for( my $cent = 0; $cent < $MAX_CENT_PER_PROC; $cent++ )
+ {
+ if( ($mcsArray[$cent] == 1) &&
+ substr($procConfig,$proc,1) =~ /1/ )
+ {
+ debugMsg( "$machine( $proc, $cent): Real File" );
+ # Use the real data to the full image
+ $sourceFile = "$dataPath/$cvpdFile";
+ }
+ else
+ {
+ debugMsg( "$machine( $proc, $cent): Empty file" );
+ # No Centaur, use empty data chunk
+ $sourceFile = $emptyCVPD;
+ }
+
+ $result = `dd if=$sourceFile of=$sysCVPDFile conv=notrunc oflag=append 2>&1 1>/dev/null`;
+ if( $? )
+ {
+ die "Error building CVPD file! proc=$proc cent=$cent\n";
+ }
+
+ }
+ }
+
+ if( -e $sysCVPDFile )
+ {
+ system( "chmod 775 $sysCVPDFile" );
+ }
+ debugMsg( "CVPD Done." );
+}
+
+
+#====================================================================
# Create the SPD data for PNOR
#====================================================================
sub createSPDData
@@ -248,7 +321,6 @@ sub createSPDData
my $result;
my $sourceFile;
my $sysSPDFile = "$outputPath/$sysSPD";
- my @mcsArray = ( 0,0,0,0,0,0,0,0 );
if( -e $sysSPDFile )
{
@@ -260,9 +332,48 @@ sub createSPDData
$cmd = " echo \"0001FF: 00\" \| xxd -r \> $emptySPD";
system( $cmd ) == 0 or die "Creating $emptySPD failed!";
- # Populating DIMMs is different across every system. The following case
- # statement will handle populating DIMMs based on the system type
- debugMsg( "Preload DIMMs for $machine" );
+ for( my $proc = 0; $proc < $maxProcs; $proc++ )
+ {
+ for( my $cent = 0; $cent < $MAX_CENT_PER_PROC; $cent++ )
+ {
+ for( my $dimm = 0; $dimm < $MAX_DIMMS_PER_CENT; $dimm++ )
+ {
+ if( ($mcsArray[$cent] == 1) &&
+ substr($procConfig,$proc,1) =~ /1/ )
+ {
+ debugMsg( "$machine( $proc, $cent, $dimm ): Real File" );
+ # Use the real data to the full image
+ $sourceFile = "$dataPath/$spdFile";
+ }
+ else
+ {
+ debugMsg( "$machine( $proc, $cent, $dimm ): Empty file" );
+ # No dimm, use empty data chunk
+ $sourceFile = $emptySPD;
+ }
+
+ $result = `dd if=$sourceFile of=$sysSPDFile conv=notrunc oflag=append 2>&1 1>/dev/null`;
+ if( $? )
+ {
+ die "Error building SPD file! $proc $cent $dimm\n";
+ }
+ }
+ }
+ }
+
+
+ if( -e $sysSPDFile )
+ {
+ system( "chmod 775 $sysSPDFile" );
+ }
+ debugMsg( "SPD Done." );
+}
+
+
+sub getCentaurConfig
+{
+ debugMsg( "getCentaurConfig $machine" );
+
for( my $mcs = 0; $mcs < $MAX_MCS; $mcs++ )
{
debugMsg( "Mcs: $mcs" );
@@ -335,39 +446,6 @@ sub createSPDData
}
debugMsg( "@mcsArray" );
- for( my $proc = 0; $proc < $maxProcs; $proc++ )
- {
- for( my $cent = 0; $cent < $MAX_CENT_PER_PROC; $cent++ )
- {
- for( my $dimm = 0; $dimm < $MAX_DIMMS_PER_CENT; $dimm++ )
- {
- if( ($mcsArray[$cent] == 1) &&
- substr($procConfig,$proc,1) =~ /1/ )
- {
- debugMsg( "$machine( $proc, $cent, $dimm ): Real File" );
- # Use the real data to the full image
- $sourceFile = "$dataPath/$spdFile";
- }
- else
- {
- debugMsg( "$machine( $proc, $cent, $dimm ): Empty file" );
- # No dimm, use empty data chunk
- $sourceFile = $emptySPD;
- }
- $result = `dd if=$sourceFile of=$sysSPDFile conv=notrunc oflag=append 2>&1 1>/dev/null`;
- if( $? )
- {
- die "Error building SPD file! $proc $cent $dimm\n";
- }
- }
- }
- }
-
- if( -e $sysSPDFile )
- {
- system( "chmod 775 $sysSPDFile" );
- }
- debugMsg( "SPD Done." );
}
diff --git a/src/build/simics/standalone.simics b/src/build/simics/standalone.simics
index 76519d6e1..3fdd07561 100755
--- a/src/build/simics/standalone.simics
+++ b/src/build/simics/standalone.simics
@@ -5,6 +5,7 @@ try {
run-python-file (lookup-file hbfw/hb-pnor-vpd-preload.py)
fpga0.sfc_master_mem.load-file ./sysmvpd.dat 0x3E0A000
fpga0.sfc_master_mem.load-file ./sysspd.dat 0x3DCA000
+ fpga0.sfc_master_mem.load-file ./syscvpd.dat 0x3E8A000
} except { echo "ERROR: Failed to preload VPD into PNOR." }
#Trigger a power on to cec-chip
diff --git a/src/include/usr/devicefw/userif.H b/src/include/usr/devicefw/userif.H
index 9f4463661..7fbad5d74 100644
--- a/src/include/usr/devicefw/userif.H
+++ b/src/include/usr/devicefw/userif.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2011,2012 */
+/* COPYRIGHT International Business Machines Corp. 2011,2013 */
/* */
/* p1 */
/* */
@@ -49,6 +49,7 @@ namespace DeviceFW
FSI,
SPD,
MVPD,
+ CVPD,
SCAN,
LAST_ACCESS_TYPE,
@@ -109,6 +110,16 @@ namespace DeviceFW
static_cast<uint64_t>(( i_keyword ))
/**
+ * Construct the device addressing parameters for the CVPD device ops.
+ * @param[in] i_record - The enumeration of the CVPD record to access.
+ * @param[in] i_keyword - The enumeration of the CVPD keyword, located
+ * within the i_record Record to access.
+ */
+ #define DEVICE_CVPD_ADDRESS( i_record, i_keyword )\
+ DeviceFW::CVPD, static_cast<uint64_t>(( i_record )),\
+ static_cast<uint64_t>(( i_keyword ))
+
+ /**
* Construct the device addressing parameters for the SCAN device ops.
* @param[in] i_ring - The ring address to scan
* @param[in] i_ringlen - The length of the ring to scan in bits
diff --git a/src/include/usr/vpd/cvpdenums.H b/src/include/usr/vpd/cvpdenums.H
new file mode 100644
index 000000000..2f52ee07a
--- /dev/null
+++ b/src/include/usr/vpd/cvpdenums.H
@@ -0,0 +1,62 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/usr/vpd/cvpdenums.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 __CVPDENUMS_H
+#define __CVPDENUMS_H
+
+namespace CVPD
+{
+
+ /**
+ * @brief Enumeration for the CVPD Records that contain
+ * the keyword enumerations below.
+ */
+ enum cvpdRecord
+ {
+ CVPD_FIRST_RECORD = 0x00,
+ VEIR = CVPD_FIRST_RECORD,
+ VER0 = 0x01,
+ MER0 = 0x02,
+ // Last Record
+ CVPD_LAST_RECORD,
+ CVPD_TEST_RECORD, // Test purposes ONLY!
+ CVPD_INVALID_RECORD = 0xFFFF,
+ };
+
+ /**
+ * @brief Enumerations for CVPD keywords that can be
+ * accessed in the CVPD.
+ */
+ enum cvpdKeyword
+ {
+ CVPD_FIRST_KEYWORD = 0x00,
+ pdI = CVPD_FIRST_KEYWORD,
+ PF = 0x01,
+ // Last Keyword
+ CVPD_LAST_KEYWORD,
+ CVPD_TEST_KEYWORD, // Test purposes ONLY!
+ CVPD_INVALID_KEYWORD = 0xFFFF,
+ };
+
+}; // end CVPD
+
+#endif
diff --git a/src/include/usr/vpd/vpdreasoncodes.H b/src/include/usr/vpd/vpdreasoncodes.H
index 2ecbba770..7e95afa58 100644
--- a/src/include/usr/vpd/vpdreasoncodes.H
+++ b/src/include/usr/vpd/vpdreasoncodes.H
@@ -40,23 +40,17 @@ namespace VPD
*/
enum vpdModuleId
{
- VPD_INVALID_MODULE = 0x00,
+ VPD_INVALID_MODULE = 0x00,
// Common VPD
-
- // Proc MVPD
- VPD_MVPD_READ_BINARY_FILE = 0x31,
- VPD_MVPD_READ = 0x32,
- VPD_MVPD_WRITE = 0x33,
- VPD_MVPD_TRANSLATE_RECORD = 0x34,
- VPD_MVPD_TRANSLATE_KEYWORD = 0x35,
- VPD_MVPD_FIND_RECORD_OFFSET = 0x36,
- VPD_MVPD_RETRIEVE_KEYWORD = 0x37,
- VPD_MVPD_FETCH_DATA = 0x38,
- VPD_MVPD_CHECK_BUFFER_SIZE = 0x39,
- VPD_MVPD_WRITE_KEYWORD = 0x3A,
- VPD_MVPD_FIND_KEYWORD_ADDR = 0x3B,
+ // IPVPD
+ VPD_IPVPD_TRANSLATE_RECORD = 0x20,
+ VPD_IPVPD_TRANSLATE_KEYWORD = 0x21,
+ VPD_IPVPD_FIND_RECORD_OFFSET = 0x22,
+ VPD_IPVPD_FIND_KEYWORD_ADDR = 0x23,
+ VPD_IPVPD_CHECK_BUFFER_SIZE = 0x24,
+
// DIMM SPD
VPD_SPD_GET_KEYWORD_VALUE = 0x61,
@@ -67,10 +61,9 @@ enum vpdModuleId
VPD_SPD_SPECIAL_CASES = 0x66,
VPD_SPD_PRESENCE_DETECT = 0x67,
VPD_SPD_CHECK_MODULE_SPECIFIC_KEYWORD = 0x68,
- VPD_SPD_GET_PNOR_ADDR = 0x69,
- VPD_SPD_WRITE_VALUE = 0x6A,
- VPD_SPD_GET_KEYWORD_ENTRY = 0x6B,
- VPD_SPD_WRITE_DATA = 0x6C,
+ VPD_SPD_WRITE_VALUE = 0x69,
+ VPD_SPD_GET_KEYWORD_ENTRY = 0x6A,
+ VPD_SPD_WRITE_DATA = 0x6B,
// Centaur FRU VPD
@@ -84,7 +77,7 @@ enum vpdModuleId
*/
enum vpdReasonCode
{
- VPD_INVALID_REASONCODE = VPD_COMP_ID | 0x00, // Invalid Reasoncode
+ VPD_INVALID_REASONCODE = VPD_COMP_ID | 0x00, // Invalid RC
VPD_INSUFFICIENT_FILE_SIZE = VPD_COMP_ID | 0x01,
VPD_OPERATION_NOT_SUPPORTED = VPD_COMP_ID | 0x02,
VPD_RECORD_NOT_FOUND = VPD_COMP_ID | 0x03,
diff --git a/src/usr/vpd/cvpd.C b/src/usr/vpd/cvpd.C
new file mode 100644
index 000000000..8064979c1
--- /dev/null
+++ b/src/usr/vpd/cvpd.C
@@ -0,0 +1,199 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/vpd/cvpd.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 */
+// ----------------------------------------------
+// Includes
+// ----------------------------------------------
+#include <string.h>
+#include <endian.h>
+#include <trace/interface.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <targeting/common/targetservice.H>
+#include <devicefw/driverif.H>
+#include <vfs/vfs.H>
+#include <vpd/vpdreasoncodes.H>
+#include <vpd/cvpdenums.H>
+#include "cvpd.H"
+#include "vpd.H"
+
+// ----------------------------------------------
+// Trace definitions
+// ----------------------------------------------
+extern trace_desc_t* g_trac_vpd;
+
+
+// ------------------------
+// Macros for unit testing
+//#define TRACUCOMP(args...) TRACFCOMP(args)
+#define TRACUCOMP(args...)
+//#define TRACSSCOMP(args...) TRACFCOMP(args)
+#define TRACSSCOMP(args...)
+
+namespace CVPD
+{
+ // ----------------------------------------------
+ // Globals
+ // ----------------------------------------------
+ mutex_t g_mutex = MUTEX_INITIALIZER;
+
+
+
+
+
+ /**
+ * @brief This function will perform the steps required to do a read from
+ * the Hostboot CVPD data.
+ *
+ * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
+ * driververif.H
+ *
+ * @param[in] i_target - Processor Target device
+ *
+ * @param [in/out] io_buffer - Pointer to the data that was read from
+ * the target device. This parameter, when set to NULL, will return
+ * the keyword size value in io_buflen.
+ *
+ * @param [in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * will indicate the number of valid bytes in the buffer being
+ * returned. This parameter will contain the size of a keyword when
+ * the io_buffer parameter is passed in NULL.
+ *
+ * @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
+ * usrif.H
+ *
+ * @param [in] i_args - This is an argument list for the device driver
+ * framework.
+ *
+ * @return errlHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t cvpdRead ( DeviceFW::OperationType i_opType,
+ TARGETING::Target * i_target,
+ void * io_buffer,
+ size_t & io_buflen,
+ int64_t i_accessType,
+ va_list i_args )
+ {
+ errlHndl_t err = NULL;
+ IpVpdFacade::input_args_t args;
+ args.record = ((cvpdRecord)va_arg( i_args, uint64_t ));
+ args.keyword = ((cvpdKeyword)va_arg( i_args, uint64_t ));
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"cvpdRead()" );
+
+ err = Singleton<CvpdFacade>::instance().read(i_target,
+ io_buffer,
+ io_buflen,
+ args);
+
+ return err;
+ }
+
+
+ /**
+ * @brief This function will perform the steps required to do a write to
+ * the Hostboot CVPD data.
+ *
+ * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
+ * driververif.H
+ *
+ * @param[in] i_target - Processor Target device
+ *
+ * @param [in/out] io_buffer - Pointer to the data that was read from
+ * the target device. It will also be used to contain data to
+ * be written to the device.
+ *
+ * @param [in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * will indicate the number of valid bytes in the buffer being
+ * returned.
+ *
+ * @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
+ * usrif.H
+ *
+ * @param [in] i_args - This is an argument list for the device driver
+ * framework.
+ *
+ * @return errlHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t cvpdWrite ( DeviceFW::OperationType i_opType,
+ TARGETING::Target * i_target,
+ void * io_buffer,
+ size_t & io_buflen,
+ int64_t i_accessType,
+ va_list i_args )
+ {
+ errlHndl_t err = NULL;
+ IpVpdFacade::input_args_t args;
+ args.record = ((cvpdRecord)va_arg( i_args, uint64_t ));
+ args.keyword = ((cvpdKeyword)va_arg( i_args, uint64_t ));
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"cvpdWrite()" );
+
+
+ err = Singleton<CvpdFacade>::instance().write(i_target,
+ io_buffer,
+ io_buflen,
+ args);
+
+ return err;
+ }
+
+ // Register with the routing code
+ DEVICE_REGISTER_ROUTE( DeviceFW::READ,
+ DeviceFW::CVPD,
+ TARGETING::TYPE_MEMBUF,
+ cvpdRead );
+ DEVICE_REGISTER_ROUTE( DeviceFW::WRITE,
+ DeviceFW::CVPD,
+ TARGETING::TYPE_MEMBUF,
+ cvpdWrite );
+
+
+
+}; // end namespace CVPD
+
+//CVPD Class Functions
+/**
+ * @brief Constructor
+ */
+CvpdFacade::CvpdFacade() :
+IpVpdFacade(CVPD::SECTION_SIZE,
+ CVPD::MAX_SECTIONS,
+ CVPD::cvpdRecords,
+ (sizeof(CVPD::cvpdRecords)/sizeof(CVPD::cvpdRecords[0])),
+ CVPD::cvpdKeywords,
+ (sizeof(CVPD::cvpdKeywords)/sizeof(CVPD::cvpdKeywords[0])),
+ PNOR::CENTAUR_VPD,
+ CVPD::g_mutex,
+ VPD::VPD_WRITE_MEMBUF)
+{
+ TRACUCOMP(g_trac_vpd, "CvpdFacade::CvpdFacade> " );
+
+}
diff --git a/src/usr/vpd/cvpd.H b/src/usr/vpd/cvpd.H
new file mode 100644
index 000000000..b50b97bad
--- /dev/null
+++ b/src/usr/vpd/cvpd.H
@@ -0,0 +1,105 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/vpd/cvpd.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 __CVPD_H
+#define __CVPD_H
+
+
+/**
+ * @file cvpd.H
+ *
+ * @brief Provides the interfaces for the CVPD device driver
+ *
+ */
+
+// ----------------------------------------------
+// Includes
+// ----------------------------------------------
+#include <errl/errlentry.H>
+#include <vpd/cvpdenums.H>
+
+#include "ipvpd.H"
+
+namespace CVPD
+{
+
+ enum
+ {
+ SECTION_SIZE = 0x1000,
+ MAX_SECTIONS = 64,
+ };
+
+
+ /**
+ * @brief Conversion of CVPD Records to corresponding character
+ * representation.
+ */
+ const IpVpdFacade::recordInfo cvpdRecords[] =
+ {
+ // -------------------------------------------------------------------
+ // NOTE: This list must remain an ordered list! There will be a
+ // testcase that checks this. When adding new entries to the
+ // list, be sure that the keyword in each entry (value 0)
+ // are in ascending order.
+ // -------------------------------------------------------------------
+ { VEIR, "VEIR" },
+ { VER0, "VER0" }, //Not currently used, but keep support
+ { MER0, "MER0" },
+ // -------------------------------------------------------------------
+ // DO NOT USE!! This is for test purposes ONLY!
+ { CVPD_TEST_RECORD, "TEST" },
+ // -------------------------------------------------------------------
+ };
+
+ /**
+ * @brief Conversion of CVPD Keywords to corresponding character
+ * representation.
+ */
+ const IpVpdFacade::keywordInfo cvpdKeywords[] =
+ {
+ // -------------------------------------------------------------------
+ // NOTE: This list must remain an ordered list! There will be a
+ // testcase that checks this. When adding new entries to
+ // the list, be sure that the keyword in each entry (value 0)
+ // are in ascending order.
+ // -------------------------------------------------------------------
+ { pdI, "#I" },
+ { PF, "PF" },
+ // -------------------------------------------------------------------
+ // DO NOT USE!! This is for test purposes ONLY!
+ { CVPD_TEST_KEYWORD, "XX" },
+ // -------------------------------------------------------------------
+ };
+
+}; // end CVPD namespace
+
+class CvpdFacade: public IpVpdFacade
+{
+ public:
+
+ /**
+ * @brief Constructor
+ */
+ CvpdFacade( );
+
+};
+#endif // __CVPD_H
diff --git a/src/usr/vpd/ipvpd.C b/src/usr/vpd/ipvpd.C
new file mode 100644
index 000000000..23321631b
--- /dev/null
+++ b/src/usr/vpd/ipvpd.C
@@ -0,0 +1,923 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/vpd/ipvpd.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 */
+// ----------------------------------------------
+// Includes
+// ----------------------------------------------
+#include <string.h>
+#include <endian.h>
+#include <trace/interface.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <targeting/common/targetservice.H>
+#include <devicefw/driverif.H>
+#include <vfs/vfs.H>
+#include <vpd/vpdreasoncodes.H>
+
+#include "vpd.H"
+#include "ipvpd.H"
+
+// ------------------------
+// Macros for unit testing
+//#define TRACUCOMP(args...) TRACFCOMP(args)
+#define TRACUCOMP(args...)
+//#define TRACSSCOMP(args...) TRACFCOMP(args)
+#define TRACSSCOMP(args...)
+
+// ----------------------------------------------
+// Trace definitions
+// ----------------------------------------------
+extern trace_desc_t* g_trac_vpd;
+
+
+// ----------------------------------------------
+// Globals
+// ----------------------------------------------
+
+static const uint64_t IPVPD_TOC_SIZE = 0x100;
+
+/**
+ * @brief Constructor
+ */
+IpVpdFacade::IpVpdFacade(uint64_t i_vpdSectionSize,
+ uint64_t i_vpdMaxSections,
+ const recordInfo* i_vpdRecords,
+ uint64_t i_recSize,
+ const keywordInfo* i_vpdKeywords,
+ uint64_t i_keySize,
+ PNOR::SectionId i_pnorSection,
+ mutex_t i_mutex,
+ VPD::VPD_MSG_TYPE i_vpdMsgType )
+:iv_vpdSectionSize(i_vpdSectionSize)
+,iv_vpdMaxSections(i_vpdMaxSections)
+,iv_vpdRecords(i_vpdRecords)
+,iv_recSize(i_recSize)
+,iv_vpdKeywords(i_vpdKeywords)
+,iv_keySize(i_keySize)
+,iv_pnorSection(i_pnorSection)
+,iv_mutex(i_mutex)
+,iv_cachePnorAddr(0x0)
+,iv_vpdMsgType(i_vpdMsgType)
+{
+ TRACUCOMP(g_trac_vpd, "IpVpdFacade::IpVpdFacade> " );
+}
+
+
+// ------------------------------------------------------------------
+// IpVpdFacade::read
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::read ( TARGETING::Target * i_target,
+ void* io_buffer,
+ size_t & io_buflen,
+ input_args_t i_args )
+{
+ errlHndl_t err = NULL;
+ const char * recordName = NULL;
+ const char * keywordName = NULL;
+ uint16_t recordOffset = 0x0;
+
+ TRACUCOMP(g_trac_vpd, "IpVpdFacade::read> " );
+
+ do
+ {
+
+ // Get the Record/keyword names
+ err = translateRecord(i_args.record,
+ recordName);
+ if( err )
+ {
+ break;
+ }
+
+ err = translateKeyword( i_args.keyword,
+ keywordName );
+
+ if( err )
+ {
+ break;
+ }
+
+ TRACSCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::read: Record (%s) and Keyword (%s)",
+ recordName, keywordName );
+
+ // Get the offset of the record requested
+ err = findRecordOffset( recordName,
+ recordOffset,
+ i_target,
+ i_args );
+
+ if( err )
+ {
+ break;
+ }
+
+ // use record offset to find/read the keyword
+ err = retrieveKeyword( keywordName,
+ recordName,
+ recordOffset,
+ i_target,
+ io_buffer,
+ io_buflen,
+ i_args );
+
+ if( err )
+ {
+ break;
+ }
+
+ } while( 0 );
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::read()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::write
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::write ( TARGETING::Target * i_target,
+ void* io_buffer,
+ size_t & io_buflen,
+ input_args_t i_args )
+{
+ errlHndl_t err = NULL;
+ const char * recordName = NULL;
+ const char * keywordName = NULL;
+ uint16_t recordOffset = 0x0;
+
+ TRACUCOMP(g_trac_vpd, "IpVpdFacade::write> " );
+
+ do
+ {
+
+ // Get the Record/keyword names
+ err = translateRecord(i_args.record,
+ recordName);
+ if( err )
+ {
+ break;
+ }
+
+ err = translateKeyword( i_args.keyword,
+ keywordName );
+
+ if( err )
+ {
+ break;
+ }
+
+ TRACSCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::Write: Record (%s) and Keyword (%s)",
+ recordName, keywordName );
+
+ // Get the offset of the record requested
+ err = findRecordOffset( recordName,
+ recordOffset,
+ i_target,
+ i_args );
+
+ if( err )
+ {
+ break;
+ }
+
+ // use record offset to find/write the keyword
+ err = writeKeyword( keywordName,
+ recordName,
+ recordOffset,
+ i_target,
+ io_buffer,
+ io_buflen,
+ i_args );
+
+ if( err )
+ {
+ break;
+ }
+
+ } while( 0 );
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::Write()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::translateRecord
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::translateRecord ( ipVpdRecord i_record,
+ const char *& o_record )
+{
+ errlHndl_t err = NULL;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::translateRecord(i_record=0x%.8X)",
+ i_record );
+
+ do
+ {
+ recordInfo tmpRecord;
+ tmpRecord.record = i_record;
+ const recordInfo * entry = std::lower_bound(iv_vpdRecords,
+ &iv_vpdRecords[iv_recSize],
+ tmpRecord,
+ compareRecords );
+
+ if( ( entry == &iv_vpdRecords[iv_recSize] )||
+ ( i_record != entry->record ) )
+ {
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"IpVpdFacade::translateRecord: No matching Record (0x%04x) found!",
+ i_record );
+
+ /*@
+ * @errortype
+ * @reasoncode VPD::VPD_RECORD_NOT_FOUND
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid VPD::VPD_IPVPD_TRANSLATE_RECORD
+ * @userdata1 Record enumeration.
+ * @userdata2 <UNUSED>
+ * @devdesc The record enumeration did not have a
+ * corresponding string value.
+ */
+ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ VPD::VPD_IPVPD_TRANSLATE_RECORD,
+ VPD::VPD_RECORD_NOT_FOUND,
+ i_record,
+ 0x0 );
+
+ break;
+ }
+
+ o_record = entry->recordName;
+ TRACDCOMP( g_trac_vpd,
+ "record name: %s",
+ entry->recordName );
+ } while( 0 );
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::translateRecord()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::translateKeyword
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::translateKeyword ( ipVpdKeyword i_keyword,
+ const char *& o_keyword )
+{
+ errlHndl_t err = NULL;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::translateKeyword()" );
+
+ do
+ {
+ keywordInfo tmpKeyword;
+ tmpKeyword.keyword = i_keyword;
+ const keywordInfo * entry =
+ std::lower_bound( iv_vpdKeywords,
+ &iv_vpdKeywords[iv_keySize],
+ tmpKeyword,
+ compareKeywords );
+
+ if( ( entry == &iv_vpdKeywords[iv_keySize] ) ||
+ ( i_keyword != entry->keyword ) )
+ {
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"IpVpdFacade::translateKeyword: No matching Keyword found!" );
+
+ /*@
+ * @errortype
+ * @reasoncode VPD::VPD_KEYWORD_NOT_FOUND
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid VPD::VPD_IPVPD_TRANSLATE_KEYWORD
+ * @userdata1 Keyword Enumeration
+ * @userdata2 <UNUSED>
+ * @devdesc The keyword enumeration did not have a
+ * corresponding string value.
+ */
+ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ VPD::VPD_IPVPD_TRANSLATE_KEYWORD,
+ VPD::VPD_KEYWORD_NOT_FOUND,
+ i_keyword,
+ 0x0 );
+
+ break;
+ }
+
+ o_keyword = entry->keywordName;
+ TRACDCOMP( g_trac_vpd,
+ "IpVpdFacade::translateKeyword: keyword name: %s",
+ entry->keywordName );
+ } while( 0 );
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::translateKeyword()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::findRecordOffset
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::findRecordOffset ( const char * i_record,
+ uint16_t & o_offset,
+ TARGETING::Target * i_target,
+ input_args_t i_args )
+{
+ errlHndl_t err = NULL;
+ uint64_t tmpOffset = 0x0;
+ char record[RECORD_BYTE_SIZE] = { '\0' };
+ uint16_t offset = 0x0;
+ bool matchFound = false;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::findRecordOffset()" );
+
+ do
+ {
+ // --------------------------------------
+ // Start reading at beginning of file
+ // First 256 bytes are the TOC
+ // --------------------------------------
+ // TOC Format is as follows:
+ // 8 bytes per entry - 32 entries possible
+ // Entry:
+ // byte 0 - 3: ASCII Record Name
+ // byte 4 - 5: Size (byte swapped)
+ // byte 6 - 7: UNUSED
+ // --------------------------------------
+ while( ( tmpOffset < IPVPD_TOC_SIZE ) &&
+ !matchFound )
+ {
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::findRecordOffset: read offset: 0x%08x",
+ tmpOffset );
+
+ // Read Record Name
+ err = fetchData( tmpOffset,
+ RECORD_BYTE_SIZE,
+ record,
+ i_target );
+ tmpOffset += RECORD_BYTE_SIZE;
+
+ if( err )
+ {
+ break;
+ }
+
+ if( !(memcmp( record, i_record, RECORD_BYTE_SIZE )) )
+ {
+ matchFound = true;
+
+ // Read the matching records offset
+ err = fetchData( tmpOffset,
+ RECORD_ADDR_BYTE_SIZE,
+ &offset,
+ i_target );
+
+ if( err )
+ {
+ break;
+ }
+ }
+ tmpOffset += (RECORD_ADDR_BYTE_SIZE + RECORD_TOC_UNUSED);
+ }
+
+ if( err )
+ {
+ break;
+ }
+ } while( 0 );
+
+ if( !matchFound )
+ {
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"IpVpdFacade::findRecordOffset: No matching Record (%s) found in TOC!",
+ i_record );
+
+ /*@
+ * @errortype
+ * @reasoncode VPD::VPD_RECORD_NOT_FOUND
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid VPD::VPD_IPVPD_FIND_RECORD_OFFSET
+ * @userdata1 Requested Record
+ * @userdata2 Requested Keyword
+ * @devdesc The requested record was not found in the VPD TOC.
+ */
+ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ VPD::VPD_IPVPD_FIND_RECORD_OFFSET,
+ VPD::VPD_RECORD_NOT_FOUND,
+ i_args.record,
+ i_args.keyword );
+ // Add trace to the log so we know what record was being requested.
+ err->collectTrace( "VPD" );
+ }
+
+ // Return the offset found, after byte swapping it.
+ o_offset = le16toh( offset );
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::findRecordOffset()" );
+
+ return err;
+}
+
+
+// ------------------------------------------------------------------
+// IpVpdFacade::retrieveKeyword
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::retrieveKeyword ( const char * i_keywordName,
+ const char * i_recordName,
+ uint16_t i_offset,
+ TARGETING::Target * i_target,
+ void * io_buffer,
+ size_t & io_buflen,
+ input_args_t i_args )
+{
+ errlHndl_t err = NULL;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::retrieveKeyword()" );
+
+ do
+ {
+ // First go find the keyword in memory
+ size_t keywordSize = 0x0;
+ uint64_t byteAddr = 0x0;
+ err = findKeywordAddr( i_keywordName,
+ i_recordName,
+ i_offset,
+ i_target,
+ keywordSize,
+ byteAddr,
+ i_args );
+ if( err )
+ {
+ break;
+ }
+
+ // If the buffer is NULL, return the keyword size in io_buflen
+ if( NULL == io_buffer )
+ {
+ io_buflen = keywordSize;
+ break;
+ }
+
+ // check size of usr buffer with io_buflen
+ err = checkBufferSize( io_buflen,
+ (size_t)keywordSize );
+ if( err )
+ {
+ break;
+ }
+
+ // Read keyword data into io_buffer
+ err = fetchData( i_offset+byteAddr,
+ keywordSize,
+ io_buffer,
+ i_target );
+ if( err )
+ {
+ break;
+ }
+
+ // Everything worked
+ io_buflen = keywordSize;
+
+ } while(0);
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::retrieveKeyword()" );
+
+ return err;
+}
+
+
+// ------------------------------------------------------------------
+// IpVpdFacade::fetchData
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::fetchData ( uint64_t i_byteAddr,
+ size_t i_numBytes,
+ void * o_data,
+ TARGETING::Target * i_target )
+{
+ errlHndl_t err = NULL;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::fetchData()" );
+
+ do
+ {
+ // Call a function in the common VPD code
+ VPD::pnorInformation info;
+ info.segmentSize = iv_vpdSectionSize;
+ info.maxSegments = iv_vpdMaxSections;
+ info.pnorSection = iv_pnorSection;
+ info.pnorSide = PNOR::CURRENT_SIDE;
+ err = VPD::readPNOR( i_byteAddr,
+ i_numBytes,
+ o_data,
+ i_target,
+ info,
+ iv_cachePnorAddr,
+ &iv_mutex );
+
+ if( err )
+ {
+ break;
+ }
+
+ } while( 0 );
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::fetchData()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::findKeywordAddr
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::findKeywordAddr ( const char * i_keywordName,
+ const char * i_recordName,
+ uint16_t i_offset,
+ TARGETING::Target * i_target,
+ size_t& o_keywordSize,
+ uint64_t& o_byteAddr,
+ input_args_t i_args )
+{
+ errlHndl_t err = NULL;
+ uint16_t offset = i_offset;
+ uint16_t recordSize = 0x0;
+ uint16_t keywordSize = 0x0;
+ char record[RECORD_BYTE_SIZE] = { '\0' };
+ char keyword[KEYWORD_BYTE_SIZE] = { '\0' };
+ bool matchFound = false;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::findKeywordAddr()" );
+
+ do
+ {
+ // Read size of Record
+ err = fetchData( offset,
+ RECORD_ADDR_BYTE_SIZE,
+ &recordSize,
+ i_target );
+ offset += RECORD_ADDR_BYTE_SIZE;
+
+ if( err )
+ {
+ break;
+ }
+
+ // Byte Swap
+ recordSize = le16toh( recordSize );
+
+ // Skip 3 bytes - RT
+ // Read 4 bytes ( Record name ) - compare with expected
+ offset += RT_SKIP_BYTES;
+ err = fetchData( offset,
+ RECORD_BYTE_SIZE,
+ record,
+ i_target );
+ offset += RECORD_BYTE_SIZE;
+
+ if( err )
+ {
+ break;
+ }
+
+ if( memcmp( record, i_recordName, RECORD_BYTE_SIZE ) )
+ {
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"IpVpdFacade::findKeywordAddr: Record(%s) for offset (0x%04x) did not match expected record(%s)!",
+ record,
+ i_offset,
+ i_recordName );
+
+ /*@
+ * @errortype
+ * @reasoncode VPD::VPD_RECORD_MISMATCH
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid VPD::VPD_IPVPD_FIND_KEYWORD_ADDR
+ * @userdata1 Current offset into VPD
+ * @userdata2 Start of Record offset
+ * @devdesc Record name does not match value expected for
+ * offset read.
+ */
+ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ VPD::VPD_IPVPD_FIND_KEYWORD_ADDR,
+ VPD::VPD_RECORD_MISMATCH,
+ offset,
+ i_offset );
+ // Add trace so we see what record was being compared
+ err->collectTrace( "VPD" );
+
+ break;
+ }
+
+ // While size < size of record
+ // Size of record is the input offset, plus the record size, plus
+ // 2 bytes for the size value.
+ while( ( offset < (recordSize + i_offset + RECORD_ADDR_BYTE_SIZE) ) )
+ {
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::findKeywordAddr: Looking for keyword, reading offset: 0x%04x",
+ offset );
+
+ // read keyword name (2 bytes)
+ err = fetchData( offset,
+ KEYWORD_BYTE_SIZE,
+ keyword,
+ i_target );
+ offset += KEYWORD_BYTE_SIZE;
+
+ if( err )
+ {
+ break;
+ }
+
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::findKeywordAddr: Read keyword name: %s",
+ keyword );
+
+ // Check if we're reading a '#' keyword. They have a 2 byte size
+ uint32_t keywordLength = KEYWORD_SIZE_BYTE_SIZE;
+ bool isPoundKwd = false;
+ if( !(memcmp( keyword, "#", 1 )) )
+ {
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::findKeywordAddr: Reading # keyword, adding 1 byte to size to read!" );
+ isPoundKwd = true;
+ keywordLength++;
+ }
+
+ // Read keyword size
+ err = fetchData( offset,
+ keywordLength,
+ &keywordSize,
+ i_target );
+ offset += keywordLength;
+
+ if( err )
+ {
+ break;
+ }
+
+ if( isPoundKwd )
+ {
+ // Swap it since 2 byte sizes are byte swapped.
+ keywordSize = le16toh( keywordSize );
+ }
+ else
+ {
+ keywordSize = keywordSize >> 8;
+ }
+
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK"IpVpdFacade::findKeywordAddr: Read keyword size: 0x%04x",
+ keywordSize );
+
+ // if keyword equal i_keywordName
+ if( !(memcmp( keyword, i_keywordName, KEYWORD_BYTE_SIZE ) ) )
+ {
+ // send back the relevant data
+ o_keywordSize = keywordSize;
+ o_byteAddr = offset - i_offset; //make address relative
+
+ // found our match, break out
+ matchFound = true;
+ break;
+ }
+ else
+ {
+ // set offset to next keyword (based on current keyword size)
+ offset += keywordSize;
+ }
+ }
+
+ if( err ||
+ matchFound )
+ {
+ break;
+ }
+ } while( 0 );
+
+ // If keyword not found in expected Record, flag error.
+ if( !matchFound &&
+ NULL == err )
+ {
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"IpVpdFacade::findKeywordAddr: No matching %s keyword found within %s record!",
+ i_keywordName,
+ i_recordName );
+
+ /*@
+ * @errortype
+ * @reasoncode VPD::VPD_KEYWORD_NOT_FOUND
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid VPD::VPD_IPVPD_FIND_KEYWORD_ADDR
+ * @userdata1 Start of Record Offset
+ * @userdata2[0:31] Requested Record
+ * @userdata2[32:63] Requested Keyword
+ * @devdesc Keyword was not found in Record starting at given
+ * offset.
+ */
+ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ VPD::VPD_IPVPD_FIND_KEYWORD_ADDR,
+ VPD::VPD_KEYWORD_NOT_FOUND,
+ i_offset,
+ TWO_UINT32_TO_UINT64( i_args.record,
+ i_args.keyword ) );
+
+ // Add trace so we know what Record/Keyword was missing
+ err->collectTrace( "VPD" );
+ }
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::findKeywordAddr()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::writeKeyword
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::writeKeyword ( const char * i_keywordName,
+ const char * i_recordName,
+ uint16_t i_offset,
+ TARGETING::Target * i_target,
+ void * i_buffer,
+ size_t & i_buflen,
+ input_args_t i_args )
+{
+ errlHndl_t err = NULL;
+
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"IpVpdFacade::writeKeyword()" );
+
+ do
+ {
+ // Note, there is no way to tell if a keyword is writable without
+ // hardcoding it so we will just assume that the callers know
+ // what they are doing
+
+ // First go find the keyword in memory
+ size_t keywordSize = 0x0;
+ uint64_t byteAddr = 0x0;
+ err = findKeywordAddr( i_keywordName,
+ i_recordName,
+ i_offset,
+ i_target,
+ keywordSize,
+ byteAddr,
+ i_args );
+ if( err )
+ {
+ break;
+ }
+
+ // check size of usr buffer with io_buflen
+ err = checkBufferSize( i_buflen,
+ keywordSize );
+ if( err )
+ {
+ break;
+ }
+
+ // Setup info needed to write from PNOR
+ VPD::pnorInformation info;
+ info.segmentSize = iv_vpdSectionSize;
+ info.maxSegments = iv_vpdMaxSections;
+ info.pnorSection = iv_pnorSection;
+ info.pnorSide = PNOR::CURRENT_SIDE;
+ err = VPD::writePNOR( i_offset+byteAddr,
+ keywordSize,
+ i_buffer,
+ i_target,
+ info,
+ iv_cachePnorAddr,
+ &iv_mutex );
+ if( err )
+ {
+ break;
+ }
+
+
+ VPD::VpdWriteMsg_t msgdata;
+
+ // Quick double-check that our constants agree with the values in the
+ // VPD message structure
+ assert( sizeof(msgdata.record) == RECORD_BYTE_SIZE );
+ assert( sizeof(msgdata.keyword) == KEYWORD_BYTE_SIZE );
+
+ // Finally, send it down to the FSP
+ msgdata.rec_num = i_target->getAttr<TARGETING::ATTR_VPD_REC_NUM>();
+ memcpy( msgdata.record, i_recordName, RECORD_BYTE_SIZE );
+ memcpy( msgdata.keyword, i_keywordName, KEYWORD_BYTE_SIZE );
+ err = VPD::sendMboxWriteMsg( keywordSize,
+ i_buffer,
+ i_target,
+ iv_vpdMsgType,
+ msgdata );
+
+ if( err )
+ {
+ break;
+ }
+
+
+ } while(0);
+
+ TRACSSCOMP( g_trac_vpd,
+ EXIT_MRK"IpVpdFacade::writeKeyword()" );
+
+ return err;
+}
+
+// ------------------------------------------------------------------
+// IpVpdFacade::checkBufferSize
+// ------------------------------------------------------------------
+errlHndl_t IpVpdFacade::checkBufferSize( size_t i_bufferSize,
+ size_t i_expectedSize )
+{
+ errlHndl_t err = NULL;
+
+ if( !(i_bufferSize >= i_expectedSize) )
+ {
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"IpVpdFacade::checkBufferSize: Buffer size (%d) is not larger than expected size (%d)",
+ i_bufferSize,
+ i_expectedSize );
+
+ /*@
+ * @errortype
+ * @reasoncode VPD::VPD_INSUFFICIENT_BUFFER_SIZE
+ * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid VPD::VPD_IPVPD_CHECK_BUFFER_SIZE
+ * @userdata1 Buffer Size
+ * @userdata2 Expected Buffer Size
+ * @devdesc Buffer size was not greater than or equal to
+ * expected buffer size.
+ */
+ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ VPD::VPD_IPVPD_CHECK_BUFFER_SIZE,
+ VPD::VPD_INSUFFICIENT_BUFFER_SIZE,
+ i_bufferSize,
+ i_expectedSize );
+ }
+
+ return err;
+}
+
+
+// ------------------------------------------------------------------
+// IpVpdFacade::compareRecords
+// ------------------------------------------------------------------
+bool IpVpdFacade::compareRecords ( const recordInfo e1,
+ const recordInfo e2 )
+{
+ if( e2.record > e1.record )
+ return true;
+ else
+ return false;
+}
+
+
+// ------------------------------------------------------------------
+// IpVpdFacade::compareKeywords
+// ------------------------------------------------------------------
+bool IpVpdFacade::compareKeywords ( const keywordInfo e1,
+ const keywordInfo e2 )
+{
+ if( e2.keyword > e1.keyword )
+ return true;
+ else
+ return false;
+}
diff --git a/src/usr/vpd/ipvpd.H b/src/usr/vpd/ipvpd.H
new file mode 100644
index 000000000..8a9f96b7b
--- /dev/null
+++ b/src/usr/vpd/ipvpd.H
@@ -0,0 +1,454 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/vpd/ipvpd.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 _VPD_IPVPD_H
+#define _VPD_IPVPD_H
+
+
+#include <pnor/pnorif.H>
+#include "vpd.H"
+
+/** @file ipvpd.H
+ * @brief Provides base support for i/p-Series style IBM VPD
+ */
+
+/**
+ * @brief Base class for i/p-Series VPD
+ *
+ */
+class IpVpdFacade
+{
+ public:
+
+ /**
+ * @brief Miscelaneous IPVPD definitions
+ */
+ enum
+ {
+ RECORD_BYTE_SIZE = 4,
+ RECORD_ADDR_BYTE_SIZE = 2,
+ KEYWORD_BYTE_SIZE = 2,
+ KEYWORD_SIZE_BYTE_SIZE = 1,
+ RECORD_TOC_UNUSED = 2,
+ RT_SKIP_BYTES = 3,
+ };
+
+ /**
+ * @brief typdef for ipVpdRecord values
+ */
+ typedef uint32_t ipVpdRecord;
+ /**
+ * @brief typdef for ipVpdKeyword values
+ */
+ typedef uint32_t ipVpdKeyword;
+
+ /**
+ * @brief Structure for all VPD dd input parameter arguments
+ */
+ typedef struct
+ {
+ ipVpdRecord record;
+ ipVpdKeyword keyword;
+ } input_args_t;
+
+ /**
+ * @brief Structure of information needed to access requested
+ * record/keyword combinations.
+ */
+ typedef struct
+ {
+ ipVpdRecord record;
+ char recordName[RECORD_BYTE_SIZE+1];
+ } recordInfo;
+
+ /**
+ */
+ typedef struct
+ {
+ ipVpdKeyword keyword;
+ char keywordName[KEYWORD_BYTE_SIZE+1];
+ } keywordInfo;
+
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] i_vpdSectionSize - Space allocated in PNOR for each
+ * instance of the current chip.
+ *
+ * @param[in] i_vpdMaxSections - Number of sections allocated in PNOR
+ * for the current chip.
+ *
+ * @param[in] i_vpdRecords - Pointer to array of VPD Records to use
+ *
+ * @param[in] i_recSize - size of i_vpdRecords array
+ *
+ * @param[in] i_vpdKeywords - Pointer to array of VPD Keywords to use
+ *
+ * @param[in] i_keyCount - size of i_vpdKeywords array
+ *
+ * @param[in] i_pnorSection - PNOR Section containing VPD for current
+ * chip
+ *
+ * @param[in] i_mutex - Mutex to ensure instance variable updates
+ * are thread safe
+ *
+ * @param[in] i_vpdMsgType - Message type to use when sending write
+ * data to FSP
+ *
+ */
+ IpVpdFacade(uint64_t i_vpdSectionSize,
+ uint64_t i_vpdMaxSections,
+ const recordInfo* i_vpdRecords,
+ uint64_t i_recSize,
+ const keywordInfo* i_vpdKeywords,
+ uint64_t i_keySize,
+ PNOR::SectionId i_pnorSection,
+ mutex_t i_mutex,
+ VPD::VPD_MSG_TYPE i_vpdMsgType );
+
+
+ /**
+ * @brief This function will perform the steps required to do a read from
+ * the Hostboot I/P Series VPD data.
+ *
+ * @param[in] i_target -Target device
+ *
+ * @param [in/out] io_buffer - Pointer to the data that was read from
+ * the target device. This parameter, when set to NULL, will return
+ * the keyword size value in io_buflen.
+ *
+ * @param [in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * will indicate the number of valid bytes in the buffer being
+ * returned. This parameter will contain the size of a keyword when
+ * the io_buffer parameter is passed in NULL.
+ *
+ * @param [in] i_args - Records/Keyword struct
+ *
+ * @return errlHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t read ( TARGETING::Target * i_target,
+ void* io_buffer,
+ size_t & io_buflen,
+ input_args_t i_args );
+
+ /**
+ * @brief This function will perform the steps required to do a write to
+ * the Hostboot I/P Series VPD data.
+ *
+ * @param[in] i_target -Target device
+ *
+ * @param [in/out] io_buffer - Pointer to the data that was read from
+ * the target device. It will also be used to contain data to
+ * be written to the device.
+ *
+ * @param [in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * willindicate the number of valid bytes in the buffer being
+ * returned.
+ *
+ * @param [in] i_args - Records/Keyword struct
+ *
+ * @return errlHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t write ( TARGETING::Target * i_target,
+ void* io_buffer,
+ size_t & io_buflen,
+ input_args_t i_args );
+
+ protected:
+
+ /**
+ * @brief This function will translate the enumeration for the VPD record
+ * into a char * variable to be used for comparing what was read from
+ * the VPD data.
+ *
+ * @param[in] i_record - The record enumeration.
+ *
+ * @param[out] o_record - The char representation of the record.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t translateRecord ( ipVpdRecord i_record,
+ const char *& o_record );
+
+ /**
+ * @brief This function will translate the enumeration for the VPD keyword
+ * into a char * variable to be used for comparing what was read from
+ * the VPD data.
+ *
+ * @param[in] i_keyword - The keyword enumeration.
+ *
+ * @param[out] o_keyword - The char representation of the record.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t translateKeyword ( ipVpdKeyword i_keyword,
+ const char *& o_keyword );
+
+ /**
+ * @brief This function will read the VPD TOC to find the offset where the
+ * given record is located within the chunk of data.
+ *
+ * @param[in] i_record - String value for the record to look for.
+ *
+ * @param[out] o_offset - The offset where the record is located.
+ *
+ * @param[in] i_target - The target to retrieve the data for.
+ *
+ * @param[in] i_args - The input arguments.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t findRecordOffset ( const char * i_record,
+ uint16_t & o_offset,
+ TARGETING::Target * i_target,
+ input_args_t i_args );
+
+ /**
+ * @brief This function will read the required keyword from the VPD data.
+ *
+ * @param[in] i_keywordName - String representation of the keyword.
+ *
+ * @param[in] i_recordName - String representation of the record.
+ *
+ * @param[in] i_offset - The offset to start reading.
+ *
+ * @param[in] i_target - The target to retrieve data for.
+ *
+ * @param[out] io_buffer - The buffer to place the data in.
+ *
+ * @param[in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * will indicate the number of valid bytes in the buffer being
+ * returned.
+ *
+ * @param[in] i_args - The input arguments.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t retrieveKeyword ( const char * i_keywordName,
+ const char * i_recordName,
+ uint16_t i_offset,
+ TARGETING::Target * i_target,
+ void * io_buffer,
+ size_t & io_buflen,
+ input_args_t i_args );
+
+ /**
+ * @brief This function will write the required keyword into the VPD data.
+ *
+ * @param[in] i_keywordName - String representation of the keyword.
+ *
+ * @param[in] i_recordName - String representation of the record.
+ *
+ * @param[in] i_offset - The offset to start writing.
+ *
+ * @param[in] i_target - The target to write data for.
+ *
+ * @param[in] i_buffer - The buffer to pull the data from.
+ *
+ * @param[in] i_buflen - Length of the buffer to be written
+ * to the target's VPD area. This value should indicate the
+ * size of the io_buffer parameter that has been allocated.
+ *
+ * @param[in] i_args - The input arguments.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t writeKeyword ( const char * i_keywordName,
+ const char * i_recordName,
+ uint16_t i_offset,
+ TARGETING::Target * i_target,
+ void * i_buffer,
+ size_t & i_buflen,
+ input_args_t i_args );
+
+ /**
+ * @brief This function will locate the byte address of a keyword
+ * within its VPD section.
+ *
+ * @param[in] i_keywordName - String representation of the keyword.
+ *
+ * @param[in] i_recordName - String representation of the record.
+ *
+ * @param[in] i_offset - The offset to start writing.
+ *
+ * @param[in] i_target - The target to write data for.
+ *
+ * @param[out] o_keywordSize - Size of keyword in bytes.
+ *
+ * @param[out] o_byteAddr - Address of keyword, relative to this target's
+ * section.
+ *
+ * @param[in] i_args - The original input arguments.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t findKeywordAddr ( const char * i_keywordName,
+ const char * i_recordName,
+ uint16_t i_offset,
+ TARGETING::Target * i_target,
+ size_t& o_keywordSize,
+ uint64_t& o_byteAddr,
+ input_args_t i_args );
+ /**
+ * @brief This function actually reads the data from the source of the VPD
+ * data.
+ *
+ * @param[in] i_byteAddr - The offset to be read.
+ *
+ * @param[in] i_numBytes - The number of bytes to read.
+ *
+ * @param[out] o_data - The data buffer where the data will be placed.
+ *
+ * @param[in] i_target - Target device.
+ *
+ * @return errHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t fetchData ( uint64_t i_byteAddr,
+ size_t i_numBytes,
+ void * o_data,
+ TARGETING::Target * i_target );
+
+
+ /**
+ * @brief This function compares 2 ipvpd record values. Used for binary
+ * search to find a match.
+ *
+ * @param[in] e1 - Entry 1 to be compared.
+ *
+ * @param[in] e2 - Entry 2 to be compared.
+ *
+ * @return bool - Whether or not the e2 value is larger than the e1 value.
+ */
+ static bool compareKeywords ( const keywordInfo e1,
+ const keywordInfo e2 );
+
+ /**
+ * @brief This function compares 2 vpd keyword values. Used for binary
+ * search to find a match.
+ *
+ * @param[in] e1 - Entry 1 to be compared.
+ *
+ * @param[in] e2 - Entry 2 to be compared.
+ *
+ * @return bool - Whether or not the e2 value is larger than the e1 value.
+ */
+ static bool compareRecords ( const recordInfo e1,
+ const recordInfo e2 );
+
+ /**
+ * @brief This function compares sizes to be sure buffers are large enough
+ * to handle the data to be put in them. If it is not, it will return
+ * an error.
+ *
+ * @param[in] i_bufferSize - The size of the buffer to check.
+ *
+ * @param[in] i_expectedSize - The minimum size the buffer should be.
+ *
+ * @return errlHndl_t - An error log will be returned if the buffer is not
+ * large enough.
+ */
+ errlHndl_t checkBufferSize( size_t i_bufferSize,
+ size_t i_expectedSize );
+
+
+ protected: // Variables
+
+ /**
+ * @brief Indicates allocated space for each chip's VPD
+ * data in PNOR.
+ */
+ uint64_t iv_vpdSectionSize;
+
+ /**
+ * @brief Indicates number of VPD sections in PNOR for
+ * current type of chip
+ */
+ uint64_t iv_vpdMaxSections;
+
+ /**
+ * @brief Pointer to array of VPD Record information
+ *
+ */
+ const recordInfo* iv_vpdRecords;
+
+ /**
+ * @brief Number of VPD Records for current chip
+ *
+ */
+ uint64_t iv_recSize;
+
+ /**
+ * @brief Pointer to array of VPD Keyword information
+ *
+ */
+ const keywordInfo* iv_vpdKeywords;
+
+ /**
+ * @brief Number of VPD Keywords for current chip
+ *
+ */
+ uint64_t iv_keySize;
+
+ /**
+ * @brief PNOR section enum for vpd type
+ *
+ */
+ PNOR::SectionId iv_pnorSection;
+
+ /**
+ * @brief VPD Operation Mutex
+ *
+ */
+ mutex_t iv_mutex;
+
+ /**
+ * @brief cached PNOR offset for VPD
+ *
+ */
+ uint64_t iv_cachePnorAddr;
+
+ /**
+ * @brief cached PNOR offset for VPD
+ *
+ */
+ VPD::VPD_MSG_TYPE iv_vpdMsgType;
+};
+
+
+
+#endif /* _VPD_IPVPD_H */
diff --git a/src/usr/vpd/makefile b/src/usr/vpd/makefile
index 36d41d0db..500edcfa9 100644
--- a/src/usr/vpd/makefile
+++ b/src/usr/vpd/makefile
@@ -23,12 +23,12 @@
ROOTPATH = ../../..
MODULE = vpd
-OBJS = vpd.o spd.o mvpd.o dimmPres.o
+OBJS = vpd.o spd.o ipvpd.o mvpd.o dimmPres.o cvpd.o
SUBDIRS = test.d
BINARY_FILES = $(IMGDIR)/dimmspd.dat:9a6e6b6a7f6d3fc77a12d38537279d402124d699
-#BINARY_FILES += $(IMGDIR)/procmvpd.dat:fb03d27717e1f0d36bb4582a07b5aaaf90de41d6
BINARY_FILES += $(IMGDIR)/procmvpd.dat:dc85f0e2f7b26f3928c817be3f0c37a9cc0e0bed
+BINARY_FILES += $(IMGDIR)/cvpd.dat:92edad6c4ecac1bc544fcd02e53e90f66cf7f5cf
include ${ROOTPATH}/config.mk
diff --git a/src/usr/vpd/mvpd.C b/src/usr/vpd/mvpd.C
index 30d1f3c62..2caedc7ab 100755..100644
--- a/src/usr/vpd/mvpd.C
+++ b/src/usr/vpd/mvpd.C
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2012,2013 */
+/* COPYRIGHT International Business Machines Corp. 2013 */
/* */
/* p1 */
/* */
@@ -20,13 +20,6 @@
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
-/**
- * @file mvpd.C
- *
- * @brief Implementation of the MVPD device driver
- *
- */
-
// ----------------------------------------------
// Includes
// ----------------------------------------------
@@ -42,13 +35,13 @@
#include <vpd/mvpdenums.H>
#include "mvpd.H"
+#include "ipvpd.H"
#include "vpd.H"
// ----------------------------------------------
// Trace definitions
// ----------------------------------------------
-trace_desc_t* g_trac_mvpd = NULL;
-TRAC_INIT( & g_trac_mvpd, "MVPD", KILOBYTE);
+extern trace_desc_t* g_trac_vpd;
// ------------------------
// Macros for unit testing
@@ -58,1086 +51,146 @@ TRAC_INIT( & g_trac_mvpd, "MVPD", KILOBYTE);
#define TRACSSCOMP(args...)
-// ----------------------------------------------
-// Defines
-// ----------------------------------------------
-
-
namespace MVPD
{
// ----------------------------------------------
// Globals
// ----------------------------------------------
-bool g_loadModule = true;
-mutex_t g_mvpdMutex = MUTEX_INITIALIZER;
-
-uint64_t g_mvpdPnorAddr = 0x0;
-
-// By setting to false, allows debug at a later time by allowing to
-// substitute a binary file (procmvpd.dat) into PNOR.
-const bool g_usePNOR = true;
-
-
-/**
-* @brief This function compares 2 mvpd record values. Used for binary
-* search to find a match.
-*
-* @param[in] e1 - Entry 1 to be compared.
-*
-* @param[in] e2 - Entry 2 to be compared.
-*
-* @return bool - Whether or not the e2 value is larger than the e1 value.
-*/
-bool compareKeywords ( const mvpdKeywordInfo e1,
- const mvpdKeywordInfo e2 );
-
-/**
-* @brief This function compares 2 mvpd keyword values. Used for binary
-* search to find a match.
-*
-* @param[in] e1 - Entry 1 to be compared.
-*
-* @param[in] e2 - Entry 2 to be compared.
-*
-* @return bool - Whether or not the e2 value is larger than the e1 value.
- */
-bool compareRecords ( const mvpdRecordInfo e1,
- const mvpdRecordInfo e2 );
-
-/**
- * @brief This function compares sizes to be sure buffers are large enough
- * to handle the data to be put in them. If it is not, it will return
- * an error.
- *
- * @param[in] i_bufferSize - The size of the buffer to check.
- *
- * @param[in] i_expectedSize - The minimum size the buffer should be.
- *
- * @return errlHndl_t - An error log will be returned if the buffer is not
- * large enough.
- */
-errlHndl_t checkBufferSize( size_t i_bufferSize,
- size_t i_expectedSize );
-
-
-// Register with the routing code
-DEVICE_REGISTER_ROUTE( DeviceFW::READ,
- DeviceFW::MVPD,
- TARGETING::TYPE_PROC,
- mvpdRead );
-DEVICE_REGISTER_ROUTE( DeviceFW::WRITE,
- DeviceFW::MVPD,
- TARGETING::TYPE_PROC,
- mvpdWrite );
-
-
-// ------------------------------------------------------------------
-// mvpdRead
-// ------------------------------------------------------------------
-errlHndl_t mvpdRead ( DeviceFW::OperationType i_opType,
- TARGETING::Target * i_target,
- void * io_buffer,
- size_t & io_buflen,
- int64_t i_accessType,
- va_list i_args )
-{
- errlHndl_t err = NULL;
- const char * recordName = NULL;
- const char * keywordName = NULL;
- uint16_t recordOffset = 0x0;
- input_args_t args;
- args.record = ((mvpdRecord)va_arg( i_args, uint64_t ));
- args.keyword = ((mvpdKeyword)va_arg( i_args, uint64_t ));
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdRead()" );
-
- do
+ mutex_t g_mutex = MUTEX_INITIALIZER;
+
+ /**
+ * @brief This function will perform the steps required to do a read from
+ * the Hostboot MVPD data.
+ *
+ * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
+ * driververif.H
+ *
+ * @param[in] i_target - Processor Target device
+ *
+ * @param [in/out] io_buffer - Pointer to the data that was read from
+ * the target device. This parameter, when set to NULL, will return
+ * the keyword size value in io_buflen.
+ *
+ * @param [in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * will indicate the number of valid bytes in the buffer being
+ * returned. This parameter will contain the size of a keyword when
+ * the io_buffer parameter is passed in NULL.
+ *
+ * @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
+ * usrif.H
+ *
+ * @param [in] i_args - This is an argument list for the device driver
+ * framework.
+ *
+ * @return errlHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t mvpdRead ( DeviceFW::OperationType i_opType,
+ TARGETING::Target * i_target,
+ void * io_buffer,
+ size_t & io_buflen,
+ int64_t i_accessType,
+ va_list i_args )
{
- // Get the Record/keyword names
- err = mvpdTranslateRecord( args.record,
- recordName );
+ errlHndl_t err = NULL;
+ IpVpdFacade::input_args_t args;
+ args.record = ((mvpdRecord)va_arg( i_args, uint64_t ));
+ args.keyword = ((mvpdKeyword)va_arg( i_args, uint64_t ));
- if( err )
- {
- break;
- }
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"mvpdRead()" );
- err = mvpdTranslateKeyword( args.keyword,
- keywordName );
+ err = Singleton<MvpdFacade>::instance().read(i_target,
+ io_buffer,
+ io_buflen,
+ args);
- if( err )
- {
- break;
- }
-
- TRACSCOMP( g_trac_mvpd,
- INFO_MRK"Read record (%s) and Keyword (%s)",
- recordName, keywordName );
-
- // Get the offset of the record requested
- err = mvpdFindRecordOffset( recordName,
- recordOffset,
- i_target,
- args );
-
- if( err )
- {
- break;
- }
-
- // use record offset to find/read the keyword
- err = mvpdRetrieveKeyword( keywordName,
- recordName,
- recordOffset,
- i_target,
- io_buffer,
- io_buflen,
- args );
-
- if( err )
- {
- break;
- }
- } while( 0 );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdRead()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdWrite
-// ------------------------------------------------------------------
-errlHndl_t mvpdWrite ( DeviceFW::OperationType i_opType,
- TARGETING::Target * i_target,
- void * io_buffer,
- size_t & io_buflen,
- int64_t i_accessType,
- va_list i_args )
-{
- errlHndl_t err = NULL;
- const char * recordName = NULL;
- const char * keywordName = NULL;
- uint16_t recordOffset = 0x0;
- input_args_t args;
- args.record = ((mvpdRecord)va_arg( i_args, uint64_t ));
- args.keyword = ((mvpdKeyword)va_arg( i_args, uint64_t ));
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdWrite()" );
-
- do
- {
- // Get the Record/keyword names
- err = mvpdTranslateRecord( args.record,
- recordName );
-
- if( err )
- {
- break;
- }
-
- err = mvpdTranslateKeyword( args.keyword,
- keywordName );
-
- if( err )
- {
- break;
- }
-
- TRACSCOMP( g_trac_mvpd,
- INFO_MRK"Write record (%s) and Keyword (%s)",
- recordName, keywordName );
-
- // Get the offset of the record requested
- err = mvpdFindRecordOffset( recordName,
- recordOffset,
- i_target,
- args );
-
- if( err )
- {
- break;
- }
-
- // use record offset to find/read the keyword
- err = mvpdWriteKeyword( keywordName,
- recordName,
- recordOffset,
- i_target,
- io_buffer,
- io_buflen,
- args );
-
- if( err )
- {
- break;
- }
- } while( 0 );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdWrite()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdTranslateRecord
-// ------------------------------------------------------------------
-errlHndl_t mvpdTranslateRecord ( mvpdRecord i_record,
- const char *& o_record )
-{
- errlHndl_t err = NULL;
- uint32_t arraySize = 0x0;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdTranslateRecord()" );
-
- do
- {
- arraySize = (sizeof(mvpdRecords)/sizeof(mvpdRecords[0]));
- mvpdRecordInfo tmpRecord;
- tmpRecord.record = i_record;
- const mvpdRecordInfo * entry = std::lower_bound( mvpdRecords,
- &mvpdRecords[arraySize],
- tmpRecord,
- compareRecords );
-
- if( ( entry == &mvpdRecords[arraySize] )||
- ( i_record != entry->record ) )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"No matching Record (0x%04x) found!",
- i_record );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_RECORD_NOT_FOUND
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_TRANSLATE_RECORD
- * @userdata1 Record enumeration.
- * @userdata2 <UNUSED>
- * @devdesc The record enumeration did not have a
- * corresponding string value.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_TRANSLATE_RECORD,
- VPD::VPD_RECORD_NOT_FOUND,
- i_record,
- 0x0 );
-
- break;
- }
-
- o_record = entry->recordName;
- TRACDCOMP( g_trac_mvpd,
- "record name: %s",
- entry->recordName );
- } while( 0 );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdTranslateRecord()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdTranslateKeyword
-// ------------------------------------------------------------------
-errlHndl_t mvpdTranslateKeyword ( mvpdKeyword i_keyword,
- const char *& o_keyword )
-{
- errlHndl_t err = NULL;
- uint32_t arraySize = 0x0;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdTranslateKeyword()" );
-
- do
- {
- arraySize = (sizeof(mvpdKeywords)/sizeof(mvpdKeywords[0]));
- mvpdKeywordInfo tmpKeyword;
- tmpKeyword.keyword = i_keyword;
- const mvpdKeywordInfo * entry = std::lower_bound( mvpdKeywords,
- &mvpdKeywords[arraySize],
- tmpKeyword,
- compareKeywords );
-
- if( ( entry == &mvpdKeywords[arraySize] ) ||
- ( i_keyword != entry->keyword ) )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"No matching Keyword found!" );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_KEYWORD_NOT_FOUND
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_TRANSLATE_KEYWORD
- * @userdata1 Keyword Enumeration
- * @userdata2 <UNUSED>
- * @devdesc The keyword enumeration did not have a
- * corresponding string value.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_TRANSLATE_KEYWORD,
- VPD::VPD_KEYWORD_NOT_FOUND,
- i_keyword,
- 0x0 );
-
- break;
- }
-
- o_keyword = entry->keywordName;
- TRACDCOMP( g_trac_mvpd,
- "keyword name: %s",
- entry->keywordName );
- } while( 0 );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdTranslateKeyword()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdFindRecordOffset
-// ------------------------------------------------------------------
-errlHndl_t mvpdFindRecordOffset ( const char * i_record,
- uint16_t & o_offset,
- TARGETING::Target * i_target,
- input_args_t i_args )
-{
- errlHndl_t err = NULL;
- uint64_t tmpOffset = 0x0;
- char record[RECORD_BYTE_SIZE] = { '\0' };
- uint16_t offset = 0x0;
- bool matchFound = false;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdFindRecordOffset()" );
-
- do
- {
- // --------------------------------------
- // Start reading at beginning of file
- // First 256 bytes are the TOC
- // --------------------------------------
- // TOC Format is as follows:
- // 8 bytes per entry - 32 entries possible
- // Entry:
- // byte 0 - 3: ASCII Record Name
- // byte 4 - 5: Size (byte swapped)
- // byte 6 - 7: UNUSED
- // --------------------------------------
- while( ( tmpOffset < 0x100 ) &&
- !matchFound )
- {
- TRACDCOMP( g_trac_mvpd,
- INFO_MRK"read offset: 0x%08x",
- tmpOffset );
-
- // Read Record Name
- err = mvpdFetchData( tmpOffset,
- RECORD_BYTE_SIZE,
- record,
- i_target );
- tmpOffset += RECORD_BYTE_SIZE;
-
- if( err )
- {
- break;
- }
-
- if( !(memcmp( record, i_record, RECORD_BYTE_SIZE )) )
- {
- matchFound = true;
-
- // Read the matching records offset
- err = mvpdFetchData( tmpOffset,
- RECORD_ADDR_BYTE_SIZE,
- &offset,
- i_target );
-
- if( err )
- {
- break;
- }
- }
- tmpOffset += (RECORD_ADDR_BYTE_SIZE + RECORD_TOC_UNUSED);
- }
-
- if( err )
- {
- break;
- }
- } while( 0 );
-
- if( !matchFound )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"No matching Record (%s) found in TOC!",
- i_record );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_RECORD_NOT_FOUND
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_FIND_RECORD_OFFSET
- * @userdata1 Requested Record
- * @userdata2 Requested Keyword
- * @devdesc The requested record was not found in the MVPD TOC.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_FIND_RECORD_OFFSET,
- VPD::VPD_RECORD_NOT_FOUND,
- i_args.record,
- i_args.keyword );
- // Add trace to the log so we know what record was being requested.
- err->collectTrace( "MVPD" );
+ return err;
}
- // Return the offset found, after byte swapping it.
- o_offset = le16toh( offset );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdFindRecordOffset()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdRetrieveKeyword
-// ------------------------------------------------------------------
-errlHndl_t mvpdRetrieveKeyword ( const char * i_keywordName,
- const char * i_recordName,
- uint16_t i_offset,
- TARGETING::Target * i_target,
- void * io_buffer,
- size_t & io_buflen,
- input_args_t i_args )
-{
- errlHndl_t err = NULL;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdRetrieveKeyword()" );
-
- do
- {
- // First go find the keyword in memory
- size_t keywordSize = 0x0;
- uint64_t byteAddr = 0x0;
- err = mvpdFindKeywordAddr( i_keywordName,
- i_recordName,
- i_offset,
- i_target,
- keywordSize,
- byteAddr,
- i_args );
- if( err )
- {
- break;
- }
-
- // If the buffer is NULL, return the keyword size in io_buflen
- if( NULL == io_buffer )
- {
- io_buflen = keywordSize;
- break;
- }
-
- // check size of usr buffer with io_buflen
- err = checkBufferSize( io_buflen,
- (size_t)keywordSize );
- if( err )
- {
- break;
- }
-
- // Read keyword data into io_buffer
- err = mvpdFetchData( i_offset+byteAddr,
- keywordSize,
- io_buffer,
- i_target );
- if( err )
- {
- break;
- }
- // Everything worked
- io_buflen = keywordSize;
- } while(0);
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdRetrieveKeyword()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdFetchData
-// ------------------------------------------------------------------
-errlHndl_t mvpdFetchData ( uint64_t i_byteAddr,
- size_t i_numBytes,
- void * o_data,
- TARGETING::Target * i_target )
-{
- errlHndl_t err = NULL;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdFetchData()" );
-
- do
+ /**
+ * @brief This function will perform the steps required to do a write to
+ * the Hostboot MVPD data.
+ *
+ * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
+ * driververif.H
+ *
+ * @param[in] i_target - Processor Target device
+ *
+ * @param [in/out] io_buffer - Pointer to the data that was read from
+ * the target device. It will also be used to contain data to
+ * be written to the device.
+ *
+ * @param [in/out] io_buflen - Length of the buffer to be read or written
+ * to/from the target. This value should indicate the size of the
+ * io_buffer parameter that has been allocated. Being returned it
+ * will indicate the number of valid bytes in the buffer being
+ * returned.
+ *
+ * @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
+ * usrif.H
+ *
+ * @param [in] i_args - This is an argument list for the device driver
+ * framework.
+ *
+ * @return errlHndl_t - NULL if successful, otherwise a pointer to the
+ * error log.
+ */
+ errlHndl_t mvpdWrite ( DeviceFW::OperationType i_opType,
+ TARGETING::Target * i_target,
+ void * io_buffer,
+ size_t & io_buflen,
+ int64_t i_accessType,
+ va_list i_args )
{
- if( likely( g_usePNOR ) )
- {
- // Call a function in the common VPD code
- VPD::pnorInformation info;
- info.segmentSize = MVPD_SECTION_SIZE;
- info.maxSegments = MVPD_MAX_SECTIONS;
- info.pnorSection = PNOR::MODULE_VPD;
- info.pnorSide = PNOR::CURRENT_SIDE;
- err = VPD::readPNOR( i_byteAddr,
- i_numBytes,
- o_data,
- i_target,
- info,
- g_mvpdPnorAddr,
- &g_mvpdMutex );
-
- if( err )
- {
- break;
- }
- }
- else
- {
- err = mvpdReadBinaryFile( i_byteAddr,
- i_numBytes,
- o_data );
-
- if( err )
- {
- break;
- }
- }
- } while( 0 );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdFetchData()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdReadBinaryFile
-// ------------------------------------------------------------------
-errlHndl_t mvpdReadBinaryFile ( uint64_t i_offset,
- size_t i_numBytes,
- void * o_data )
-{
- errlHndl_t err = NULL;
- const char * fileName = "procmvpd.dat";
- const char * startAddr = NULL;
- size_t fileSize;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdReadBinaryFile()" );
-
- do
- {
- if( g_loadModule )
- {
- mutex_lock( &g_mvpdMutex );
-
- if( g_loadModule )
- {
- // Load the file
- TRACUCOMP( g_trac_mvpd,
- "Load file" );
- err = VFS::module_load( fileName );
-
- if( err )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"Error opening binary MVPD file: %s",
- fileName );
- mutex_unlock( &g_mvpdMutex );
+ errlHndl_t err = NULL;
+ IpVpdFacade::input_args_t args;
+ args.record = ((mvpdRecord)va_arg( i_args, uint64_t ));
+ args.keyword = ((mvpdKeyword)va_arg( i_args, uint64_t ));
- break;
- }
+ TRACSSCOMP( g_trac_vpd,
+ ENTER_MRK"mvpdWrite()" );
- g_loadModule = false;
- }
- mutex_unlock( &g_mvpdMutex );
- }
+ err = Singleton<MvpdFacade>::instance().write(i_target,
+ io_buffer,
+ io_buflen,
+ args);
- // Get the starting address of the file/module
- TRACUCOMP( g_trac_mvpd,
- "Get starting address/size" );
- err = VFS::module_address( fileName,
- startAddr,
- fileSize );
-
- if( err )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"Error getting starting address of binary MVPD "
- "file: %s",
- fileName );
-
- break;
- }
-
- // Check that we can read the amount of data we need to from the
- // file we just loaded
- TRACUCOMP( g_trac_mvpd,
- "Check Size vs file size" );
- if( (i_offset + i_numBytes) > fileSize )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"Unable to read %d bytes from %s at offset 0x%08x "
- "because file size is only %d bytes!",
- i_numBytes,
- fileName,
- i_offset,
- fileSize );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_INSUFFICIENT_FILE_SIZE
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_READ_BINARY_FILE
- * @userdata1 File Size
- * @userdata2[0:31] Starting offset into file
- * @userdata2[32:63] Number of bytes to read
- * @devdesc File is not sufficiently large to read number of
- * bytes at offset given without overrunning file.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_READ_BINARY_FILE,
- VPD::VPD_INSUFFICIENT_FILE_SIZE,
- fileSize,
- TWO_UINT32_TO_UINT64( i_offset,
- fileSize ) );
-
- break;
- }
-
- // Retrieve the data requested
- TRACUCOMP( g_trac_mvpd,
- "Copy data out of file" );
- memcpy( o_data, (startAddr + i_offset), i_numBytes );
- } while( 0 );
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdReadBinaryFile()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// checkBufferSize
-// ------------------------------------------------------------------
-errlHndl_t checkBufferSize( size_t i_bufferSize,
- size_t i_expectedSize )
-{
- errlHndl_t err = NULL;
-
- if( !(i_bufferSize >= i_expectedSize) )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"Buffer size (%d) is not larger than expected size "
- "(%d)",
- i_bufferSize,
- i_expectedSize );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_INSUFFICIENT_BUFFER_SIZE
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_CHECK_BUFFER_SIZE
- * @userdata1 Buffer Size
- * @userdata2 Expected Buffer Size
- * @devdesc Buffer size was not greater than or equal to
- * expected buffer size.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_CHECK_BUFFER_SIZE,
- VPD::VPD_INSUFFICIENT_BUFFER_SIZE,
- i_bufferSize,
- i_expectedSize );
+ return err;
}
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// compareRecords
-// ------------------------------------------------------------------
-bool compareRecords ( const mvpdRecordInfo e1,
- const mvpdRecordInfo e2 )
-{
- if( e2.record > e1.record )
- return true;
- else
- return false;
-}
-
+ // Register with the routing code
+ DEVICE_REGISTER_ROUTE( DeviceFW::READ,
+ DeviceFW::MVPD,
+ TARGETING::TYPE_PROC,
+ mvpdRead );
+ DEVICE_REGISTER_ROUTE( DeviceFW::WRITE,
+ DeviceFW::MVPD,
+ TARGETING::TYPE_PROC,
+ mvpdWrite );
-// ------------------------------------------------------------------
-// compareKeywords
-// ------------------------------------------------------------------
-bool compareKeywords ( const mvpdKeywordInfo e1,
- const mvpdKeywordInfo e2 )
-{
- if( e2.keyword > e1.keyword )
- return true;
- else
- return false;
-}
+}; // end MVPD namespace
-// ------------------------------------------------------------------
-// mvpdFindKeywordAddr
-// ------------------------------------------------------------------
-errlHndl_t mvpdFindKeywordAddr ( const char * i_keywordName,
- const char * i_recordName,
- uint16_t i_offset,
- TARGETING::Target * i_target,
- size_t& o_keywordSize,
- uint64_t& o_byteAddr,
- input_args_t i_args )
-{
- errlHndl_t err = NULL;
- uint16_t offset = i_offset;
- uint16_t recordSize = 0x0;
- uint16_t keywordSize = 0x0;
- char record[RECORD_BYTE_SIZE] = { '\0' };
- char keyword[KEYWORD_BYTE_SIZE] = { '\0' };
- bool matchFound = false;
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdFindKeywordAddr()" );
- do
- {
- // Read size of Record
- err = mvpdFetchData( offset,
- RECORD_ADDR_BYTE_SIZE,
- &recordSize,
- i_target );
- offset += RECORD_ADDR_BYTE_SIZE;
-
- if( err )
- {
- break;
- }
-
- // Byte Swap
- recordSize = le16toh( recordSize );
-
- // Skip 3 bytes - RT
- // Read 4 bytes ( Record name ) - compare with expected
- offset += RT_SKIP_BYTES;
- err = mvpdFetchData( offset,
- RECORD_BYTE_SIZE,
- record,
- i_target );
- offset += RECORD_BYTE_SIZE;
-
- if( err )
- {
- break;
- }
-
- if( memcmp( record, i_recordName, RECORD_BYTE_SIZE ) )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"Record(%s) for offset (0x%04x) did not match "
- "expected record(%s)!",
- record,
- i_offset,
- i_recordName );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_RECORD_MISMATCH
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_FIND_KEYWORD_ADDR
- * @userdata1 Current offset into MVPD
- * @userdata2 Start of Record offset
- * @devdesc Record name does not match value expected for
- * offset read.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_FIND_KEYWORD_ADDR,
- VPD::VPD_RECORD_MISMATCH,
- offset,
- i_offset );
- // Add trace so we see what record was being compared
- err->collectTrace( "MVPD" );
-
- break;
- }
-
- // While size < size of record
- // Size of record is the input offset, plus the record size, plus
- // 2 bytes for the size value.
- while( ( offset < (recordSize + i_offset + RECORD_ADDR_BYTE_SIZE) ) )
- {
- TRACDCOMP( g_trac_mvpd,
- INFO_MRK"Looking for keyword, reading offset: 0x%04x",
- offset );
-
- // read keyword name (2 bytes)
- err = mvpdFetchData( offset,
- KEYWORD_BYTE_SIZE,
- keyword,
- i_target );
- offset += KEYWORD_BYTE_SIZE;
-
- if( err )
- {
- break;
- }
-
- TRACDCOMP( g_trac_mvpd,
- INFO_MRK"Read keyword name: %s",
- keyword );
-
- // Check if we're reading a '#' keyword. They have a 2 byte size
- uint32_t keywordLength = KEYWORD_SIZE_BYTE_SIZE;
- bool isPoundKwd = false;
- if( !(memcmp( keyword, "#", 1 )) )
- {
- TRACDCOMP( g_trac_mvpd,
- INFO_MRK"Reading # keyword, adding 1 byte to size "
- "to read!" );
- isPoundKwd = true;
- keywordLength++;
- }
-
- // Read keyword size
- err = mvpdFetchData( offset,
- keywordLength,
- &keywordSize,
- i_target );
- offset += keywordLength;
-
- if( err )
- {
- break;
- }
-
- if( isPoundKwd )
- {
- // Swap it since 2 byte sizes are byte swapped.
- keywordSize = le16toh( keywordSize );
- }
- else
- {
- keywordSize = keywordSize >> 8;
- }
-
- TRACDCOMP( g_trac_mvpd,
- INFO_MRK"Read keyword size: 0x%04x",
- keywordSize );
-
- // if keyword equal i_keywordName
- if( !(memcmp( keyword, i_keywordName, KEYWORD_BYTE_SIZE ) ) )
- {
- // send back the relevant data
- o_keywordSize = keywordSize;
- o_byteAddr = offset - i_offset; //make address relative
-
- // found our match, break out
- matchFound = true;
- break;
- }
- else
- {
- // set offset to next keyword (based on current keyword size)
- offset += keywordSize;
- }
- }
-
- if( err ||
- matchFound )
- {
- break;
- }
- } while( 0 );
-
- // If keyword not found in expected Record, flag error.
- if( !matchFound &&
- NULL == err )
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"No matching %s keyword found within %s record!",
- i_keywordName,
- i_recordName );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_KEYWORD_NOT_FOUND
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_FIND_KEYWORD_ADDR
- * @userdata1 Start of Record Offset
- * @userdata2[0:31] Requested Record
- * @userdata2[32:63] Requested Keyword
- * @devdesc Keyword was not found in Record starting at given
- * offset.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_FIND_KEYWORD_ADDR,
- VPD::VPD_KEYWORD_NOT_FOUND,
- i_offset,
- TWO_UINT32_TO_UINT64( i_args.record,
- i_args.keyword ) );
-
- // Add trace so we know what Record/Keyword was missing
- err->collectTrace( "MVPD" );
- }
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdFindKeywordAddr()" );
-
- return err;
-}
-
-
-// ------------------------------------------------------------------
-// mvpdWriteKeyword
-// ------------------------------------------------------------------
-errlHndl_t mvpdWriteKeyword ( const char * i_keywordName,
- const char * i_recordName,
- uint16_t i_offset,
- TARGETING::Target * i_target,
- void * i_buffer,
- size_t & i_buflen,
- input_args_t i_args )
+//MVPD Class Functions
+/**
+ * @brief Constructor
+ */
+MvpdFacade::MvpdFacade() :
+IpVpdFacade(MVPD::SECTION_SIZE,
+ MVPD::MAX_SECTIONS,
+ MVPD::mvpdRecords,
+ (sizeof(MVPD::mvpdRecords)/sizeof(MVPD::mvpdRecords[0])),
+ MVPD::mvpdKeywords,
+ (sizeof(MVPD::mvpdKeywords)/sizeof(MVPD::mvpdKeywords[0])),
+ PNOR::MODULE_VPD,
+ MVPD::g_mutex,
+ VPD::VPD_WRITE_PROC)
{
- errlHndl_t err = NULL;
-
- TRACSSCOMP( g_trac_mvpd,
- ENTER_MRK"mvpdWriteKeyword()" );
-
- do
- {
- // Note, there is no way to tell if a keyword is writable without
- // hardcoding it so we will just assume that the callers know
- // what they are doing
-
- // First go find the keyword in memory
- size_t keywordSize = 0x0;
- uint64_t byteAddr = 0x0;
- err = mvpdFindKeywordAddr( i_keywordName,
- i_recordName,
- i_offset,
- i_target,
- keywordSize,
- byteAddr,
- i_args );
- if( err )
- {
- break;
- }
-
- // check size of usr buffer with io_buflen
- err = checkBufferSize( i_buflen,
- keywordSize );
- if( err )
- {
- break;
- }
-
- // Now write it out to PNOR
- if( likely( g_usePNOR ) )
- {
- // Setup info needed to write from PNOR
- VPD::pnorInformation info;
- info.segmentSize = MVPD_SECTION_SIZE;
- info.maxSegments = MVPD_MAX_SECTIONS;
- info.pnorSection = PNOR::MODULE_VPD;
- info.pnorSide = PNOR::CURRENT_SIDE;
- err = VPD::writePNOR( i_offset+byteAddr,
- keywordSize,
- i_buffer,
- i_target,
- info,
- g_mvpdPnorAddr,
- &g_mvpdMutex );
-
- if( err )
- {
- break;
- }
- }
- else
- {
- TRACFCOMP( g_trac_mvpd,
- ERR_MRK"There is no way to write mvpd when not using PNOR!" );
-
- /*@
- * @errortype
- * @reasoncode VPD::VPD_INVALID_WRITE_METHOD
- * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
- * @moduleid VPD::VPD_MVPD_WRITE_KEYWORD
- * @userdata1 Write Offset
- * @userdata2 Number of Bytes to Write
- * @devdesc g_usePNOR is false, but there isn't an
- * alternate way to write PNOR.
- */
- err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
- VPD::VPD_MVPD_WRITE_KEYWORD,
- VPD::VPD_INVALID_WRITE_METHOD,
- byteAddr,
- keywordSize );
-
- break;
- }
-
- VPD::VpdWriteMsg_t msgdata;
-
- // Quick double-check that our constants agree with the values in the
- // VPD message structure
- assert( sizeof(msgdata.record) == RECORD_BYTE_SIZE );
- assert( sizeof(msgdata.keyword) == KEYWORD_BYTE_SIZE );
-
- // Finally, send it down to the FSP
- msgdata.rec_num = i_target->getAttr<TARGETING::ATTR_VPD_REC_NUM>();
- memcpy( msgdata.record, i_recordName, RECORD_BYTE_SIZE );
- memcpy( msgdata.keyword, i_keywordName, KEYWORD_BYTE_SIZE );
- err = VPD::sendMboxWriteMsg( keywordSize,
- i_buffer,
- i_target,
- VPD::VPD_WRITE_PROC,
- msgdata );
-
- if( err )
- {
- break;
- }
-
-
- } while(0);
-
- TRACSSCOMP( g_trac_mvpd,
- EXIT_MRK"mvpdWriteKeyword()" );
-
- return err;
+ TRACUCOMP(g_trac_vpd, "MvpdFacade::MvpdFacade> " );
}
-
-} // end namespace MVPD
diff --git a/src/usr/vpd/mvpd.H b/src/usr/vpd/mvpd.H
index 26aba4c49..cb84a8a27 100755..100644
--- a/src/usr/vpd/mvpd.H
+++ b/src/usr/vpd/mvpd.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2012,2013 */
+/* COPYRIGHT International Business Machines Corp. 2013 */
/* */
/* p1 */
/* */
@@ -20,422 +20,143 @@
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
-#ifndef __MVPD_H
-#define __MVPD_H
+/* File mvpdnew.H created by ADAM R. MUHLE on Tue Jan 29 2013. */
-/**
- * @file mvpd.H
- *
- * @brief Provides the interfaces for the MVPD device driver
- *
- */
+/* Change Activity: */
+/* End Change Activity */
-// ----------------------------------------------
-// Includes
-// ----------------------------------------------
-#include <errl/errlentry.H>
+#ifndef _MVPD_H
+#define _MVPD_H
-namespace MVPD
-{
-
-/**
-* @brief Miscelaneous MVPD definitions
-*/
-enum
-{
- RECORD_BYTE_SIZE = 4,
- RECORD_ADDR_BYTE_SIZE = 2,
- KEYWORD_BYTE_SIZE = 2,
- KEYWORD_SIZE_BYTE_SIZE = 1,
- RECORD_TOC_UNUSED = 2,
- RT_SKIP_BYTES = 3,
+#include <vpd/mvpdenums.H>
- MVPD_SECTION_SIZE = 0x10000,
- MVPD_MAX_SECTIONS = 8,
-};
-
-/**
-* @brief Structure for all MVPD dd input parameter arguments
-*/
-typedef struct
-{
- mvpdRecord record;
- mvpdKeyword keyword;
-} input_args_t;
+#include "ipvpd.H"
-/**
- * @brief Structure of information needed to access requested
- * record/keyword combinations.
- */
-typedef struct
+namespace MVPD
{
- mvpdRecord record;
- char recordName[RECORD_BYTE_SIZE+1];
-} mvpdRecordInfo;
-
-/**
- */
-typedef struct
+ // ----------------------------------------------
+ // Defines
+ // ----------------------------------------------
+ enum
+ {
+ SECTION_SIZE = 0x10000, //64KB VPD per processor
+ MAX_SECTIONS = 8, //8 Processors in PNOR
+ };
+
+ const IpVpdFacade::recordInfo mvpdRecords[] =
+ {
+ // -------------------------------------------------------------------
+ // NOTE: This list must remain an ordered list! There will be a
+ // testcase that checks this. When adding new entries to the
+ // list, be sure that the keyword in each entry (value 0)
+ // are in ascending order.
+ // -------------------------------------------------------------------
+ { CRP0, "CRP0" },
+ { CP00, "CP00" },
+ { VINI, "VINI" },
+ { LRP0, "LRP0" },
+ { LRP1, "LRP1" },
+ { LRP2, "LRP2" },
+ { LRP3, "LRP3" },
+ { LRP4, "LRP4" },
+ { LRP5, "LRP5" },
+ { LRP6, "LRP6" },
+ { LRP7, "LRP7" },
+ { LRP8, "LRP8" },
+ { LRP9, "LRP9" },
+ { LRPA, "LRPA" },
+ { LRPB, "LRPB" },
+ { LRPC, "LRPC" },
+ { LRPD, "LRPD" },
+ { LRPE, "LRPE" },
+ { LWP0, "LWP0" },
+ { LWP1, "LWP1" },
+ { LWP2, "LWP2" },
+ { LWP3, "LWP3" },
+ { LWP4, "LWP4" },
+ { LWP5, "LWP5" },
+ { LWP6, "LWP6" },
+ { LWP7, "LWP7" },
+ { LWP8, "LWP8" },
+ { LWP9, "LWP9" },
+ { LWPA, "LWPA" },
+ { LWPB, "LWPB" },
+ { LWPC, "LWPC" },
+ { LWPD, "LWPD" },
+ { LWPE, "LWPE" },
+ { VWML, "VWML" },
+ { MER0, "MER0" },
+ // -------------------------------------------------------------------
+ // DO NOT USE!! This is for test purposes ONLY!
+ { MVPD_TEST_RECORD, "TEST" },
+ // -------------------------------------------------------------------
+ };
+
+ /**
+ * @brief Conversion of MVPD Keywords to corresponding character
+ * representation.
+ */
+ const IpVpdFacade::keywordInfo mvpdKeywords[] =
+ {
+ // -------------------------------------------------------------------
+ // NOTE: This list must remain an ordered list! There will be a
+ // testcase that checks this. When adding new entries to
+ // the list, be sure that the keyword in each entry (value 0)
+ // are in ascending order.
+ // -------------------------------------------------------------------
+ { VD, "VD" },
+ { ED, "ED" },
+ { TE, "TE" },
+ { DD, "DD" },
+ { pdP, "#P" },
+ { ST, "ST" },
+ { DN, "DN" },
+ { PG, "PG" },
+ { PK, "PK" },
+ { pdR, "#R" },
+ { pdV, "#V" },
+ { pdH, "#H" },
+ { SB, "SB" },
+ { DR, "DR" },
+ { VZ, "VZ" },
+ { CC, "CC" },
+ { CE, "CE" },
+ { FN, "FN" },
+ { PN, "PN" },
+ { SN, "SN" },
+ { PR, "PR" },
+ { HE, "HE" },
+ { CT, "CT" },
+ { HW, "HW" },
+ { pdM, "#M" },
+ { IN, "IN" },
+ { pd2, "#2" },
+ { pd3, "#3" },
+ { OC, "OC" },
+ { FO, "FO" },
+ { pdI, "#I" },
+ { pdG, "#G" },
+ { MK, "MK" },
+ { PB, "PB" },
+ { CH, "CH" },
+ // -------------------------------------------------------------------
+ // DO NOT USE!! This is for test purposes ONLY!
+ { MVPD_TEST_KEYWORD, "XX" },
+ // -------------------------------------------------------------------
+ };
+
+} //end namespace MVPD
+
+class MvpdFacade: public IpVpdFacade
{
- mvpdKeyword keyword;
- char keywordName[KEYWORD_BYTE_SIZE+1];
-} mvpdKeywordInfo;
-
+ public:
-/**
- * @brief Conversion of MVPD Records to corresponding character representation.
- */
-const mvpdRecordInfo mvpdRecords[] =
-{
- // -------------------------------------------------------------------
- // NOTE: This list must remain an ordered list! There will be a
- // testcase that checks this. When adding new entries to the
- // list, be sure that the keyword in each entry (value 0)
- // are in ascending order.
- // -------------------------------------------------------------------
- { CRP0, "CRP0" },
- { CP00, "CP00" },
- { VINI, "VINI" },
- { LRP0, "LRP0" },
- { LRP1, "LRP1" },
- { LRP2, "LRP2" },
- { LRP3, "LRP3" },
- { LRP4, "LRP4" },
- { LRP5, "LRP5" },
- { LRP6, "LRP6" },
- { LRP7, "LRP7" },
- { LRP8, "LRP8" },
- { LRP9, "LRP9" },
- { LRPA, "LRPA" },
- { LRPB, "LRPB" },
- { LRPC, "LRPC" },
- { LRPD, "LRPD" },
- { LRPE, "LRPE" },
- { LWP0, "LWP0" },
- { LWP1, "LWP1" },
- { LWP2, "LWP2" },
- { LWP3, "LWP3" },
- { LWP4, "LWP4" },
- { LWP5, "LWP5" },
- { LWP6, "LWP6" },
- { LWP7, "LWP7" },
- { LWP8, "LWP8" },
- { LWP9, "LWP9" },
- { LWPA, "LWPA" },
- { LWPB, "LWPB" },
- { LWPC, "LWPC" },
- { LWPD, "LWPD" },
- { LWPE, "LWPE" },
- { VWML, "VWML" },
- { MER0, "MER0" },
- // -------------------------------------------------------------------
- // DO NOT USE!! This is for test purposes ONLY!
- { MVPD_TEST_RECORD, "TEST" },
- // -------------------------------------------------------------------
-};
+ /**
+ * @brief Constructor
+ */
+ MvpdFacade( );
-/**
- * @brief Conversion of MVPD Keywords to corresponding character representation.
- */
-const mvpdKeywordInfo mvpdKeywords[] =
-{
- // -------------------------------------------------------------------
- // NOTE: This list must remain an ordered list! There will be a
- // testcase that checks this. When adding new entries to
- // the list, be sure that the keyword in each entry (value 0)
- // are in ascending order.
- // -------------------------------------------------------------------
- { VD, "VD" },
- { ED, "ED" },
- { TE, "TE" },
- { DD, "DD" },
- { pdP, "#P" },
- { ST, "ST" },
- { DN, "DN" },
- { PG, "PG" },
- { PK, "PK" },
- { pdR, "#R" },
- { pdV, "#V" },
- { pdH, "#H" },
- { SB, "SB" },
- { DR, "DR" },
- { VZ, "VZ" },
- { CC, "CC" },
- { CE, "CE" },
- { FN, "FN" },
- { PN, "PN" },
- { SN, "SN" },
- { PR, "PR" },
- { HE, "HE" },
- { CT, "CT" },
- { HW, "HW" },
- { pdM, "#M" },
- { IN, "IN" },
- { pd2, "#2" },
- { pd3, "#3" },
- { OC, "OC" },
- { FO, "FO" },
- { pdI, "#I" },
- { pdG, "#G" },
- { MK, "MK" },
- { PB, "PB" },
- { CH, "CH" },
- // -------------------------------------------------------------------
- // DO NOT USE!! This is for test purposes ONLY!
- { MVPD_TEST_KEYWORD, "XX" },
- // -------------------------------------------------------------------
};
+#endif /* _MVPD_H */
-/**
- * @brief This function will perform the steps required to do a read from
- * the Hostboot MVPD data.
- *
- * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
- * driververif.H
- *
- * @param[in] i_target - Processor Target device
- *
- * @param [in/out] io_buffer - Pointer to the data that was read from
- * the target device. This parameter, when set to NULL, will return the
- * keyword size value in io_buflen.
- *
- * @param [in/out] io_buflen - Length of the buffer to be read or written
- * to/from the target. This value should indicate the size of the
- * io_buffer parameter that has been allocated. Being returned it will
- * indicate the number of valid bytes in the buffer being returned.
- * This parameter will contain the size of a keyword when the io_buffer
- * parameter is passed in NULL.
- *
- * @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
- * usrif.H
- *
- * @param [in] i_args - This is an argument list for the device driver
- * framework.
- *
- * @return errlHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
-*/
-errlHndl_t mvpdRead ( DeviceFW::OperationType i_opType,
- TARGETING::Target * i_target,
- void * io_buffer,
- size_t & io_buflen,
- int64_t i_accessType,
- va_list i_args );
-
-/**
- * @brief This function will perform the steps required to do a write to
- * the Hostboot MVPD data.
- *
- * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
- * driververif.H
- *
- * @param[in] i_target - Processor Target device
- *
- * @param [in/out] io_buffer - Pointer to the data that was read from
- * the target device. It will also be used to contain data to
- * be written to the device.
- *
- * @param [in/out] io_buflen - Length of the buffer to be read or written
- * to/from the target. This value should indicate the size of the
- * io_buffer parameter that has been allocated. Being returned it will
- * indicate the number of valid bytes in the buffer being returned.
- *
- * @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
- * usrif.H
- *
- * @param [in] i_args - This is an argument list for the device driver
- * framework.
- *
- * @return errlHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
-*/
-errlHndl_t mvpdWrite ( DeviceFW::OperationType i_opType,
- TARGETING::Target * i_target,
- void * io_buffer,
- size_t & io_buflen,
- int64_t i_accessType,
- va_list i_args );
-
-/**
- * @brief This function actually reads the data from the source of the MVPD
- * data.
- *
- * @param[in] i_byteAddr - The offset to be read.
- *
- * @param[in] i_numBytes - The number of bytes to read.
- *
- * @param[out] o_data - The data buffer where the data will be placed.
- *
- * @param[in] i_target - Processor Target device.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
-*/
-errlHndl_t mvpdFetchData ( uint64_t i_byteAddr,
- size_t i_numBytes,
- void * o_data,
- TARGETING::Target * i_target );
-
-/**
- * @brief This function reads a binary file that contains the MVPD data for
- * all targets.
- *
- * @param[in] i_offset - The offset to read.
- *
- * @param[in] i_numBytes - The number of bytes to read.
- *
- * @param[out] o_data - The Data buffer where the data will be placed.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
-*/
-errlHndl_t mvpdReadBinaryFile ( uint64_t i_offset,
- size_t i_numBytes,
- void * o_data );
-
-/**
- * @brief This function will translate the enumeration for the MVPD record
- * into a char * variable to be used for comparing what was read from
- * the MVPD data.
- *
- * @param[in] i_record - The record enumeration.
- *
- * @param[out] o_record - The char representation of the record.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t mvpdTranslateRecord ( mvpdRecord i_record,
- const char *& o_record );
-
-/**
- * @brief This function will translate the enumeration for the MVPD keyword
- * into a char * variable to be used for comparing what was read from
- * the MVPD data.
- *
- * @param[in] i_keyword - The keyword enumeration.
- *
- * @param[out] o_keyword - The char representation of the record.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t mvpdTranslateKeyword ( mvpdKeyword i_keyword,
- const char *& o_keyword );
-
-/**
- * @brief This function will read the MVPD TOC to find the offset where the
- * given record is located within the chunk of data.
- *
- * @param[in] i_record - String value for the record to look for.
- *
- * @param[out] o_offset - The offset where the record is located.
- *
- * @param[in] i_target - The target to retrieve the data for.
- *
- * @param[in] i_args - The input arguments.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t mvpdFindRecordOffset ( const char * i_record,
- uint16_t & o_offset,
- TARGETING::Target * i_target,
- input_args_t i_args );
-
-/**
- * @brief This function will read the required keyword from the MVPD data.
- *
- * @param[in] i_keywordName - String representation of the keyword.
- *
- * @param[in] i_recordName - String representation of the record.
- *
- * @param[in] i_offset - The offset to start reading.
- *
- * @param[in] i_target - The target to retrieve data for.
- *
- * @param[out] io_buffer - The buffer to place the data in.
- *
- * @param[in/out] io_buflen - Length of the buffer to be read or written
- * to/from the target. This value should indicate the size of the
- * io_buffer parameter that has been allocated. Being returned it will
- * indicate the number of valid bytes in the buffer being returned.
- *
- * @param[in] i_args - The input arguments.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t mvpdRetrieveKeyword ( const char * i_keywordName,
- const char * i_recordName,
- uint16_t i_offset,
- TARGETING::Target * i_target,
- void * io_buffer,
- size_t & io_buflen,
- input_args_t i_args );
-
-/**
- * @brief This function will write the required keyword into the MVPD data.
- *
- * @param[in] i_keywordName - String representation of the keyword.
- *
- * @param[in] i_recordName - String representation of the record.
- *
- * @param[in] i_offset - The offset to start writing.
- *
- * @param[in] i_target - The target to write data for.
- *
- * @param[in] i_buffer - The buffer to pull the data from.
- *
- * @param[in] i_buflen - Length of the buffer to be written
- * to the target's VPD area. This value should indicate the size of the
- * io_buffer parameter that has been allocated.
- *
- * @param[in] i_args - The input arguments.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t mvpdWriteKeyword ( const char * i_keywordName,
- const char * i_recordName,
- uint16_t i_offset,
- TARGETING::Target * i_target,
- void * i_buffer,
- size_t & i_buflen,
- input_args_t i_args );
-
-/**
- * @brief This function will locate the byte address of a keyword
- * within its VPD section.
- *
- * @param[in] i_keywordName - String representation of the keyword.
- *
- * @param[in] i_recordName - String representation of the record.
- *
- * @param[in] i_offset - The offset to start writing.
- *
- * @param[in] i_target - The target to write data for.
- *
- * @param[out] o_keywordSize - Size of keyword in bytes.
- *
- * @param[out] o_byteAddr - Address of keyword, relative to this target's
- * section.
- *
- * @param[in] i_args - The original input arguments.
- *
- * @return errHndl_t - NULL if successful, otherwise a pointer to the
- * error log.
- */
-errlHndl_t mvpdFindKeywordAddr ( const char * i_keywordName,
- const char * i_recordName,
- uint16_t i_offset,
- TARGETING::Target * i_target,
- size_t& o_keywordSize,
- uint64_t& o_byteAddr,
- input_args_t i_args );
-
-
-}; // end MVPD namespace
-
-#endif // __MVPD_H
diff --git a/src/usr/vpd/test/cvpdtest.H b/src/usr/vpd/test/cvpdtest.H
new file mode 100755
index 000000000..b9bdf2e7d
--- /dev/null
+++ b/src/usr/vpd/test/cvpdtest.H
@@ -0,0 +1,744 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/vpd/test/cvpdtest.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 __CVPDTEST_H
+#define __CVPDTEST_H
+
+/**
+ * @file cvpdtest.H
+ *
+ * @brief Test cases for CVPD code
+ */
+#include <sys/time.h>
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <devicefw/driverif.H>
+#include <targeting/common/predicates/predicatectm.H>
+
+#include <vpd/cvpdenums.H>
+#include <vpd/vpdreasoncodes.H>
+#include "../cvpd.H"
+#include "../ipvpd.H"
+
+
+extern trace_desc_t* g_trac_vpd;
+
+using namespace TARGETING;
+
+/**
+ * @brief Structure to define record/keyword pairs for CVPD tests.
+ */
+struct cvpdTestData
+{
+ IpVpdFacade::ipVpdRecord record;
+ IpVpdFacade::ipVpdRecord keyword;
+};
+
+/**
+ * @brief Data sample to be used for CVPD testing.
+ * NOTE: By reading this entire list, it also validates that the records
+ * and keywords that we expect to be there are actually there...
+ */
+cvpdTestData cvpdData[] =
+{
+ { CVPD::VEIR, CVPD::pdI },
+ { CVPD::MER0, CVPD::pdI },
+
+};
+
+void getMembufTargets( TargetHandleList & o_membufList )
+{
+ // Get top level system target
+ TARGETING::TargetService & tS = TARGETING::targetService();
+ TARGETING::Target * sysTarget = NULL;
+ tS.getTopLevelTarget( sysTarget );
+ assert( sysTarget != NULL );
+
+ // Get a Membuf Target
+ TARGETING::PredicateCTM predMemb( TARGETING::CLASS_CHIP,
+ TARGETING::TYPE_MEMBUF );
+ tS.getAssociated( o_membufList,
+ sysTarget,
+ TARGETING::TargetService::CHILD,
+ TARGETING::TargetService::ALL,
+ &predMemb );
+
+ TRACDCOMP( g_trac_vpd,
+ "getMembufTargets() - found %d Memory Buffers",
+ o_membufList.size() );
+
+ return;
+}
+
+TARGETING::Target* getFunctionalMembufTarget()
+{
+ TARGETING::Target * theTarget = NULL;
+ TRACDCOMP( g_trac_vpd,
+ "getFunctionalMembufTarget() - Finding a membuf" );
+
+ do {
+ // Get the Memory Buffer targets
+ TargetHandleList membufList;
+ getMembufTargets( membufList );
+
+ if( ( 0 == membufList.size() ) ||
+ ( NULL == membufList[0] ) )
+ {
+ continue; // add continue because have no Membuf targets
+ }
+
+ for(uint32_t i=0; i<membufList.size(); i++)
+ {
+ if(membufList[i]->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ {
+ theTarget = membufList[i];
+ break;
+ }
+ }
+ }while(0);
+
+ return theTarget;
+
+}
+
+class CVPDTest: public CxxTest::TestSuite
+{
+ public:
+
+ /**
+ * @brief This function will test CVPD reads.
+ */
+ void testCvpdRead ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+ uint64_t theRecord = 0x0;
+ uint64_t theKeyword = 0x0;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdRead()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdRead() - No Functional Targets found!");
+ break;
+ }
+
+ uint8_t * theData = NULL;
+ size_t theSize = 0;
+ const uint32_t numCmds = sizeof(cvpdData)/sizeof(cvpdData[0]);
+ for( uint32_t curCmd = 0; curCmd < numCmds; curCmd++ )
+ {
+ cmds++;
+ theRecord = (uint64_t)cvpdData[curCmd].record;
+ theKeyword = (uint64_t)cvpdData[curCmd].keyword;
+ err = deviceRead( theTarget,
+ NULL,
+ theSize,
+ DEVICE_CVPD_ADDRESS( theRecord,
+ theKeyword ) );
+
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdRead() - failure reading "
+ "keyword size!! rec: 0x%04x, kwd: 0x%04x",
+ theRecord,
+ theKeyword );
+ TS_FAIL( "testCvpdRead() - Failure reading keyword size!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+ continue;
+ }
+
+ theData = static_cast<uint8_t*>(malloc( theSize ));
+
+ // Read record/keyword pair
+ err = deviceRead( theTarget,
+ theData,
+ theSize,
+ DEVICE_CVPD_ADDRESS( theRecord,
+ theKeyword ) );
+
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdRead() - Failure on Record: "
+ "0x%04x, keyword: 0x%04x, of size: 0x%04x "
+ "- test %d",
+ theRecord,
+ theKeyword,
+ theSize, curCmd );
+ TS_FAIL( "testCvpdRead() - Failure during CVPD read!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+
+ // Free the data
+ if( NULL != theData )
+ {
+ free( theData );
+ theData = NULL;
+ }
+ continue;
+ }
+
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK"testCvpdRead Results:" );
+ for( uint32_t i = 0; i < theSize; i++ )
+ {
+ TRACDCOMP( g_trac_vpd,
+ INFO_MRK" Byte[%d]: 0x%02x",
+ i, theData[i] );
+ }
+
+ // Free the data
+ if( NULL != theData )
+ {
+ free( theData );
+ theData = NULL;
+ }
+ }
+ } while( 0 );
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdRead - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test CVPD writes.
+ */
+ void testCvpdWrite ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+ uint8_t* testData = NULL;
+ uint8_t* origData = NULL;
+ uint8_t* verifyData = NULL;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdWrite()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdWrite() - No Functional Targets found!");
+ break;
+ }
+
+ // first figure out how big the keyword is
+ cmds++;
+ size_t theSize = 0;
+ err = deviceRead( theTarget,
+ testData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::VEIR,CVPD::pdI) );
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdWrite() - failure getting size of VEIR/#I, RC=%.4X",
+ err->reasonCode() );
+ TS_FAIL( "testCvpdWrite() - Failure calling deviceRead!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+ continue;
+ }
+
+ // save off the original data
+ origData = new uint8_t[theSize];
+ cmds++;
+ err = deviceRead( theTarget,
+ origData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::VEIR,CVPD::pdI) );
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdWrite() - failure reading VEIR/#I, RC=%.4X",
+ err->reasonCode() );
+ TS_FAIL( "testCvpdWrite() - Failure calling deviceRead!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+ continue;
+ }
+ TRACFBIN( g_trac_vpd, "testCvpdWrite() - orig=",
+ origData, theSize );
+
+ // fill it up with some dummy data
+ testData = new uint8_t[theSize];
+ for( size_t x=0; x<theSize; x++ )
+ {
+ testData[x] = x;
+ }
+
+ // write the new data in
+ cmds++;
+ err = deviceWrite( theTarget,
+ testData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::VEIR,CVPD::pdI) );
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdWrite() - failure writing VEIR/#I, RC=%.4X",
+ err->reasonCode() );
+ TS_FAIL( "testCvpdWrite() - Failure calling deviceWrite!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+ continue;
+ }
+
+ // verify the data got written
+ cmds++;
+ verifyData = new uint8_t[theSize];
+ err = deviceRead( theTarget,
+ verifyData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::VEIR,CVPD::pdI) );
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdWrite() - failure reading VEIR/#I to verify, RC=%.4X",
+ err->reasonCode() );
+ TS_FAIL( "testCvpdWrite() - Failure calling deviceRead!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+ continue;
+ }
+ TRACFBIN( g_trac_vpd, "testCvpdWrite() - verif=",
+ verifyData, theSize );
+
+ // compare what we read to what we wrote
+ if( memcmp( testData, verifyData, theSize ) )
+ {
+ fails++;
+ TRACFBIN( g_trac_vpd, "testCvpdWrite() - wrote=",
+ testData, theSize );
+ TRACFBIN( g_trac_vpd, "testCvpdWrite() - read=",
+ verifyData, theSize );
+ TS_FAIL( "testCvpdWrite - Data mismatch!" );
+ }
+
+ // put the original data back to be a good citizen
+ cmds++;
+ err = deviceWrite( theTarget,
+ origData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::VEIR,CVPD::pdI) );
+ if( err )
+ {
+ fails++;
+ TRACFCOMP( g_trac_vpd,
+ ERR_MRK"testCvpdWrite() - failure writing original data back into VEIR/#I, RC=%.4X",
+ err->reasonCode() );
+ TS_FAIL( "testCvpdWrite() - Failure calling deviceRead!" );
+ errlCommit( err,
+ VPD_COMP_ID );
+ continue;
+ }
+
+ } while( 0 );
+
+ if( NULL != testData )
+ {
+ delete[] testData;
+ testData = NULL;
+ }
+
+ if( NULL != origData )
+ {
+ delete[] origData;
+ origData = NULL;
+ }
+
+ if( NULL != verifyData )
+ {
+ delete[] verifyData;
+ verifyData = NULL;
+ }
+
+ if( cmds == 0 )
+ {
+ TS_FAIL(x"testCvpdWrite - No tests ran, something is wrong...");
+ }
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdWrite - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test that an error is generated when a
+ * record is passed in that cannot be found in the structure
+ * that defines the Records string representation.
+ */
+ void testCvpdInvalidRecord ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdInvalidRecord()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdInvalidRecord() - No Functional Targets found!");
+ break;
+ }
+
+
+ size_t theSize = 1;
+ uint8_t * theData = new uint8_t[theSize];
+
+ cmds++;
+ err = deviceRead( theTarget,
+ theData,
+ theSize,
+ DEVICE_CVPD_ADDRESS( CVPD::CVPD_LAST_RECORD,
+ CVPD::pdI ) );
+
+ if( NULL == err )
+ {
+ fails++;
+ TS_FAIL( "testCvpdInvalidRecord() - Error expected with "
+ "record of type CVPD_LAST_RECORD (0x%04x), but "
+ "no error returned!",
+ CVPD::CVPD_LAST_RECORD );
+ }
+ else
+ {
+ delete err;
+ err = NULL;
+ }
+
+ if( NULL != theData )
+ {
+ delete theData;
+ theData = NULL;
+ }
+ } while( 0 );
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdInvalidRecord - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test for a record which is not in the TOC
+ * of the CVPD area.
+ */
+ void testCvpdMissingRecord ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdMissingRecord()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdMissingRecord() - No Functional Targets found!");
+ break;
+ }
+
+ size_t theSize = 1;
+ uint8_t * theData = new uint8_t[theSize];
+
+ cmds++;
+ err = deviceRead( theTarget,
+ theData,
+ theSize,
+ DEVICE_CVPD_ADDRESS( CVPD::CVPD_TEST_RECORD,
+ CVPD::pdI ) );
+
+ if( NULL == err )
+ {
+ fails++;
+ TS_FAIL( "testCvpdMissingRecord() - ");
+ }
+ else
+ {
+ delete err;
+ err = NULL;
+ }
+
+ if( NULL != theData )
+ {
+ delete theData;
+ theData = NULL;
+ }
+ } while( 0 );
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdMissingRecord - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test for a keyword that cannot be found
+ * in the expected record
+ */
+ void testCvpdMissingKeyword ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdMissingKeyword()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdMissingKeyword() - No Functional Targets found!");
+ break;
+ }
+
+ size_t theSize = 1;
+ uint8_t * theData = new uint8_t[theSize];
+
+ cmds++;
+ err = deviceRead(theTarget,
+ theData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::CVPD_FIRST_RECORD,
+ CVPD::CVPD_TEST_KEYWORD));
+
+ if( NULL == err )
+ {
+ fails++;
+ TS_FAIL("testCvpdMissingKeyword() - Expected error from "
+ "invalid Keyword missing from associated record!");
+ }
+ else
+ {
+ delete err;
+ err = NULL;
+ }
+
+ if( NULL != theData )
+ {
+ delete theData;
+ theData = NULL;
+ }
+ } while( 0 );
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdMissingKeyword - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test that an error is generated when a
+ * keyword is passed in that cannot be found in the structure
+ * that defines the Keywords string representation.
+ */
+ void testCvpdInvalidKeyword ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdInvalidKeyword()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdInvalidKeyword() - No Functional Targets found!");
+ break;
+ }
+
+ size_t theSize = 1;
+ uint8_t * theData = new uint8_t[theSize];
+
+ cmds++;
+ err = deviceRead(theTarget,
+ theData,
+ theSize,
+ DEVICE_CVPD_ADDRESS(CVPD::VEIR,
+ CVPD::CVPD_LAST_KEYWORD));
+
+ if( NULL == err )
+ {
+ fails++;
+ TS_FAIL( "testCvpdInvalidKeyword() - Error expected with "
+ "keyword of type CVPD_LAST_KEYWORD (0x%04x), but "
+ "no error returned!",
+ CVPD::CVPD_LAST_KEYWORD );
+ }
+ else
+ {
+ delete err;
+ err = NULL;
+ }
+
+ if( NULL != theData )
+ {
+ delete theData;
+ theData = NULL;
+ }
+ } while( 0 );
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdInvalidKeyword - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test that an error is generated when a
+ * buffer that has an insufficient size is passed in to read a
+ * record/keyword.
+ */
+ void testCvpdInvalidBufferSize ( void )
+ {
+ errlHndl_t err = NULL;
+ uint64_t cmds = 0x0;
+ uint64_t fails = 0x0;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdInvalidBufferSize()" );
+
+ do
+ {
+ TARGETING::Target * theTarget = getFunctionalMembufTarget();
+ if(theTarget == NULL)
+ {
+ TS_FAIL("testCvpdInvalidBufferSize() - No Functional Targets found!");
+ break;
+ }
+
+ uint8_t * theData = new uint8_t[1];
+ size_t theSize = 0;
+
+ cmds++;
+ err = deviceRead( theTarget,
+ theData,
+ theSize,
+ DEVICE_CVPD_ADDRESS( CVPD::VEIR,
+ CVPD::pdI ) );
+
+ if( NULL == err )
+ {
+ fails++;
+ TS_FAIL( "testCvpdInvalidBufferSize() - Error was expected "
+ "for an invalid size of 0x0 for a CVPD read!" );
+ }
+ else
+ {
+ delete err;
+ err = NULL;
+ }
+
+ if( NULL != theData )
+ {
+ delete theData;
+ theData = NULL;
+ }
+ } while( 0 );
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdInvalidBufferSize - %d/%d fails",
+ fails, cmds );
+ }
+
+ /**
+ * @brief This function will test the numerical order of the cvpdRecords
+ * and cvpdKeywords structures.
+ */
+ void testCvpdCheckStructOrder ( void )
+ {
+ uint64_t fails = 0x0;
+ IpVpdFacade::ipVpdRecord prevRecord = CVPD::CVPD_FIRST_RECORD;
+ IpVpdFacade::ipVpdKeyword prevKeyword = CVPD::CVPD_FIRST_KEYWORD;
+
+ TRACFCOMP( g_trac_vpd,
+ ENTER_MRK"testCvpdCheckStructOrder()" );
+
+ // Check the cvpdRecords structure for proper order
+ uint32_t entry = 0x0;
+ for( entry = 0;
+ entry < (sizeof(CVPD::cvpdRecords)/
+ sizeof(CVPD::cvpdRecords[0]));
+ entry++ )
+ {
+ if( !(CVPD::cvpdRecords[entry].record >= prevRecord) )
+ {
+ fails++;
+ TS_FAIL( "testCvpdCheckStructOrder() - Record table out of "
+ "order! Cur Record: 0x%04x, Prev Record: 0x%04x",
+ CVPD::cvpdRecords[entry].record,
+ prevRecord );
+ }
+ prevRecord = CVPD::cvpdRecords[entry].record;
+ }
+
+ // Check the cvpdKeywords structure for proper order
+ for( entry = 0;
+ entry < (sizeof(CVPD::cvpdKeywords)/
+ sizeof(CVPD::cvpdKeywords[0]));
+ entry++ )
+ {
+ if( !(CVPD::cvpdKeywords[entry].keyword >= prevKeyword) )
+ {
+ fails++;
+ TS_FAIL( "testCvpdCheckStructOrder() - Keyword table out of order! Cur Keyword: 0x%04x, Prev Keyword: 0x%04x",
+ CVPD::cvpdKeywords[entry].keyword,
+ prevKeyword );
+ }
+ prevKeyword = CVPD::cvpdKeywords[entry].keyword;
+ }
+
+ TRACFCOMP( g_trac_vpd,
+ "testCvpdCheckStructOrder - %d fails",
+ fails );
+ }
+};
+
+#endif
diff --git a/src/usr/vpd/test/mvpdtest.H b/src/usr/vpd/test/mvpdtest.H
index a7685550e..94faefc58 100755
--- a/src/usr/vpd/test/mvpdtest.H
+++ b/src/usr/vpd/test/mvpdtest.H
@@ -39,20 +39,20 @@
#include <vpd/mvpdenums.H>
#include <vpd/vpdreasoncodes.H>
#include "../mvpd.H"
+#include "../ipvpd.H"
-extern trace_desc_t* g_trac_mvpd;
+extern trace_desc_t* g_trac_vpd;
using namespace TARGETING;
-using namespace MVPD;
/**
* @brief Structure to define record/keyword pairs for MVPD tests.
*/
struct mvpdTestData
{
- mvpdRecord record;
- mvpdKeyword keyword;
+ IpVpdFacade::ipVpdRecord record;
+ IpVpdFacade::ipVpdRecord keyword;
};
/**
@@ -62,157 +62,158 @@ struct mvpdTestData
*/
mvpdTestData mvpdData[] =
{
- { CRP0, VD },
- { CRP0, ED },
- { CRP0, TE },
- { CRP0, DD },
-// { CRP0, pdP }, // TODO - no #P in test data
- { CRP0, ST },
- { CP00, VD },
- { CP00, PG },
-// { CP00, PK }, // TODO - no PK in test data
- { CP00, pdR },
- { CP00, pdG },
- { CP00, pdV },
- { CP00, pdH },
-// { CP00, pdP }, // TODO - no #P in test data
- { CP00, SB },
- { CP00, MK },
- { CP00, PB },
- { LRP4, VD },
- { LRP4, pdV },
- { LRP4, pdP },
- { LRP4, pdM },
- { LRP4, CH },
- { LRP5, VD },
- { LRP5, pdV },
- { LRP5, pdP },
- { LRP5, pdM },
- { LRP5, CH },
- { LRP6, VD },
- { LRP6, pdV },
- { LRP6, pdP },
- { LRP6, pdM },
- { LRP6, CH },
-/* // TODO no LRP7,LRP8,LRP9,LRPA,LRPB,LWPO,LWP1,LWP2,LWP3 in test data
- { LRP7, VD },
- { LRP7, pdV },
- { LRP7, pdP },
- { LRP7, pdM },
- { LRP7, CH },
- { LRP8, VD },
- { LRP8, pdV },
- { LRP8, pdP },
- { LRP8, pdM },
- { LRP8, CH },
- { LRP9, VD },
- { LRP9, pdV },
- { LRP9, pdP },
- { LRP9, pdM },
- { LRP9, CH },
- { LRPA, VD },
- { LRPA, pdV },
- { LRPA, pdP },
- { LRPA, pdM },
- { LRPA, CH },
- { LRPB, VD },
- { LRPB, pdV },
- { LRPB, pdP },
- { LRPB, pdM },
- { LRPB, CH },
- { LRPC, VD },
- { LRPC, pdV },
- { LRPC, pdP },
- { LRPC, pdM },
- { LRPC, CH },
- { LRPD, VD },
- { LRPD, pdV },
- { LRPD, pdP },
- { LRPD, pdM },
- { LRPD, CH },
- { LRPE, VD },
- { LRPE, pdV },
- { LRPE, pdP },
- { LRPE, pdM },
- { LRPE, CH },
- { LWP0, VD },
- { LWP0, pd2 },
- { LWP0, pd3 },
- { LWP0, IN },
- { LWP1, VD },
- { LWP1, pd2 },
- { LWP1, pd3 },
- { LWP1, IN },
- { LWP2, VD },
- { LWP2, pd2 },
- { LWP2, pd3 },
- { LWP2, IN },
- { LWP3, VD },
- { LWP3, pd2 },
- { LWP3, pd3 },
- { LWP3, IN },
-*/
- { LWP4, VD },
- { LWP4, pd2 },
- { LWP4, pd3 },
- { LWP4, IN },
- { LWP5, VD },
- { LWP5, pd2 },
- { LWP5, pd3 },
- { LWP5, IN },
- { LWP6, VD },
- { LWP6, pd2 },
- { LWP6, pd3 },
- { LWP6, IN },
-/* // TODO no LWP7,LWP8,LWP9,LWPA,LWPB in test data
- { LWP7, VD },
- { LWP7, pd2 },
- { LWP7, pd3 },
- { LWP7, IN },
- { LWP8, VD },
- { LWP8, pd2 },
- { LWP8, pd3 },
- { LWP8, IN },
- { LWP9, VD },
- { LWP9, pd2 },
- { LWP9, pd3 },
- { LWP9, IN },
- { LWPA, VD },
- { LWPA, pd2 },
- { LWPA, pd3 },
- { LWPA, IN },
- { LWPB, VD },
- { LWPB, pd2 },
- { LWPB, pd3 },
- { LWPB, IN },
- { LWPC, VD },
- { LWPC, pd2 },
- { LWPC, pd3 },
- { LWPC, IN },
- { LWPD, VD },
- { LWPD, pd2 },
- { LWPD, pd3 },
- { LWPD, IN },
- { LWPE, VD },
- { LWPE, pd2 },
- { LWPE, pd3 },
- { LWPE, IN },
-*/
- { VINI, DR },
- { VINI, VZ },
- { VINI, CC },
- { VINI, CE },
- { VINI, FN },
- { VINI, PN },
- { VINI, SN },
- { VINI, PR },
- { VINI, HE },
- { VINI, CT },
- { VINI, HW },
-
- { VWML, pdI },
-
- { MER0, pdI },
+ { MVPD::CRP0, MVPD::VD },
+ { MVPD::CRP0, MVPD::ED },
+ { MVPD::CRP0, MVPD::TE },
+ { MVPD::CRP0, MVPD::DD },
+ //{ MVPD::CRP0, pdP }, // no #P in test data
+ { MVPD::CRP0, MVPD::ST },
+ { MVPD::CP00, MVPD::VD },
+ { MVPD::CP00, MVPD::PG },
+ // { MVPD::CP00, MVPD::PK }, // no PK in test data
+ { MVPD::CP00, MVPD::pdR },
+ { MVPD::CP00, MVPD::pdG },
+ { MVPD::CP00, MVPD::pdV },
+ { MVPD::CP00, MVPD::pdH },
+ // { MVPD::CP00, pdP }, // no #P in test data
+ { MVPD::CP00, MVPD::SB },
+ { MVPD::CP00, MVPD::MK },
+ { MVPD::CP00, MVPD::PB },
+ { MVPD::LRP4, MVPD::VD },
+ { MVPD::LRP4, MVPD::pdV },
+ { MVPD::LRP4, MVPD::pdP },
+ { MVPD::LRP4, MVPD::pdM },
+ { MVPD::LRP4, MVPD::CH },
+ { MVPD::LRP5, MVPD::VD },
+ { MVPD::LRP5, MVPD::pdV },
+ { MVPD::LRP5, MVPD::pdP },
+ { MVPD::LRP5, MVPD::pdM },
+ { MVPD::LRP5, MVPD::CH },
+ { MVPD::LRP6, MVPD::VD },
+ { MVPD::LRP6, MVPD::pdV },
+ { MVPD::LRP6, MVPD::pdP },
+ { MVPD::LRP6, MVPD::pdM },
+ { MVPD::LRP6, MVPD::CH },
+ /* // no LRP7,LRP8,LRP9,LRPA,LRPB,LWPO,LWP1,LWP2,LWP3
+ in test data
+ { MVPD::LRP7, VD },
+ { MVPD::LRP7, MVPD::pdV },
+ { MVPD::LRP7, MVPD::pdP },
+ { MVPD::LRP7, MVPD::pdM },
+ { MVPD::LRP7, MVPD::CH },
+ { MVPD::LRP8, MVPD::VD },
+ { MVPD::LRP8, MVPD::pdV },
+ { MVPD::LRP8, MVPD::pdP },
+ { MVPD::LRP8, MVPD::pdM },
+ { MVPD::LRP8, MVPD::CH },
+ { MVPD::LRP9, MVPD::VD },
+ { MVPD::LRP9, MVPD::pdV },
+ { MVPD::LRP9, MVPD::pdP },
+ { MVPD::LRP9, MVPD::pdM },
+ { MVPD::LRP9, MVPD::CH },
+ { MVPD::LRPA, MVPD::VD },
+ { MVPD::LRPA, MVPD::pdV },
+ { MVPD::LRPA, MVPD::pdP },
+ { MVPD::LRPA, MVPD::pdM },
+ { MVPD::LRPA, MVPD::CH },
+ { MVPD::LRPB, MVPD::VD },
+ { MVPD::LRPB, MVPD::pdV },
+ { MVPD::LRPB, MVPD::pdP },
+ { MVPD::LRPB, MVPD::pdM },
+ { MVPD::LRPB, MVPD::CH },
+ { MVPD::LRPC, MVPD::VD },
+ { MVPD::LRPC, MVPD::pdV },
+ { MVPD::LRPC, MVPD::pdP },
+ { MVPD::LRPC, MVPD::pdM },
+ { MVPD::LRPC, MVPD::CH },
+ { MVPD::LRPD, MVPD::VD },
+ { MVPD::LRPD, MVPD::pdV },
+ { MVPD::LRPD, MVPD::pdP },
+ { MVPD::LRPD, MVPD::pdM },
+ { MVPD::LRPD, MVPD::CH },
+ { MVPD::LRPE, MVPD::VD },
+ { MVPD::LRPE, MVPD::pdV },
+ { MVPD::LRPE, MVPD::pdP },
+ { MVPD::LRPE, MVPD::pdM },
+ { MVPD::LRPE, MVPD::CH },
+ { MVPD::LWP0, MVPD::VD },
+ { MVPD::LWP0, MVPD::pd2 },
+ { MVPD::LWP0, MVPD::pd3 },
+ { MVPD::LWP0, MVPD::IN },
+ { MVPD::LWP1, MVPD::VD },
+ { MVPD::LWP1, MVPD::pd2 },
+ { MVPD::LWP1, MVPD::pd3 },
+ { MVPD::LWP1, MVPD::IN },
+ { MVPD::LWP2, MVPD::VD },
+ { MVPD::LWP2, MVPD::pd2 },
+ { MVPD::LWP2, MVPD::pd3 },
+ { MVPD::LWP2, MVPD::IN },
+ { MVPD::LWP3, MVPD::VD },
+ { MVPD::LWP3, MVPD::pd2 },
+ { MVPD::LWP3, MVPD::pd3 },
+ { MVPD::LWP3, MVPD::IN },
+ */
+ { MVPD::LWP4, MVPD::VD },
+ { MVPD::LWP4, MVPD::pd2 },
+ { MVPD::LWP4, MVPD::pd3 },
+ { MVPD::LWP4, MVPD::IN },
+ { MVPD::LWP5, MVPD::VD },
+ { MVPD::LWP5, MVPD::pd2 },
+ { MVPD::LWP5, MVPD::pd3 },
+ { MVPD::LWP5, MVPD::IN },
+ { MVPD::LWP6, MVPD::VD },
+ { MVPD::LWP6, MVPD::pd2 },
+ { MVPD::LWP6, MVPD::pd3 },
+ { MVPD::LWP6, MVPD::IN },
+ /* // no LWP7,LWP8,LWP9,LWPA,LWPB in test data
+ { MVPD::LWP7, MVPD::VD },
+ { MVPD::LWP7, MVPD::pd2 },
+ { MVPD::LWP7, MVPD::pd3 },
+ { MVPD::LWP7, MVPD::IN },
+ { MVPD::LWP8, MVPD::VD },
+ { MVPD::LWP8, MVPD::pd2 },
+ { MVPD::LWP8, MVPD::pd3 },
+ { MVPD::LWP8, MVPD::IN },
+ { MVPD::LWP9, MVPD::VD },
+ { MVPD::LWP9, MVPD::pd2 },
+ { MVPD::LWP9, MVPD::pd3 },
+ { MVPD::LWP9, MVPD::IN },
+ { MVPD::LWPA, MVPD::VD },
+ { MVPD::LWPA, MVPD::pd2 },
+ { MVPD::LWPA, MVPD::pd3 },
+ { MVPD::LWPA, MVPD::IN },
+ { MVPD::LWPB, MVPD::VD },
+ { MVPD::LWPB, MVPD::pd2 },
+ { MVPD::LWPB, MVPD::pd3 },
+ { MVPD::LWPB, MVPD::IN },
+ { MVPD::LWPC, MVPD::VD },
+ { MVPD::LWPC, MVPD::pd2 },
+ { MVPD::LWPC, MVPD::pd3 },
+ { MVPD::LWPC, MVPD::IN },
+ { MVPD::LWPD, MVPD::VD },
+ { MVPD::LWPD, MVPD::pd2 },
+ { MVPD::LWPD, MVPD::pd3 },
+ { MVPD::LWPD, MVPD::IN },
+ { MVPD::LWPE, MVPD::VD },
+ { MVPD::LWPE, MVPD::pd2 },
+ { MVPD::LWPE, MVPD::pd3 },
+ { MVPD::LWPE, MVPD::IN },
+ */
+ { MVPD::VINI, MVPD::DR },
+ { MVPD::VINI, MVPD::VZ },
+ { MVPD::VINI, MVPD::CC },
+ { MVPD::VINI, MVPD::CE },
+ { MVPD::VINI, MVPD::FN },
+ { MVPD::VINI, MVPD::PN },
+ { MVPD::VINI, MVPD::SN },
+ { MVPD::VINI, MVPD::PR },
+ { MVPD::VINI, MVPD::HE },
+ { MVPD::VINI, MVPD::CT },
+ { MVPD::VINI, MVPD::HW },
+
+ { MVPD::VWML, MVPD::pdI },
+
+ { MVPD::MER0, MVPD::pdI },
};
void getProcTargets( TargetHandleList & o_procList )
@@ -232,17 +233,50 @@ void getProcTargets( TargetHandleList & o_procList )
TARGETING::TargetService::ALL,
&predProc );
- TRACDCOMP( g_trac_mvpd,
+ TRACDCOMP( g_trac_vpd,
"getProcTargets() - found %d Processors",
o_procList.size() );
return;
}
+TARGETING::Target* getFunctionalProcTarget()
+{
+ TARGETING::Target * theTarget = NULL;
+ TRACDCOMP( g_trac_vpd,
+ "getFunctionalProcTarget() - Finding a processor" );
+
+ do {
+ // Get the Processor targets
+ TargetHandleList procList;
+ getProcTargets( procList );
+
+ if( ( 0 == procList.size() ) ||
+ ( NULL == procList[0] ) )
+ {
+ continue; // add continue because have no Proc targets
+ }
+
+ for(uint32_t i=0; i<procList.size(); i++)
+ {
+ if(procList[i]->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ {
+ theTarget = procList[i];
+ break;
+ }
+ }
+ }while(0);
+
+ return theTarget;
+
+}
+
+
class MVPDTest: public CxxTest::TestSuite
{
public:
+
/**
* @brief This function will test MVPD reads.
*/
@@ -254,38 +288,16 @@ class MVPDTest: public CxxTest::TestSuite
uint64_t theRecord = 0x0;
uint64_t theKeyword = 0x0;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdRead()" );
do
{
- TARGETING::Target * theTarget = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
- TRACFCOMP( g_trac_mvpd,
- "testMvpdRead() - No Proc Targets found!" );
-
- continue; // add continue because have no proc targets
- }
-
- // Use the first Proc in the list
- theTarget = procList[0];
-
- // check to see if the target is functional
- if
- (!theTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
- {
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdRead() - Proc Target [0] non functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdRead() - No Functional Targets found!");
+ break;
}
uint8_t * theData = NULL;
@@ -305,12 +317,12 @@ class MVPDTest: public CxxTest::TestSuite
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdRead() - failure reading "
"keyword size!! rec: 0x%04x, kwd: 0x%04x",
theRecord,
theKeyword );
- TS_FAIL( "testMvpdRead() - Failure reading keyword size!" );
+ TS_FAIL("testMvpdRead() -Failure reading keyword size!");
errlCommit( err,
VPD_COMP_ID );
continue;
@@ -328,7 +340,7 @@ class MVPDTest: public CxxTest::TestSuite
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdRead() - Failure on Record: "
"0x%04x, keyword: 0x%04x, of size: 0x%04x "
"- test %d",
@@ -348,11 +360,11 @@ class MVPDTest: public CxxTest::TestSuite
continue;
}
- TRACDCOMP( g_trac_mvpd,
+ TRACDCOMP( g_trac_vpd,
INFO_MRK"testMvpdRead Results:" );
for( uint32_t i = 0; i < theSize; i++ )
{
- TRACDCOMP( g_trac_mvpd,
+ TRACDCOMP( g_trac_vpd,
INFO_MRK" Byte[%d]: 0x%02x",
i, theData[i] );
}
@@ -366,7 +378,7 @@ class MVPDTest: public CxxTest::TestSuite
}
} while( 0 );
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdRead - %d/%d fails",
fails, cmds );
}
@@ -383,50 +395,29 @@ class MVPDTest: public CxxTest::TestSuite
uint8_t* origData = NULL;
uint8_t* verifyData = NULL;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdWrite()" );
do
{
- TARGETING::Target * theTgt = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
- {
- TRACFCOMP( g_trac_mvpd,
- "testMvpdWrite() - No Proc Targets found!" );
-
- continue; // no proc targets.
- }
-
- // Use the first Proc in the list
- theTgt = procList[0];
-
- // check to see if the target is functional
- if(!theTgt->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdWrite() - Proc Target [0] non functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdWrite() - No Functional Targets found!");
+ break;
}
// first figure out how big the keyword is
cmds++;
size_t theSize = 0;
- err = deviceRead( theTgt,
+ err = deviceRead( theTarget,
testData,
theSize,
- DEVICE_MVPD_ADDRESS(VWML,pdI) );
+ DEVICE_MVPD_ADDRESS(MVPD::VWML,MVPD::pdI) );
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdWrite() - failure getting size of VWML/#I, RC=%.4X",
err->reasonCode() );
TS_FAIL( "testMvpdWrite() - Failure calling deviceRead!" );
@@ -438,14 +429,14 @@ class MVPDTest: public CxxTest::TestSuite
// save off the original data
origData = new uint8_t[theSize];
cmds++;
- err = deviceRead( theTgt,
+ err = deviceRead( theTarget,
origData,
theSize,
- DEVICE_MVPD_ADDRESS(VWML,pdI) );
+ DEVICE_MVPD_ADDRESS(MVPD::VWML,MVPD::pdI) );
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdWrite() - failure reading VWML/#I, RC=%.4X",
err->reasonCode() );
TS_FAIL( "testMvpdWrite() - Failure calling deviceRead!" );
@@ -453,7 +444,8 @@ class MVPDTest: public CxxTest::TestSuite
VPD_COMP_ID );
continue;
}
- TRACFBIN( g_trac_mvpd, "orig=", origData, theSize );
+ TRACFBIN( g_trac_vpd, "testMvpdWrite() - orig=",
+ origData, theSize );
// fill it up with some dummy data
testData = new uint8_t[theSize];
@@ -464,14 +456,14 @@ class MVPDTest: public CxxTest::TestSuite
// write the new data in
cmds++;
- err = deviceWrite( theTgt,
+ err = deviceWrite( theTarget,
testData,
theSize,
- DEVICE_MVPD_ADDRESS(VWML,pdI) );
+ DEVICE_MVPD_ADDRESS(MVPD::VWML,MVPD::pdI) );
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdWrite() - failure writing VWML/#I, RC=%.4X",
err->reasonCode() );
TS_FAIL( "testMvpdWrite() - Failure calling deviceWrite!" );
@@ -483,14 +475,14 @@ class MVPDTest: public CxxTest::TestSuite
// verify the data got written
cmds++;
verifyData = new uint8_t[theSize];
- err = deviceRead( theTgt,
+ err = deviceRead( theTarget,
verifyData,
theSize,
- DEVICE_MVPD_ADDRESS(VWML,pdI) );
+ DEVICE_MVPD_ADDRESS(MVPD::VWML,MVPD::pdI) );
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdWrite() - failure reading VWML/#I to verify, RC=%.4X",
err->reasonCode() );
TS_FAIL( "testMvpdWrite() - Failure calling deviceRead!" );
@@ -498,27 +490,30 @@ class MVPDTest: public CxxTest::TestSuite
VPD_COMP_ID );
continue;
}
- TRACFBIN( g_trac_mvpd, "verif=", verifyData, theSize );
+ TRACFBIN( g_trac_vpd, "testMvpdWrite() - verif=",
+ verifyData, theSize );
// compare what we read to what we wrote
if( memcmp( testData, verifyData, theSize ) )
{
fails++;
- TRACFBIN( g_trac_mvpd, "wrote=", testData, theSize );
- TRACFBIN( g_trac_mvpd, "read=", verifyData, theSize );
+ TRACFBIN( g_trac_vpd, "testMvpdWrite() - wrote=",
+ testData, theSize );
+ TRACFBIN( g_trac_vpd, "testMvpdWrite() - read=",
+ verifyData, theSize );
TS_FAIL( "testMvpdWrite - Data mismatch!" );
}
// put the original data back to be a good citizen
cmds++;
- err = deviceWrite( theTgt,
+ err = deviceWrite( theTarget,
origData,
theSize,
- DEVICE_MVPD_ADDRESS(VWML,pdI) );
+ DEVICE_MVPD_ADDRESS(MVPD::VWML,MVPD::pdI) );
if( err )
{
fails++;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ERR_MRK"testMvpdWrite() - failure writing original data back into VWML/#I, RC=%.4X",
err->reasonCode() );
TS_FAIL( "testMvpdWrite() - Failure calling deviceRead!" );
@@ -552,15 +547,15 @@ class MVPDTest: public CxxTest::TestSuite
TS_FAIL( "testMvpdWrite - No tests ran, something is wrong..." );
}
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdWrite - %d/%d fails",
fails, cmds );
}
/**
- * @brief This function will test that an error is generated when a record
- * is passed in that cannot be found in the structure that defines the
- * Records string representation.
+ * @brief This function will test that an error is generated when a
+ * record is passed in that cannot be found in the structure
+ * that defines the Records string representation.
*/
void testMvpdInvalidRecord ( void )
{
@@ -568,40 +563,16 @@ class MVPDTest: public CxxTest::TestSuite
uint64_t cmds = 0x0;
uint64_t fails = 0x0;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdInvalidRecord()" );
do
{
- TARGETING::Target * theTarget = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
- {
- TRACFCOMP( g_trac_mvpd,
- "testMvpdInvalidRecord() - No Proc Targets "
- "found!" );
-
- continue;
- }
-
- // Use the first Proc in the list
- theTarget = procList[0];
-
- // check to see if the target is functional
- if
- (!theTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdInvalidRecord() - Proc Target [0] non "
- "functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdInvalidRecord() - No Functional Targets found!");
+ break;
}
size_t theSize = 1;
@@ -611,8 +582,8 @@ class MVPDTest: public CxxTest::TestSuite
err = deviceRead( theTarget,
theData,
theSize,
- DEVICE_MVPD_ADDRESS( MVPD_LAST_RECORD,
- pdP ) );
+ DEVICE_MVPD_ADDRESS( MVPD::MVPD_LAST_RECORD,
+ MVPD::pdP ) );
if( NULL == err )
{
@@ -620,7 +591,7 @@ class MVPDTest: public CxxTest::TestSuite
TS_FAIL( "testMvpdInvalidRecord() - Error expected with "
"record of type MVPD_LAST_RECORD (0x%04x), but "
"no error returned!",
- MVPD_LAST_RECORD );
+ MVPD::MVPD_LAST_RECORD );
}
else
{
@@ -635,14 +606,14 @@ class MVPDTest: public CxxTest::TestSuite
}
} while( 0 );
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdInvalidRecord - %d/%d fails",
fails, cmds );
}
/**
- * @brief This function will test for a record which is not in the TOC of
- * the MVPD area.
+ * @brief This function will test for a record which is not in the TOC
+ * of the MVPD area.
*/
void testMvpdMissingRecord ( void )
{
@@ -650,40 +621,16 @@ class MVPDTest: public CxxTest::TestSuite
uint64_t cmds = 0x0;
uint64_t fails = 0x0;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdMissingRecord()" );
do
{
- TARGETING::Target * theTarget = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
- {
- TRACFCOMP( g_trac_mvpd,
-
- "testMvpdMissingRecord() - No Proc Targets found!" );
-
- continue;
- }
-
- // Use the first Proc in the list
- theTarget = procList[0];
-
- // check to see if the target is functional
- if
- (!theTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdMissingRecord() - Proc Target [0] "
- "non functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdMissingRecord() - No Functional Targets found!");
+ break;
}
size_t theSize = 1;
@@ -693,8 +640,8 @@ class MVPDTest: public CxxTest::TestSuite
err = deviceRead( theTarget,
theData,
theSize,
- DEVICE_MVPD_ADDRESS( MVPD_TEST_RECORD,
- pdP ) );
+ DEVICE_MVPD_ADDRESS( MVPD::MVPD_TEST_RECORD,
+ MVPD::pdP ) );
if( NULL == err )
{
@@ -714,7 +661,7 @@ class MVPDTest: public CxxTest::TestSuite
}
} while( 0 );
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdMissingRecord - %d/%d fails",
fails, cmds );
}
@@ -729,57 +676,33 @@ class MVPDTest: public CxxTest::TestSuite
uint64_t cmds = 0x0;
uint64_t fails = 0x0;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdMissingKeyword()" );
do
{
- TARGETING::Target * theTarget = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
- {
- TRACFCOMP( g_trac_mvpd,
-
- "testMvpdMissingKeyword() - No Proc Targets found!" );
-
- continue;
- }
-
- // Use the first Proc in the list
- theTarget = procList[0];
-
- // check to see if the target is functional
- if
- (!theTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdMissingKeyword() - Proc Target [0] "
- "non functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdMissingKeyword() - No Functional Targets found!");
+ break;
}
size_t theSize = 1;
uint8_t * theData = new uint8_t[theSize];
cmds++;
- err = deviceRead( theTarget,
- theData,
- theSize,
- DEVICE_MVPD_ADDRESS( MVPD_FIRST_RECORD,
- MVPD_TEST_KEYWORD ) );
+ err = deviceRead(theTarget,
+ theData,
+ theSize,
+ DEVICE_MVPD_ADDRESS(MVPD::MVPD_FIRST_RECORD,
+ MVPD::MVPD_TEST_KEYWORD));
if( NULL == err )
{
fails++;
- TS_FAIL( "testMvpdMissingKeyword() - Expected error from "
- "invalid Keyword missing from associated record!" );
+ TS_FAIL("testMvpdMissingKeyword() - Expected error from "
+ "invalid Keyword missing from associated record!");
}
else
{
@@ -794,15 +717,15 @@ class MVPDTest: public CxxTest::TestSuite
}
} while( 0 );
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdMissingKeyword - %d/%d fails",
fails, cmds );
}
/**
- * @brief This function will test that an error is generated when a keyword
- * is passed in that cannot be found in the structure that defines the
- * Keywords string representation.
+ * @brief This function will test that an error is generated when a
+ * keyword is passed in that cannot be found in the structure
+ * that defines the Keywords string representation.
*/
void testMvpdInvalidKeyword ( void )
{
@@ -810,51 +733,27 @@ class MVPDTest: public CxxTest::TestSuite
uint64_t cmds = 0x0;
uint64_t fails = 0x0;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdInvalidKeyword()" );
do
{
- TARGETING::Target * theTarget = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
- {
- TRACFCOMP( g_trac_mvpd,
-
- "testMvpdInvalidKeyword() - No Proc Targets found!" );
-
- continue;
- }
-
- // Use the first Proc in the list
- theTarget = procList[0];
-
- // check to see if the target is functional
- if
- (!theTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdInvalidKeyword() - Proc Target [0] "
- "non functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdInvalidKeyword() - No Functional Targets found!");
+ break;
}
size_t theSize = 1;
uint8_t * theData = new uint8_t[theSize];
cmds++;
- err = deviceRead( theTarget,
- theData,
- theSize,
- DEVICE_MVPD_ADDRESS( CRP0,
- MVPD_LAST_KEYWORD ) );
+ err = deviceRead(theTarget,
+ theData,
+ theSize,
+ DEVICE_MVPD_ADDRESS(MVPD::CRP0,
+ MVPD::MVPD_LAST_KEYWORD));
if( NULL == err )
{
@@ -862,7 +761,7 @@ class MVPDTest: public CxxTest::TestSuite
TS_FAIL( "testMvpdInvalidKeyword() - Error expected with "
"keyword of type MVPD_LAST_KEYWORD (0x%04x), but "
"no error returned!",
- MVPD_LAST_KEYWORD );
+ MVPD::MVPD_LAST_KEYWORD );
}
else
{
@@ -877,14 +776,15 @@ class MVPDTest: public CxxTest::TestSuite
}
} while( 0 );
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdInvalidKeyword - %d/%d fails",
fails, cmds );
}
/**
- * @brief This function will test that an error is generated when a buffer
- * that has an insufficient size is passed in to read a record/keyword.
+ * @brief This function will test that an error is generated when a
+ * buffer that has an insufficient size is passed in to read a
+ * record/keyword.
*/
void testMvpdInvalidBufferSize ( void )
{
@@ -892,40 +792,16 @@ class MVPDTest: public CxxTest::TestSuite
uint64_t cmds = 0x0;
uint64_t fails = 0x0;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdInvalidBufferSize()" );
do
{
- TARGETING::Target * theTarget = NULL;
-
- // Get the processor targets
- TargetHandleList procList;
- getProcTargets( procList );
-
- if( ( 0 == procList.size() ) ||
- ( NULL == procList[0] ) )
+ TARGETING::Target * theTarget = getFunctionalProcTarget();
+ if(theTarget == NULL)
{
- TRACFCOMP( g_trac_mvpd,
- "testMvpdInvalidBufferSize() - No Proc Targets "
- "found!" );
-
- continue;
- }
-
- // Use the first Proc in the list
- theTarget = procList[0];
-
- // check to see if the target is functional
- if
- (!theTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional)
- {
-
- TRACFCOMP( g_trac_mvpd,
- "testMvpdInvalidBufferSize() - Proc Target [0] "
- "non functional!" );
-
- continue; // add continue because target is non functional
+ TS_FAIL("testMvpdInvalidBufferSize() - No Functional Targets found!");
+ break;
}
uint8_t * theData = new uint8_t[1];
@@ -935,8 +811,8 @@ class MVPDTest: public CxxTest::TestSuite
err = deviceRead( theTarget,
theData,
theSize,
- DEVICE_MVPD_ADDRESS( CRP0,
- DD ) );
+ DEVICE_MVPD_ADDRESS( MVPD::CRP0,
+ MVPD::DD ) );
if( NULL == err )
{
@@ -957,7 +833,7 @@ class MVPDTest: public CxxTest::TestSuite
}
} while( 0 );
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdInvalidBufferSize - %d/%d fails",
fails, cmds );
}
@@ -969,50 +845,51 @@ class MVPDTest: public CxxTest::TestSuite
void testMvpdCheckStructOrder ( void )
{
uint64_t fails = 0x0;
- mvpdRecord prevRecord = MVPD_FIRST_RECORD;
- mvpdKeyword prevKeyword = MVPD_FIRST_KEYWORD;
+ IpVpdFacade::ipVpdRecord prevRecord = MVPD::MVPD_FIRST_RECORD;
+ IpVpdFacade::ipVpdKeyword prevKeyword = MVPD::MVPD_FIRST_KEYWORD;
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
ENTER_MRK"testMvpdCheckStructOrder()" );
// Check the mvpdRecords structure for proper order
uint32_t entry = 0x0;
for( entry = 0;
- entry < (sizeof(mvpdRecords)/sizeof(mvpdRecords[0]));
+ entry < (sizeof(MVPD::mvpdRecords)/
+ sizeof(MVPD::mvpdRecords[0]));
entry++ )
{
- if( !(mvpdRecords[entry].record >= prevRecord) )
+ if( !(MVPD::mvpdRecords[entry].record >= prevRecord) )
{
fails++;
TS_FAIL( "testMvpdCheckStructOrder() - Record table out of "
"order! Cur Record: 0x%04x, Prev Record: 0x%04x",
- mvpdRecords[entry].record,
+ MVPD::mvpdRecords[entry].record,
prevRecord );
}
- prevRecord = mvpdRecords[entry].record;
+ prevRecord = MVPD::mvpdRecords[entry].record;
}
// Check the mvpdKeywords structure for proper order
for( entry = 0;
- entry < (sizeof(mvpdKeywords)/sizeof(mvpdKeywords[0]));
+ entry < (sizeof(MVPD::mvpdKeywords)/\
+ sizeof(MVPD::mvpdKeywords[0]));
entry++ )
{
- if( !(mvpdKeywords[entry].keyword >= prevKeyword) )
+ if( !(MVPD::mvpdKeywords[entry].keyword >= prevKeyword) )
{
fails++;
- TS_FAIL( "testMvpdCheckStructOrder() - Keyword table out of "
- "order! Cur Keyword: 0x%04x, Prev Keyword: 0x%04x",
- mvpdKeywords[entry].keyword,
- prevKeyword );
+ TS_FAIL("testMvpdCheckStructOrder() - Keyword table out of "
+ "order! Cur Keyword: 0x%04x, Prev Keyword: 0x%04x",
+ MVPD::mvpdKeywords[entry].keyword,
+ prevKeyword );
}
- prevKeyword = mvpdKeywords[entry].keyword;
+ prevKeyword = MVPD::mvpdKeywords[entry].keyword;
}
- TRACFCOMP( g_trac_mvpd,
+ TRACFCOMP( g_trac_vpd,
"testMvpdCheckStructOrder - %d fails",
fails );
}
-
};
#endif
diff --git a/src/usr/vpd/vpd.C b/src/usr/vpd/vpd.C
index 54fefa8b9..d610d4c1a 100644
--- a/src/usr/vpd/vpd.C
+++ b/src/usr/vpd/vpd.C
@@ -33,6 +33,13 @@
trace_desc_t* g_trac_vpd = NULL;
TRAC_INIT( & g_trac_vpd, "VPD", KILOBYTE );
+// ------------------------
+// Macros for unit testing
+//#define TRACUCOMP(args...) TRACFCOMP(args)
+#define TRACUCOMP(args...)
+//#define TRACSSCOMP(args...) TRACFCOMP(args)
+#define TRACSSCOMP(args...)
+
namespace VPD
{
@@ -44,15 +51,15 @@ errlHndl_t getVpdLocation ( int64_t & o_vpdLocation,
{
errlHndl_t err = NULL;
- TRACSSCOMP( g_trac_spd,
+ TRACSSCOMP( g_trac_vpd,
ENTER_MRK"getVpdLocation()" );
o_vpdLocation = i_target->getAttr<TARGETING::ATTR_VPD_REC_NUM>();
- TRACUCOMP( g_trac_spd,
+ TRACUCOMP( g_trac_vpd,
INFO_MRK"Using VPD location: %d",
o_vpdLocation );
- TRACSSCOMP( g_trac_spd,
+ TRACSSCOMP( g_trac_vpd,
EXIT_MRK"getVpdLocation()" );
return err;
@@ -267,7 +274,7 @@ errlHndl_t sendMboxWriteMsg ( size_t i_numBytes,
memcpy( msg->extra_data, i_data, i_numBytes );
TRACFCOMP( g_trac_vpd,
- INFO_MRK"Send msg to FSP to write VPD type %.8X, record %d, offset 0x%X",
+ INFO_MRK"sendMboxWriteMsg: Send msg to FSP to write VPD type %.8X, record %d, offset 0x%X",
i_type,
i_record.rec_num,
i_record.offset );
@@ -294,14 +301,6 @@ errlHndl_t sendMboxWriteMsg ( size_t i_numBytes,
{
l_err->collectTrace("SPD",1024);
}
- else if( VPD_WRITE_PROC == i_type )
- {
- l_err->collectTrace("MVPD",1024);
- }
- else if( VPD_WRITE_MEMBUF == i_type )
- {
- //l_err->collectTrace("CVPD",1024); @TODO-Fill in with RTC:44009
- }
// just commit the log and move on, nothing else to do
errlCommit( l_err, VPD_COMP_ID );
diff --git a/src/usr/vpd/vpd.H b/src/usr/vpd/vpd.H
index 20ff3d908..f35bf9eb9 100644
--- a/src/usr/vpd/vpd.H
+++ b/src/usr/vpd/vpd.H
@@ -25,13 +25,6 @@
#include <pnor/pnorif.H>
-// ------------------------
-// Macros for unit testing
-//#define TRACUCOMP(args...) TRACFCOMP(args)
-#define TRACUCOMP(args...)
-//#define TRACSSCOMP(args...) TRACFCOMP(args)
-#define TRACSSCOMP(args...)
-
namespace VPD
{
OpenPOWER on IntegriCloud