diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sbefw/sbeHostUtils.H | 8 | ||||
-rw-r--r-- | src/sbefw/sbeTimerSvc.C | 103 | ||||
-rw-r--r-- | src/sbefw/sbeTimerSvc.H | 69 | ||||
-rw-r--r-- | src/sbefw/sbe_host_intf.H | 18 | ||||
-rw-r--r-- | src/sbefw/sbe_sp_intf.H | 3 | ||||
-rw-r--r-- | src/sbefw/sbecmdCntrlTimer.C | 144 | ||||
-rw-r--r-- | src/sbefw/sbecmdCntrlTimer.H | 45 | ||||
-rw-r--r-- | src/sbefw/sbecmdparser.C | 23 | ||||
-rw-r--r-- | src/sbefw/sbefwfiles.mk | 4 | ||||
-rwxr-xr-x | src/test/testcases/test.xml | 3 | ||||
-rw-r--r-- | src/test/testcases/testExecutorCntrlTimer.py | 144 | ||||
-rwxr-xr-x | src/test/testcases/testExecutorCntrlTimer.xml | 34 | ||||
-rw-r--r-- | src/test/testcases/testExecutorStopTimer.py | 146 | ||||
-rw-r--r-- | src/test/testcases/testPSUUtil.py | 2 |
14 files changed, 739 insertions, 7 deletions
diff --git a/src/sbefw/sbeHostUtils.H b/src/sbefw/sbeHostUtils.H index d50483dc..092c884b 100644 --- a/src/sbefw/sbeHostUtils.H +++ b/src/sbefw/sbeHostUtils.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -92,6 +92,12 @@ typedef enum // firmware to trigger Stop15 exit on thread 0 on the master core. // This would be used to trigger hostboot in istep 16 SBE_SBE2PSU_DOORBELL_SET_BIT2 = 0x2000000000000000ull, + + // Bit 14 OR flag for SBE->PSU Doorbell Register; + // When this is set by SBE, it would trigger an interrupt to host + // firmware to inform that timer has expired. + SBE_SBE2PSU_DOORBELL_SET_BIT14 = 0x0002000000000000ull, + } sbe_sbe2psuDoorbellReg_UpdateFlags; diff --git a/src/sbefw/sbeTimerSvc.C b/src/sbefw/sbeTimerSvc.C new file mode 100644 index 00000000..9909be83 --- /dev/null +++ b/src/sbefw/sbeTimerSvc.C @@ -0,0 +1,103 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/sbefw/sbeTimerSvc.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* [+] 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 */ +/* + * @file: src/sbefw/sbeTimerSvc.C + * + * @brief This file contains the SBE timer service + * + */ + +#include "sbetrace.H" +#include "sbeTimerSvc.H" +#include "sbe_sp_intf.H" +#include "pk.h" + +uint32_t timerService::startTimer(uint32_t i_time, PkTimerCallback i_callBack ) +{ + #define SBE_FUNC "timerService::startTimer " + uint32_t l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + do + { + int l_pkRc = 0; + if( !init ) + { + l_pkRc = pk_timer_create(&fixedTimer, i_callBack, NULL); + if(l_pkRc) + { + SBE_ERROR(SBE_FUNC" Pk Timer Create failed, RC=[%d]", l_pkRc); + l_rc = SBE_SEC_OS_FAILURE; + break; + } + init = true; + } + if( isActive() ) + { + SBE_ERROR(SBE_FUNC" Timer already started"); + l_rc = SBE_SEC_TIMER_ALREADY_STARTED; + break; + } + // Schedule the timer + l_pkRc = pk_timer_schedule(&fixedTimer, + PK_MILLISECONDS((uint32_t)i_time)); + if(l_pkRc) + { + SBE_ERROR(SBE_FUNC" Pk Timer Schedule failed, RC=[%d]", l_pkRc); + l_rc = SBE_SEC_OS_FAILURE; + break; + } + } while(0); + return l_rc; + #undef SBE_FUNC +} + +uint32_t timerService::stopTimer( ) +{ + #define SBE_FUNC "timerService::stopTimer " + uint32_t l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + PkMachineContext ctx; + do + { + // The critical section enter/exit set is done to ensure + // pk_timer_cancel operations are non-interrupible. + pk_critical_section_enter(&ctx); + if( !isActive() ) + { + SBE_INFO(SBE_FUNC" Timer is not running"); + break; + } + // Cancel the timer + int l_pkRc = pk_timer_cancel(&fixedTimer ); + if(l_pkRc) + { + SBE_ERROR(SBE_FUNC" Pk Timer cancel failed, RC=[%d]", l_pkRc); + l_rc = SBE_SEC_OS_FAILURE; + break; + } + } while(0); + pk_critical_section_exit(&ctx); + return l_rc; + #undef SBE_FUNC +} + diff --git a/src/sbefw/sbeTimerSvc.H b/src/sbefw/sbeTimerSvc.H new file mode 100644 index 00000000..a4a4a240 --- /dev/null +++ b/src/sbefw/sbeTimerSvc.H @@ -0,0 +1,69 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/sbefw/sbeTimerSvc.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* [+] 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 */ +/* + * @file: src/sbefw/sbeTimerSvc.H + * + * @brief This file contains the SBE Timer Service + * + */ + +#ifndef __SBEFW_TIMER_SVC_H +#define __SBEFW_TIMER_SVC_H +#include <stdint.h> +#include "pk_api.h" + +// structure for timer service +struct timerService +{ + bool init; /* Timer initialised */ + PkTimer fixedTimer; /* pk timer */ + + /** + * @brief start timer + * + * @param[in] i_time time in ms + * @param[in] i_callBack callback function on timer expiry + * + * @return error code as per sbe secondary errors + */ + uint32_t startTimer(uint32_t i_time, PkTimerCallback i_callBack ); + + /** + * @brief stop timer + * + * @return error code as per sbe secondary errors + */ + uint32_t stopTimer(); + + /** + * @brief Returns timer status + */ + inline bool isActive() + { + return ( init && pk_deque_is_queued( &(fixedTimer.deque) )); + } +}; + +#endif //__SBEFW_TIMER_SVC_H diff --git a/src/sbefw/sbe_host_intf.H b/src/sbefw/sbe_host_intf.H index 82613027..57d679bb 100644 --- a/src/sbefw/sbe_host_intf.H +++ b/src/sbefw/sbe_host_intf.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -51,6 +51,7 @@ enum sbePsuCommandClass SBE_PSU_CMD_CLASS_UNKNOWN = 0, SBE_PSU_CMD_CLASS_CORE_STATE = 0xD1, SBE_PSU_CMD_CLASS_RING_ACCESS = 0xD3, + SBE_PSU_CMD_CLASS_CNTRL_TIMER = 0xD4, SBE_PSU_CMD_CLASS_GENERIC = 0xD7, }; @@ -64,6 +65,15 @@ enum sbePsuCoreStateControlCommands }; /** + * @brief enums for SBE-Host interface control timer commands + */ +enum sbePsuControlTimerCommands +{ + SBE_PSU_CMD_CONTROL_TIMER = 0x01, + SBE_PSU_CMD_CONTROL_TIMER_UNKNOWN = 0xFF, +}; + +/** * @brief enums for SBE-Host interface ring access messages */ enum sbePsuRingAccessMessages @@ -98,4 +108,10 @@ enum sbePsuDmtCmdFlags SBE_PSU_FLAGS_STOP_DMT = 0x0002, }; +enum sbePsuCntrlTimerFlags +{ + SBE_PSU_FLAGS_START_TIMER = 0x0001, + SBE_PSU_FLAGS_STOP_TIMER = 0x0002, +}; + #endif // __SBEFW_SBE_HOST_INTF_H diff --git a/src/sbefw/sbe_sp_intf.H b/src/sbefw/sbe_sp_intf.H index 348d50ba..88b6d38e 100644 --- a/src/sbefw/sbe_sp_intf.H +++ b/src/sbefw/sbe_sp_intf.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -209,6 +209,7 @@ enum sbeSecondaryResponse SBE_SEC_HW_OP_TIMEOUT = 0x10, SBE_SEC_PCB_PIB_ERR = 0x11, SBE_SEC_FIFO_PARITY_ERROR = 0x12, + SBE_SEC_TIMER_ALREADY_STARTED = 0x13, }; /** diff --git a/src/sbefw/sbecmdCntrlTimer.C b/src/sbefw/sbecmdCntrlTimer.C new file mode 100644 index 00000000..62324979 --- /dev/null +++ b/src/sbefw/sbecmdCntrlTimer.C @@ -0,0 +1,144 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/sbefw/sbecmdCntrlTimer.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* [+] 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 */ +/* + * @file: src/sbefw/sbecmdCntrlTimer.C + * + * @brief This file contains the SBE Timer Commands + * + */ + +#include "sbecmdCntrlTimer.H" +#include "sbetrace.H" +#include "sbe_sp_intf.H" +#include "sbeFFDC.H" +#include "sbeHostMsg.H" +#include "sbeHostUtils.H" +#include "sbeTimerSvc.H" + +#include "fapi2.H" +using namespace fapi2; + +// Global instance to track PK timer +static timerService g_hostTimerSvc; + +// Callback +void sbeTimerExpiryCallback(void *) +{ + #define SBE_FUNC "sbeTimerExpiryCallback " + SBE_ENTER(SBE_FUNC); + + do + { + // indicate the Host via Bit SBE_SBE2PSU_DOORBELL_SET_BIT14 + // that Timer has expired + SBE_INFO(SBE_FUNC "Updating door bell bit 14"); + uint32_t l_rc = sbeSetSbe2PsuDbBitX(SBE_SBE2PSU_DOORBELL_SET_BIT14); + if(l_rc) + { + SBE_ERROR(SBE_FUNC " Failed to Write " + "SBE_SBE2PSU_DOORBELL_SET_BIT14"); + pk_halt(); + } + }while(0); + SBE_EXIT(SBE_FUNC); + #undef SBE_FUNC + +} +///////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +uint32_t sbeCntrlTimer( uint8_t *i_pArg ) +{ + #define SBE_FUNC "sbeCntrlTimer " + SBE_ENTER(SBE_FUNC); + uint32_t l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + uint32_t l_fapiRc = FAPI2_RC_SUCCESS; + + do + { + if(g_sbePsu2SbeCmdReqHdr.flags & SBE_PSU_FLAGS_START_TIMER) + { + uint64_t time = 0; + l_rc = sbeReadPsu2SbeMbxReg(SBE_HOST_PSU_MBOX_REG1, + (sizeof(time)/sizeof(uint64_t)), + &time, true); + + if(SBE_SEC_OPERATION_SUCCESSFUL != l_rc) + { + SBE_ERROR(SBE_FUNC" Failed to extract SBE_HOST_PSU_MBOX_REG1"); + break; + } + + SBE_INFO(SBE_FUNC "Start Timer. Time: [%08X]", + SBE::lower32BWord(time)); + + l_rc = g_hostTimerSvc.startTimer( (uint32_t )time, + (PkTimerCallback)&sbeTimerExpiryCallback); + if(SBE_SEC_OPERATION_SUCCESSFUL != l_rc) + { + g_sbeSbe2PsuRespHdr.setStatus(SBE_PRI_INTERNAL_ERROR, l_rc); + SBE_ERROR(SBE_FUNC" g_hostTimerSvc.startTimer failed"); + l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + break; + } + break; + } + // Acknowledge host + l_rc = sbeAcknowledgeHost(); + if(l_rc) + { + SBE_ERROR(SBE_FUNC " Failed to Sent Ack to Host over " + "SBE_SBE2PSU_DOORBELL_SET_BIT1"); + break; + } + + if(g_sbePsu2SbeCmdReqHdr.flags & SBE_PSU_FLAGS_STOP_TIMER) + { + SBE_INFO(SBE_FUNC "Stop Timer."); + l_rc = g_hostTimerSvc.stopTimer( ); + if(SBE_SEC_OPERATION_SUCCESSFUL != l_rc) + { + g_sbeSbe2PsuRespHdr.setStatus(SBE_PRI_INTERNAL_ERROR, l_rc); + SBE_ERROR(SBE_FUNC" g_hostTimerSvc.stopTimer failed"); + l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + break; + } + break; + } + + g_sbeSbe2PsuRespHdr.setStatus( SBE_PRI_INVALID_COMMAND, + SBE_SEC_COMMAND_NOT_SUPPORTED); + SBE_ERROR(SBE_FUNC" Not a valid flag 0x%4X", + (uint16_t) g_sbePsu2SbeCmdReqHdr.flags); + }while(0); + + // Send the response + sbePSUSendResponse(g_sbeSbe2PsuRespHdr, l_fapiRc, l_rc); + + SBE_EXIT(SBE_FUNC); + return l_rc; + #undef SBE_FUNC +} + diff --git a/src/sbefw/sbecmdCntrlTimer.H b/src/sbefw/sbecmdCntrlTimer.H new file mode 100644 index 00000000..f945da46 --- /dev/null +++ b/src/sbefw/sbecmdCntrlTimer.H @@ -0,0 +1,45 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/sbefw/sbecmdCntrlTimer.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* 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 */ +/* + * @file: ppe/sbe/sbefw/sbecmdCntrlTimer.H + * + * @brief This file contains the SBE control timer command details + * + */ + +#ifndef __SBEFW_SBECMD_CNTRL_TIMER_H +#define __SBEFW_SBECMD_CNTRL_TIMER_H + +#include <stdint.h> + +/** + * @brief SBE Psu Control timer chipop (0xD401) + * + * @param[in] i_pArg Buffer to be passed to the function (not used as of now) + * + * @return Rc from the Psu access utility + */ +uint32_t sbeCntrlTimer( uint8_t *i_pArg ); + +#endif // __SBEFW_SBECMD_CNTRL_TIMER_H diff --git a/src/sbefw/sbecmdparser.C b/src/sbefw/sbecmdparser.C index 4457321e..01b31e04 100644 --- a/src/sbefw/sbecmdparser.C +++ b/src/sbefw/sbecmdparser.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -48,6 +48,7 @@ #include "sberegaccess.H" #include "sbecmdmpipl.H" #include "sbecmdtracearray.H" +#include "sbecmdCntrlTimer.H" // Declaration static const uint16_t HARDWARE_FENCED_STATE = @@ -248,6 +249,19 @@ static sbeCmdStruct_t g_sbeCoreStateControlCmdArray [] = }; ////////////////////////////////////////////////////////////// +// @brief g_sbeControlTimerCmdArray +// +////////////////////////////////////////////////////////////// +static sbeCmdStruct_t g_sbeControlTimerCmdArray [] = +{ + {sbeCntrlTimer, + SBE_PSU_CMD_CONTROL_TIMER, + SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE| + SBE_FENCE_AT_MPIPL|SBE_FENCE_AT_DUMPING, + }, +}; + +////////////////////////////////////////////////////////////// // @brief g_sbePutRingFromImageCmdArray // ////////////////////////////////////////////////////////////// @@ -361,6 +375,13 @@ uint8_t sbeGetCmdStructAttr (const uint8_t i_cmdClass, *o_ppCmd = (sbeCmdStruct_t*)g_sbePsuGenericCmdArray; break; + case SBE_PSU_CMD_CLASS_CNTRL_TIMER: + l_numCmds = sizeof(g_sbeControlTimerCmdArray) / + sizeof(sbeCmdStruct_t); + *o_ppCmd = (sbeCmdStruct_t*)g_sbeControlTimerCmdArray; + break; + + // This will grow with each class of chipOp in future default: break; diff --git a/src/sbefw/sbefwfiles.mk b/src/sbefw/sbefwfiles.mk index 3e44a5af..6fd29618 100644 --- a/src/sbefw/sbefwfiles.mk +++ b/src/sbefw/sbefwfiles.mk @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2016 +# Contributors Listed Below - COPYRIGHT 2015,2017 # [+] International Business Machines Corp. # # @@ -46,6 +46,8 @@ SBEFW-CPP-SOURCES += sbecmdmpipl.C SBEFW-CPP-SOURCES += sbefapiutil.C SBEFW-CPP-SOURCES += sbeutil.C SBEFW-CPP-SOURCES += sbecmdtracearray.C +SBEFW-CPP-SOURCES += sbeTimerSvc.C +SBEFW-CPP-SOURCES += sbecmdCntrlTimer.C SBEFW-C-SOURCES = SBEFW-S-SOURCES = diff --git a/src/test/testcases/test.xml b/src/test/testcases/test.xml index 4bc43092..76d1998e 100755 --- a/src/test/testcases/test.xml +++ b/src/test/testcases/test.xml @@ -5,7 +5,7 @@ <!-- --> <!-- OpenPOWER sbe Project --> <!-- --> -<!-- Contributors Listed Below - COPYRIGHT 2015,2016 --> +<!-- Contributors Listed Below - COPYRIGHT 2015,2017 --> <!-- [+] International Business Machines Corp. --> <!-- --> <!-- --> @@ -44,6 +44,7 @@ <include>../simics/targets/p9_nimbus/sbeTest/testSystemFabricMap.xml</include> <include>../simics/targets/p9_nimbus/sbeTest/testArrayAccess.xml</include> <include>../simics/targets/p9_nimbus/sbeTest/testGetRing.xml</include> + <include>../simics/targets/p9_nimbus/sbeTest/testExecutorCntrlTimer.xml</include> <include>../simics/targets/p9_nimbus/sbeTest/testQuiesce.xml</include> <testcase> <simcmd>sbe-trace 0</simcmd> diff --git a/src/test/testcases/testExecutorCntrlTimer.py b/src/test/testcases/testExecutorCntrlTimer.py new file mode 100644 index 00000000..9bdd68c3 --- /dev/null +++ b/src/test/testcases/testExecutorCntrlTimer.py @@ -0,0 +1,144 @@ +#!/usr/bin/python +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/test/testcases/testExecutorCntrlTimer.py $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2016,2017 +# +# +# 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 +import testPSUUtil +import testRegistry as reg +import testUtil + +#------------------------------- +# This is a Test Expected Data +#------------------------------- +''' +This data are the values or strings that needs to be validated for the test. +''' +''' +#------------------------------------------------------------------------------------------------------------------------------ +# SBE side test data - 20 ms timer +#------------------------------------------------------------------------------------------------------------------------------ +''' +sbe_test_startTimer = ( + #----------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #----------------------------------------------------------------------------------------------------- + ["write", reg.REG_MBOX0, "0000010100F0D401", 8, "None", "Writing to MBOX0 address"], + ["write", reg.REG_MBOX1, "0000000000000020", 8, "None", "Writing to MBOX1 address"], + ["write", reg.PSU_SBE_DOORBELL_REG_WO_OR, "8000000000000000", 8, "None", "Update SBE Doorbell register to interrupt SBE"], + ) +''' +#------------------------------------------------------------------------------------------------------------------------------ +# SBE side test data - Stop Timer. +# In this test case though timer is already expired, we want to check that +# stop timer does not fail in that case +#------------------------------------------------------------------------------------------------------------------------------ +''' +sbe_test_StopTimer = ( + #----------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #----------------------------------------------------------------------------------------------------- + ["write", reg.REG_MBOX0, "0000010200F0D401", 8, "None", "Writing to MBOX0 address"], + ["write", reg.PSU_SBE_DOORBELL_REG_WO_OR, "8000000000000000", 8, "None", "Update SBE Doorbell register to interrupt SBE"], + ) +''' +#--------------------- +# Host side test data - SUCCESS +#--------------------- +''' +host_test_Timer_Cmd_success = ( + #---------------------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #---------------------------------------------------------------------------------------------------------------- + ["read", reg.REG_MBOX4, "0", 8, "0000000000F0D401", "Reading Host MBOX4 data to Validate"], + ) +''' +#----------------------------------------------------------------------- +# Do not modify - Used to simulate interrupt on Ringing Doorbell on Host +#----------------------------------------------------------------------- +''' +host_polling_data = ( + #---------------------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #---------------------------------------------------------------------------------------------------------------- + ["read", reg.PSU_HOST_DOORBELL_REG_WO_OR, "0", 8, "8000000000000000", "Reading Host Doorbell for Interrupt"], + ) + +timer_polling_data = ( + #---------------------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #---------------------------------------------------------------------------------------------------------------- + ["read", reg.PSU_HOST_DOORBELL_REG_WO_OR, "0", 8, "0002000000000000", "Reading Host Doorbell for Interrupt"], + ) + +#------------------------- +# Main Function +#------------------------- +def main(): + # Run Simics initially + testUtil.runCycles( 10000000 ); + + # Intialize the class obj instances + regObj = testPSUUtil.registry() # Registry obj def for operation + + print "\n Execute SBE Test set1 [ PutCntrlTimer ] ...\n" + + ''' + Test Case 1 + ''' + print "\n Test Start timer\n" + # HOST->SBE data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_startTimer ) + + #Poll on HOST DoorBell Register for interrupt + regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) + + #SBE->HOST data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) + + #Poll on HOST DoorBell Register for interrupt + print "\n Poll on Host side for Timer INTR ...\n" + regObj.pollingOn( testPSUUtil.simSbeObj, timer_polling_data, 50 ) + + ''' + Test Case 2. Stop timer when timer already expired + ''' + print "\n Test Stop timer\n" + # HOST->SBE data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_StopTimer ) + + #Poll on HOST DoorBell Register for interrupt + regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) + + #SBE->HOST data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) + + +if __name__ == "__main__": + main() + if err: + print ( "\nTest Suite completed with error(s)" ) + #sys.exit(1) + else: + print ( "\nTest Suite completed with no errors" ) + #sys.exit(0); + + diff --git a/src/test/testcases/testExecutorCntrlTimer.xml b/src/test/testcases/testExecutorCntrlTimer.xml new file mode 100755 index 00000000..550b1c47 --- /dev/null +++ b/src/test/testcases/testExecutorCntrlTimer.xml @@ -0,0 +1,34 @@ +<!-- IBM_PROLOG_BEGIN_TAG --> +<!-- This is an automatically generated prolog. --> +<!-- --> +<!-- $Source: src/test/testcases/testExecutorCntrlTimer.xml $ --> +<!-- --> +<!-- OpenPOWER sbe Project --> +<!-- --> +<!-- Contributors Listed Below - COPYRIGHT 2016,2017 --> +<!-- --> +<!-- --> +<!-- 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 --> +<?xml version="1.0" encoding="UTF-8"?> + + <testcase> + <simcmd>run-python-file targets/p9_nimbus/sbeTest/testExecutorCntrlTimer.py</simcmd> + <exitonerror>yes</exitonerror> + </testcase> + <testcase> + <simcmd>run-python-file targets/p9_nimbus/sbeTest/testExecutorStopTimer.py</simcmd> + <exitonerror>yes</exitonerror> + </testcase> + diff --git a/src/test/testcases/testExecutorStopTimer.py b/src/test/testcases/testExecutorStopTimer.py new file mode 100644 index 00000000..6305d443 --- /dev/null +++ b/src/test/testcases/testExecutorStopTimer.py @@ -0,0 +1,146 @@ +#!/usr/bin/python +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/test/testcases/testExecutorStopTimer.py $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2016,2017 +# +# +# 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 +import testPSUUtil +import testRegistry as reg +import testUtil + +#------------------------------- +# This is a Test Expected Data +#------------------------------- +''' +This data are the values or strings that needs to be validated for the test. +''' +''' +#------------------------------------------------------------------------------------------------------------------------------ +# SBE side test data - 200 ms timer +#------------------------------------------------------------------------------------------------------------------------------ +''' +sbe_test_startTimer = ( + #----------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #----------------------------------------------------------------------------------------------------- + ["write", reg.REG_MBOX0, "0000010100F0D401", 8, "None", "Writing to MBOX0 address"], + ["write", reg.REG_MBOX1, "0000000000000200", 8, "None", "Writing to MBOX1 address"], + ["write", reg.PSU_SBE_DOORBELL_REG_WO_OR, "8000000000000000", 8, "None", "Update SBE Doorbell register to interrupt SBE"], + ) +''' +#------------------------------------------------------------------------------------------------------------------------------ +# SBE side test data - Stop Timer. +#------------------------------------------------------------------------------------------------------------------------------ +''' +sbe_test_StopTimer = ( + #----------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #----------------------------------------------------------------------------------------------------- + ["write", reg.REG_MBOX0, "0000010200F0D401", 8, "None", "Writing to MBOX0 address"], + ["write", reg.PSU_SBE_DOORBELL_REG_WO_OR, "8000000000000000", 8, "None", "Update SBE Doorbell register to interrupt SBE"], + ) +''' +#--------------------- +# Host side test data - SUCCESS +#--------------------- +''' +host_test_Timer_Cmd_success = ( + #---------------------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #---------------------------------------------------------------------------------------------------------------- + ["read", reg.REG_MBOX4, "0", 8, "0000000000F0D401", "Reading Host MBOX4 data to Validate"], + ) +''' +#----------------------------------------------------------------------- +# Do not modify - Used to simulate interrupt on Ringing Doorbell on Host +#----------------------------------------------------------------------- +''' +host_polling_data = ( + #---------------------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #---------------------------------------------------------------------------------------------------------------- + ["read", reg.PSU_HOST_DOORBELL_REG_WO_OR, "0", 8, "8000000000000000", "Reading Host Doorbell for Interrupt"], + ) + +timer_polling_data = ( + #---------------------------------------------------------------------------------------------------------------- + # OP Reg ValueToWrite size Test Expected Data Description + #---------------------------------------------------------------------------------------------------------------- + ["read", reg.PSU_HOST_DOORBELL_REG_WO_OR, "0", 8, "0002000000000000", "Reading Host Doorbell for Interrupt"], + ) + +#------------------------- +# Main Function +#------------------------- +def main(): + # Run Simics initially + testUtil.runCycles( 10000000 ); + + # Intialize the class obj instances + regObj = testPSUUtil.registry() # Registry obj def for operation + + print "\n Execute SBE Test set1 [ PutCntrlTimer ] ...\n" + + ''' + Test Case 1 + ''' + print "\n Test Start timer\n" + # HOST->SBE data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_startTimer ) + + #Poll on HOST DoorBell Register for interrupt + regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) + + #SBE->HOST data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) + + print "\n Test Stop timer\n" + # HOST->SBE data set execution + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_StopTimer ) + + #Poll on HOST DoorBell Register for interrupt + regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) + + isTimerFired = True; + #SBE->HOST data set execution + # As we have stopped the timer, timer should not fire + regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) + try: + #Poll on HOST DoorBell Register for interrupt + print "\n Poll on Host side for Timer INTR ...\n" + regObj.pollingOn( testPSUUtil.simSbeObj, timer_polling_data, 20 ) + except: + isTimerFired = False + + if isTimerFired: + print "\n Problem. Timer not cancelled\n" + raise Exception('Timer Not cancelled '); + +if __name__ == "__main__": + main() + if err: + print ( "\nTest Suite completed with error(s)" ) + #sys.exit(1) + else: + print ( "\nTest Suite completed with no errors" ) + #sys.exit(0); + + diff --git a/src/test/testcases/testPSUUtil.py b/src/test/testcases/testPSUUtil.py index e2b03b7f..6b814701 100644 --- a/src/test/testcases/testPSUUtil.py +++ b/src/test/testcases/testPSUUtil.py @@ -365,7 +365,7 @@ class registry(object): break else: retries = retries - 1 - return FAILURE + return SUCCESS #---------------------------------------------------- # Load the function and execute |