summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Schwartz <whs@us.ibm.com>2014-09-22 08:21:04 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2014-10-06 10:18:00 -0500
commit79ab9af6f2d2413c4154226e6dd5b99c00df2873 (patch)
tree7c0434989d1c5dbdd57437e6d721247942edb765
parent750cf6dfb94beb118c3618e2bd43af0314ed37fd (diff)
downloadtalos-hostboot-79ab9af6f2d2413c4154226e6dd5b99c00df2873.tar.gz
talos-hostboot-79ab9af6f2d2413c4154226e6dd5b99c00df2873.zip
Enable OCB channel communications
Port FSP hwcoOCC.C and hwsvTestSvcOCC_impl.C to provide ocb indirect access. Change-Id: I8d5a69feb26810e97a77f4970647af4ae6bbaad1 RTC: 115584 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13517 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
-rw-r--r--src/include/usr/hwpf/hwp/occ/occAccess.H74
-rw-r--r--src/include/usr/hwpf/hwpf_reasoncodes.H11
-rw-r--r--src/usr/hwpf/hwp/occ/makefile5
-rw-r--r--src/usr/hwpf/hwp/occ/occAccess.C292
-rw-r--r--src/usr/hwpf/test/makefile13
-rw-r--r--src/usr/hwpf/test/occAccessTest.H325
6 files changed, 711 insertions, 9 deletions
diff --git a/src/include/usr/hwpf/hwp/occ/occAccess.H b/src/include/usr/hwpf/hwp/occ/occAccess.H
new file mode 100644
index 000000000..b13f280af
--- /dev/null
+++ b/src/include/usr/hwpf/hwp/occ/occAccess.H
@@ -0,0 +1,74 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/usr/hwpf/hwp/occ/occAccess.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#ifndef OCCACCESS_H_
+#define OCCACCESS_H_
+
+#include <config.h>
+#include <errl/errlentry.H>
+#include <targeting/common/commontargeting.H>
+#include <fapi.H>
+
+#ifdef CONFIG_HTMGT
+namespace HBOCC
+{
+
+ /**
+ * @brief Read OCC SRAM
+ *
+ * @param[in] i_pTarget PROC or OCC target pointer
+ * @param[in] i_addr OCI Address to be used for the operation
+ * @param[in,out] io_dataBuf Reference to data buffer
+ * @return errlHndl_t Error log if operation failed
+ */
+ errlHndl_t readSRAM(const TARGETING::Target*i_pTarget,
+ const uint32_t i_addr,
+ ecmdDataBufferBase & io_dataBuf);
+
+ /**
+ * @brief Write OCC SRAM
+ *
+ * @param[in] i_pTarget PROC or OCC target pointer
+ * @param[in] i_addr OCI Address to be used for the operation
+ * @param[in] i_dataBuf Reference to data buffer
+ * @return errlHndl_t Error log if operation failed
+ */
+ errlHndl_t writeSRAM(const TARGETING::Target*i_pTarget,
+ const uint32_t i_addr,
+ ecmdDataBufferBase & io_dataBuf);
+
+ /**
+ * @brief Write OCC Circular Buffer
+ *
+ * @param[in] i_pTarget PROC or OCC target pointer
+ * @param[in] i_dataBuf Reference to data buffer
+ * @return errlHndl_t Error log if operation failed
+ */
+ errlHndl_t writeCircularBuffer(const TARGETING::Target*i_pTarget,
+ ecmdDataBufferBase & i_dataBuf);
+
+} //end OCC namespace
+#endif // CONFIG_HTMGT
+
+#endif
diff --git a/src/include/usr/hwpf/hwpf_reasoncodes.H b/src/include/usr/hwpf/hwpf_reasoncodes.H
index 24eb3ee33..344117d25 100644
--- a/src/include/usr/hwpf/hwpf_reasoncodes.H
+++ b/src/include/usr/hwpf/hwpf_reasoncodes.H
@@ -71,6 +71,8 @@ namespace fapi
MOD_ATTR_OVERRIDE = 0x1D,
MOD_PLAT_SPECIAL_WAKEUP = 0x1E,
MOD_PLAT_EN_VDDR = 0x1F,
+ MOD_GET_OCC_CHIP_TARGET = 0x20,
+ MOD_ACCESS_OCB_INDIRECT_CHANNEL = 0x21,
};
@@ -107,25 +109,22 @@ namespace fapi
RC_NO_SINGLE_MCS = HWPF_COMP_ID | 0x21,
RC_NO_SINGLE_MEMBUFF = HWPF_COMP_ID | 0x22,
RC_STATE_MISMATCH = HWPF_COMP_ID | 0x23,
-
- // OCC Errors
RC_MM_UNMAP_ERR = HWPF_COMP_ID | 0x24,
-
- // VDDR Errors
RC_VDDR_EMPTY_MSG = HWPF_COMP_ID | 0x25,
RC_VDDR_ERROR_MSG = HWPF_COMP_ID | 0x26,
RC_VDDR_POWR_ERR = HWPF_COMP_ID | 0x27,
RC_INCORRECT_MSG_TYPE = HWPF_COMP_ID | 0x28,
-
RC_NO_SINGLE_MBA = HWPF_COMP_ID | 0x29,
RC_HOST_TIMER_EXPIRED = HWPF_COMP_ID | 0x2A,
RC_HOST_TIMER_THREAD_FAIL = HWPF_COMP_ID | 0x2B,
RC_NULL_POINTER = HWPF_COMP_ID | 0x2C,
-
RC_RT_WAKEUP_FAILED = HWPF_COMP_ID | 0x2D,
RC_NO_MIRRORED_MEMORY = HWPF_COMP_ID | 0x2E,
RC_VDDR_INVALID_VOLTAGE = HWPF_COMP_ID | 0x2F,
RC_TIMEOUT_EN_VDDR = HWPF_COMP_ID | 0x30,
+ RC_TARGET_UNSUPPORTED = HWPF_COMP_ID | 0x31,
+ RC_INVALID_DATA_BUFFER_LENGTH = HWPF_COMP_ID | 0x32,
+
};
/**
diff --git a/src/usr/hwpf/hwp/occ/makefile b/src/usr/hwpf/hwp/occ/makefile
index bf8a1a951..306b142b3 100644
--- a/src/usr/hwpf/hwp/occ/makefile
+++ b/src/usr/hwpf/hwp/occ/makefile
@@ -5,7 +5,9 @@
#
# OpenPOWER HostBoot Project
#
-# COPYRIGHT International Business Machines Corp. 2013,2014
+# Contributors Listed Below - COPYRIGHT 2013,2014
+# [+] International Business Machines Corp.
+#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -28,6 +30,7 @@ SUBDIRS += runtime.d
## Objects unique to HB IPL
OBJS += occ.o
+OBJS += $(if $(CONFIG_HTMGT),occAccess.o)
## Objects common to HB IPL and HBRT
include occ.mk
diff --git a/src/usr/hwpf/hwp/occ/occAccess.C b/src/usr/hwpf/hwp/occ/occAccess.C
new file mode 100644
index 000000000..abbc00ebf
--- /dev/null
+++ b/src/usr/hwpf/hwp/occ/occAccess.C
@@ -0,0 +1,292 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/hwp/occ/occAccess.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+#include <stdint.h>
+
+#include <errl/errlentry.H>
+#include <occ/occAccess.H>
+#include <targeting/common/utilFilter.H>
+
+// Fapi
+#include <fapi.H>
+#include <fapiPlatHwpInvoker.H>
+#include <hwpf/hwpf_reasoncodes.H>
+
+// Procedures
+#include <p8_ocb_init.H>
+#include <p8_ocb_indir_setup_linear.H>
+#include <p8_ocb_indir_access.H>
+
+// Easy macro replace for unit testing
+//#define TRACUCOMP(args...) TRACFCOMP(args)
+#define TRACUCOMP(args...)
+
+namespace HBOCC
+{
+
+// Passed target should be either a PROC or an OCC target
+// If passed an OCC, then use it's parent PROC
+// If passed a PROC, then use it
+errlHndl_t getChipTarget(const TARGETING::Target* i_target,
+ TARGETING::Target* & o_pChipTarget)
+{
+ errlHndl_t l_errl = NULL;
+ TARGETING::TYPE l_type = TARGETING::TYPE_NA;
+ bool l_found = false; //error if no chip target found
+ uint32_t l_huid = 0xFFFFFFFF; //read for error FFDC
+
+ do
+ {
+ if(NULL == i_target) //unexpected error
+ {
+ TRACFCOMP( g_fapiTd, ERR_MRK"getChipTarget: null target passed");
+ break; // log and return error
+ }
+
+ l_type = i_target->getAttr<TARGETING::ATTR_TYPE> ();
+ if (TARGETING::TYPE_OCC == l_type) // if OCC, use parent PROC
+ {
+ const TARGETING::Target * l_pChipTarget = getParentChip(
+ const_cast<TARGETING::Target *>(i_target));
+ o_pChipTarget = const_cast<TARGETING::Target *>(l_pChipTarget);
+ if (NULL == o_pChipTarget)
+ {
+ l_huid = i_target->getAttr<TARGETING::ATTR_HUID>();
+ TRACFCOMP( g_fapiTd, ERR_MRK"getChipTarget:"
+ " Error OCC target has no parent"
+ " Target type: 0x%X huid:0x%X",
+ l_type, l_huid);
+ break; // log and return error
+ }
+ l_found = true;
+ }
+ else if (TARGETING::TYPE_PROC == l_type) //use passed PROC target
+ {
+ o_pChipTarget = const_cast<TARGETING::Target *>(i_target);
+ l_found = true;
+ }
+ else // unexpected target type
+ {
+ l_huid = i_target->getAttr<TARGETING::ATTR_HUID>();
+ TRACFCOMP( g_fapiTd, ERR_MRK"getChipTarget:"
+ " Error Unexpected target type. Not PROC or"
+ " OCC. Target is of type: 0x%X huid:0x%X",
+ l_type, l_huid);
+ break; // log and return error
+ }
+
+ }
+ while (0);
+
+ if (!l_found)
+ {
+ /*@
+ * @errortype
+ * @moduleid fapi::MOD_GET_OCC_CHIP_TARGET
+ * @reasoncode fapi::RC_TARGET_UNSUPPORTED
+ * @userdata1 Target Type
+ * @userdata2 Target HUID
+ * @devdesc PROC or OCC expected
+ * @custdesc A problem occurred during the IPL
+ * of the system.
+ */
+ const bool hbSwError = true;
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi::MOD_GET_OCC_CHIP_TARGET,
+ fapi::RC_TARGET_UNSUPPORTED,
+ l_type,
+ l_huid,
+ hbSwError);
+ }
+
+ return l_errl;
+}
+
+// common wrapper to p8_ocb_indir_access to access an OCB indirect channel
+enum accessOCBIndirectCmd
+{
+ ACCESS_OCB_READ_LINEAR,
+ ACCESS_OCB_WRITE_LINEAR,
+ ACCESS_OCB_WRITE_CIRCULAR,
+};
+
+errlHndl_t accessOCBIndirectChannel(accessOCBIndirectCmd i_cmd,
+ const TARGETING::Target * i_pTarget,
+ const uint32_t i_addr,
+ ecmdDataBufferBase & io_dataBuf)
+{
+ errlHndl_t l_errl = NULL;
+ uint32_t l_len = 0;
+ TARGETING::Target* l_pChipTarget = NULL;
+
+ uint32_t l_channel = OCB_CHAN0; // OCB channel (0,1,2,3)
+ uint32_t l_operation = OCB_GET; // Operation(Get, Put)
+ bool l_ociAddrValid = true; // use oci_address
+ bool l_setup=true; // set up linear
+
+ TRACUCOMP( g_fapiTd, ENTER_MRK"accessOCBIndirectChannel cmd=%d",i_cmd);
+
+ switch (i_cmd)
+ {
+ case (ACCESS_OCB_READ_LINEAR):
+ break; // use defaults
+ case (ACCESS_OCB_WRITE_LINEAR):
+ l_operation = OCB_PUT;
+ break;
+ case (ACCESS_OCB_WRITE_CIRCULAR):
+ l_channel = OCB_CHAN1;
+ l_operation = OCB_PUT;
+ l_ociAddrValid = false;
+ l_setup = false;
+ break;
+ }
+
+ TRACUCOMP( g_fapiTd, INFO_MRK"accessOCBIndirectChannel"
+ " channel=%d operation=%d addrValid=%d",
+ l_channel,l_operation,l_ociAddrValid);
+ do
+ {
+ l_errl = getChipTarget(i_pTarget,l_pChipTarget);
+ if (l_errl)
+ {
+ break; //exit with error
+ }
+ TRACUCOMP( g_fapiTd, INFO_MRK"accessOCBIndirectChannel:"
+ " target=%.8x type=%d",
+ get_huid(l_pChipTarget),
+ l_pChipTarget->getAttr<TARGETING::ATTR_TYPE>());
+
+ fapi::Target l_fapiTarget(fapi::TARGET_TYPE_PROC_CHIP,
+ reinterpret_cast<void *> (l_pChipTarget) );
+
+ // buffer must be multiple of bytes
+ if(io_dataBuf.getByteLength()%8 != 0)
+ {
+ TRACFCOMP( g_fapiImpTd, ERR_MRK"accessOCBIndirectChannel:"
+ " Error Improper data size:%d(in bytes),size of data"
+ " requested to be read is not aligned in size of 8 Bytes",
+ io_dataBuf.getByteLength());
+ /*@
+ * @errortype
+ * @moduleid fapi::MOD_ACCESS_OCB_INDIRECT_CHANNEL
+ * @reasoncode fapi::RC_INVALID_DATA_BUFFER_LENGTH
+ * @userdata1 Length of requested buffer size(in Bytes) to
+ * perform read operation.
+ * @userdata2 OCI address
+ * @devdesc Improper data size, data is not 8 byte aligned.
+ * @custdesc A problem occurred during the IPL
+ * of the system.
+ */
+ const bool hbSwError = true;
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi::MOD_ACCESS_OCB_INDIRECT_CHANNEL,
+ fapi::RC_INVALID_DATA_BUFFER_LENGTH,
+ io_dataBuf.getByteLength(),
+ i_addr,
+ hbSwError);
+ break; // return with error
+ }
+
+ // TODO RTC: 116027 To be consistent with FSP code hwcoOCC.C,
+ // p8_ocb_indir_setup_linear is always called for read and write
+ // linear and not called for write circular.
+ // a) linear read and write set up may only be needed once
+ // b) circular write may need to be set up once
+ if (l_setup)
+ {
+ FAPI_INVOKE_HWP(l_errl, p8_ocb_indir_setup_linear, l_fapiTarget,
+ OCB_CHAN0, OCB_TYPE_LINSTR, i_addr);
+ if(l_errl)
+ {
+ TRACFCOMP( g_fapiImpTd, ERR_MRK"accessOCBIndirectChannel:"
+ " Error [0x%X] in call to "
+ " FAPI_INVOKE_HWP(p8_ocb_indir_setup_linear)",
+ l_errl->reasonCode());
+ break; // return with error
+ }
+ }
+
+ // perform operation
+ FAPI_INVOKE_HWP(l_errl, p8_ocb_indir_access, l_fapiTarget,
+ l_channel,l_operation,io_dataBuf.getByteLength()/8,
+ io_dataBuf,l_len,l_ociAddrValid,i_addr);
+ if(l_errl)
+ {
+ TRACFCOMP( g_fapiImpTd, ERR_MRK"accessOCBIndirectChannel:"
+ " Error [0x%X] in call to"
+ " FAPI_INVOKE_HWP(p8_ocb_indir_access)",
+ l_errl->reasonCode());
+ break; // return with error
+ }
+
+ }
+ while (0);
+
+ TRACUCOMP( g_fapiTd, EXIT_MRK"accessOCBIndirectChannel");
+
+ return l_errl;
+}
+
+// Read OCC SRAM
+errlHndl_t readSRAM(const TARGETING::Target * i_pTarget,
+ const uint32_t i_addr,
+ ecmdDataBufferBase & io_dataBuf)
+{
+ errlHndl_t l_errl = NULL;
+ l_errl = accessOCBIndirectChannel(ACCESS_OCB_READ_LINEAR,
+ i_pTarget,
+ i_addr,
+ io_dataBuf);
+ return l_errl;
+}
+
+// Write OCC SRAM
+errlHndl_t writeSRAM(const TARGETING::Target * i_pTarget,
+ const uint32_t i_addr,
+ ecmdDataBufferBase & i_dataBuf)
+{
+ errlHndl_t l_errl = NULL;
+ l_errl = accessOCBIndirectChannel(ACCESS_OCB_WRITE_LINEAR,
+ i_pTarget,
+ i_addr,
+ i_dataBuf);
+ return l_errl;
+}
+
+// Write OCC Circular Buffer
+errlHndl_t writeCircularBuffer(const TARGETING::Target * i_pTarget,
+ ecmdDataBufferBase & i_dataBuf)
+{
+ errlHndl_t l_errl = NULL;
+ l_errl = accessOCBIndirectChannel(ACCESS_OCB_WRITE_CIRCULAR,
+ i_pTarget,
+ 0,
+ i_dataBuf);
+ return l_errl;
+}
+
+} //end OCC namespace
diff --git a/src/usr/hwpf/test/makefile b/src/usr/hwpf/test/makefile
index 76a7aeea7..f1760b904 100644
--- a/src/usr/hwpf/test/makefile
+++ b/src/usr/hwpf/test/makefile
@@ -5,7 +5,9 @@
#
# OpenPOWER HostBoot Project
#
-# COPYRIGHT International Business Machines Corp. 2011,2014
+# Contributors Listed Below - COPYRIGHT 2011,2014
+# [+] International Business Machines Corp.
+#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -25,7 +27,14 @@ MODULE = testhwpf
include hwpftest.mk
-TESTS = *.H
+TESTS += fapiattrtest.H
+TESTS += fapirctest.H
+TESTS += fapitargettest.H
+TESTS += hwpftest.H
+TESTS += hwpisteperrortest.H
+TESTS += hwpMBvpdAccessorTest.H
+TESTS += hwpMvpdAccessorTest.H
+TESTS += $(if $(CONFIG_HTMGT),occAccessTest.H)
SUBDIRS += runtime.d
include ${ROOTPATH}/config.mk
diff --git a/src/usr/hwpf/test/occAccessTest.H b/src/usr/hwpf/test/occAccessTest.H
new file mode 100644
index 000000000..143c0439c
--- /dev/null
+++ b/src/usr/hwpf/test/occAccessTest.H
@@ -0,0 +1,325 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/test/occAccessTest.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+#ifndef __OCCACCESSTEST_H
+#define __OCCACCESSTEST_H
+
+#include <stdint.h>
+
+#include <occ/occAccess.H>
+#include <errl/errlentry.H>
+#include <vfs/vfs.H>
+#include <hwpf/hwpf_reasoncodes.H>
+
+// fapi support
+#include <fapi.H>
+
+// targeting support
+#include <targeting/common/commontargeting.H>
+#include <targeting/common/utilFilter.H>
+#include <targeting/common/targetservice.H>
+#include <targeting/common/util.H>
+
+using namespace TARGETING;
+
+class occAccessTest : public CxxTest::TestSuite
+{
+public:
+
+void testAccessOCBIndirectChannel()
+{
+ TS_TRACE ("testAccessOCBIndirectChannel: enter");
+
+ errlHndl_t l_errl = NULL;
+ bool occ_loaded = false;
+ bool l_error = false;
+
+ do
+ {
+ //*********************************************************************
+ // load occ if needed
+ //*********************************************************************
+
+ if ( !VFS::module_is_loaded( "libocc.so" ) )
+ {
+ TS_TRACE("testAccessOCBIndirectChannel: load occ module");
+ l_errl = VFS::module_load( "libocc.so" );
+
+ if ( l_errl )
+ {
+ // load module returned with errl set
+ TS_FAIL("testAccessOCBIndirectChannel:"
+ " could not load occ module");
+ l_error = true;
+ break;
+ }
+ occ_loaded = true;
+ }
+
+ //*********************************************************************
+ // Find a PROC target and its OCC target
+ //*********************************************************************
+
+ //Get a Proc target
+ TARGETING::TargetHandleList l_procTargetList;
+ getAllChips(l_procTargetList,
+ TYPE_PROC,
+ true);
+
+ if (0==l_procTargetList.size()) //unexpected error
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: No Proc targets");
+ l_error = true;
+ break;
+ }
+ const TARGETING::Target* l_procTarget = l_procTargetList[0];
+
+ //Find an OCC target
+ TARGETING::TargetHandleList l_occTargetList;
+ getChildChiplets( l_occTargetList,
+ l_procTarget,
+ TYPE_OCC,
+ true);
+ // if there are no OCCs in this configuration, use the PROC target
+ if (0==l_occTargetList.size())
+ {
+ TS_TRACE("testAccessOCBIndirectChannel: No OCC targets");
+ l_occTargetList.push_back(l_procTargetList[0]);
+ }
+ const TARGETING::Target* l_occTarget = l_occTargetList[0];
+
+ //*********************************************************************
+ // Read and Write the OCC linear buffer
+ // 1. Read current value
+ // 2. Write test data
+ // 3. Read back and verify
+ // 4. Restore current value
+ //*********************************************************************
+ ecmdDataBufferBase l_currentData(64);
+ ecmdDataBufferBase l_testData(64);
+ ecmdDataBufferBase l_readBackData(64);
+ uint32_t l_addr = 0xFFFF6000;//sample value from TMGT.
+ const uint64_t l_testValue = 0x0123456789ABCDEF;
+
+
+ // read current data (use proc target)
+ TS_TRACE("testAccessOCBIndirectChannel:"
+ " target=%.8x type=%d read current",
+ get_huid(l_procTarget),
+ (l_procTarget)->getAttr<TARGETING::ATTR_TYPE>());
+
+ l_errl = HBOCC::readSRAM(l_procTarget,l_addr,l_currentData);
+ if (l_errl)
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: Read OCC SRAM failed");
+ l_error = true;
+ break;
+ }
+ TS_TRACE("testAccessOCBIndirectChannel: current data=%lx",
+ l_currentData.getDoubleWord(0));
+
+ // write test data (use occ target)
+ TS_TRACE("testAccessOCBIndirectChannel:"
+ " target=%.8x type=%d write test",
+ get_huid(l_occTarget),
+ (l_occTarget)->getAttr<TARGETING::ATTR_TYPE>());
+
+ l_testData.setDoubleWord(0,l_testValue);
+ l_errl = HBOCC::writeSRAM(l_occTarget,l_addr,l_testData);
+ if (l_errl)
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: write test data failed");
+ l_error = true;
+ break;
+ }
+ TS_TRACE("testAccessOCBIndirectChannel: test data=%lx",
+ l_testData.getDoubleWord(0));
+
+ // read test data back (use proc target)
+ TS_TRACE("testAccessOCBIndirectChannel:"
+ " target=%.8x type=%d read test data",
+ get_huid(l_procTarget),
+ (l_procTarget)->getAttr<TARGETING::ATTR_TYPE>());
+
+ l_errl = HBOCC::readSRAM(l_procTarget,l_addr,l_readBackData);
+ if (l_errl)
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: read test data failed");
+ l_error = true;
+ break;
+ }
+ TS_TRACE("testAccessOCBIndirectChannel: read back data=%lx",
+ l_readBackData.getDoubleWord(0));
+
+ if(l_testValue != l_readBackData.getDoubleWord(0))
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: read back compare failed");
+ l_error = true;
+ break;
+ }
+
+ // write original data back (use proc target)
+ TS_TRACE("testAccessOCBIndirectChannel:"
+ " target=%.8x type=%d write orginial back",
+ get_huid(l_procTarget),
+ (l_procTarget)->getAttr<TARGETING::ATTR_TYPE>());
+
+ l_errl = HBOCC::writeSRAM(l_procTarget,l_addr,l_currentData);
+ if (l_errl)
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: restore data failed");
+ l_error = true;
+ break;
+ }
+
+ //*********************************************************************
+ // Test write circular
+ //*********************************************************************
+ ecmdDataBufferBase l_data(64); // value 0
+
+ // write circular (use proc target)
+ TS_TRACE("testAccessOCBIndirectChannel:"
+ " target=%.8x type=%d write circular",
+ get_huid(l_procTarget),
+ (l_procTarget)->getAttr<TARGETING::ATTR_TYPE>());
+
+ l_errl = HBOCC::writeCircularBuffer(l_procTarget,l_data);
+ if (l_errl)
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: write circular failed");
+ l_error = true;
+ break;
+ }
+ TS_TRACE("testAccessOCBIndirectChannel: write circular data=%lx",
+ l_data.getDoubleWord(0));
+
+ //*********************************************************************
+ // Error tests
+ //*********************************************************************
+
+ // null target
+ const TARGETING::Target* l_nullTarget = NULL;
+ l_errl = HBOCC::writeCircularBuffer(l_nullTarget,l_data);
+ if (l_errl) {
+ TS_TRACE("testAccessOCBIndirectChannel: null test rc=%x",
+ static_cast<uint32_t>(l_errl->reasonCode()));
+ }
+ if (!l_errl || (RC_TARGET_UNSUPPORTED != l_errl->reasonCode()))
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: null target test failed");
+ l_error = true;
+ break;
+ }
+ delete l_errl;
+ l_errl = NULL;
+
+ // wrong target type
+ TARGETING::TargetHandleList l_wrongTargetList;
+ getAllChips(l_wrongTargetList,
+ TYPE_MEMBUF,
+ true);
+
+ if (0==l_wrongTargetList.size()) //unexpected error
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: No wrong targets");
+ l_error = true;
+ break;
+ }
+ const TARGETING::Target* l_wrongTarget = l_wrongTargetList[0];
+
+ l_errl = HBOCC::writeCircularBuffer(l_wrongTarget,l_data);
+ if (l_errl) {
+ TS_TRACE("testAccessOCBIndirectChannel: wrong target rc=%x",
+ static_cast<uint32_t>(l_errl->reasonCode()));
+ }
+ if (!l_errl || (RC_TARGET_UNSUPPORTED != l_errl->reasonCode()))
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: wrong target test failed");
+ l_error = true;
+ break;
+ }
+ delete l_errl;
+ l_errl = NULL;
+
+ // wrong data length
+ ecmdDataBufferBase l_wrongData(65);
+
+ l_errl = HBOCC::readSRAM(l_procTarget,l_addr,l_wrongData);
+ if (l_errl) {
+ TS_TRACE("testAccessOCBIndirectChannel: wrong data rc=%x",
+ static_cast<uint32_t>(l_errl->reasonCode()));
+ }
+ if (!l_errl || (RC_INVALID_DATA_BUFFER_LENGTH != l_errl->reasonCode()))
+ {
+ TS_FAIL("testAccessOCBIndirectChannel: wrong data length failed");
+ l_error = true;
+ break;
+ }
+ delete l_errl;
+ l_errl = NULL;
+
+ }
+ while (0);
+
+ //*********************************************************************
+ // unload occ if needed
+ //*********************************************************************
+ if (occ_loaded)
+ {
+ errlHndl_t l_tmpErrl = NULL;
+ l_tmpErrl = VFS::module_unload( "libocc.so" );
+ if ( l_tmpErrl )
+ {
+ TS_WARN("testAccessOCBIndirectChannel:"
+ " Error unloading libocc module" );
+ delete l_tmpErrl;
+ l_tmpErrl = NULL;
+ }
+ else
+ {
+ TS_TRACE("testAccessOCBIndirectChannel: unload occ module");
+ }
+ }
+
+
+ if (l_errl) //Test case failed, commit error
+ {
+ errlCommit(l_errl,HWPF_COMP_ID);
+ TS_TRACE ("testAccessOCBIndirectChannel: exit FAILED log committed");
+ }
+ else if (l_error) //Failed without an error log created
+ {
+ TS_TRACE ("testAccessOCBIndirectChannel: exit FAILED");
+ }
+ else
+ {
+ TS_TRACE ("testAccessOCBIndirectChannel: exit PASSED");
+ }
+
+}
+
+}; // end class
+
+#endif
OpenPOWER on IntegriCloud