summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/runtime/interface.h50
-rw-r--r--src/include/usr/runtime/runtime_reasoncodes.H1
-rw-r--r--src/usr/isteps/pm/runtime/rt_pm.C174
-rw-r--r--src/usr/isteps/pm/runtime/test/firmwareRequestTest.H94
-rw-r--r--src/usr/pnor/test/makefile2
-rw-r--r--src/usr/testcore/rtloader/loader.H69
6 files changed, 350 insertions, 40 deletions
diff --git a/src/include/runtime/interface.h b/src/include/runtime/interface.h
index 7f2062775..265ba2d0f 100644
--- a/src/include/runtime/interface.h
+++ b/src/include/runtime/interface.h
@@ -490,6 +490,56 @@ typedef struct hostInterfaces
uint64_t i_scomData );
/**
+ * @brief Structure to be sent and received in the
+ * firmware_request call
+ *
+ */
+ enum
+ {
+ HBRT_FW_MSG_TYPE_REQ_NOP = 0,
+ HBRT_FW_MSG_TYPE_RESP_NOP = 1,
+ HBRT_FW_MSG_TYPE_RESP_GENERIC = 2,
+ HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE = 3,
+ };
+
+ struct hbrt_fw_msg // define struct hbrt_fw_msg
+ {
+ hbrt_fw_msg() { req_hcode_update = { 0 }; }; // ctor
+
+ uint64_t io_type; // message type from HBRT_FW_MSG_TYPE enum
+ union
+ {
+ // This struct is returned from skiboot with
+ // io_type set to HBRT_FW_MSG_TYPE_RESP_GENERIC or
+ // with HBRT_FW_MSG_TYPE_RESP_NOP
+ struct
+ {
+ uint64_t o_status; // return code for a generic response
+ } resp_generic;
+
+ // This struct is sent from HBRT with
+ // io_type set to HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE
+ struct
+ {
+ uint64_t i_chipId; // processor chip ID plus ID type,
+ // always proc (0x0)
+ uint32_t i_section; // runtime section to update
+ // (passthru to pore_gen_scom)
+ uint32_t i_operation; // type of operation to perform
+ // (passthru to pore_gen_scom)
+ uint64_t i_scomAddr; // fully qualified scom address
+ uint64_t i_scomData; // data for operation
+ } req_hcode_update;
+ };
+ };
+
+ // Created this enum to hold the base size of hbrt_fw_msg
+ // Can't do #define - sizeof not allowed to be used in #defines
+ // Can't do a constant, if you do, you will need to create
+ // an instance of this struct to get to it
+ enum { HBRT_FW_MSG_BASE_SIZE = sizeof(uint64_t) };
+
+ /**
* @brief Send a request to firmware, and receive a response
* @details
* req_len bytes are sent to runtime firmware, and resp_len
diff --git a/src/include/usr/runtime/runtime_reasoncodes.H b/src/include/usr/runtime/runtime_reasoncodes.H
index c36b9415d..8bf056675 100644
--- a/src/include/usr/runtime/runtime_reasoncodes.H
+++ b/src/include/usr/runtime/runtime_reasoncodes.H
@@ -57,6 +57,7 @@ namespace RUNTIME
MOD_POPULATE_TPMINFOBYNODE = 0x19, /**< populate_hbruntime.C */
MOD_FILL_RSVMEM_HBDATA = 0x20, /**< populate_hbruntime.C */
MOD_ATTR_RUNTIME_CHECK_PREP_FAIL = 0x21, /**< populate_hbruntime.C */
+ MOD_PM_RT_FIRMWARE_REQUEST = 0x22, /**< rt_pm.C */
};
enum RuntimeReasonCode
diff --git a/src/usr/isteps/pm/runtime/rt_pm.C b/src/usr/isteps/pm/runtime/rt_pm.C
index 070512b8d..862e92ce7 100644
--- a/src/usr/isteps/pm/runtime/rt_pm.C
+++ b/src/usr/isteps/pm/runtime/rt_pm.C
@@ -334,11 +334,12 @@ namespace RTPM
}
if( g_hostInterfaces == NULL ||
- g_hostInterfaces->hcode_scom_update == NULL )
+ ( g_hostInterfaces->hcode_scom_update == NULL &&
+ g_hostInterfaces->firmware_request == NULL ))
{
TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
- ERR_MRK"hcode_update: "
- "Hypervisor hcode_scom_update interface not linked");
+ ERR_MRK"hcode_update: Hypervisor hcode_scom_update"
+ "/firmware_request interface not linked");
/*@
* @errortype
* @moduleid MOD_PM_RT_HCODE_UPDATE
@@ -346,15 +347,17 @@ namespace RTPM
* @userdata1[0:31] Target HUID
* @userdata1[32:63] SCOM restore section
* @userdata2 SCOM address
- * @devdesc HCODE scom update runtime interface not linked.
+ * @devdesc HCODE scom update runtime
+ * interface not linked.
*/
- l_err= new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL,
- MOD_PM_RT_HCODE_UPDATE,
- RC_PM_RT_INTERFACE_ERR,
- TWO_UINT32_TO_UINT64(
+ l_err= new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ MOD_PM_RT_HCODE_UPDATE,
+ RC_PM_RT_INTERFACE_ERR,
+ TWO_UINT32_TO_UINT64(
TARGETING::get_huid(i_target),
i_section),
- i_rel_scom_addr);
+ i_rel_scom_addr);
break;
}
@@ -393,37 +396,130 @@ namespace RTPM
break;
}
- rc = g_hostInterfaces->hcode_scom_update(l_chipId,
- i_section,
- i_operation,
- l_scomAddr,
- i_scom_data);
-
- if(rc)
+ // If hcode_scom_update is not NULL then use that method
+ // else use firmware_request. hcode_scom_update takes
+ // precedence over firmware_request
+ if (g_hostInterfaces->hcode_scom_update != nullptr)
{
- TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
- ERR_MRK"hcode_update: "
- "HCODE scom update failed. "
- "rc 0x%X target 0x%llX chipId 0x%llX section 0x%X "
- "operation 0x%X scomAddr 0x%llX scomData 0x%llX",
- rc, get_huid(i_target), l_chipId, i_section,
- i_operation, l_scomAddr, i_scom_data);
-
- // convert rc to error log
- /*@
- * @errortype
- * @moduleid MOD_PM_RT_HCODE_UPDATE
- * @reasoncode RC_PM_RT_HCODE_UPDATE_ERR
- * @userdata1 Hypervisor return code
- * @userdata2 SCOM address
- * @devdesc HCODE SCOM update error
- */
- l_err=new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL,
- MOD_PM_RT_HCODE_UPDATE,
- RC_PM_RT_HCODE_UPDATE_ERR,
- rc,
- l_scomAddr);
- break;
+ rc = g_hostInterfaces->hcode_scom_update(l_chipId,
+ i_section,
+ i_operation,
+ l_scomAddr,
+ i_scom_data);
+ if(rc)
+ {
+ TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
+ ERR_MRK"hcode_update: "
+ "HCODE scom update failed. "
+ "rc 0x%X target 0x%llX chipId 0x%llX section 0x%X "
+ "operation 0x%X scomAddr 0x%llX scomData 0x%llX",
+ rc, get_huid(i_target), l_chipId, i_section,
+ i_operation, l_scomAddr, i_scom_data);
+
+ // convert rc to error log
+ /*@
+ * @errortype
+ * @moduleid MOD_PM_RT_HCODE_UPDATE
+ * @reasoncode RC_PM_RT_HCODE_UPDATE_ERR
+ * @userdata1 Hypervisor return code
+ * @userdata2 SCOM address
+ * @devdesc HCODE SCOM update error
+ */
+ l_err=new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ MOD_PM_RT_HCODE_UPDATE,
+ RC_PM_RT_HCODE_UPDATE_ERR,
+ rc,
+ l_scomAddr);
+ break;
+ }
+ }
+ else if (g_hostInterfaces->firmware_request != nullptr)
+ {
+ hostInterfaces::hbrt_fw_msg l_req_fw_msg;
+ l_req_fw_msg.io_type =
+ hostInterfaces::HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE;
+ l_req_fw_msg.req_hcode_update.i_chipId = l_chipId;
+ l_req_fw_msg.req_hcode_update.i_section = i_section;
+ l_req_fw_msg.req_hcode_update.i_operation = i_operation;
+ l_req_fw_msg.req_hcode_update.i_scomAddr = l_scomAddr;
+ l_req_fw_msg.req_hcode_update.i_scomData = i_scom_data;
+
+ hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
+ uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
+ rc = g_hostInterfaces->firmware_request(sizeof(l_req_fw_msg),
+ &l_req_fw_msg, &l_resp_fw_msg_size, &l_resp_fw_msg);
+ if(rc)
+ {
+ TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
+ ERR_MRK"firmware request: "
+ "firmware request for hcode scom update failed. "
+ "rc 0x%X target 0x%llX chipId 0x%llX section 0x%X "
+ "operation 0x%X scomAddr 0x%llX scomData 0x%llX",
+ rc, get_huid(i_target), l_chipId, i_section,
+ i_operation, l_scomAddr, i_scom_data);
+
+ // convert rc to error log
+ /*@
+ * @errortype
+ * @moduleid MOD_PM_RT_FIRMWARE_REQUEST
+ * @reasoncode RC_PM_RT_HCODE_UPDATE_ERR
+ * @userdata1[0:31] Firmware Request return code
+ * @userdata1[32:63] SCOM address
+ * @userdata2[0:31] Generic response code - if it exits
+ * @userdata2[32:63] Firmware Respone type
+ * @devdesc Firmware Request for
+ * HCODE SCOM update error
+ */
+ //
+ // Pack the generic responce code if the response
+ // is of type "RESP_GENERIC"
+ // else just send the response type alone
+ uint64_t l_userData2 = 0;
+ if (l_resp_fw_msg_size >=
+ hostInterfaces::HBRT_FW_MSG_BASE_SIZE)
+ {
+ // just assign the response type for now
+ l_userData2 = l_resp_fw_msg.io_type;
+
+ // Pack the response code if it is available
+ if ((l_resp_fw_msg_size >=
+ (hostInterfaces::HBRT_FW_MSG_BASE_SIZE +
+ sizeof(l_resp_fw_msg.resp_generic))) &&
+ hostInterfaces::HBRT_FW_MSG_TYPE_RESP_GENERIC ==
+ l_resp_fw_msg.io_type)
+ {
+ l_userData2 = TWO_UINT32_TO_UINT64
+ (l_resp_fw_msg.resp_generic.o_status,
+ l_resp_fw_msg.io_type);
+ }
+ }
+
+ l_err=new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ MOD_PM_RT_FIRMWARE_REQUEST,
+ RC_PM_RT_HCODE_UPDATE_ERR,
+ TWO_UINT32_TO_UINT64(rc, l_scomAddr),
+ l_userData2);
+
+ if (l_resp_fw_msg_size > 0)
+ {
+ l_err->addFFDC( ISTEP_COMP_ID,
+ &l_resp_fw_msg,
+ l_resp_fw_msg_size,
+ 0, 0, false );
+ }
+
+ if (sizeof(l_req_fw_msg) > 0)
+ {
+ l_err->addFFDC( ISTEP_COMP_ID,
+ &l_req_fw_msg,
+ sizeof(l_req_fw_msg),
+ 0, 0, false );
+ }
+
+ break;
+ }
}
// Disable special wakeup
diff --git a/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H b/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H
new file mode 100644
index 000000000..2ac57ddd5
--- /dev/null
+++ b/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H
@@ -0,0 +1,94 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/isteps/pm/runtime/test/firmwareRequestTest.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014,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 */
+
+#include <cxxtest/TestSuite.H>
+#include <runtime/interface.h>
+
+extern trace_desc_t* g_trac_pnor;
+
+class FirmwareRequestTest : public CxxTest::TestSuite
+{
+ public:
+ /**
+ * @brief: testFirmwareRequest
+ * tests that the firmware_request is being accessed properly
+ */
+ void testFirmwareRequest (void)
+ {
+ TRACFCOMP(g_trac_pnor, ENTER_MRK
+ "FirmwareRequestTest::testFirmwareRequest" );
+
+ if (g_hostInterfaces == NULL ||
+ g_hostInterfaces->firmware_request == NULL)
+ {
+ TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
+ "Hypervisor firmware_request interface not linked");
+ }
+ else
+ {
+ hostInterfaces::hbrt_fw_msg l_req_fw_msg;
+ l_req_fw_msg.io_type =
+ hostInterfaces::HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE;
+ l_req_fw_msg.req_hcode_update.i_chipId = 0;
+ l_req_fw_msg.req_hcode_update.i_section = 0;
+ l_req_fw_msg.req_hcode_update.i_operation = 0;
+ l_req_fw_msg.req_hcode_update.i_scomAddr = 0;
+ l_req_fw_msg.req_hcode_update.i_scomData = 0;
+
+
+ hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
+ uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
+ int rc = g_hostInterfaces->firmware_request(sizeof(l_resp_fw_msg),
+ &l_req_fw_msg, &l_resp_fw_msg_size, &l_resp_fw_msg);
+
+ TRACFCOMP(g_trac_pnor, "FirmwareRequestTest::testFirmwareRequest: "
+ "rc:%d, type:%d, resp:%d",
+ rc, l_resp_fw_msg.io_type,
+ l_resp_fw_msg.resp_generic.o_status);
+
+ if (rc != 1)
+ {
+ TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
+ "firware_request failed - returned wrong value");
+ }
+
+ if (l_resp_fw_msg.io_type !=
+ hostInterfaces::HBRT_FW_MSG_TYPE_RESP_GENERIC)
+ {
+ TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
+ "firware_request failed - received incorrect msg_type");
+ }
+
+ if (l_resp_fw_msg.resp_generic.o_status != 264)
+ {
+ TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
+ "firware_request failed - received incorrect resp");
+ }
+
+ TRACFCOMP(g_trac_pnor, EXIT_MRK
+ "FirmwareRequestTest::testFirmwareRequest");
+ }
+ }
+};
diff --git a/src/usr/pnor/test/makefile b/src/usr/pnor/test/makefile
index 098ea84a9..f7dc08612 100644
--- a/src/usr/pnor/test/makefile
+++ b/src/usr/pnor/test/makefile
@@ -5,7 +5,7 @@
#
# OpenPOWER HostBoot Project
#
-# Contributors Listed Below - COPYRIGHT 2011,2016
+# Contributors Listed Below - COPYRIGHT 2011,2017
# [+] Google Inc.
# [+] International Business Machines Corp.
#
diff --git a/src/usr/testcore/rtloader/loader.H b/src/usr/testcore/rtloader/loader.H
index ac454e9f1..58979745d 100644
--- a/src/usr/testcore/rtloader/loader.H
+++ b/src/usr/testcore/rtloader/loader.H
@@ -46,6 +46,7 @@
#include <config.h>
#include <util/utilrsvdmem.H>
#include <sys/misc.h>
+#include <errno.h>
trace_desc_t* g_trac_hbrt = NULL;
@@ -145,6 +146,7 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
intf->ipmi_msg= rt_ipmi_msg;
intf->clock_gettime = clock_gettime;
intf->hcode_scom_update = rt_hcode_update;
+ intf->firmware_request = rt_firmware_request;
// Call init.
runtimeInterfaces_t* rtInterface =
@@ -702,6 +704,73 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
return 0;
}
+ //--------------------------------------------------------------------
+ static int rt_firmware_request(uint64_t i_reqLen, void *i_req,
+ uint64_t* o_respLen, void *o_resp )
+ {
+ int retVal = 0;
+ do
+ {
+ if (i_req == nullptr ||
+ o_respLen == nullptr ||
+ o_resp == nullptr)
+ {
+ retVal = -EINVAL;
+ break;
+ }
+
+ hostInterfaces::hbrt_fw_msg* l_req_fw_msg =
+ (hostInterfaces::hbrt_fw_msg*) i_req;
+ hostInterfaces::hbrt_fw_msg* l_resp_fw_msg =
+ (hostInterfaces::hbrt_fw_msg*) o_resp;
+
+ if (i_reqLen < (hostInterfaces::HBRT_FW_MSG_BASE_SIZE +
+ sizeof(l_req_fw_msg->req_hcode_update)))
+ {
+ retVal = -EINVAL;
+ break;
+ }
+
+ if (*o_respLen < (hostInterfaces::HBRT_FW_MSG_BASE_SIZE +
+ sizeof(l_resp_fw_msg->resp_generic)))
+ {
+ retVal = -EINVAL;
+ break;
+ }
+
+ if (hostInterfaces::HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE
+ == l_req_fw_msg->io_type)
+ {
+ TRACFCOMP(g_trac_hbrt, ENTER_MRK
+ "rt_firmware_request for HCODE SCOM update: "
+ "type:%d, chipId:0x%X, section:%d, "
+ "operation:%d, scomAddr:0x%X scomData:0x%X",
+ l_req_fw_msg->io_type,
+ l_req_fw_msg->req_hcode_update.i_chipId,
+ l_req_fw_msg->req_hcode_update.i_section,
+ l_req_fw_msg->req_hcode_update.i_operation,
+ l_req_fw_msg->req_hcode_update.i_scomAddr,
+ l_req_fw_msg->req_hcode_update.i_scomData);
+ }
+ else
+ {
+ TRACFCOMP(g_trac_hbrt, ENTER_MRK
+ "rt_firmware_request an unrecognized request: "
+ "type:%d", l_req_fw_msg->io_type);
+ }
+
+ l_resp_fw_msg->io_type =
+ hostInterfaces::HBRT_FW_MSG_TYPE_RESP_GENERIC;
+ // dummy return value for testing
+ l_resp_fw_msg->resp_generic.o_status = 264;
+
+ TRACFCOMP(g_trac_hbrt, EXIT_MRK"rt_firmware_request");
+ retVal = 1; // just return 1 for testing
+
+ } while (0) ;
+ return retVal;
+ }
+
static uint64_t cv_hb_data_addr;
static uint64_t cv_comm_addr;
static uint64_t cv_comm_phys_addr;
OpenPOWER on IntegriCloud