summaryrefslogtreecommitdiffstats
path: root/src/include/usr/fapi2
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/usr/fapi2')
-rw-r--r--src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H2
-rw-r--r--src/include/usr/fapi2/plat_hw_access.H8
-rw-r--r--src/include/usr/fapi2/subroutine_executor.H94
3 files changed, 97 insertions, 7 deletions
diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
index 16c871263..98eddff7b 100644
--- a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
+++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
@@ -59,6 +59,7 @@ namespace fapi2
MOD_FAPI2_PLAT_PARSE_WOF_TABLES = 0x10,
MOD_FAPI2_CVPD_ACCESS = 0x11,
MOD_FAPI2_BAD_DQ_BITMAP = 0x12,
+ MOD_FAPI2_GET_CHIP_CFAM_TARGET = 0x13,
};
/**
@@ -125,6 +126,7 @@ namespace fapi2
RC_MM_SET_PERMISSION_FAILED = FAPI2_COMP_ID | 0x31,
RC_MM_REMOVE_PAGES_FAILED = FAPI2_COMP_ID | 0x32,
RC_MM_SET_PERMISSION2_FAILED = FAPI2_COMP_ID | 0x33,
+ RC_INVALID_PARENT_TARGET_FOUND = FAPI2_COMP_ID | 0x34,
// HWP generated errors
RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f,
diff --git a/src/include/usr/fapi2/plat_hw_access.H b/src/include/usr/fapi2/plat_hw_access.H
index 94faa7443..3972f137f 100644
--- a/src/include/usr/fapi2/plat_hw_access.H
+++ b/src/include/usr/fapi2/plat_hw_access.H
@@ -220,6 +220,14 @@ void checkPibMask(errlHndl_t& io_errLog );
// No spy access interface as HB doesn't allow spy access.
// --------------------------------------------------------------------------
+/**
+* @brief Determine if a given target is on the master proc chip
+* @param[in] i_Target TARGETING::Target which op is being called on
+* @param[out] i_isMaster True if on master proc chip, false if not
+* @return errlHndl_t
+*/
+errlHndl_t isOnMasterProc(TARGETING::Target * i_target, bool & o_isMaster);
+
} // End namespace
diff --git a/src/include/usr/fapi2/subroutine_executor.H b/src/include/usr/fapi2/subroutine_executor.H
index 7d9acda1b..82ca296a3 100644
--- a/src/include/usr/fapi2/subroutine_executor.H
+++ b/src/include/usr/fapi2/subroutine_executor.H
@@ -37,8 +37,50 @@
#define SUBROUTINEEXECUTOR_H_
#include <fapi2_subroutine_executor.H>
-
+#include <errl/errlmanager.H>
+#include <string.h>
+#include <stdarg.h>
+#include <sbeio/sbeioif.H>
#include <plat_trace.H>
+#include <secureboot/service.H>
+#include <plat_hw_access.H>
+
+/**
+* @brief Given a hwp name, and its parameters, serialize the parmeters and pass the serialized
+* data to the SBE via a FIFO chipop
+* @param[in] i_hwpName String representing the name of the hwp to be called
+* @param[in] i_Target TARGETING::Target which op is being called on
+* @param[in] types Any variable length of arguments, which along with target should get passed
+* in as parameters to the given HWP
+* @return errlHndl_t Error log handle on failure.
+*/
+template<class... Types>
+errlHndl_t requestHwpViaSbe(const char * i_hwpName, TARGETING::Target * i_target, Types... types)
+{
+ errlHndl_t l_errl = nullptr;
+
+ //Determine argument byte size
+ size_t l_sizeOfArgInBytes =0;
+ using expander = int[];
+ (void) expander{ 0, (l_sizeOfArgInBytes+=sizeof(types), 0)... };
+
+ //Set up the buffer which will be passed to chip op send function
+ uint8_t l_buffer[l_sizeOfArgInBytes];
+ uint8_t* l_bufferPtr = &l_buffer[0];
+ memset(l_bufferPtr, 0, l_sizeOfArgInBytes);
+
+ // Serialize the arguments into the buffer
+ (void) expander{ 0, ((memcpy(l_bufferPtr,&types,sizeof(types)),l_bufferPtr+=sizeof(types)), 0)... };
+
+ //Call the chip op send function to request the SBE to call the HWP
+ l_errl = SBEIO::sendSecureHwpRequest(i_target, l_bufferPtr, l_sizeOfArgInBytes, i_hwpName);
+
+ return l_errl;
+}
+
+
+//Macros that return the 1st argument
+#define _GET_1ST_ARG(N, ...) N
/**
* @brief Subroutine Executor macro example code - Platforms will need to
@@ -48,11 +90,49 @@
* execute the Subroutine (e.g. dlopening a shared library)
*/
#define FAPI_PLAT_CALL_SUBROUTINE(RC, FUNC, _args...) \
+{ \
+ do \
{ \
- FAPI_DBG("executing FAPI_PLAT_CALL_SUBROUTINE macro"); \
- RC = FUNC(_args); \
- }
-
-//@todo - RTC:179062 - Add real chipop support
+ errlHndl_t l_errl = nullptr; \
+ /* Read the FUNC as a string and pass it to the conversion method \
+ to determine what hwp we need to request */ \
+ const char* l_function = #FUNC; \
+ /*Read the target argument, which is the first argument in the list */ \
+ TARGETING::Target* l_target = \
+ reinterpret_cast<TARGETING::Target*>(_GET_1ST_ARG(_args).get()); \
+ /*Check if secureboot is enabled and if the target exists on the master proc*/ \
+ bool isSecure = SECUREBOOT::enabled(); \
+ bool isMaster = false; \
+ l_errl = isOnMasterProc(l_target, isMaster); \
+ if(l_errl) \
+ { \
+ FAPI_INF("subroutine_executor: Failed trying to determine is target was on master chip"); \
+ RC.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); \
+ break; \
+ } \
+ /*Run hwp on host if targ is on master, we are not in securemode*/ \
+ if(isMaster || !isSecure) \
+ { \
+ FAPI_INF("subroutine_executor: isSecure = %d isMaster = %d .. executing hwp %s on host", \
+ isSecure, isMaster, l_function); \
+ RC = FUNC(_args); \
+ } \
+ /*Otherwise request the HWP via chipop to the SBE*/ \
+ else \
+ { \
+ FAPI_INF("subroutine_executor: isSecure = %d isMaster = %d .. executing hwp %s on host", \
+ isSecure, isMaster, l_function); \
+ l_errl = requestHwpViaSbe(l_function, l_target, _args); \
+ /*For now until SBE support comes fallback to running on host if chipop fails*/ \
+ if(l_errl) \
+ { \
+ /*Commit the error as informational and attempt hwp */ \
+ l_errl->setSev(ERRORLOG::ERRL_SEV_INFORMATIONAL); \
+ errlCommit(l_errl, SBEIO_COMP_ID); \
+ RC = FUNC(_args);\
+ } \
+ } \
+ } while(0); \
+}
-#endif
+#endif \ No newline at end of file
OpenPOWER on IntegriCloud