diff options
author | Stephen Cprek <smcprek@us.ibm.com> | 2017-10-03 09:36:58 -0500 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2017-10-24 13:58:43 -0400 |
commit | 0ff075bac5d78384a625de70b34b7ef363a25fd6 (patch) | |
tree | 30e1a8e011be3b2bfde6d4e616f8745dde212d28 /src/include/usr/runtime | |
parent | da12bd653f7eabbc2d97938a3ac25666187e6abb (diff) | |
download | talos-hostboot-0ff075bac5d78384a625de70b34b7ef363a25fd6.tar.gz talos-hostboot-0ff075bac5d78384a625de70b34b7ef363a25fd6.zip |
Create Pre Verified Lid Manager and refactor exisiting implementation
Change-Id: I5417b8e381bf15a1b696cf006940eedd7a1e235c
RTC:125304
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/47110
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
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: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/include/usr/runtime')
-rw-r--r-- | src/include/usr/runtime/populate_hbruntime.H | 79 | ||||
-rw-r--r-- | src/include/usr/runtime/preverifiedlidmgr.H | 203 |
2 files changed, 282 insertions, 0 deletions
diff --git a/src/include/usr/runtime/populate_hbruntime.H b/src/include/usr/runtime/populate_hbruntime.H new file mode 100644 index 000000000..7ba405038 --- /dev/null +++ b/src/include/usr/runtime/populate_hbruntime.H @@ -0,0 +1,79 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/runtime/populate_hbruntime.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 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 <hdat/hdat.H> + +namespace RUNTIME +{ + +/** + * @brief Get the next Reserved HB memory range and set all member variables + * of struct. Additionally trace out relevant parts of the struct + * @param[in] i_type, HDAT Range type + * @param[in] i_rangeId, HDAT Range ID [Frequently node ID, see hdatMsVpdRhbAddrRange_t] + * @param[in] i_startAddr, Range Starting Address + * @param[in] i_size, Size of address space to reserve + * @param[in] i_label, Label String Ptr + * @param[in] i_permission, HDAT permission type [default read/write] + * + * @return errlHndl_t, nullptr on success; otherwise errlog + */ +errlHndl_t setNextHbRsvMemEntry(const HDAT::hdatMsVpdRhbAddrRangeType i_type, + const uint16_t i_rangeId, + const uint64_t i_startAddr, + const uint64_t i_size, + const char* i_label, + const HDAT::hdatRhbPermType i_permission = + HDAT::RHB_READ_WRITE + ); + +/** + * @brief Map physical address to virtual + * @param[in] i_addr Physical address + * @param[in] i_size Size of block to be mapped, in bytes. + * @param[out] o_addr Virtual address + * @return Error handle if error + */ +errlHndl_t mapPhysAddr(uint64_t i_addr, size_t i_size, uint64_t& o_addr); + +/** + * @brief Unmap virtual address block + * @param[in] i_addr Virtual address + * @return Error handle if error + */ +errlHndl_t unmapVirtAddr(uint64_t i_addr); + +// PNOR sections that will be pre-verified and loaded into HB reserved memory +extern const std::vector<PNOR::SectionId> preVerifiedPnorSections; + +/** + * @brief Pre verify Pnor sections and load into HB reserved memory + * + * @param[in] i_sec - pnor section to pre-verify and load + * + * @return Error handle if error + */ +errlHndl_t hbResvLoadSecureSection (const PNOR::SectionId i_sec); + +} // End of Namespace
\ No newline at end of file diff --git a/src/include/usr/runtime/preverifiedlidmgr.H b/src/include/usr/runtime/preverifiedlidmgr.H new file mode 100644 index 000000000..ca096e5e1 --- /dev/null +++ b/src/include/usr/runtime/preverifiedlidmgr.H @@ -0,0 +1,203 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/runtime/preverifiedlidmgr.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 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 */ +#ifndef __PREVERIFIEDLIDMGR_H +#define __PREVERIFIEDLIDMGR_H + +#include <map> +#include <errl/errlentry.H> +#include <pnor/pnorif.H> +#include <runtime/interface.h> +#include <sys/sync.h> +#include <attributeenums.H> + +class PreVerifiedLidMgr +{ + public: + + /** + * @brief Initialize and lock pre verified LID manager + * + * @param[in] i_prevAddr - previous HB reserved memory address + * @param[in] i_prevSize - previous HB reserved memory address size + * @param[in] i_rangeId - range id for HDAT entries + * [Frequently node ID, see hdatMsVpdRhbAddrRange_t] + */ + static void initLock(const uint64_t i_prevAddr, + const size_t i_prevSize = 0, + const uint64_t i_rangeId = 0); + + /** + * @brief Unlock Pre Verified Lid manager + */ + static void unlock(); + + /** + * @brief Load PNOR section into HB reserved memory + * + * @param[in] i_sec - PNOR section ID + * @param[in] i_addr - Virtual Address of PNOR section + * @param[in] i_size - Size of PNOR section + * + * @return Error handle if error + */ + static errlHndl_t loadFromPnor(const PNOR::SectionId i_sec, + const uint64_t i_addr, + const size_t i_size); + + protected: + + /** + * @brief Default Constructor + */ + PreVerifiedLidMgr() {} + + /** + * @brief Default Destructor + */ + ~PreVerifiedLidMgr() {} + + /** + * @brief Static instance function + */ + static PreVerifiedLidMgr& getInstance(); + + private: + + // Private Implementations of Static Public Methods + + /** + * @brief Internal implementation of init function. + */ + void _initLock(const uint64_t i_prevAddr, + const size_t i_prevSize = 0, + const uint64_t i_rangeId = 0); + + /** + * @brief Internal implementation of unlock function. + */ + void _unlock(); + + /** + * @brief Internal implementation of loadFromPnor function. + */ + errlHndl_t _loadFromPnor(const PNOR::SectionId i_sec, + const uint64_t i_addr, + const size_t i_size); + + // Private Members/Variables + + // Cache the payload type + static TARGETING::PAYLOAD_KIND cv_payloadKind; + + // Bool to check if the first PHYP lid has been loaded or not. + static bool cv_phypLidSeen; + + // Collection of data needed for Hostboot Reserved Memory + struct ResvMemInfo + { + // Range Id for HDAT entries + uint64_t rangeId; + // Current address of HB reserved memory + uint64_t curAddr; + // Previous size of HB reserved memory entry + size_t prevSize; + }; + + // Pointer to either Deafult or PHYP Reserved Memory Info + static ResvMemInfo* cv_pResvMemInfo; + + // Collection of data needed for Hostboot Reserved Memory + static ResvMemInfo cv_resvMemInfo; + + // Location for PHYP lids to go. + static ResvMemInfo cv_phypResvMemInfo; + + // Map of what lids have been loaded already. + static std::map<uint64_t,bool> cv_lidsLoaded; + + // Mutex to prevent concurrent HB reserved memory operations. + static mutex_t cv_mutex; + + // Mutex to prevent concurrent loading into HB reserved memory + static mutex_t cv_loadImageMutex; + + // Function pointer to help finding the next address + // Depends on the payload kind + uint64_t (*getNextAddress)(const size_t); + + /** + * @brief Get aligned reserved memory size for OPAL + * Note: Historically we have used the aligned size for OPAL + * alignment regardless of mode. Even if that means there is + * some wasted space. + * + * @return uint64_t - aligned address + */ + static uint64_t getAlignedSize(const size_t i_imgSize); + + /** + * @brief Get Next available HB reserved memory address for PHYP mode + * Note: PHYP we build up starting at the end of the previously + * allocated HOMER/OCC areas, + * + * @return uint64_t - next available address + */ + static uint64_t getNextPhypAddress(const size_t i_prevSize); + + /** + * @brief Get Next available HB reserved memory address for OPAL mode + * Note: OPAL we build downwards from the top of memory where the + * HOMER/OCC areas were placed + * + * @return uint64_t - next available address + */ + static uint64_t getNextOpalAddress(const size_t i_curSize); + + /** + * @brief Check if lid has already been loaded into HB reserved memory + * + * @param[in] uint32_t - lid id to check if loaded + * + * @return bool - True if previously loaded, false otherwise. + */ + bool isLidLoaded(uint32_t i_lidId); + + /** + * @brief Load Image into HB reserved memory + * + * @param[in] i_imgAddr - address of generic image + * @param[in] i_imgSize - address of image size + * + * @return Error handle if error + */ + errlHndl_t loadImage(const uint64_t i_imgAddr, + const size_t i_imgSize); + + // Allow test cases to have direct access + friend class PreVerifiedLidMgrTest; +}; + + +#endif
\ No newline at end of file |