summaryrefslogtreecommitdiffstats
path: root/sbe/image/sbe_main.C
diff options
context:
space:
mode:
authorSachin Gupta <sgupta2m@in.ibm.com>2015-06-30 02:13:08 -0500
committerJennifer A. Stofer <stofer@us.ibm.com>2015-07-28 15:12:08 -0500
commit8fd7df0b85039d5dc5f8a23f0d80cbce7d30a600 (patch)
tree2911df3c710b674d1db421a44ffdc995dd1e01ee /sbe/image/sbe_main.C
parentc2596d555aad0a91b2ddd4ea5d38fdb92649ee4b (diff)
downloadtalos-sbe-8fd7df0b85039d5dc5f8a23f0d80cbce7d30a600.tar.gz
talos-sbe-8fd7df0b85039d5dc5f8a23f0d80cbce7d30a600.zip
Target initialization using vectors
- Add initial getChildren implementation (for review only) - Updated attribute generation scripts with better error messages - Move functions to plat_target.H and target.C - Allow for override of PPE_TYPE Change-Id: Ib28fdd71413b33d43f0f7dc4711222da92a19237 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/18948 Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Tested-by: Jennifer A. Stofer <stofer@us.ibm.com>
Diffstat (limited to 'sbe/image/sbe_main.C')
-rw-r--r--sbe/image/sbe_main.C364
1 files changed, 364 insertions, 0 deletions
diff --git a/sbe/image/sbe_main.C b/sbe/image/sbe_main.C
new file mode 100644
index 00000000..3f859e86
--- /dev/null
+++ b/sbe/image/sbe_main.C
@@ -0,0 +1,364 @@
+//-----------------------------------------------------------------------------
+// *! (C) Copyright International Business Machines Corp. 2014
+// *! All Rights Reserved -- Property of IBM
+// *! *** IBM Confidential ***
+//-----------------------------------------------------------------------------
+
+/// \file sample_main.c
+/// \brief Sample program that creates and starts a thread
+///
+/// This file demonstrates how to create a thread and run it. It also provides
+/// an example of how to add traces to the code.
+#include <fapi2.H>
+//#include <p9_sbe_perv.H>
+
+#include <vector>
+
+
+
+
+extern "C"
+{
+
+#include "pk.h"
+#include "pk_trace.h"
+//#include "pk_trace_wrap.h"
+//#include "common_scom_addresses.H"
+//#include "p9_sbe_perv.H"
+#include "p9_hcd_cache.H"
+#include "p9_hcd_core.H"
+#include "proc_sbe_fixed.H"
+#include "trac_interface.h"
+
+}
+
+namespace fapi2attr
+{
+
+extern ProcChipAttributes_t* G_proc_chip_attributes asm("G_proc_chip_attributes") __attribute__ ((section (".fixed")));
+extern PervAttributes_t* G_perv_attributes asm("G_perv_attributes") __attribute__ ((section (".fixed")));
+extern CoreAttributes_t* G_core_attributes asm("G_core_attributes") __attribute__ ((section (".fixed")));
+extern EQAttributes_t* G_eq_attributes asm("G_eq_attributes") __attribute__ ((section (".fixed")));
+extern EXAttributes_t* G_ex_attributes asm("G_ex_attributes") __attribute__ ((section (".fixed")));
+
+}
+
+extern "C" {
+
+
+#define KERNEL_STACK_SIZE 256
+#define MAIN_THREAD_STACK_SIZE 256
+
+// Necessary Kernel Structures
+uint8_t G_kernel_stack[KERNEL_STACK_SIZE];
+uint8_t G_main_thread_stack[MAIN_THREAD_STACK_SIZE];
+PkThread G_main_thread;
+
+
+fapi2::ReturnCode
+hwp_chip(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target);
+
+fapi2::ReturnCode
+hwp_chip2(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target);
+
+
+fapi2::ReturnCode
+hwp_core(const fapi2::Target<fapi2::TARGET_TYPE_CORE> & i_target);
+
+fapi2::ReturnCode
+hwp_eq(const fapi2::Target<fapi2::TARGET_TYPE_EQ> & i_target);
+
+fapi2::ReturnCode
+hwp_perv(const fapi2::Target<fapi2::TARGET_TYPE_PERV> & i_target);
+
+
+//---------------------------------------------------------------------------
+
+
+void main_thread(void* arg)
+{
+
+ // This is workaround. Currently we do not have code to initialise
+ // global objects. So initializing global objects against using local
+ // initialized object
+ FAPI_DBG("Workaround temporary allocation of Global Vector");
+ std::vector<fapi2::plat_target_handle_t> targets1;
+ G_vec_targets = std::move(targets1);
+
+ // Intialize the targets
+ fapi2::plat_TargetsInit();
+
+ // Get a specific target
+ fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>chip_target_new =
+ fapi2::plat_getChipTarget();
+
+ FAPI_DBG("chip_target_new = 0x%08X", (uint32_t)(chip_target_new.get()>>32));
+
+ FAPI_TRY(hwp_chip(chip_target_new));
+
+ FAPI_TRY(hwp_chip2(chip_target_new));
+
+ ///
+#ifndef __noRC__
+ // PIB Errors are masked for platforms like SBE where
+ // explict error code checking is to occur
+ fapi2::setPIBErrorMask(0b11111111);
+#else
+ // PIB Errors are unmaskd for platforms that desire to take machine
+ // check interrupts
+ fapi2::setPIBErrorMask(0b00000000);
+#endif
+
+// FAPI_TRY(hwp_chip(chip_target_new));
+
+// FAPI_TRY(p9_sbe_attr_setup(chip_target));
+// FAPI_TRY(p9_sbe_check_master(chip_target));
+// FAPI_TRY(p9_sbe_setup_evid(chip_target));
+
+
+fapi_try_exit:
+ return;
+
+}
+
+// A Chip try
+fapi2::ReturnCode
+hwp_chip(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target)
+{
+
+ FAPI_DBG("i_target = 0x%08X", (uint32_t)(i_target.get()>>32));
+
+ auto l_perv_functional_vector =
+ i_target.getChildren<fapi2::TARGET_TYPE_PERV>
+ (fapi2::TARGET_STATE_PRESENT);
+
+ // Get the TPChiplet target
+ uint32_t i = 0;
+ for (auto it: l_perv_functional_vector)
+ {
+
+ FAPI_DBG("Perv Functional Target %u value=%08X chiplet %02X",
+ i,
+ (uint32_t)(it.get()>>32),
+ (uint32_t)(it.getChipletNumber()));
+
+ ++i;
+ }
+
+ auto l_core_functional_vector =
+ i_target.getChildren<fapi2::TARGET_TYPE_CORE>
+ (fapi2::TARGET_STATE_PRESENT);
+
+ // Get the Core Chiplet targets
+ uint32_t j = 0;
+ for (auto it: l_core_functional_vector)
+ {
+
+ FAPI_DBG("Core Functional Target %u value=%08X chiplet %02X",
+ j,
+ (uint32_t)(it.get()>>32),
+ (uint32_t)(it.getChipletNumber()));
+
+ ++j;
+ }
+
+
+ fapi2::buffer<uint64_t> data = 0;
+ const uint32_t address = 0x0006d010;
+
+ FAPI_INF("hwp_chip %u", address);
+
+ uint64_t databuffer;
+ getscom_abs(address, &databuffer);
+
+ databuffer = 0xDEAD000000000000ull;
+
+ putscom_abs(address, databuffer);
+
+ data = 0xBADC0DE800000000ull;
+ FAPI_TRY(fapi2::putScom(i_target, address, data));
+
+
+ FAPI_TRY(fapi2::getScom(i_target, address, data));
+ FAPI_DBG("First getSCOM: data = %016llX", revle64(data));
+
+ data.setBit<0, 16>();
+ FAPI_TRY(fapi2::putScom(i_target, 0x0006d010, data));
+
+ return fapi2::FAPI2_RC_SUCCESS;
+
+fapi_try_exit:
+ return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
+}
+
+// A Chip try
+fapi2::ReturnCode
+hwp_chip2(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target)
+{
+
+ FAPI_DBG("i_target = 0x%08X", (uint32_t)(i_target.get()>>32));
+
+
+ auto l_eq_functional_vector =
+ i_target.getChildren<fapi2::TARGET_TYPE_EQ>
+ (fapi2::TARGET_STATE_PRESENT);
+
+ // Get the EQ Chiplet target
+ uint32_t k = 0;
+ for (auto it: l_eq_functional_vector)
+ {
+
+ FAPI_DBG("EQ Functional Target %u value=%08X chiplet %02X",
+ k,
+ (uint32_t)(it.get()>>32),
+ (uint32_t)(it.getChipletNumber()));
+
+ ++k;
+ }
+
+
+ auto l_mcs_functional_vector =
+ i_target.getChildren<fapi2::TARGET_TYPE_MCS>
+ (fapi2::TARGET_STATE_PRESENT);
+
+ // Get the MCS Chiplet target
+ uint32_t m = 0;
+ for (auto it: l_mcs_functional_vector)
+ {
+
+ FAPI_DBG("MCS Functional Target %u value=%08X chiplet %02X",
+ m,
+ (uint32_t)(it.get()>>32),
+ (uint32_t)(it.getChipletNumber()));
+
+ ++m;
+ }
+
+
+ return fapi2::FAPI2_RC_SUCCESS;
+
+fapi_try_exit:
+ return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
+}
+
+// A Core try
+fapi2::ReturnCode
+hwp_core(const fapi2::Target<fapi2::TARGET_TYPE_CORE> & i_target)
+{
+
+ // Temporary target that pulls out only the chiplet overly. This keeps
+ // from having to compute this for each SCOM operation.
+// fapi2::Target<fapi2::TARGET_TYPE_ADDRESS> iv_target (i_target.getAddressOverlay());
+
+ fapi2::buffer<uint64_t> data = 0;
+ fapi2::buffer<uint64_t> mask;
+
+ uint32_t address = 0x200F5678;
+ FAPI_TRY(fapi2::getScom(i_target, address, data));
+
+ FAPI_TRY(fapi2::putScom(i_target, 0x20006789, data));
+
+ data = 0xBADC0DEBADC0DEBAull;
+ FAPI_TRY(fapi2::putScom(i_target, 0x0000AAAA, data));
+
+ FAPI_TRY(fapi2::getScom(i_target, address, data));
+
+ FAPI_TRY(fapi2::modifyScom(i_target, address, data, fapi2::CHIP_OP_MODIFY_MODE_OR));
+
+
+ mask = BITS(4,4);
+ FAPI_TRY(fapi2::putScomUnderMask(i_target, address, data, mask));
+
+ return fapi2::FAPI2_RC_SUCCESS;
+
+fapi_try_exit:
+
+ return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
+}
+
+// An EQ try
+fapi2::ReturnCode
+hwp_eq(const fapi2::Target<fapi2::TARGET_TYPE_EQ> & i_target)
+{
+ fapi2::buffer<uint64_t> data = 0;
+
+ uint64_t address = 0x1000F2222;
+ FAPI_TRY(fapi2::getScom(i_target, address, data));
+
+
+ FAPI_TRY(fapi2::putScom(i_target, 0x10006789, data));
+
+ data = 0xDEADBEEFDEADBEEFull;
+ FAPI_TRY(fapi2::putScom(i_target, 0x1000ABCD, data));
+
+ return fapi2::FAPI2_RC_SUCCESS;
+
+fapi_try_exit:
+
+ return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
+}
+
+// A Perv try
+fapi2::ReturnCode
+hwp_perv(const fapi2::Target<fapi2::TARGET_TYPE_PERV> & i_target)
+{
+ fapi2::buffer<uint64_t> data = 0;;
+
+ uint64_t address = 0x00005678;
+
+ for (uint32_t i = 0; i < 5; i++)
+ {
+ FAPI_TRY(fapi2::getScom(i_target, address+i, data));
+
+ data.setBit<4>();
+
+ FAPI_TRY(fapi2::putScom(i_target, address+i, data));
+
+ data = 0xDEADBEEFDEADBEEFull;
+ FAPI_TRY(fapi2::putScom(i_target, address+(2*i), data));
+ }
+
+ return fapi2::FAPI2_RC_SUCCESS;
+
+fapi_try_exit:
+
+ return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
+}
+
+
+
+// The main function is called by the boot code (after initializing some
+// registers)
+int main(int argc, char **argv)
+{
+ // initializes kernel data (stack, threads, timebase, timers, etc.)
+ pk_initialize((PkAddress)G_kernel_stack,
+ KERNEL_STACK_SIZE,
+ 0,
+ 500000000);
+
+ PK_TRACE("Kernel init completed");
+
+ //Initialize the thread control block for G_main_thread
+ pk_thread_create(&G_main_thread,
+ (PkThreadRoutine)main_thread,
+ (void*)NULL,
+ (PkAddress)G_main_thread_stack,
+ (size_t)MAIN_THREAD_STACK_SIZE,
+ (PkThreadPriority)1);
+
+ PK_TRACE_BIN("G_main_thread", &G_main_thread, sizeof(G_main_thread));
+
+ //Make G_main_thread runnable
+ pk_thread_resume(&G_main_thread);
+
+ PK_TRACE("Starting thread(s)");
+
+ // Start running the highest priority thread.
+ // This function never returns
+ pk_start_threads();
+
+ return 0;
+}
+
+} // extern C
OpenPOWER on IntegriCloud