summaryrefslogtreecommitdiffstats
path: root/src/usr/trace/compdesc.C
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2012-10-31 16:01:11 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-12-14 10:18:59 -0600
commitda3888270ff596441bf78535c26dee0a7d923145 (patch)
tree019b88ce38e87b8346e0ef659f058556e26dec42 /src/usr/trace/compdesc.C
parent6d7290eca2b0e753d1b954a56e2c82284dd23eb9 (diff)
downloadtalos-hostboot-da3888270ff596441bf78535c26dee0a7d923145.tar.gz
talos-hostboot-da3888270ff596441bf78535c26dee0a7d923145.zip
Lockless trace implementation
RTC: 35396 Change-Id: I96ea0d95606f04abb4dc2b0470345ca475b53912 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/2520 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/trace/compdesc.C')
-rw-r--r--src/usr/trace/compdesc.C98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/usr/trace/compdesc.C b/src/usr/trace/compdesc.C
new file mode 100644
index 000000000..92b306949
--- /dev/null
+++ b/src/usr/trace/compdesc.C
@@ -0,0 +1,98 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/trace/compdesc.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 */
+#include "compdesc.H"
+#include "service.H"
+#include <assert.h>
+#include <string.h>
+#include <string_ext.h>
+
+namespace TRACE
+{
+ ComponentDesc::ComponentDesc(const char* i_comp, uint32_t i_size,
+ uint8_t i_bufferType) :
+ iv_bufferType(i_bufferType), iv_debugEnabled(false),
+ iv_maxSize(i_size), iv_curSize(0),
+ iv_first(NULL), iv_last(NULL)
+ {
+ assert(iv_bufferType < BUFFER_COUNT);
+
+ memset(iv_compName, '\0', sizeof(iv_compName));
+ strcpy(iv_compName, i_comp); // No buffer overrun because of assert
+ // in ComponentList::getDescriptor.
+ strupr(iv_compName);
+
+ iv_compNameLen = strlen(iv_compName) + 1;
+ }
+
+ ComponentList::ComponentList() :
+ iv_components()
+ {
+ mutex_init(&iv_mutex);
+ };
+
+ ComponentList::~ComponentList()
+ {
+ mutex_destroy(&iv_mutex);
+ };
+
+ ComponentDesc* ComponentList::getDescriptor(const char* i_comp,
+ uint32_t i_size,
+ uint8_t i_bufferType)
+ {
+ ComponentDesc* l_rc = NULL;
+
+ assert(strlen(i_comp) < ComponentDesc::COMP_SIZE);
+
+ // Fix up the component name to be upper case.
+ char l_compName[ComponentDesc::COMP_SIZE];
+ memset(l_compName, '\0', sizeof(l_compName));
+ strcpy(l_compName, i_comp);
+ strupr(l_compName);
+
+ mutex_lock(&iv_mutex);
+
+ // Look for existing descriptor.
+ for(List::iterator i = iv_components.begin();
+ i != iv_components.end();
+ ++i)
+ {
+ if (0 == memcmp(&i->iv_compName, l_compName, sizeof(l_compName)))
+ {
+ l_rc = &(*i);
+ break;
+ }
+ }
+
+ // Insert new descriptor if none found.
+ if ((NULL == l_rc) && (i_size > 0))
+ {
+ iv_components.push_back(ComponentDesc(l_compName, i_size,
+ i_bufferType));
+ l_rc = &iv_components.back();
+ }
+
+ mutex_unlock(&iv_mutex);
+ return l_rc;
+ }
+
+};
OpenPOWER on IntegriCloud