summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDean Sanner <dsanner@us.ibm.com>2016-06-28 09:56:14 -0500
committerWilliam G. Hoffa <wghoffa@us.ibm.com>2016-08-17 11:16:11 -0400
commit183d1d89e624456cd831ca5dceb6c03edf07035c (patch)
treeba23039ab9a4b7b37e9cead11f63272a6f439905 /src
parent025298b52002867f1e3516ba9810fd4642262980 (diff)
downloadtalos-hostboot-183d1d89e624456cd831ca5dceb6c03edf07035c.tar.gz
talos-hostboot-183d1d89e624456cd831ca5dceb6c03edf07035c.zip
Utility functions for mbox scratch reg access
Change-Id: If262e891934b5228ea1fa9081a0c85a40a52036d RTC:127348 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/26346 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Prachi Gupta <pragupta@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com> Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/util/utilmbox_scratch.H100
-rw-r--r--src/usr/trace/daemon/daemon.C60
-rw-r--r--src/usr/trace/daemon/daemon.H7
-rw-r--r--src/usr/util/makefile3
-rw-r--r--src/usr/util/utilmbox_scratch.C119
5 files changed, 228 insertions, 61 deletions
diff --git a/src/include/usr/util/utilmbox_scratch.H b/src/include/usr/util/utilmbox_scratch.H
new file mode 100644
index 000000000..b1111cd14
--- /dev/null
+++ b/src/include/usr/util/utilmbox_scratch.H
@@ -0,0 +1,100 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/usr/util/utilmbox_scratch.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2012,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 UTILMBOX_SCRATCH_H
+#define UTILMBOX_SCRATCH_H
+
+/**
+ * @file utilmbox_scratch.H
+ *
+ * @brief Utilies to manipulate mbox scratch debug communication
+ *
+ * Used for creating and manipulating memory streams
+ *
+ */
+
+/*****************************************************************************/
+// I n c l u d e s
+/*****************************************************************************/
+#include <initservice/mboxRegs.H>
+
+// Utility Includes
+
+/*****************************************************************************/
+// Forwards
+/*****************************************************************************/
+
+//*****************************************************************************/
+// C o n s t a n t s
+/*****************************************************************************/
+namespace Util
+{
+ enum
+ {
+ MSG_TYPE_MASK = 0xE0000000,
+ MSG_COUNT_MASK = 0x1F000000,
+ MSG_USAGE_MASK = MSG_TYPE_MASK | MSG_COUNT_MASK,
+ MSG_USAGE_SHIFT = 24,
+ MSG_DATA_SIZE_MASK = ~MSG_USAGE_MASK,
+
+ MSG_TYPE_TRACE = 0x00,
+ MSG_TYPE_ATTRDUMP = 0x01,
+ };
+
+ /**
+ * @brief This places the address and buffer size for the debug tool
+ * into the mailbox scratch regs in a synchronous fashion. It will also
+ * wait for the tool to ack the reciept of data before returning
+ *
+ * @param[in] i_usage 1 byte of "usage" data. Caller defined
+ * @param[in] i_addr Physical real address of buffer
+ * @param[in] i_size Size of data in bytes
+ *
+ * @return none
+ */
+ void writeDebugCommRegs(uint8_t i_usage, uint32_t i_addr, uint32_t i_size);
+
+ /**
+ * @brief This function writes data to mailbox scratch reg
+ * These scom addresses are always accessible and any errors are commited
+ * internally
+ * @param[in] i_addr Scom address of mailbox reg to write
+ * @param[in] i_data Data to write to mailbox (only 0:31 are valid)
+ *
+ * @return none
+ */
+ void writeScratchReg(uint64_t i_addr, uint64_t i_data);
+
+ /**
+ * @brief This function reads data to mailbox scratch reg
+ * These scom addresses are always accessible and any errors are commited
+ * internally
+ * @param[in] i_addr Scom address of mailbox reg to read
+ *
+ * @return Data in mailbox scratch reg (only 0:31 are valid)
+ */
+ uint64_t readScratchReg(uint64_t i_addr);
+};
+
+#endif //UTILMEM_H
diff --git a/src/usr/trace/daemon/daemon.C b/src/usr/trace/daemon/daemon.C
index 447f25f55..49fe6da32 100644
--- a/src/usr/trace/daemon/daemon.C
+++ b/src/usr/trace/daemon/daemon.C
@@ -48,6 +48,7 @@
#include <mbox/mboxif.H>
#include <config.h>
#include <console/consoleif.H>
+#include <util/utilmbox_scratch.H>
namespace TRACE
{
@@ -115,7 +116,8 @@ namespace TRACEDAEMON
INITSERVICE::LOWEST_PRIORITY);
// Clear scratch register.
- writeScratchReg(0, 0);
+ Util::writeScratchReg(INITSERVICE::SPLESS::MBOX_SCRATCH_REG1, 0);
+ Util::writeScratchReg(INITSERVICE::SPLESS::MBOX_SCRATCH_REG2, 0);
// Loop handling messages.
while (msg_t* msg = iv_service->iv_daemon->wait())
@@ -476,14 +478,10 @@ namespace TRACEDAEMON
else
{
// Write scratch register indicating is available.
- writeScratchReg(reinterpret_cast<uint64_t>(i_buffer) << 32,
- i_size << 32);
-
- // Wait for tools to extract the buffer.
- while(0 != readScratchReg())
- {
- task_yield();
- }
+ uint64_t l_addr = reinterpret_cast<uint64_t>(i_buffer);
+ Util::writeDebugCommRegs(Util::MSG_TYPE_TRACE,
+ l_addr,
+ i_size);
free(i_buffer);
}
}
@@ -776,50 +774,6 @@ namespace TRACEDAEMON
sendExtractBuffer(NULL, 0);
}
-
- void Daemon::writeScratchReg(uint64_t i_value1, uint64_t i_value2)
- {
- size_t l_size = sizeof(uint64_t);
-
- errlHndl_t l_errl =
- deviceWrite(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
- &i_value1, l_size,
- DEVICE_SCOM_ADDRESS(MB_SCRATCH_REGISTER_1));
-
- if (l_errl)
- {
- errlCommit(l_errl, TRACE_COMP_ID);
- }
-
- l_errl =
- deviceWrite(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
- &i_value2, l_size,
- DEVICE_SCOM_ADDRESS(MB_SCRATCH_REGISTER_2));
-
- if (l_errl)
- {
- errlCommit(l_errl, TRACE_COMP_ID);
- }
- }
-
- uint64_t Daemon::readScratchReg()
- {
- size_t l_size = sizeof(uint64_t);
- uint64_t value = 0;
-
- errlHndl_t l_errl =
- deviceRead(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
- &value, l_size,
- DEVICE_SCOM_ADDRESS(MB_SCRATCH_REGISTER_1));
-
- if (l_errl)
- {
- errlCommit(l_errl, TRACE_COMP_ID);
- }
-
- return value;
- }
-
}
// Define an entry point for the trace daemon module.
diff --git a/src/usr/trace/daemon/daemon.H b/src/usr/trace/daemon/daemon.H
index 4c7f369d5..57e908696 100644
--- a/src/usr/trace/daemon/daemon.H
+++ b/src/usr/trace/daemon/daemon.H
@@ -96,13 +96,6 @@ namespace TRACEDAEMON
/** Locklessly move a trace entry from one location to another. */
void replaceEntry(TRACE::Entry* from, TRACE::Entry* to);
- /** Write mailbox scratch 1 & 2 registers to a values.
- * scratch 1 contains the trace buffer address
- * scratch 2 contains the trace buffer size */
- void writeScratchReg(uint64_t i_value1, uint64_t i_value2);
- /** Read mailbox scratch 1 register. */
- uint64_t readScratchReg();
-
/** Client-service object. */
TRACE::Service* iv_service;
diff --git a/src/usr/util/makefile b/src/usr/util/makefile
index 7a5aa7651..70df3b790 100644
--- a/src/usr/util/makefile
+++ b/src/usr/util/makefile
@@ -5,7 +5,7 @@
#
# OpenPOWER HostBoot Project
#
-# Contributors Listed Below - COPYRIGHT 2012,2015
+# Contributors Listed Below - COPYRIGHT 2012,2016
# [+] International Business Machines Corp.
#
#
@@ -32,6 +32,7 @@ OBJS += utilmem.o
OBJS += utilfile.o
OBJS += utillidmgr.o
OBJS += utillidpnor.o
+OBJS += utilmbox_scratch.o
SUBDIRS += test.d
SUBDIRS += runtime.d
diff --git a/src/usr/util/utilmbox_scratch.C b/src/usr/util/utilmbox_scratch.C
new file mode 100644
index 000000000..9a38b8dff
--- /dev/null
+++ b/src/usr/util/utilmbox_scratch.C
@@ -0,0 +1,119 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/util/utilmbox_scratch.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 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 */
+/**
+ * @file utilmem.C
+ *
+ * @brief Stream manipulation
+ *
+ * Used for creating and manipulating streams
+ */
+
+/*****************************************************************************/
+// I n c l u d e s
+/*****************************************************************************/
+#include <limits.h>
+#include <util/util_reasoncodes.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <devicefw/userif.H>
+#include <sys/task.h>
+#include <util/utilmbox_scratch.H>
+
+#include "utilbase.H"
+
+using namespace ERRORLOG;
+
+namespace Util
+{
+
+ // ----------------------------------------------
+ // Globals
+ // ----------------------------------------------
+ mutex_t g_mutex = MUTEX_INITIALIZER;
+
+
+ uint64_t readScratchReg(uint64_t i_addr)
+ {
+ size_t l_size = sizeof(uint64_t);
+ uint64_t value = 0;
+
+ errlHndl_t l_errl =
+ deviceRead(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
+ &value, l_size,
+ DEVICE_SCOM_ADDRESS(i_addr));
+
+ if (l_errl)
+ {
+ errlCommit(l_errl, UTIL_COMP_ID);
+ }
+
+ return value;
+ }
+
+ void writeScratchReg(uint64_t i_addr, uint64_t i_data)
+ {
+ size_t l_size = sizeof(uint64_t);
+
+ errlHndl_t l_errl =
+ deviceWrite(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
+ &i_data, l_size,
+ DEVICE_SCOM_ADDRESS(i_addr));
+
+ if (l_errl)
+ {
+ errlCommit(l_errl, UTIL_COMP_ID);
+ }
+ }
+
+ void writeDebugCommRegs(uint8_t i_usage, uint32_t i_addr, uint32_t i_size)
+ {
+ //convert input into uint64_t for scom write
+ uint64_t l_bufAddr = i_addr;
+ uint64_t l_bufSize = (i_size & MSG_DATA_SIZE_MASK) |
+ (i_usage << MSG_USAGE_SHIFT);
+
+ l_bufAddr <<=32;
+ l_bufSize <<=32;
+
+ //Lock to prevent concurrent access
+ mutex_lock(&g_mutex);
+
+
+ //Write out the data to be xferred to debug tool
+ writeScratchReg(INITSERVICE::SPLESS::MBOX_SCRATCH_REG1, l_bufAddr);
+ writeScratchReg(INITSERVICE::SPLESS::MBOX_SCRATCH_REG2, l_bufSize);
+
+ //wait paitently until tool has gotten the data
+ //tool will zero addr when ready to continue
+ while(0 != readScratchReg(INITSERVICE::SPLESS::MBOX_SCRATCH_REG1))
+ {
+ task_yield();
+ }
+
+ //Release lock
+ mutex_unlock(&g_mutex);
+ }
+
+};
OpenPOWER on IntegriCloud