summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2012-09-12 18:38:11 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-09-16 15:32:22 -0500
commit0f919cc423980168c5eaaf19d40c9071deeeef3e (patch)
tree07281bd882842195d3b614db575cb988bb4ed872 /src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C
parente5e78bda78b89fcaa8b601084a06d3e566465af3 (diff)
downloadtalos-hostboot-0f919cc423980168c5eaaf19d40c9071deeeef3e.tar.gz
talos-hostboot-0f919cc423980168c5eaaf19d40c9071deeeef3e.zip
Fix duplicate proc_pba_bar_config files
Change-Id: Ic0f562cbc4abd75de3760777320865cee9986539 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1729 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C')
-rw-r--r--src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C247
1 files changed, 147 insertions, 100 deletions
diff --git a/src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C b/src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C
index 72eff97b2..c12affb58 100644
--- a/src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C
+++ b/src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C
@@ -1,27 +1,27 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C $
- *
- * IBM CONFIDENTIAL
- *
- * COPYRIGHT International Business Machines Corp. 2012
- *
- * p1
- *
- * Object Code Only (OCO) source materials
- * Licensed Internal Code Source Materials
- * IBM HostBoot Licensed Internal Code
- *
- * The source code for this program is not published or other-
- * wise divested of its trade secrets, irrespective of what has
- * been deposited with the U.S. Copyright Office.
- *
- * Origin: 30
- *
- * IBM_PROLOG_END_TAG
- */
-// $Id: proc_pba_bar_config.C,v 1.6 2012/05/23 15:22:10 stillgs Exp $
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/hwp/build_winkle_images/proc_pba_bar_config/proc_pba_bar_config.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+// $Id: proc_pba_bar_config.C,v 1.8 2012/08/13 13:04:20 stillgs Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_pba_bar_config.C,v $
//------------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2011
@@ -61,6 +61,7 @@
#include "p8_scom_addresses.H"
#include "proc_pba_init.H"
#include "proc_pba_bar_config.H"
+#include "pba_firmware_register.H"
#include "proc_pm.H"
@@ -77,9 +78,9 @@ using namespace fapi;
#define BAR_ADDR_RANGECHECK_ 0x0003FFFFFFF00000ull
#define BAR_ADDR_RANGECHECK_HIGH 0xFFFC000000000000ull
#define BAR_ADDR_RANGECHECK_LOW 0x00000000000FFFFFull
-#define BAR_MASK_RANGECHECK 0x000001FFFFF00000ull
-#define BAR_MASK_RANGECHECK_HIGH 0xFFFFFE0000000000ull
-#define BAR_MASK_RANGECHECK_LOW 0x00000000000FFFFFull
+#define BAR_SIZE_RANGECHECK 0x000001FFFFF00000ull
+#define BAR_SIZE_RANGECHECK_HIGH 0xFFFFFE0000000000ull
+#define BAR_SIZE_RANGECHECK_LOW 0x00000000000FFFFFull
// ----------------------------------------------------------------------
// Global variables
@@ -93,6 +94,9 @@ using namespace fapi;
// Function definitions
// ----------------------------------------------------------------------
+uint64_t PowerOf2Roundedup (uint64_t value);
+
+
// --------------------------------------------- proc_pba_bar_config ----
// function:
// initialize initialize a specific set of PBA_BAR (=cmd_scope and address), PBA_BARMSK (mask/size)
@@ -103,83 +107,33 @@ using namespace fapi;
@param i_target the target
@param i_index specifies which set of BAR / BARMSK registers to set. [0..3]
@param i_pba_bar_addr PBA base address - 1MB grandularity
-@param i_pba_bar_mask PBA base address mask that defines the bits that are not used from the PBA base address - 1MB grandularity
- The value of this mask + 1 defines the size of the window that is accessible.
- (ex. 700000 yields an 8MB region)
+@param i_pba_bar_size PBA region size in MB; if not a power of two value,
+ the value will be rounded up to the next power of 2 for setting the
+ hardware mask
@param i_pba_cmd_scope command scope according to pba spec
*/
fapi::ReturnCode
proc_pba_bar_config (const Target& i_target,
- uint32_t i_index,
- uint64_t i_pba_bar_addr,
- uint64_t i_pba_bar_mask,
- uint64_t i_pba_cmd_scope
+ uint32_t i_index,
+ uint64_t i_pba_bar_addr,
+ uint64_t i_pba_bar_size,
+ uint64_t i_pba_cmd_scope
)
{
- // Define structures that map the register fields
-
- typedef union pba_barn {
- uint64_t value;
- struct {
-#ifdef _BIG_ENDIAN
- uint32_t high_order;
- uint32_t low_order;
-#else
- uint32_t low_order;
- uint32_t high_order;
-#endif // _BIG_ENDIAN
- } words;
- struct {
-#ifdef _BIG_ENDIAN
- uint64_t cmd_scope : 3;
- uint64_t reserved0 : 1;
- uint64_t reserved1 : 10;
- uint64_t addr : 50;
-#else
- uint64_t addr : 50;
- uint64_t reserved1 : 10;
- uint64_t reserved0 : 1;
- uint64_t cmd_scope : 3;
-#endif // _BIG_ENDIAN
- } fields;
- } pba_barn_t;
-
-
- typedef union pba_barmskn {
- uint64_t value;
- struct {
-#ifdef _BIG_ENDIAN
- uint32_t high_order;
- uint32_t low_order;
-#else
- uint32_t low_order;
- uint32_t high_order;
-#endif // _BIG_ENDIAN
- } words;
- struct {
-#ifdef _BIG_ENDIAN
- uint64_t reserved0 : 23;
- uint64_t mask : 41;
-#else
- uint64_t mask : 41;
- uint64_t reserved0 : 23;
-#endif // _BIG_ENDIAN
- } fields;
- } pba_barmskn_t;
-
-
-
- ecmdDataBufferBase data(64);
+
+ ecmdDataBufferBase data(64);
fapi::ReturnCode l_rc;
uint32_t l_ecmdRc = 0;
pba_barn_t bar;
pba_barmskn_t barmask;
- FAPI_INF("Called with index %x, address 0x%16llX, mask 0x%16llX scope 0x%16llX",
- i_index, i_pba_bar_addr, i_pba_bar_mask, i_pba_cmd_scope);
+ uint64_t work_size;
+
+ FAPI_DBG("Called with index %x, address 0x%16llX, size 0x%16llX scope 0x%16llX",
+ i_index, i_pba_bar_addr, i_pba_bar_size, i_pba_cmd_scope);
// check if pba_bar scope in range
if ( i_pba_cmd_scope > PBA_CMD_SCOPE_FOREIGN1 )
@@ -189,7 +143,7 @@ proc_pba_bar_config (const Target& i_target,
return l_rc;
}
- // check if pba_addr amd pba_mask are within range, high order bits checked, not low order!
+ // check if pba_addr amd pba_size are within range, high order bits checked, not low order!
// this means if we need a check for "is this value on the correct boundary value => needs to be implemented
if ( (BAR_ADDR_RANGECHECK_HIGH & i_pba_bar_addr) != 0x0ull)
{
@@ -197,20 +151,60 @@ proc_pba_bar_config (const Target& i_target,
FAPI_SET_HWP_ERROR(l_rc, RC_PROC_PBA_ADDR_OUT_OF_RANGE);
return l_rc;
}
- if ( (BAR_MASK_RANGECHECK_HIGH & i_pba_bar_mask) != 0x0ull)
+ if ( (i_pba_bar_size) == 0x0ull)
{
- FAPI_ERR("ERROR: Mask out of Range");
- FAPI_SET_HWP_ERROR(l_rc, RC_PROC_PBA_BAR_MASK_OUT_OF_RANGE);
+ FAPI_ERR("ERROR: Size must be 1MB or greater");
+ FAPI_SET_HWP_ERROR(l_rc, RC_PROC_PBA_BAR_MASK_OUT_OF_RANGE); // \todo change xml!!!
return l_rc;
}
+ // The PBA Mask indicates which bits from 23:43 (1MB grandularity) are
+ // enabled to be passed from the OCI addresses. Inverting this mask
+ // indicates which address bits are going to come from the PBA BAR value.
+ // The image address (the starting address) must match these post mask bits
+ // to be resident in the range.
+ //
+ // Starting bit number: 64 bit Big Endian
+ // 12223344
+ // 60482604
+ // region_inverted_mask = i_mem_mask ^ BAR_MASK_LIMIT; // XOR
+
+
+ // Check that the image address passed is within the memory region that
+ // is also passed.
+ //
+ // The PBA Mask indicates which bits from 23:43 (1MB grandularity) are
+ // enabled to be passed from the OCI addresses. Inverting this mask
+ // indicates which address bits are going to come from the PBA BAR value.
+ // The image address (the starting address) must match these post mask bits
+ // to be resident in the range.
+ //
+ // Starting bit number: 64 bit Big Endian
+ // 12223344
+ // 60482604
+ // region_inverted_mask = i_mem_mask ^ BAR_MASK_LIMIT; // XOR
+
+ // Set bits 14:22 as these are unconditional address bits
+ //region_inverted_mask = region_inverted_mask | BAR_ADDR_UNMASKED;
+ //computed_image_address = region_inverted_mask && image_address;
+ // Need to AND the address
+ //if (computed_image_address != i_mem_bar )
+ //{
+ // FAPI_ERR("SLW image address check failure. ");
+ // FAPI_SET_HWP_ERROR(rc, RC_PROCPM_POREBAR_IMAGE_ADDR_ERROR);
+ // return rc;
+ //}
+
+
+
// put the parameters into the correct fields
+ bar.value=0;
bar.fields.cmd_scope = i_pba_cmd_scope;
- bar.fields.addr = i_pba_bar_addr;
- barmask.fields.mask = i_pba_bar_mask;
+ bar.fields.addr = i_pba_bar_addr >> 20;
- FAPI_INF("bar.fields address 0x%16llX, scope 0x%16llX",
+ FAPI_DBG("bar.fields address 0x%16llX, scope 0x%16llX",
bar.fields.addr, bar.fields.cmd_scope);
+ FAPI_DBG("bar.value 0x%16llX", bar.value);
// Write the BAR
l_ecmdRc |= data.setDoubleWord(0, bar.value);
@@ -221,7 +215,7 @@ proc_pba_bar_config (const Target& i_target,
return l_rc;
}
-// $$ FAPI_DBG(" PBA_BAR: %s", data.genHexLeftStr(0,64).c_str());
+ FAPI_DBG(" PBA_BAR%x: %16llX", i_index, data.getDoubleWord(0));
l_rc = fapiPutScom(i_target, PBA_BARs[i_index], data);
if(l_rc)
{
@@ -229,7 +223,29 @@ proc_pba_bar_config (const Target& i_target,
return l_rc;
}
- // Write the MASK
+ // Compute and write the mask based on passed region size.
+
+ // If the size is already a power of 2, then set the mask to that value - 1.
+ // If the is not a power of 2, then set the mask the rounded up power of 2
+ // value minus 1.
+
+ work_size = PowerOf2Roundedup(i_pba_bar_size);
+ FAPI_DBG(" i_pba_bar_size %16llu work_size: %16llu", i_pba_bar_size, work_size);
+
+ barmask.value=0;
+ barmask.fields.mask = work_size-1;
+
+ FAPI_DBG("bar.fields mask 0x%16llX", barmask.fields.mask);
+
+
+ // Write the MASK
+
+ // The size is tranlated to a mask by:
+ // Shifting the s
+ //
+ //
+ //
+
l_ecmdRc |= data.setDoubleWord(0, barmask.value);
if (l_ecmdRc)
{
@@ -238,7 +254,7 @@ proc_pba_bar_config (const Target& i_target,
return l_rc;
}
-// $$ FAPI_DBG(" PBA_BARMSK: %s", data.genHexLeftStr(0,64).c_str());
+ FAPI_DBG(" PBA_BARMSK%x: %16llu", i_index, data.getDoubleWord(0));
l_rc = fapiPutScom(i_target, PBA_BARMSKs[i_index], data);
if(l_rc)
{
@@ -249,6 +265,37 @@ proc_pba_bar_config (const Target& i_target,
return l_rc;
}
+///-----------------------------------------------------------------------------
+/// Determine if a number is a power of two or not
+///-----------------------------------------------------------------------------
+bool
+isPowerOfTwo(uint64_t value)
+{
+ // if value ANDed with the value-1 is 0, then value is a power of 2.
+ // if value is 0, this is considered not a power of 2 and will return false.
+
+ return !(value & (value - 1));
+
+}
+
+///-----------------------------------------------------------------------------
+/// Round up to next higher power of 2 (return value if it's already a power of
+/// 2).
+///-----------------------------------------------------------------------------
+uint64_t
+PowerOf2Roundedup (uint64_t value)
+{
+ if (value < 0)
+ return 0;
+ --value;
+ value |= value >> 1;
+ value |= value >> 2;
+ value |= value >> 4;
+ value |= value >> 8;
+ value |= value >> 16;
+ return value+1;
+}
+
} //end extern C
OpenPOWER on IntegriCloud