Skip to content

Commit

Permalink
Add wrapper to exp_getidec HWP so we can call it in platform code
Browse files Browse the repository at this point in the history
There has been a trend to create more HWPs that process raw data.
This allows Hostboot and Cronus to share more code. The trick is
that we generally want to call these HWPs inside traditionally
hostboot-only code. This new fapiwrap directory will help encapsulate
all of the calls to ekb code in one place. That way if we ever need
to remove HWPs/EKB code it will be easier to stub out the calls. In the
past we have contaminated a lot of Hostboot-only code with calls out
to EKB code. This new new directory should help avoid this issue.

Change-Id: I2b2d0d1e62c97f0976c9c9ede3fe2eac30c7a40f
RTC: 214627
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/83029
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
  • Loading branch information
crgeddes authored and dcrowell77 committed Sep 20, 2019
1 parent d0f0ff1 commit b7c4af2
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 1 deletion.
60 changes: 60 additions & 0 deletions src/include/usr/fapiwrap/fapiWrapif.H
@@ -0,0 +1,60 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/fapiwrap/fapiWrapif.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2019 */
/* [+] 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 */
#ifndef _FAPIWRAPIF_H
#define _FAPIWRAPIF_H

#include <errl/errlentry.H> // Also gets us targeting/common/target.H


/* *** Overview ***
There has been a trend to create more HWPs that process raw data.
This allows Hostboot and Cronus (and other platforms to share more code.
The trick is that we generally want to call these HWPs inside what has
traditionally been Hostboot-only code. The fapiwrap directory will help
encapsulate all of the calls to ekb code in one place. That way if we
ever need to remove HWPs/EKB code it will be easier to stub out the calls.
We have found in the past we have contaminated a lot of Hostboot-only
code with calls to EKB code. This directory should help address that problem.
*/


namespace FAPIWRAP
{
/**
* @brief This function wraps around the FAPI2 HWP "exp_getidec" which
* takes in a OCMB target and returns the associated chipId
* and ec level.
* Chip Ids can be found in src/import/chips/common/utils/chipids.H
* @param[in] i_ocmbChip - Explorer OCMB target to lookup values on
* @param[out] o_chipId - Power Chip Id associated with this OCMB
* @param[out] o_ec - EC level of this chip
* @return errlHndl_t - nullptr if no error, otherwise contains error
*/
errlHndl_t explorer_getidec( TARGETING::Target * i_ocmbChip,
uint16_t& o_chipId,
uint8_t& o_ec);
}

#endif
10 changes: 10 additions & 0 deletions src/include/usr/hbotcompid.H
Expand Up @@ -505,6 +505,16 @@ const char BPM_COMP_NAME[] = "bpm";

//@}

//
/** @name FAPIWRAP
* Wrapper around fapi2 HWP for hb platform to use
*/
//@{
const compId_t FAPIWRAP_COMP_ID = 0x4400;
const char FAPIWRAP_COMP_NAME[] = "fapiwrap";

//@}

//
//
/** @name HDAT
Expand Down
1 change: 1 addition & 0 deletions src/makefile
Expand Up @@ -220,6 +220,7 @@ EXTENDED_MODULES += mmio
EXTENDED_MODULES += smf
EXTENDED_MODULES += expaccess
EXTENDED_MODULES += expupd
EXTENDED_MODULES += fapiwrap

#***************************************
# Working test modules
Expand Down
58 changes: 58 additions & 0 deletions src/usr/fapiwrap/fapiWrap.C
@@ -0,0 +1,58 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/fapiwrap/fapiWrap.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2019 */
/* [+] 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 <fapiwrap/fapiWrapif.H> // interface definitions
#include <fapi2/plat_hwp_invoker.H> // FAPI_INVOKE_HWP
#include <trace/interface.H> // tracing includes

#include <exp_getidec.H> // exp_getidec

trace_desc_t* g_trac_fapiwrap;
TRAC_INIT(&g_trac_fapiwrap, FAPIWRAP_COMP_NAME, 6*KILOBYTE, TRACE::BUFFER_SLOW);


namespace FAPIWRAP
{
errlHndl_t explorer_getidec( TARGETING::Target * i_ocmbChip,
uint16_t& o_chipId,
uint8_t& o_ec)
{
errlHndl_t l_errl = nullptr;

//assert type of i_ocmbChip == TARGETING::TYPE_OCMB_CHIP
assert(i_ocmbChip->getAttr<TARGETING::ATTR_TYPE>() == TARGETING::TYPE_OCMB_CHIP,
"exp_getidec_wrap: error expected type OCMB_CHIP");

fapi2::Target <fapi2::TARGET_TYPE_OCMB_CHIP> l_fapi_ocmb_target(i_ocmbChip);

FAPI_INVOKE_HWP(l_errl,
exp_getidec,
l_fapi_ocmb_target,
o_chipId,
o_ec);

return l_errl;
}
}
50 changes: 50 additions & 0 deletions src/usr/fapiwrap/makefile
@@ -0,0 +1,50 @@
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/usr/fapiwrap/makefile $
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2019
# [+] 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
ROOTPATH = ../../..
MODULE = fapiwrap

# Add the import path to the include path
EXTRAINCDIR += ${ROOTPATH}/src/import
# to get fapi2.H
EXTRAINCDIR += ${ROOTPATH}/src/import/hwpf/fapi2/include/
# to get target.H
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/fapi2/
# to get common_ringId.H
EXTRAINCDIR += ${ROOTPATH}/src/import/chips/common/utils/imageProcs/
# to get ffdc_includes.H
EXTRAINCDIR += ${ROOTPATH}/src/import/chips/p9/procedures/hwp/ffdc/

# HWP include directories :
EXTRAINCDIR += ${ROOTPATH}/src/import/chips/ocmb/explorer/procedures/hwp/memory/

# HWP objects
OBJS += exp_getidec.o

OBJS += fapiWrap.o

# Add HWP src directories to VPATH
VPATH += ${ROOTPATH}/src/import/chips/ocmb/explorer/procedures/hwp/memory/

include ${ROOTPATH}/config.mk
12 changes: 11 additions & 1 deletion src/usr/initservice/extinitsvc/extinitsvctasks.H
Expand Up @@ -276,7 +276,17 @@ const TaskInfo g_exttaskinfolist[] = {
EXT_IMAGE, // Extended Module
}
},

/**
* @brief fapiwrap task, handles fapi wrapper for platform libraries
*/
{
"libfapiwrap.so" , // taskname
NULL, // no pointer to fn
{
INIT_TASK, // task type
EXT_IMAGE, // Extended Module
}
},

// @todo RTC:145354 Restore testprdf and testattn in p9 branch
/**
Expand Down
1 change: 1 addition & 0 deletions src/usr/makefile
Expand Up @@ -38,6 +38,7 @@ SUBDIRS += errl.d
SUBDIRS += errldisplay.d
SUBDIRS += expaccess.d
SUBDIRS += fapi2.d
SUBDIRS += fapiwrap.d
SUBDIRS += fsi.d
SUBDIRS += fsiscom.d
SUBDIRS += gpio.d
Expand Down

0 comments on commit b7c4af2

Please sign in to comment.