From f01a301bb62629f4cfdb6bfb62d36074fc6cdbae Mon Sep 17 00:00:00 2001 From: "CHRISTINA L. GRAVES" Date: Thu, 8 Oct 2015 11:51:59 -0500 Subject: p9_adu_access and p9_adu_setup L2 procedures Change-Id: I1c42feddfa2cfadbfb16b3e2185bd771d82c331a Original-Change-Id: Id374670d8f75dc74f37967f6c95ef773796e3f1e Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21092 Tested-by: Jenkins Server Reviewed-by: Joseph J. McGill Reviewed-by: Thi N. Tran Reviewed-by: STEPHEN M. CPREK Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/49794 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Christian R. Geddes --- .../chips/p9/procedures/hwp/nest/p9_adu_access.C | 110 +++++++++++++++++++++ .../chips/p9/procedures/hwp/nest/p9_adu_access.H | 103 +++++++++++++++++++ .../chips/p9/procedures/hwp/nest/p9_adu_setup.C | 110 +++++++++++++++++++++ .../chips/p9/procedures/hwp/nest/p9_adu_setup.H | 109 ++++++++++++++++++++ 4 files changed, 432 insertions(+) create mode 100644 src/import/chips/p9/procedures/hwp/nest/p9_adu_access.C create mode 100644 src/import/chips/p9/procedures/hwp/nest/p9_adu_access.H create mode 100644 src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.C create mode 100644 src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.H (limited to 'src/import') diff --git a/src/import/chips/p9/procedures/hwp/nest/p9_adu_access.C b/src/import/chips/p9/procedures/hwp/nest/p9_adu_access.C new file mode 100644 index 000000000..66c527a12 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/nest/p9_adu_access.C @@ -0,0 +1,110 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/chips/p9/procedures/hwp/nest/p9_adu_access.C $ */ +/* */ +/* OpenPOWER HostBoot 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 p9_adu_access.C +/// @brief Read coherent state of memory via the ADU (FAPI) +/// +// *HWP HWP Owner Christina Graves clgraves@us.ibm.com +// *HWP FW Owner: Thi Tran thi@us.ibm.com +// *HWP Team: Nest +// *HWP Level: 2 +// *HWP Consumed by: SBE +// +//-------------------------------------------------------------------------- + + +//-------------------------------------------------------------------------- +// Includes +//-------------------------------------------------------------------------- +#include +#include + +extern "C" { + +//-------------------------------------------------------------------------- +// HWP entry point +//-------------------------------------------------------------------------- + fapi2::ReturnCode p9_adu_access(const + fapi2::Target& i_target, + const uint64_t i_address, + const bool i_rnw, + const uint32_t i_flags, + const bool i_firstGranule, + const bool i_lastGranule, + uint8_t io_data[]) + { + // mark HWP entry + FAPI_DBG("Entering ...\n"); + + if(i_lastGranule && (i_flags & FLAG_AUTOINC)) + { + //call this function to clear the altd_auto_inc bit before the last iteration + FAPI_TRY(p9_adu_coherent_clear_autoinc(i_target), "Error from p9_adu_coherent_clear_autoinc"); + } + + if (i_rnw) + { + //read the data + FAPI_TRY(p9_adu_coherent_adu_read(i_target, i_firstGranule, i_address, i_flags, io_data), + "Error from p9_adu_coherent_adu_read"); + } + else + { + //write the data + FAPI_TRY(p9_adu_coherent_adu_write(i_target, i_firstGranule, i_address, i_flags, io_data), + "Error from p9_adu_coherent_adu_write"); + } + + //If we are not in fastmode or this is the last granule, we want to check the status + if ((i_lastGranule) || !(i_flags & FLAG_FASTMODE)) + { + FAPI_TRY(p9_adu_coherent_status_check(i_target, ((i_flags & FLAG_AUTOINC) + && !i_lastGranule)), "Error from p9_adu_coherent_status_check"); + + //If it's the last read/write + if (i_lastGranule) + { + FAPI_TRY(p9_adu_coherent_cleanup_adu(i_target), + "Error doing p9_adu_coherent_cleanup_adu"); + } + } + + fapi_try_exit: + + if (fapi2::current_err + && !(i_flags & FLAG_LEAVE_DIRTY)) + { + (void) p9_adu_coherent_utils_reset_adu(i_target); + uint32_t num_attempts = i_flags & FLAG_LOCK_TRIES; + (void) p9_adu_coherent_manage_lock(i_target, false, false, num_attempts); + } + + FAPI_DBG("Exiting..."); + return fapi2::current_err; + } + +} // extern "C" diff --git a/src/import/chips/p9/procedures/hwp/nest/p9_adu_access.H b/src/import/chips/p9/procedures/hwp/nest/p9_adu_access.H new file mode 100644 index 000000000..41fedf691 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/nest/p9_adu_access.H @@ -0,0 +1,103 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/chips/p9/procedures/hwp/nest/p9_adu_access.H $ */ +/* */ +/* OpenPOWER HostBoot 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 p9_adu_access.H +/// @brief Read coherent state of memory via the ADU (FAPI) +/// +// *HWP HWP Owner: Christina Graves clgraves@us.ibm.com +// *HWP FW Owner: Thi Tran thi@us.ibm.com +// *HWP Team: Nest +// *HWP Level: 1 +// *HWP Consumed by: +// ---------------------------------------------------------------------------------- +// +// *! ADDITIONAL COMMENTS : +// *! +// *! The purpose of this procedure is to perform a coherent read from system +// *! memory via fabric commands issued from the ADU. +// *! +// *! Succcessful operation assumes that: +// *! o System clocks are running +// *! o Fabric is initalized +// *! +// *! +//----------------------------------------------------------------------------------- + +#ifndef _P9_ADU_ACCESS_H_ +#define _P9_ADU_ACCESS_H_ + +//----------------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------------- + +#include +#include +#include + +//----------------------------------------------------------------------------------- +// Structure definitions +//----------------------------------------------------------------------------------- + +//function pointer typedef definition for HWP call support +typedef fapi2::ReturnCode +(*p9_adu_access_FP_t) (const fapi2::Target&, + const uint64_t, + const bool, + const uint32_t, + const bool, + const bool, + uint8_t[] ); + +//----------------------------------------------------------------------------------- +// Constant definitions +//----------------------------------------------------------------------------------- + +extern "C" { + +//----------------------------------------------------------------------------------- +// Function prototype +//----------------------------------------------------------------------------------- + +/// @brief do the actual read/write from the ADU +/// @param[in] i_target => P9 chip target +/// @param[in] i_address => base real address for read/write operation (expected to be 8B aligned) +/// @param[in] i_rnw => if the operation is a read not write (1 for read, 0 for write) +/// @param[in] i_flags => other information that is needed - the flags are: +/// @param[in] i_lastGranule => if this is the last 8B of data that we are collecting (true = last granule, false = not last granule) +/// @param[in] i_firstGranule => if this is the first 8B of data that we are collecting (true = first granule, false = not first granule) +/// @param[in, out] io_data => The data is read/written +/// @return FAPI_RC_SUCCESS if the read/write completes successfully + fapi2::ReturnCode p9_adu_access( + const fapi2::Target& i_target, + const uint64_t i_address, + const bool i_rnw, + const uint32_t i_flags, + const bool i_firstGranule, + const bool i_lastGranule, + uint8_t io_data[]); +} //extern "C" + +#endif //_P9_ADU_ACCESS_H_ diff --git a/src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.C b/src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.C new file mode 100644 index 000000000..c41ca26be --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.C @@ -0,0 +1,110 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.C $ */ +/* */ +/* OpenPOWER HostBoot 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 p9_adu_setup.C +/// @brief Setup the registers for a read/write to the ADU +// +// *HWP HWP Owner: Christina Graves clgraves@us.ibm.com +// *HWP FW Owner: Thi Tran thi@us.ibm.com +// *HWP Team: Nest +// *HWP Level: 2 +// *HWP Consumed by: SBE +// +//-------------------------------------------------------------------------- + +//-------------------------------------------------------------------------- +// Includes +//-------------------------------------------------------------------------- +#include +#include + +extern "C" +{ + +//-------------------------------------------------------------------------- +// HWP entry point +//-------------------------------------------------------------------------- + fapi2::ReturnCode p9_adu_setup(const fapi2::Target + & i_target, + const uint64_t i_address, + const bool i_rnw, + const uint32_t i_flags, + uint32_t& o_numGranules) + { + //return code + uint32_t num_attempts = 1; + bool lock_pick = false; + + // mark HWP entry + FAPI_DBG("Entering ...\n"); + + //ADU status/control information + bool adu_is_dirty = false; + bool adu_leave_dirty = i_flags & FLAG_LEAVE_DIRTY; + + //check arguments + FAPI_TRY(p9_adu_coherent_utils_check_args(i_target, i_address), + "Error from p9_adu_coherent_utils_check_args"); + + //ensure fabric is running + FAPI_TRY(p9_adu_coherent_utils_check_fbc_state(i_target), + "Error from p9_adu_coherent_utils_check_fbc_status"); + + //reset ADU state machines and status register + FAPI_TRY(p9_adu_coherent_utils_reset_adu(i_target), "p9_adu_setup: Error from p9_adu_coherent_utils_reset_adu"); + + //acquire ADU lock to guarantee exclusive use of the ADU resources + lock_pick = i_flags & FLAG_LOCK_PICK; + num_attempts = i_flags & FLAG_LOCK_TRIES; + FAPI_TRY(p9_adu_coherent_manage_lock(i_target, lock_pick, true, num_attempts), + "Error from p9_adu_coherent_manage_lock"); + + //figure out how many granules can be requested before setup needs to be run again + FAPI_TRY(p9_adu_coherent_utils_get_num_granules(i_address, o_numGranules), + "Error from p9_adu_coherent_utils_get_num_granules"); + + //Set dirty since we need to attempt to cleanup/release the lock so the ADU is not in a locked state if operation fails from this point + adu_is_dirty = true; + + //setup the ADU registers for the read/write + FAPI_TRY(p9_adu_coherent_setup_adu(i_target, i_address, i_rnw, i_flags), + "Error from p9_adu_coherent_setup_registers"); + + fapi_try_exit: + + //if an error has occurred, ADU is dirty, and instructed to clean up, + //attempt to reset ADU and free lock (propogate rc of original fail) + if (fapi2::current_err && adu_is_dirty && !adu_leave_dirty) + { + (void) p9_adu_coherent_utils_reset_adu(i_target); + (void) p9_adu_coherent_manage_lock(i_target, false, false, num_attempts); + } + + FAPI_DBG("Exiting..."); + return fapi2::current_err; + } + +} // extern "C" diff --git a/src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.H b/src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.H new file mode 100644 index 000000000..dc2bbdf7e --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.H @@ -0,0 +1,109 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/chips/p9/procedures/hwp/nest/p9_adu_setup.H $ */ +/* */ +/* OpenPOWER HostBoot 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 p9_adu_setup.H +/// @brief Setup the adu to do reads/writes +// +// *HWP HWP Owner: Christina Graves clgraves@us.ibm.com +// *HWP FW Owner: Thi Tran thi@us.ibm.com +// *HWP Team: Nest +// *HWP Level: 1 +// *HWP Consumed by: +//----------------------------------------------------------------------------------- +// *! ADDITIONAL COMMENTS: +// *! +// *! The purpose of this procedure is to setup the ADU to do reads/writes +// *! and to return the number of granules (number of 8B reads/writes) that +// *! can be done before setup needs to be called again +// *! +// *! Successful operation assumes that: +// *! +// *! High-level procedure flow: +// *! +// *! +//------------------------------------------------------------------------------------ + +#ifndef _P9_ADU_SETUP_H_ +#define _P9_ADU_SETUP_H_ + +//----------------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------------- + +#include +#include + +//----------------------------------------------------------------------------------- +// Structure definitions +//----------------------------------------------------------------------------------- + +//function pointer typedef definition for HWP call support +typedef fapi2::ReturnCode +(*p9_adu_setup_FP_t) (const fapi2::Target&, + const uint64_t, + const bool, + const uint32_t, + uint32_t&); + +//----------------------------------------------------------------------------------- +// Constant definitions +//----------------------------------------------------------------------------------- + +extern "C" { + +//----------------------------------------------------------------------------------- +// Function prototype +//----------------------------------------------------------------------------------- + +/// @brief setup for reads/writes from the ADU +/// @param[in] i_target => P9 chip target +/// @param[in] i_address => base real address for read/write operation (expected to be 8B aligned) +/// @param[in] i_rnw => if the operation is read not write (1 for read, 0 for write) +/// @param[in] i_flags => other information that is needed - the flags are: +/// -bit 0-cache inhibited - use cache-inhibited ttype? +/// (true = ci, false = dma partial) +/// -bit 1-autoinc - utilize ADU HW auto-increment function +/// -bit 2-lock pick - pick ADU lock (if required) +/// -bit 3-leave dirty - in the case of a fail with lock held, +/// do not reset ADU & do not release lock +/// -bit 4-fastmode - check status only at the end of read/write stream +/// -bit 5-itag - collect itag with each 8B read/write +/// -bit 6:13-size - transaction size +/// -bit 14:32-lock tries - number of ADU lock acquisitions to attempt +/// before giving up or attempting lock pick +/// @param[out] o_numGranules => number of 8B granules that can be read/written before setup needs to be called again +// +/// @return FAPI_RC_SUCCESS if the setup completes successfully, +// + fapi2::ReturnCode p9_adu_setup( + const fapi2::Target& i_target, + const uint64_t i_address, + const bool i_rnw, + const uint32_t i_flags, + uint32_t& o_numGranules); +} //extern "C" + +#endif //_P9_ADU_SETUP_H_ -- cgit v1.2.1