diff options
Diffstat (limited to 'src/sbefw')
-rw-r--r-- | src/sbefw/app/Makefile | 56 | ||||
-rw-r--r-- | src/sbefw/app/power/Makefile (renamed from src/sbefw/app/MakefileSeeprom) | 32 | ||||
-rw-r--r-- | src/sbefw/app/power/apppowerfiles.mk (renamed from src/sbefw/app/sbeappseepromfiles.mk) | 19 | ||||
-rw-r--r-- | src/sbefw/app/power/chipop_table.C | 317 | ||||
-rw-r--r-- | src/sbefw/app/power/sbeapp.C (renamed from src/sbefw/app/sbeapp.C) | 4 | ||||
-rw-r--r-- | src/sbefw/app/sbeappfiles.mk | 29 | ||||
-rw-r--r-- | src/sbefw/core/chipop_handler.C | 221 | ||||
-rw-r--r-- | src/sbefw/core/chipop_handler.H (renamed from src/sbefw/core/sbecmdparser.H) | 104 | ||||
-rw-r--r-- | src/sbefw/core/sbecmdparser.C | 603 | ||||
-rw-r--r-- | src/sbefw/core/sbecmdprocessor.C | 5 | ||||
-rw-r--r-- | src/sbefw/core/sbecmdreceiver.C | 6 | ||||
-rw-r--r-- | src/sbefw/core/sbecorefiles.mk | 5 |
12 files changed, 673 insertions, 728 deletions
diff --git a/src/sbefw/app/Makefile b/src/sbefw/app/Makefile deleted file mode 100644 index de682146..00000000 --- a/src/sbefw/app/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/sbefw/app/Makefile $ -# -# 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 -#export P2P_ENABLE = 1 - -export SUB_OBJDIR = /sbefw/app - -include img_defs.mk -include sbeappfiles.mk - -OBJS := $(addprefix $(OBJDIR)/, $(SBEAPP_OBJECTS)) - -libsbeapp.a: $(OBJS) - $(AR) crs $(OBJDIR)/libsbeapp.a $(OBJDIR)/*.o - -.PHONY: clean sbeapp -sbeapp: $(OBJS) - -$(OBJS) $(OBJS:.o=.d): | $(OBJDIR) - -$(OBJDIR): - mkdir -p $(OBJDIR) - - -#clean the kernel directory first, then the application level clean -clean: - rm -fr $(OBJDIR) - -ifneq ($(MAKECMDGOALS),clean) -include $(OBJS:.o=.d) -endif - - - - - diff --git a/src/sbefw/app/MakefileSeeprom b/src/sbefw/app/power/Makefile index 905121bb..a366531a 100644 --- a/src/sbefw/app/MakefileSeeprom +++ b/src/sbefw/app/power/Makefile @@ -1,12 +1,11 @@ # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # -# $Source: src/sbeapp/Makefile $ +# $Source: src/sbefw/app/power/Makefile $ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2016,2017 -# [+] International Business Machines Corp. +# Contributors Listed Below - COPYRIGHT 2016,2018 # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,27 +23,32 @@ # IBM_PROLOG_END_TAG #export P2P_ENABLE = 1 -export SUB_OBJDIR = /sbefw/appseeprom - -include img_defs.mk -include sbeappseepromfiles.mk - +ifneq ($(img_mem), seeprom) +export SUB_OBJDIR = /sbefw/app/power_pibmem +OBJS = $(addprefix $(OBJDIR)/, $(APPPOWERPIBMEM_OBJECTS)) +LIBNAME = libsbeapppowerpibmem +else +export SUB_OBJDIR = /sbefw/app/power_seeprom GCC-CFLAGS += -mlongcall GCC-DEFS += -D__SBEFW_SEEPROM__=1 -OBJS := $(addprefix $(OBJDIR)/, $(SBEAPPSEEPROM_OBJECTS)) +OBJS = $(addprefix $(OBJDIR)/, $(APPPOWERSEEPROM_OBJECTS)) +LIBNAME = libsbeapppowerseeprom +endif -libsbeappseeprom.a: $(OBJS) - $(AR) crs $(OBJDIR)/libsbeappseeprom.a $(OBJDIR)/*.o +include img_defs.mk +include apppowerfiles.mk + +$(LIBNAME).a: $(OBJS) + $(AR) crs $(OBJDIR)/$(LIBNAME).a $(OBJDIR)/*.o -.PHONY: clean sbeappseeprom -sbeappseeprom: $(OBJS) +.PHONY: clean sbeapppower +sbeapppower: $(OBJS) $(OBJS) $(OBJS:.o=.d): | $(OBJDIR) $(OBJDIR): mkdir -p $(OBJDIR) - #clean the kernel directory first, then the application level clean clean: rm -fr $(OBJDIR) diff --git a/src/sbefw/app/sbeappseepromfiles.mk b/src/sbefw/app/power/apppowerfiles.mk index b79a1cd1..531c8787 100644 --- a/src/sbefw/app/sbeappseepromfiles.mk +++ b/src/sbefw/app/power/apppowerfiles.mk @@ -1,11 +1,11 @@ # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # -# $Source: src/sbefw/app/sbeappseepromfiles.mk $ +# $Source: src/sbefw/app/power/apppowerfiles.mk $ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2017 +# Contributors Listed Below - COPYRIGHT 2015,2018 # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,9 +21,16 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG -SBEAPPSEEPROM-CPP-SOURCES = sbeapp.C +APPPOWERPIBMEM-CPP-SOURCES = chipop_table.C -SBEAPPSEEPROM-C-SOURCES = -SBEAPPSEEPROM-S-SOURCES = +APPPOWERPIBMEM-C-SOURCES = +APPPOWERPIBMEM-S-SOURCES = -SBEAPPSEEPROM_OBJECTS = $(SBEAPPSEEPROM-C-SOURCES:.c=.o) $(SBEAPPSEEPROM-CPP-SOURCES:.C=.o) $(SBEAPPSEEPROM-S-SOURCES:.S=.o) +APPPOWERPIBMEM_OBJECTS = $(APPPOWERPIBMEM-C-SOURCES:.c=.o) $(APPPOWERPIBMEM-CPP-SOURCES:.C=.o) $(APPPOWERPIBMEM-S-SOURCES:.S=.o) + +APPPOWERSEEPROM-CPP-SOURCES = sbeapp.C + +APPPOWERSEEPROM-C-SOURCES = +APPPOWERSEEPROM-S-SOURCES = + +APPPOWERSEEPROM_OBJECTS = $(APPPOWERSEEPROM-C-SOURCES:.c=.o) $(APPPOWERSEEPROM-CPP-SOURCES:.C=.o) $(APPPOWERSEEPROM-S-SOURCES:.S=.o) diff --git a/src/sbefw/app/power/chipop_table.C b/src/sbefw/app/power/chipop_table.C new file mode 100644 index 00000000..471262fe --- /dev/null +++ b/src/sbefw/app/power/chipop_table.C @@ -0,0 +1,317 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/sbefw/app/power/chipop_table.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2017,2018 */ +/* */ +/* */ +/* 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 "sbecmdscomaccess.H" +#include "sbecmdiplcontrol.H" +#include "sbecmdgeneric.H" +#include "sbecmdmemaccess.H" +#include "sbecmdregaccess.H" +#include "sbecmdcntrldmt.H" +#include "sbecmdringaccess.H" +#include "sbecmdsram.H" +#include "sbecmdcntlinst.H" +#include "sbecmdringaccess.H" +#include "sbetrace.H" +#include "sbe_sp_intf.H" +#include "sbeHostMsg.H" +#include "sbe_host_intf.H" +#include "sbestates.H" +#include "sberegaccess.H" +#include "sbecmdmpipl.H" +#include "sbecmdtracearray.H" +#include "sbecmdCntrlTimer.H" +#include "sbecmdfastarray.H" + +#include "core/chipop_handler.H" + +static const uint16_t HARDWARE_FENCED_STATE = + SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_DMT; + +static const uint16_t PUT_HARDWARE_FENCED_STATE = + HARDWARE_FENCED_STATE|SBE_FENCE_AT_MPIPL; + +//////////////////////////////////////////////////////////////// +// @brief g_sbeScomCmdArray +//////////////////////////////////////////////////////////////// +CMD_ARR( + A2, + {sbeGetScom, + SBE_CMD_GETSCOM, + HARDWARE_FENCED_STATE, + }, + {sbePutScom, + SBE_CMD_PUTSCOM, + HARDWARE_FENCED_STATE, + }, + {sbeModifyScom, + SBE_CMD_MODIFYSCOM, + HARDWARE_FENCED_STATE, + }, + {sbePutScomUnderMask, + SBE_CMD_PUTSCOM_MASK, + HARDWARE_FENCED_STATE, + }, + {sbeMultiScom, + SBE_CMD_MULTISCOM, + HARDWARE_FENCED_STATE, + } +) + +//////////////////////////////////////////////////////////////// +// @brief g_sbeIplControlCmdArray +// +//////////////////////////////////////////////////////////////// +CMD_ARR( + A1, + {sbeHandleIstep, + SBE_CMD_EXECUTE_ISTEP, + HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING, + }, + {sbeHandleSuspendIO, + SBE_CMD_SUSPEND_IO, + SBE_FENCE_AT_DUMPING, + } +) + +//////////////////////////////////////////////////////////////// +// @brief g_sbeGenericCmdArray +// +//////////////////////////////////////////////////////////////// +CMD_ARR( + A8, + {sbeGetCapabilities, + SBE_CMD_GET_SBE_CAPABILITIES, + SBE_NO_FENCE, + }, + + {sbeGetFfdc, + SBE_CMD_GET_SBE_FFDC, + SBE_NO_FENCE, + }, + + {sbeFifoQuiesce, + SBE_CMD_QUIESCE, + SBE_NO_FENCE, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeMemoryAccessCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + A4, + {sbeGetMem, + SBE_CMD_GETMEM, + SBE_FENCE_AT_CONTINUOUS_IPL, + }, + + {sbePutMem, + SBE_CMD_PUTMEM, + PUT_HARDWARE_FENCED_STATE, + }, + + {sbeGetOccSram, + SBE_CMD_GETSRAM_OCC, + HARDWARE_FENCED_STATE, + }, + + {sbePutOccSram, + SBE_CMD_PUTSRAM_OCC, + PUT_HARDWARE_FENCED_STATE, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeInstructionCntlCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + A7, + {sbeCntlInst, + SBE_CMD_CONTROL_INSTRUCTIONS, + HARDWARE_FENCED_STATE, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeRegAccessCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + A5, + {sbeGetReg, + SBE_CMD_GETREG, + HARDWARE_FENCED_STATE, + }, + {sbePutReg, + SBE_CMD_PUTREG, + PUT_HARDWARE_FENCED_STATE | SBE_FENCE_AT_SECURE_MODE, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeMpiplCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + A9, + {sbeEnterMpipl, + SBE_CMD_MPIPL_ENTER, + PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_ISTEP| + SBE_FENCE_AT_DUMPING, + // Allow Fspless system to enter MPIPL + // Issue 157287 + }, + + {sbeContinueMpipl, + SBE_CMD_MPIPL_CONTINUE, + HARDWARE_FENCED_STATE|SBE_FENCE_AT_ISTEP| + SBE_FENCE_AT_RUNTIME|SBE_FENCE_AT_DUMPING, + // Only allowed State is MPIPL + }, + + {sbeStopClocks, + SBE_CMD_MPIPL_STOPCLOCKS, + HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeRingAccessCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + A3, + {sbeGetRing, + SBE_CMD_GETRING, + SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE, + }, + + {sbePutRing, + SBE_CMD_PUTRING, + HARDWARE_FENCED_STATE|SBE_FENCE_AT_QUIESCE, + } +) + +//////////////////////////////////////////////////////////////// +// @brief g_sbeArrayAccessCmdArray[] +// +//////////////////////////////////////////////////////////////// +CMD_ARR( + A6, + {sbeControlFastArray, + SBE_CMD_CONTROL_FAST_ARRAY, + SBE_FENCE_AT_QUIESCE, + }, + {sbeControlTraceArray, + SBE_CMD_CONTROL_TRACE_ARRAY, + SBE_FENCE_AT_QUIESCE, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeCoreStateControlCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + D1, + {sbeControlDeadmanTimer, + SBE_PSU_CMD_CONTROL_DEADMAN, + SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE| + SBE_FENCE_AT_MPIPL|SBE_FENCE_AT_ISTEP| + SBE_FENCE_AT_DUMPING, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbeControlTimerCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + D4, + {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 +// +////////////////////////////////////////////////////////////// +CMD_ARR( + D3, + {sbePutRingFromImagePSU, + SBE_PSU_MSG_PUT_RING_FROM_IMAGE, + PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_QUIESCE, + } +) +// +////////////////////////////////////////////////////////////// +// @brief g_sbePsuGenericCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + D6, + {sbeUpdateMemAccessRegion, + SBE_PSU_MSG_UPDATE_MEM_REGION, + SBE_FENCE_AT_QUIESCE, + } +) + +////////////////////////////////////////////////////////////// +// @brief g_sbePsuGenericCmdArray +// +////////////////////////////////////////////////////////////// +CMD_ARR( + D7, + {sbeReadMem, + SBE_PSU_GENERIC_MSG_READ_SBE_MEM, + SBE_NO_FENCE, + }, + + {sbeSetFFDCAddr, + SBE_PSU_GENERIC_MSG_SET_FFDC_ADDR, + SBE_NO_FENCE, + }, + + {sbePsuQuiesce, + SBE_PSU_GENERIC_MSG_QUIESCE, + SBE_NO_FENCE, + }, + + {sbeSetSystemFabricMap, + SBE_PSU_GENERIC_MSG_SYSTEM_FABRIC_MAP, + SBE_NO_FENCE, + }, + + {sbeStashKeyAddrPair, + SBE_PSU_GENERIC_MSG_STASH_MPIPL_CONFIG, + SBE_NO_FENCE, + } +) + +// Mandatory macro inclusion +CMD_CLASS_DEFAULT_INTIALISATION diff --git a/src/sbefw/app/sbeapp.C b/src/sbefw/app/power/sbeapp.C index 036cd551..569a0955 100644 --- a/src/sbefw/app/sbeapp.C +++ b/src/sbefw/app/power/sbeapp.C @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/sbefw/app/sbeapp.C $ */ +/* $Source: src/sbefw/app/power/sbeapp.C $ */ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2017 */ +/* Contributors Listed Below - COPYRIGHT 2017,2018 */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ diff --git a/src/sbefw/app/sbeappfiles.mk b/src/sbefw/app/sbeappfiles.mk deleted file mode 100644 index 6cfbb542..00000000 --- a/src/sbefw/app/sbeappfiles.mk +++ /dev/null @@ -1,29 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/sbefw/app/sbeappfiles.mk $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2015,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 -SBEAPP-CPP-SOURCES = sbeapp.C - -SBEAPP-C-SOURCES = -SBEAPP-S-SOURCES = - -SBEAPP_OBJECTS = $(SBEAPP-C-SOURCES:.c=.o) $(SBEAPP-CPP-SOURCES:.C=.o) $(SBEAPP-S-SOURCES:.S=.o) diff --git a/src/sbefw/core/chipop_handler.C b/src/sbefw/core/chipop_handler.C new file mode 100644 index 00000000..b2ae4991 --- /dev/null +++ b/src/sbefw/core/chipop_handler.C @@ -0,0 +1,221 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/sbefw/core/chipop_handler.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2017,2018 */ +/* */ +/* */ +/* 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 "sbetrace.H" +#include "sbe_sp_intf.H" +#include "sbestates.H" +#include "sberegaccess.H" +#include "sbeglobals.H" + +#include "chipop_handler.H" + +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +uint8_t sbeGetCmdStructAttr (const uint8_t i_cmdClass, + cmdStruct_t **o_ppCmd) +{ + #define SBE_FUNC " sbeGetCmdStructAttr " + uint8_t l_numCmds = 0; + *o_ppCmd = NULL; + + size_t cmdClassIndex = HASH_KEY(i_cmdClass); + if(cmdClassIndex < cmdClassTable.len && + cmdClassTable.cmdClassArr[cmdClassIndex].cmdTable) + { + l_numCmds = cmdClassTable.cmdClassArr[cmdClassIndex].cmdTable->len; + *o_ppCmd = cmdClassTable.cmdClassArr[cmdClassIndex].cmdTable->cmdArr; + } + + return l_numCmds; + #undef SBE_FUNC +} + +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +uint8_t sbeValidateCmdClass (const uint8_t i_cmdClass, + const uint8_t i_cmdOpcode) +{ + #define SBE_FUNC " sbeValidateCmdClass " + uint8_t l_rc = SBE_SEC_COMMAND_NOT_SUPPORTED; + + SBE_INFO(SBE_FUNC"i_cmdClass[0x%02X], " + "i_cmdOpcode[0x%02X]", i_cmdClass, i_cmdOpcode); + + do + { + uint8_t l_numCmds = 0; + cmdStruct_t *l_pCmd = NULL; + + l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd); + if (!l_numCmds) + { + SBE_ERROR(SBE_FUNC"SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED " + "i_cmdClass[0x%02X], i_cmdOpcode[0x%02X]", + i_cmdClass, i_cmdOpcode); + // Command class not supported + l_rc = SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED; + break; + } + + // @TODO via RTC : 128654 + // Analyze on merging the validation functions into one + // and also on using loop vs switch case performance + for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd) + { + if (i_cmdOpcode == l_pCmd->cmd_opcode) + { + // Command found + l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + break; + } + } + } while (false); + + return l_rc; + #undef SBE_FUNC +} + +sbeCmdFunc_t sbeFindCmdFunc (const uint8_t i_cmdClass, + const uint8_t i_cmdOpcode) + +{ + #define SBE_FUNC " sbeFindCmdFunc " + uint8_t l_numCmds = 0; + cmdStruct_t *l_pCmd = NULL; + + l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd); + + for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd) + { + if (i_cmdOpcode == l_pCmd->cmd_opcode) + { + break; + } + } + + return l_pCmd ? (l_pCmd->cmd_func) : NULL; + #undef SBE_FUNC +} + +sbeChipOpRc_t sbeIsCmdAllowed (const uint8_t i_cmdClass, + const uint8_t i_cmdOpcode) +{ + #define SBE_FUNC " sbeIsCmdAllowedAtState " + bool l_ret = true; + sbeChipOpRc_t retRc; + uint8_t l_numCmds = 0; + cmdStruct_t *l_pCmd = NULL; + l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd); + + for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd) + { + if (i_cmdOpcode == l_pCmd->cmd_opcode) + { + // Get the Present State + uint64_t l_state = + SbeRegAccess::theSbeRegAccess().getSbeState(); + SBE_INFO(SBE_FUNC "SBE State [0x%08X] Fence State[0x%04X]", + (uint32_t)(l_state & 0xFFFFFFFF),l_pCmd->cmd_state_fence); + + switch(l_state) + { + case SBE_STATE_UNKNOWN: + case SBE_STATE_FAILURE: + // All operations are fenced here, return false + // Reset is the only Option available + break; + + case SBE_STATE_IPLING: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_CONTINUOUS_IPL)? false:true); + break; + } + + case SBE_STATE_ISTEP: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_ISTEP)? false:true); + break; + } + + case SBE_STATE_RUNTIME: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_RUNTIME)? false:true); + break; + } + + case SBE_STATE_DUMP: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_DUMPING)? false:true); + break; + } + + case SBE_STATE_MPIPL: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_MPIPL)? false:true); + break; + } + + case SBE_STATE_DMT: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_DMT)? false:true); + break; + } + + case SBE_STATE_QUIESCE: + { + l_ret = ((l_pCmd->cmd_state_fence & + SBE_FENCE_AT_QUIESCE)? false:true); + break; + } + + default: + l_ret = false; + break; + } + if(false == l_ret) + { + retRc.primStatus = SBE_PRI_INVALID_COMMAND; + retRc.secStatus = SBE_SEC_COMMAND_NOT_ALLOWED_IN_THIS_STATE; + break; + } + // Check if the command is allowed in current security mode + if((SBE_GLOBAL->sbeFWSecurityEnabled) + && (SBE_FENCE_AT_SECURE_MODE & l_pCmd->cmd_state_fence)) + { + retRc.primStatus = SBE_PRI_UNSECURE_ACCESS_DENIED; + retRc.secStatus = SBE_SEC_BLACKLISTED_CHIPOP_ACCESS; + break; + } + break; + } + } + // For any other state, which is not handled above, return from here + return retRc; + #undef SBE_FUNC +} diff --git a/src/sbefw/core/sbecmdparser.H b/src/sbefw/core/chipop_handler.H index 3d90c007..79761169 100644 --- a/src/sbefw/core/sbecmdparser.H +++ b/src/sbefw/core/chipop_handler.H @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/sbefw/core/sbecmdparser.H $ */ +/* $Source: src/sbefw/core/chipop_handler.H $ */ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2017,2018 */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -21,17 +21,10 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ -/* - * @file: ppe/sbe/sbefw/sbecmdparser.H - * - * @brief This file contains the SBE command details - * - */ - -#ifndef __SBEFW_SBECMDPARSER_H -#define __SBEFW_SBECMDPARSER_H +#pragma once #include <stdint.h> +#include <stddef.h> #include "sbe_sp_intf.H" // Chip-op response codes @@ -131,5 +124,92 @@ typedef uint32_t ( *sbeCmdFunc_t ) (uint8_t *i_pArg); sbeCmdFunc_t sbeFindCmdFunc (const uint8_t i_cmdClass, const uint8_t i_cmdOpcode); +////////////////////////////CHIP-OP table helper//////////////////////////// +typedef struct { + sbeChipOpFunc_t cmd_func; /* Command function pointer */ + uint8_t cmd_opcode; /* Command opcode */ + uint16_t cmd_state_fence; /* Command fencing based on SBE state */ +} cmdStruct_t; + +typedef struct { + cmdStruct_t* cmdArr; + size_t len; +} cmdStructTable_t; + +typedef struct +{ + uint8_t cmdClass; + cmdStructTable_t* cmdTable; +} cmdClass_t; + +typedef struct +{ + cmdClass_t* cmdClassArr; + size_t len; +} cmdClassTable_t; + +extern cmdClassTable_t cmdClassTable; +extern cmdStructTable_t cmdTable; + +///////////////Auto population of chip-op table in project files/////////////// +#define CMD_CLASS(cmdClass) \ + { 0x##cmdClass, cmdStructP_t<0x##cmdClass>::value } + +template <int T> +struct cmdStructP_t +{ + static constexpr cmdStructTable_t* value = NULL; +}; + +#define CMD_ARR(cmdclass, ...) \ + cmdStruct_t cmdClassArr_##cmdclass[] = \ + { \ + __VA_ARGS__ \ + }; \ + \ + cmdStructTable_t cmdClassArr_table_##cmdclass = { \ + cmdClassArr_##cmdclass, \ + sizeof(cmdClassArr_##cmdclass)/sizeof(cmdClassArr_##cmdclass[0]) \ + }; \ + template <> \ + struct cmdStructP_t<0x##cmdclass> \ + { \ + static constexpr cmdStructTable_t* value = &cmdClassArr_table_##cmdclass; \ + }; + +// Keep this hash updated with the cmdClassArr +#define HASH_KEY(key) (key < 0xD1 ? (key-0xA1) : (key-0xD1+0x09)) + +#define CMD_CLASS_DEFAULT_INTIALISATION \ +constexpr cmdClass_t cmdClassArr[] = { \ + CMD_CLASS(A1), \ + CMD_CLASS(A2), \ + CMD_CLASS(A3), \ + CMD_CLASS(A4), \ + CMD_CLASS(A5), \ + CMD_CLASS(A6), \ + CMD_CLASS(A7), \ + CMD_CLASS(A8), \ + CMD_CLASS(A9), \ + CMD_CLASS(D1), \ + CMD_CLASS(D2), \ + CMD_CLASS(D3), \ + CMD_CLASS(D4), \ + CMD_CLASS(D5), \ + CMD_CLASS(D6), \ + CMD_CLASS(D7), \ +}; \ +\ +cmdClassTable_t cmdClassTable = { \ + const_cast<cmdClass_t*>(cmdClassArr), \ + sizeof(cmdClassArr)/sizeof(cmdClassArr[0]) \ +}; \ +\ +constexpr bool validateCmdClassHash(uint8_t index) { \ + return (index >= sizeof(cmdClassArr)/sizeof(cmdClassArr[0])) || \ + ((HASH_KEY(cmdClassArr[index].cmdClass)) == index && \ + validateCmdClassHash(index + 1)); \ +} \ +\ +static_assert(validateCmdClassHash(0), "Bad chipop_table, check cmdclass hashes"); -#endif // __SBEFW_SBECMDPARSER_H diff --git a/src/sbefw/core/sbecmdparser.C b/src/sbefw/core/sbecmdparser.C deleted file mode 100644 index 1671f8a3..00000000 --- a/src/sbefw/core/sbecmdparser.C +++ /dev/null @@ -1,603 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/sbefw/core/sbecmdparser.C $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2015,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/sbecmdparser.C - * - * @brief This file contains the SBE FIFO Commands - * - */ - -#include "sbecmdparser.H" -#include "sbecmdscomaccess.H" -#include "sbecmdiplcontrol.H" -#include "sbecmdgeneric.H" -#include "sbecmdmemaccess.H" -#include "sbecmdregaccess.H" -#include "sbecmdcntrldmt.H" -#include "sbecmdringaccess.H" -#include "sbecmdsram.H" -#include "sbecmdcntlinst.H" -#include "sbecmdringaccess.H" -#include "sbetrace.H" -#include "sbe_sp_intf.H" -#include "sbeHostMsg.H" -#include "sbe_host_intf.H" -#include "sbestates.H" -#include "sberegaccess.H" -#include "sbecmdmpipl.H" -#include "sbecmdtracearray.H" -#include "sbecmdCntrlTimer.H" -#include "sbecmdfastarray.H" -#include "sbeglobals.H" - -// Declaration -static const uint16_t HARDWARE_FENCED_STATE = - SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_DMT; - -static const uint16_t PUT_HARDWARE_FENCED_STATE = - HARDWARE_FENCED_STATE|SBE_FENCE_AT_MPIPL; - -//////////////////////////////////////////////////////////////// -// @brief g_sbeScomCmdArray -//////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeScomCmdArray [] = -{ - {sbeGetScom, - SBE_CMD_GETSCOM, - HARDWARE_FENCED_STATE, - }, - {sbePutScom, - SBE_CMD_PUTSCOM, - HARDWARE_FENCED_STATE, - }, - {sbeModifyScom, - SBE_CMD_MODIFYSCOM, - HARDWARE_FENCED_STATE, - }, - {sbePutScomUnderMask, - SBE_CMD_PUTSCOM_MASK, - HARDWARE_FENCED_STATE, - }, - {sbeMultiScom, - SBE_CMD_MULTISCOM, - HARDWARE_FENCED_STATE, - }, -}; - -//////////////////////////////////////////////////////////////// -// @brief g_sbeIplControlCmdArray -// -//////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeIplControlCmdArray [] = -{ - {sbeHandleIstep, - SBE_CMD_EXECUTE_ISTEP, - HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING, - }, - {sbeHandleSuspendIO, - SBE_CMD_SUSPEND_IO, - SBE_FENCE_AT_DUMPING, - }, -}; - -//////////////////////////////////////////////////////////////// -// @brief g_sbeGenericCmdArray -// -//////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeGenericCmdArray [] = -{ - {sbeGetCapabilities, - SBE_CMD_GET_SBE_CAPABILITIES, - SBE_NO_FENCE, - }, - - {sbeGetFfdc, - SBE_CMD_GET_SBE_FFDC, - SBE_NO_FENCE, - }, - - {sbeFifoQuiesce, - SBE_CMD_QUIESCE, - SBE_NO_FENCE, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbeMemoryAccessCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeMemoryAccessCmdArray [] = -{ - {sbeGetMem, - SBE_CMD_GETMEM, - SBE_FENCE_AT_CONTINUOUS_IPL, - }, - - {sbePutMem, - SBE_CMD_PUTMEM, - PUT_HARDWARE_FENCED_STATE, - }, - - {sbeGetOccSram, - SBE_CMD_GETSRAM_OCC, - HARDWARE_FENCED_STATE, - }, - - {sbePutOccSram, - SBE_CMD_PUTSRAM_OCC, - PUT_HARDWARE_FENCED_STATE, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbeInstructionCntlCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeInstructionCntlCmdArray[] = -{ - {sbeCntlInst, - SBE_CMD_CONTROL_INSTRUCTIONS, - HARDWARE_FENCED_STATE, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbeRegAccessCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeRegAccessCmdArray [] = -{ - {sbeGetReg, - SBE_CMD_GETREG, - HARDWARE_FENCED_STATE, - }, - - {sbePutReg, - SBE_CMD_PUTREG, - PUT_HARDWARE_FENCED_STATE | SBE_FENCE_AT_SECURE_MODE, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbeMpiplCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeMpiplCmdArray[] = -{ - {sbeEnterMpipl, - SBE_CMD_MPIPL_ENTER, - PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_ISTEP| - SBE_FENCE_AT_DUMPING, - // Allow Fspless system to enter MPIPL - // Issue 157287 - }, - - {sbeContinueMpipl, - SBE_CMD_MPIPL_CONTINUE, - HARDWARE_FENCED_STATE|SBE_FENCE_AT_ISTEP| - SBE_FENCE_AT_RUNTIME|SBE_FENCE_AT_DUMPING, - // Only allowed State is MPIPL - }, - - {sbeStopClocks, - SBE_CMD_MPIPL_STOPCLOCKS, - HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbeRingAccessCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeRingAccessCmdArray [] = -{ - {sbeGetRing, - SBE_CMD_GETRING, - SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE, - }, - - {sbePutRing, - SBE_CMD_PUTRING, - HARDWARE_FENCED_STATE|SBE_FENCE_AT_QUIESCE, - }, -}; - -// @brief g_sbeArrayAccessCmdArray[] -// -//////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeArrayAccessCmdArray[] = -{ - {sbeControlFastArray, - SBE_CMD_CONTROL_FAST_ARRAY, - SBE_FENCE_AT_QUIESCE, - }, - {sbeControlTraceArray, - SBE_CMD_CONTROL_TRACE_ARRAY, - SBE_FENCE_AT_QUIESCE, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbeCoreStateControlCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbeCoreStateControlCmdArray [] = -{ - {sbeControlDeadmanTimer, - SBE_PSU_CMD_CONTROL_DEADMAN, - SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE| - SBE_FENCE_AT_MPIPL|SBE_FENCE_AT_ISTEP| - SBE_FENCE_AT_DUMPING, - }, -}; - -////////////////////////////////////////////////////////////// -// @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 -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbePutRingFromImageCmdArray [] = -{ - {sbePutRingFromImagePSU, - SBE_PSU_MSG_PUT_RING_FROM_IMAGE, - PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_QUIESCE, - }, -}; -// -////////////////////////////////////////////////////////////// -// @brief g_sbePsuGenericCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbePsuMemRegionCmdArray[] = -{ - {sbeUpdateMemAccessRegion, - SBE_PSU_MSG_UPDATE_MEM_REGION, - SBE_FENCE_AT_QUIESCE, - }, -}; - -////////////////////////////////////////////////////////////// -// @brief g_sbePsuGenericCmdArray -// -////////////////////////////////////////////////////////////// -static sbeCmdStruct_t g_sbePsuGenericCmdArray[] = -{ - {sbeReadMem, - SBE_PSU_GENERIC_MSG_READ_SBE_MEM, - SBE_NO_FENCE, - }, - - {sbeSetFFDCAddr, - SBE_PSU_GENERIC_MSG_SET_FFDC_ADDR, - SBE_NO_FENCE, - }, - - {sbePsuQuiesce, - SBE_PSU_GENERIC_MSG_QUIESCE, - SBE_NO_FENCE, - }, - - {sbeSetSystemFabricMap, - SBE_PSU_GENERIC_MSG_SYSTEM_FABRIC_MAP, - SBE_NO_FENCE, - }, - - {sbeStashKeyAddrPair, - SBE_PSU_GENERIC_MSG_STASH_MPIPL_CONFIG, - SBE_NO_FENCE, - }, -}; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -uint8_t sbeGetCmdStructAttr (const uint8_t i_cmdClass, - sbeCmdStruct_t **o_ppCmd) -{ - #define SBE_FUNC " sbeGetCmdStructAttr " - uint8_t l_numCmds = 0; - *o_ppCmd = NULL; - - switch(i_cmdClass) - { - // FIFO Commands - case SBE_CMD_CLASS_IPL_CONTROL: - // @TODO via RTC : 128655 - // Use C++ style typecase - l_numCmds = sizeof(g_sbeIplControlCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeIplControlCmdArray; - break; - case SBE_CMD_CLASS_SCOM_ACCESS: - l_numCmds = sizeof(g_sbeScomCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeScomCmdArray; - break; - case SBE_CMD_CLASS_GENERIC_MESSAGE: - l_numCmds = sizeof(g_sbeGenericCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeGenericCmdArray; - break; - - case SBE_CMD_CLASS_MEMORY_ACCESS: - l_numCmds = sizeof(g_sbeMemoryAccessCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeMemoryAccessCmdArray; - break; - - case SBE_CMD_CLASS_INSTRUCTION_CONTROL: - l_numCmds = sizeof(g_sbeInstructionCntlCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeInstructionCntlCmdArray; - break; - - case SBE_CMD_CLASS_REGISTER_ACCESS: - l_numCmds = sizeof(g_sbeRegAccessCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeRegAccessCmdArray; - break; - - case SBE_CMD_CLASS_RING_ACCESS: - l_numCmds = sizeof(g_sbeRingAccessCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeRingAccessCmdArray; - break; - - case SBE_CMD_CLASS_MPIPL_COMMANDS: - l_numCmds = sizeof(g_sbeMpiplCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeMpiplCmdArray; - break; - - case SBE_CMD_CLASS_ARRAY_ACCESS: - l_numCmds = sizeof(g_sbeArrayAccessCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeArrayAccessCmdArray; - break; - - // PSU Commands - case SBE_PSU_CMD_CLASS_CORE_STATE: - l_numCmds = sizeof(g_sbeCoreStateControlCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbeCoreStateControlCmdArray; - break; - - case SBE_PSU_CMD_CLASS_RING_ACCESS: - l_numCmds = sizeof(g_sbePutRingFromImageCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbePutRingFromImageCmdArray; - break; - - case SBE_PSU_CMD_CLASS_GENERIC: - l_numCmds = sizeof(g_sbePsuGenericCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbePsuGenericCmdArray; - break; - - case SBE_PSU_CMD_CLASS_SECURITY_CONTROL_MSG: - l_numCmds = sizeof(g_sbePsuMemRegionCmdArray) / - sizeof(sbeCmdStruct_t); - *o_ppCmd = (sbeCmdStruct_t*)g_sbePsuMemRegionCmdArray; - 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; - } - return l_numCmds; - #undef SBE_FUNC -} - - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -uint8_t sbeValidateCmdClass (const uint8_t i_cmdClass, - const uint8_t i_cmdOpcode) -{ - #define SBE_FUNC " sbeValidateCmdClass " - uint8_t l_rc = SBE_SEC_COMMAND_NOT_SUPPORTED; - - SBE_INFO(SBE_FUNC"i_cmdClass[0x%02X], " - "i_cmdOpcode[0x%02X]", i_cmdClass, i_cmdOpcode); - - do - { - uint8_t l_numCmds = 0; - sbeCmdStruct_t *l_pCmd = NULL; - - l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd); - if (!l_numCmds) - { - SBE_ERROR(SBE_FUNC"SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED " - "i_cmdClass[0x%02X], i_cmdOpcode[0x%02X]", - i_cmdClass, i_cmdOpcode); - // Command class not supported - l_rc = SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED; - break; - } - - // @TODO via RTC : 128654 - // Analyze on merging the validation functions into one - // and also on using loop vs switch case performance - for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd) - { - if (i_cmdOpcode == l_pCmd->cmd_opcode) - { - // Command found - l_rc = SBE_SEC_OPERATION_SUCCESSFUL; - break; - } - } - } while (false); - - return l_rc; - #undef SBE_FUNC -} - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -sbeChipOpRc_t sbeIsCmdAllowed (const uint8_t i_cmdClass, - const uint8_t i_cmdOpcode) -{ - #define SBE_FUNC " sbeIsCmdAllowedAtState " - bool l_ret = true; - sbeChipOpRc_t retRc; - uint8_t l_numCmds = 0; - sbeCmdStruct_t *l_pCmd = NULL; - l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd); - - for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd) - { - if (i_cmdOpcode == l_pCmd->cmd_opcode) - { - // Get the Present State - uint64_t l_state = - SbeRegAccess::theSbeRegAccess().getSbeState(); - SBE_INFO(SBE_FUNC "SBE State [0x%08X] Fence State[0x%04X]", - (uint32_t)(l_state & 0xFFFFFFFF),l_pCmd->cmd_state_fence); - - switch(l_state) - { - case SBE_STATE_UNKNOWN: - case SBE_STATE_FAILURE: - // All operations are fenced here, return false - // Reset is the only Option available - break; - - case SBE_STATE_IPLING: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_CONTINUOUS_IPL)? false:true); - break; - } - - case SBE_STATE_ISTEP: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_ISTEP)? false:true); - break; - } - - case SBE_STATE_RUNTIME: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_RUNTIME)? false:true); - break; - } - - case SBE_STATE_DUMP: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_DUMPING)? false:true); - break; - } - - case SBE_STATE_MPIPL: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_MPIPL)? false:true); - break; - } - - case SBE_STATE_DMT: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_DMT)? false:true); - break; - } - - case SBE_STATE_QUIESCE: - { - l_ret = ((l_pCmd->cmd_state_fence & - SBE_FENCE_AT_QUIESCE)? false:true); - break; - } - - default: - l_ret = false; - break; - } - - if(false == l_ret) - { - retRc.primStatus = SBE_PRI_INVALID_COMMAND; - retRc.secStatus = SBE_SEC_COMMAND_NOT_ALLOWED_IN_THIS_STATE; - break; - } - // Check if the command is allowed in current security mode - if((SBE_GLOBAL->sbeFWSecurityEnabled) - && (SBE_FENCE_AT_SECURE_MODE & l_pCmd->cmd_state_fence)) - { - retRc.primStatus = SBE_PRI_UNSECURE_ACCESS_DENIED; - retRc.secStatus = SBE_SEC_BLACKLISTED_CHIPOP_ACCESS; - break; - } - break; - } - } - return retRc; - #undef SBE_FUNC -} - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -sbeCmdFunc_t sbeFindCmdFunc (const uint8_t i_cmdClass, - const uint8_t i_cmdOpcode) - -{ - #define SBE_FUNC " sbeFindCmdFunc " - uint8_t l_numCmds = 0; - sbeCmdStruct_t *l_pCmd = NULL; - - l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd); - - for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd) - { - if (i_cmdOpcode == l_pCmd->cmd_opcode) - { - break; - } - } - - return l_pCmd ? (l_pCmd->cmd_func) : NULL; - #undef SBE_FUNC -} diff --git a/src/sbefw/core/sbecmdprocessor.C b/src/sbefw/core/sbecmdprocessor.C index aacf892a..476142bb 100644 --- a/src/sbefw/core/sbecmdprocessor.C +++ b/src/sbefw/core/sbecmdprocessor.C @@ -5,7 +5,8 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -31,7 +32,6 @@ #include "sbeexeintf.H" #include "sbefifo.H" -#include "sbecmdparser.H" #include "sbeirq.H" #include "sbetrace.H" #include "sbe_sp_intf.H" @@ -46,6 +46,7 @@ #include "fapi2.H" #include "sbeutil.H" #include "sbeglobals.H" +#include "core/chipop_handler.H" using namespace fapi2; // Forward declaration for performAttrSetup diff --git a/src/sbefw/core/sbecmdreceiver.C b/src/sbefw/core/sbecmdreceiver.C index ca716c65..15017a47 100644 --- a/src/sbefw/core/sbecmdreceiver.C +++ b/src/sbefw/core/sbecmdreceiver.C @@ -5,7 +5,8 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -31,7 +32,6 @@ #include "sbeexeintf.H" #include "sbefifo.H" -#include "sbecmdparser.H" #include "sbeirq.H" #include "sbetrace.H" #include "sbe_sp_intf.H" @@ -43,6 +43,8 @@ #include "sbeutil.H" #include "sbeglobals.H" +#include "core/chipop_handler.H" + ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// void sbeCommandReceiver_routine(void *i_pArg) diff --git a/src/sbefw/core/sbecorefiles.mk b/src/sbefw/core/sbecorefiles.mk index 3cfe235f..104a8fc1 100644 --- a/src/sbefw/core/sbecorefiles.mk +++ b/src/sbefw/core/sbecorefiles.mk @@ -5,7 +5,8 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2017 +# Contributors Listed Below - COPYRIGHT 2015,2018 +# [+] International Business Machines Corp. # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +26,6 @@ SBECORE-CPP-SOURCES = sbemain.C SBECORE-CPP-SOURCES += sbeirq.C SBECORE-CPP-SOURCES += sbecmdreceiver.C SBECORE-CPP-SOURCES += sbecmdprocessor.C -SBECORE-CPP-SOURCES += sbecmdparser.C SBECORE-CPP-SOURCES += sbecmdscomaccess.C SBECORE-CPP-SOURCES += sbecmdiplcontrol.C SBECORE-CPP-SOURCES += pool.C @@ -53,6 +53,7 @@ SBECORE-CPP-SOURCES += sbeglobals.C SBECORE-CPP-SOURCES += sbeMemAccessInterface.C SBECORE-CPP-SOURCES += sbeSecureMemRegionManager.C SBECORE-CPP-SOURCES += sbeSecurity.C +SBECORE-CPP-SOURCES += chipop_handler.C SBECORE-C-SOURCES = SBECORE-S-SOURCES = |