diff options
author | Sachin Gupta <sgupta2m@in.ibm.com> | 2016-11-24 04:14:05 -0600 |
---|---|---|
committer | AMIT J. TENDOLKAR <amit.tendolkar@in.ibm.com> | 2017-01-11 10:13:56 -0500 |
commit | df7e2b85dbf9e51987a9b79a5e18f258bf5dac45 (patch) | |
tree | ecc948a5a1b9a97ed8fb2d894cfd595d709551ad /src/sbefw | |
parent | 9db0477faba296410c240b66dcd00747c8a781fd (diff) | |
download | talos-sbe-df7e2b85dbf9e51987a9b79a5e18f258bf5dac45.tar.gz talos-sbe-df7e2b85dbf9e51987a9b79a5e18f258bf5dac45.zip |
Timer service
RTC: 134268
Change-Id: Ie2bb96861f5a12937350048287e23705d0f8bcb0
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/32986
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: RAJA DAS <rajadas2@in.ibm.com>
Reviewed-by: AMIT J. TENDOLKAR <amit.tendolkar@in.ibm.com>
Diffstat (limited to 'src/sbefw')
-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 |
9 files changed, 412 insertions, 5 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 = |