diff options
author | crgeddes <crgeddes@us.ibm.com> | 2015-08-26 13:50:30 -0500 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2016-03-03 16:17:52 -0500 |
commit | c73c1d03450fb1dfa0ef9c98485999aeaa0257d7 (patch) | |
tree | 70056c4a6b064db49d7419d2d5040f6569ea51fc /src/include | |
parent | 8f30c7db00a3ce2940900ec2ba67838bcf432b98 (diff) | |
download | talos-hostboot-c73c1d03450fb1dfa0ef9c98485999aeaa0257d7.tar.gz talos-hostboot-c73c1d03450fb1dfa0ef9c98485999aeaa0257d7.zip |
FFS Support for Bootloader
This commit moves functionality out of pnor_common.C and puts it in
a new file pnor_utils.C this file will be shared with bootloader and
hostboot code. Quite a few files were pulled apart in order to make
includes easier across modules. These are lpc_const.H and pnor_const.H.
bl_pnorAccess leverages the new pnor_utils.C file that will help the
bootloader parse pnor TOC
Change-Id: I740f6f8a707760756a261535e62e2d0a849324f8
RTC:134064
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/696
Tested-by: Jenkins Server
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/bootloader/bl_pnorAccess.H | 104 | ||||
-rw-r--r-- | src/include/usr/lpc/lpc_const.H | 48 | ||||
-rw-r--r-- | src/include/usr/pnor/pnor_const.H | 122 | ||||
-rw-r--r-- | src/include/usr/pnor/pnor_reasoncodes.H | 6 | ||||
-rw-r--r-- | src/include/usr/pnor/pnorif.H | 98 |
5 files changed, 287 insertions, 91 deletions
diff --git a/src/include/bootloader/bl_pnorAccess.H b/src/include/bootloader/bl_pnorAccess.H new file mode 100644 index 000000000..bc19a4dc2 --- /dev/null +++ b/src/include/bootloader/bl_pnorAccess.H @@ -0,0 +1,104 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/bootloader/bl_pnorAccess.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* [+] 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 __BL_PNORACCESS_H +#define __BL_PNORACCESS_H + + +#include <pnor_const.H> +#include <pnor_utils.H> +#include <ffs.h> + +/** @file bl_pnorAccess.H + * @brief Provides interface to the PNOR flash for bootloader + */ + +/** + * @brief bootloader PNOR access class + * Provide interfaces for the bootloader to look through pnor and find toc + */ + +class bl_pnorAccess +{ + + friend class pnorutilsTest; + public: + +/** + * @brief Get the hostboot base image + * + * @param[in] i_pnorStart MMIO address to access the start of pnor flash + * + * @param[out] o_hbbSection Struct that holds information about the + * Hostboot Base Image Section + * + * @param[out] o_errCode Anything besides PNOR:NO_ERROR is an error + * + * @param[out] o_tocUsed Tells you which table of contents was used + * + * @return void + */ +static void getHBBSection(uint64_t i_pnorStart, + PNOR::SectionData_t& o_hbbSection, + uint32_t& o_errCode, + uint8_t& o_tocUsed); + + private: +/** + * @brief Read in the toc and get information about each section + * + * @param[in] i_tocBuffer Buffer containing a single TOC + * + * @param[out] o_errCode Anything besides PNOR:NO_ERROR is an error + * + * @param[out] o_TOC Array of section data describing contents of pnor + * + * @param[in] i_baseAddr MMIO address to access the start of pnor flash + * + * @return void + */ +static void readTOC(uint8_t i_tocBuffer[PNOR::TOC_SIZE], uint32_t & o_errCode, + PNOR::SectionData_t * o_TOC, uint64_t i_baseAddr); + +/** + * @brief Find a valid TOC within specified side of pnor flash + side is determined by the base mmio address passed in + * + * @param[in] i_pnorBase MMIO address to access the start of pnor flash + * + * @param[out] o_TOC Array of section data describing contents of pnor + * + * @param[out] o_errCode Anything besides PNOR:NO_ERROR is an error + * + * @param[out] o_tocUsed Tells you which table of contents was used + * + * @return void + */ +static void findTOC(uint64_t i_pnorBase, PNOR::SectionData_t * o_TOC, + uint32_t& o_errCode, uint8_t& o_tocUsed); + +}; + +#endif
\ No newline at end of file diff --git a/src/include/usr/lpc/lpc_const.H b/src/include/usr/lpc/lpc_const.H new file mode 100644 index 000000000..a7857e707 --- /dev/null +++ b/src/include/usr/lpc/lpc_const.H @@ -0,0 +1,48 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/lpc/lpc_const.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* [+] 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 LPC_CONST_H +#define LPC_CONST_H + +#include <stdint.h> +#include <builtins.h> + +namespace LPC +{ + /** + * @brief Some general constants + * + */ + enum { + LPCHC_FW_SPACE = 0xF0000000, /**< LPC Host Controller FW Space */ + LPCHC_MEM_SPACE = 0xE0000000, /**< LPC Host Controller Mem Space */ + LPCHC_IO_SPACE = 0xD0010000, /**< LPC Host Controller I/O Space */ + LPCHC_REG_SPACE = 0xC0012000, /**< LPC Host Ctlr Register Space */ + + /** Physical addr of the start of LPC address space*/ + LPC_PHYS_BASE = 0x6030000000000, + }; +} + +#endif
\ No newline at end of file diff --git a/src/include/usr/pnor/pnor_const.H b/src/include/usr/pnor/pnor_const.H new file mode 100644 index 000000000..1f0b08574 --- /dev/null +++ b/src/include/usr/pnor/pnor_const.H @@ -0,0 +1,122 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/pnor/pnor_const.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* [+] 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 __PNOR_PNOR_CONST_H +#define __PNOR_PNOR_CONST_H + +#include <stdint.h> +#include <builtins.h> + +namespace PNOR +{ + +/** + * PNOR Sections + */ +enum SectionId +{ + TOC, /**< Table of Contents */ + // Value of HB_EXT_CODE must be 1 for debug framework. + HB_EXT_CODE, /**< Hostboot Extended Image */ + GLOBAL_DATA, /**< Global Data */ + HB_BASE_CODE, /**< Hostboot Base Image */ + CENTAUR_SBE, /**< Centaur Self-Boot Engine image */ + SBE_IPL, /**< Self-Boot Engine IPL image */ + WINK, /**< Sleep Winkle Reference image */ + PAYLOAD, /**< HAL/OPAL */ + HB_RUNTIME, /**< Hostboot Runtime (for Sapphire) */ + HB_DATA, /**< Hostboot Data */ + GUARD_DATA, /**< Guard Data */ + HB_ERRLOGS, /**< Hostboot Error log Repository */ + DIMM_JEDEC_VPD, /**< DIMM JEDEC VPD */ + MODULE_VPD, /**< Module VPD */ + CENTAUR_VPD, /**< Centaur VPD */ + NVRAM, /**< Opal NVRAM */ + OCC, /**< OCC lid */ + FIRDATA, /**< FIRDATA */ + ATTR_TMP, /**< Temporary Attribute Override */ + ATTR_PERM, /**< Permanent Attribute Override */ + CAPP, /**< CAPP lid */ + VERSION, /**< PNOR version string section */ + HB_BOOTLOADER, /**< Hostboot Bootloader image */ + TEST, /**< Scratch space for PNOR test cases */ + TESTRO, /**< Scratch space for PNOR ReadOnly test cases */ + BACKUP_PART, /**< Backup of TOC*/ + NUM_SECTIONS, /**< Number of defined sections */ + + FIRST_SECTION = TOC, /**< First section (for looping) */ + /**< Used for error cases, initialization */ + INVALID_SECTION = NUM_SECTIONS, +}; + +/** + * Information about a section of PNOR + */ + // Size and layout of this structure must be maintained for debug framework. +struct SectionInfo_t +{ + SectionId id; /**< Identifier for this section */ + const char* name; /**< Name of the section */ + uint64_t vaddr; /**< Virtual address of the start of the section */ + uint32_t flashAddr; /**< Flash address of the start of the section*/ + uint64_t size; /**< Size of partition in bytes */ + bool eccProtected; /**< Section is ECC protected */ + bool sha512Version; /**< Version Checking */ + bool sha512perEC; /**< Version Checking perEC */ + bool readOnly; /**< Section is read only */ +}; + +/** + * PNOR Sides + */ +enum SideId +{ + WORKING = 0, +#ifdef CONFIG_PNOR_TWO_SIDE_SUPPORT + ALTERNATE = 1, +#endif + NUM_SIDES, + INVALID_SIDE = NUM_SIDES, + FIRST_SIDE = WORKING, +}; + +enum +{ + INVALID_OFFSET = 0xFFFFFFF, // Invalid primary or alternate TOC + BACKUP_TOC_OFFSET = 0x8000, + INVALID_FLASH_OFFSET = 0xFFFFFFFF, +}; + +/** @brief PNOR::TEST section offsets for test cases to prevent + * concurrency problems + */ +enum TestSectionOffset{ + pnorTestSec_readwrite_offset = 0x100, + pnorTestSec_smartwrite_offset = 0x120, + pnorTestSec_rt_readwrite_offset = 0x6000, +}; + +} + +#endif
\ No newline at end of file diff --git a/src/include/usr/pnor/pnor_reasoncodes.H b/src/include/usr/pnor/pnor_reasoncodes.H index 4133c8a0f..d10cd44c6 100644 --- a/src/include/usr/pnor/pnor_reasoncodes.H +++ b/src/include/usr/pnor/pnor_reasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -153,6 +153,10 @@ namespace PNOR RC_INVALID_WORKING_TOC = PNOR_COMP_ID | 0x28, RC_INVALID_TOC = PNOR_COMP_ID | 0x29, RC_WRONG_SIZE_FROM_READ = PNOR_COMP_ID | 0x2A, + RC_NULL_TOC_BUFFER = PNOR_COMP_ID | 0x2B, + RC_TOC_HDR_CHECKSUM_ERR = PNOR_COMP_ID | 0x2C, + RC_PNOR_PARSE_ENTRIES_ERR = PNOR_COMP_ID | 0x2D, + RC_PNOR_SET_VADDR_FAILED = PNOR_COMP_ID | 0x2E, //@fixme-RTC:131607-Temporary value to allow HWSV compile //termination_rc diff --git a/src/include/usr/pnor/pnorif.H b/src/include/usr/pnor/pnorif.H index 79a9a0f62..1a18750b5 100644 --- a/src/include/usr/pnor/pnorif.H +++ b/src/include/usr/pnor/pnorif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -28,6 +28,7 @@ #include <stdint.h> #include <builtins.h> +#include <pnor/pnor_const.H> #include <errl/errlentry.H> #include <utility> #include <config.h> @@ -36,75 +37,6 @@ namespace PNOR { /** - * PNOR Sections - */ -enum SectionId -{ - TOC, /**< Table of Contents */ - // Value of HB_EXT_CODE must be 1 for debug framework. - HB_EXT_CODE, /**< Hostboot Extended Image */ - GLOBAL_DATA, /**< Global Data */ - HB_BASE_CODE, /**< Hostboot Base Image */ - CENTAUR_SBE, /**< Centaur Self-Boot Engine image */ - SBE_IPL, /**< Self-Boot Engine IPL image */ - WINK, /**< Sleep Winkle Reference image */ - PAYLOAD, /**< HAL/OPAL */ - HB_RUNTIME, /**< Hostboot Runtime (for Sapphire) */ - HB_DATA, /**< Hostboot Data */ - GUARD_DATA, /**< Guard Data */ - HB_ERRLOGS, /**< Hostboot Error log Repository */ - DIMM_JEDEC_VPD, /**< DIMM JEDEC VPD */ - MODULE_VPD, /**< Module VPD */ - CENTAUR_VPD, /**< Centaur VPD */ - NVRAM, /**< Opal NVRAM */ - OCC, /**< OCC lid */ - FIRDATA, /**< FIRDATA */ - ATTR_TMP, /**< Temporary Attribute Override */ - ATTR_PERM, /**< Permanent Attribute Override */ - CAPP, /**< CAPP lid */ - VERSION, /**< PNOR version string section */ - TEST, /**< Scratch space for PNOR test cases */ - TESTRO, /**< Scratch space for PNOR ReadOnly test cases */ - - NUM_SECTIONS, /**< Number of defined sections */ - - FIRST_SECTION = TOC, /**< First section (for looping) */ - LAST_SECTION = TEST, /**< Last section (for looping) */ - INVALID_SECTION = NUM_SECTIONS, /**< Used for error cases, initialization */ -}; - -/** - * Information about a section of PNOR - */ - // Size and layout of this structure must be maintained for debug framework. -struct SectionInfo_t -{ - SectionId id; /**< Identifier for this section */ - const char* name; /**< Name of the section */ - uint64_t vaddr; /**< Virtual address of the start of the section */ - uint32_t flashAddr; /**< Flash address of the start of the section*/ - uint64_t size; /**< Size of partition in bytes */ - bool eccProtected; /**< Section is ECC protected */ - bool sha512Version; /**< Version Checking */ - bool sha512perEC; /**< Version Checking perEC */ - bool readOnly; /**< Section is read only */ -}; - -/** - * PNOR Sides - */ -enum SideId -{ - WORKING = 0, -#ifdef CONFIG_PNOR_TWO_SIDE_SUPPORT - ALTERNATE = 1, -#endif - NUM_SIDES, - INVALID_SIDE = NUM_SIDES, - FIRST_SIDE = WORKING, -}; - -/** * Information about a side of PNOR */ struct SideInfo_t @@ -120,9 +52,12 @@ struct SideInfo_t uint64_t hbbMmioOffset; /**< HBB MMIO Offset associated with hbbAddress*/ }; -enum +/** Information about PNOR Layout */ +struct PnorInfo_t { - INVALID_OFFSET = 0xFFFFFFF, // Invalid primary or alternate TOC + uint32_t mmioOffset; //< Address of MMIO access + uint32_t norWorkarounds; //< NOR flash workarounds + uint32_t flashSize; //< Size of PNOR in bytes }; /** @@ -190,23 +125,6 @@ errlHndl_t clearSection(PNOR::SectionId i_section); */ errlHndl_t validateAltMaster( void ); -/** @brief PNOR::TEST section offsets for test cases to prevent - * concurrency problems - */ -enum TestSectionOffset{ - pnorTestSec_readwrite_offset = 0x100, - pnorTestSec_smartwrite_offset = 0x120, - pnorTestSec_rt_readwrite_offset = 0x6000, -}; - -/** Information about PNOR Layout */ -struct PnorInfo_t -{ - uint32_t mmioOffset; //< Address of MMIO access - uint32_t norWorkarounds; //< NOR flash workarounds - uint32_t flashSize; //< Size of PNOR in bytes -}; - /** * @brief Retrieve some information about the PNOR/SFC hardware * @@ -214,6 +132,6 @@ struct PnorInfo_t */ void getPnorInfo( PnorInfo_t& o_pnorInfo ); -} +} // PNOR #endif |