diff options
author | Andrew Geissler <andrewg@us.ibm.com> | 2011-05-16 07:21:33 -0500 |
---|---|---|
committer | Andrew J. Geissler <andrewg@us.ibm.com> | 2011-05-18 10:14:35 -0500 |
commit | 5f28dffa51ef4fe402e1e8609fd8afa44e834db6 (patch) | |
tree | cd61f8be390ccbf8e6df49e8d82b339c70e24232 /src/usr/trace | |
parent | 82fa0190a4ad346500a9b5d75abc9f85c23b08e8 (diff) | |
download | blackbird-hostboot-5f28dffa51ef4fe402e1e8609fd8afa44e834db6.tar.gz blackbird-hostboot-5f28dffa51ef4fe402e1e8609fd8afa44e834db6.zip |
Updated per trace code review comments.
- Fixed merge issue with src/makefile
- Updated per second code review
- Got trace tests up and running
Change-Id: I932ac4eb6d2389e39ce5efb1dd2f5cfa97f7b70b
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'src/usr/trace')
-rw-r--r-- | src/usr/trace/makefile | 2 | ||||
-rw-r--r-- | src/usr/trace/test/makefile | 6 | ||||
-rw-r--r-- | src/usr/trace/test/tracetest.H | 129 | ||||
-rw-r--r-- | src/usr/trace/trace.C | 276 | ||||
-rw-r--r-- | src/usr/trace/trace.H | 132 |
5 files changed, 288 insertions, 257 deletions
diff --git a/src/usr/trace/makefile b/src/usr/trace/makefile index d963a9895..fa4b14324 100644 --- a/src/usr/trace/makefile +++ b/src/usr/trace/makefile @@ -3,4 +3,6 @@ MODULE = trace OBJS = trace.o tracebuffer.o +SUBDIRS = test.d + include ${ROOTPATH}/config.mk diff --git a/src/usr/trace/test/makefile b/src/usr/trace/test/makefile new file mode 100644 index 000000000..ba38d6f66 --- /dev/null +++ b/src/usr/trace/test/makefile @@ -0,0 +1,6 @@ +ROOTPATH = ../../../.. + +MODULE = testtrace +TESTS = *.H + +include ${ROOTPATH}/config.mk diff --git a/src/usr/trace/test/tracetest.H b/src/usr/trace/test/tracetest.H new file mode 100644 index 000000000..0767352c6 --- /dev/null +++ b/src/usr/trace/test/tracetest.H @@ -0,0 +1,129 @@ +#ifndef __TEST_TRACETEST_H +#define __TEST_TRACETEST_H + +/** + * @file tracetest.H + * + * @brief All unit tests for the trace module in host boot. +*/ + +#include <cxxtest/TestSuite.H> +//#include <trace/interface.H> +#include <tracinterface.H> + +class TraceTest : public CxxTest::TestSuite +{ +public: + + /** + * @test Test Component Trace Interfaces + */ + void testTracComp(void) + { + trace_desc_t *g_trac_test = NULL; + TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLE", 4096); + + if(g_trac_test == NULL) + { + TS_FAIL("g_trac_test was returned as NULL!"); + } + else + { + // Component trace tests - There is no easy way to validate these + // are working but we can at least ensure we don't cause host boot + // to crash when running them. + + for(uint32_t i=0;i<100;i++) + { + TRACFCOMP(g_trac_test, "Thread ID: %d", task_gettid()); + TRACFCOMP(g_trac_test, "Validate all number types (c,u,X,d): %c %u 0x%X %d", + 'a',i,i+1,i+2); + + TRACFCOMP(g_trac_test, "Validate pointer type (p): %p", + g_trac_test); + + TRACFCOMP(g_trac_test, "64 Bit Value Test - 0x123456789ABCDEF0: 0x%X", + 0x123456789ABCDEF0); + + // Do a debug trace + TRACDCOMP(g_trac_test,"This is a debug trace"); + + // Need to run a formatting test, but I know it will fail. + } + + // Be sure a NULL trace descriptor does not cause a failure + TRACFCOMP(NULL,"This trace should never show up"); + + } + } + + /** + * @test Test Binary Trace Interface + */ + void testTracBinary(void) + { + trace_desc_t *g_trac_test = NULL; + TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLE", 4096); + + if(g_trac_test == NULL) + { + TS_FAIL("g_trac_test was returned as NULL!"); + } + else + { + // Binary trace tests - There is no easy way to validate these + // are working but we can at least ensure we don't cause host boot + // to crash when running them. + TRACFBIN(g_trac_test,"Binary dump of trace descriptor", + g_trac_test,sizeof(trace_desc_t)); + + TRACDBIN(g_trac_test,"Unaligned Debug binary trace of the trace descriptor", + g_trac_test,9); + + // Be sure a NULL trace descriptor does not cause a failure + TRACFBIN(NULL,"This trace should never show up", + g_trac_test,sizeof(trace_desc_t)); + + // Be sure it handles a size of 0 + TRACFBIN(NULL,"This trace should never show up - 0 size", + g_trac_test,0); + } + } + + /** + * @test Test a mix of traces + */ + void testTracMix(void) + { + trace_desc_t *g_trac_test = NULL; + TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLE", 4096); + + if(g_trac_test == NULL) + { + TS_FAIL("g_trac_test was returned as NULL!"); + } + else + { + uint32_t l_size = 0; + + for(uint32_t i=0;i<100;i++) + { + + TRACFCOMP(g_trac_test, INFO_MRK"Validate all number types (c,u,X,d): %c %u 0x%X %d", + 'a',i,i+1,i+2); + + l_size = i % sizeof(trace_desc_t); + + TRACFBIN(g_trac_test,"Unaligned Binary dump of trace descriptor", + g_trac_test,l_size); + + TRACFCOMP(g_trac_test, "64 Bit Value Test - 0x123456789ABCDEF0: 0x%X", + 0x123456789ABCDEF0); + + } + } + } +}; + +#endif + diff --git a/src/usr/trace/trace.C b/src/usr/trace/trace.C index 33a3de888..b5105a654 100644 --- a/src/usr/trace/trace.C +++ b/src/usr/trace/trace.C @@ -1,7 +1,9 @@ /* TODO - * - Add support in for debug traces - * - Time support + * - Add support in for debug trace enable/disable * - FORMAT_PRINTF support + * - %s support + * - Multiple buffer support + * - Prolog * * */ @@ -17,8 +19,9 @@ #include <stdlib.h> #include <sys/task.h> #include <sys/mutex.h> +#include <string.h> -#include "trace.H" +#include <trace/trace.H> /******************************************************************************/ // Namespace @@ -30,28 +33,43 @@ namespace TRACE // Globals/Constants /******************************************************************************/ -#define TRAC_TIME_REAL 0 // upper 32 = seconds, lower 32 = microseconds -#define TRAC_TIME_50MHZ 1 -#define TRAC_TIME_200MHZ 2 -#define TRAC_TIME_167MHZ 3 // 166666667Hz -#define COMP_NAME_SIZE 16 +const uint32_t TRAC_TIME_REAL = 0; // upper 32 = seconds, lower 32 = microseconds +const uint32_t TRAC_TIME_50MHZ = 1; +const uint32_t TRAC_TIME_200MHZ = 2; +const uint32_t TRAC_TIME_167MHZ = 3; // 166666667Hz +const uint32_t COMP_NAME_SIZE = 16; -// Global value used as a "timer" to provide tracing point32_t of reference -uint32_t g_trac_time_high = 0; -uint32_t g_trac_time_low = 0; +const uint64_t TRAC_DEFAULT_BUFFER_SIZE = 0x1000; -// Global Mutex -mutex_t g_trac_mutex; - -// Global buffer +// Global trace buffer. - Keep global so it can be found in syms file trace_desc_t *g_trac_global = NULL; +/******************************************************************************/ +// Trace::Trace +/******************************************************************************/ +Trace::Trace() +{ + iv_trac_mutex = mutex_create(); + + g_trac_global = static_cast<trace_desc_t *>(malloc(TRAC_DEFAULT_BUFFER_SIZE)); + + initValuesBuffer(g_trac_global, + "GLOBAL"); +} + +/******************************************************************************/ +// Trace::~Trace +/******************************************************************************/ +Trace::~Trace() +{ + +} /******************************************************************************/ // trace_adal_init_buffer /******************************************************************************/ -void trace_adal_init_buffer(trace_desc_t **o_td, const char* i_comp, +void Trace::initBuffer(trace_desc_t **o_td, const char* i_comp, const size_t i_size ) { /*------------------------------------------------------------------------*/ @@ -63,35 +81,18 @@ void trace_adal_init_buffer(trace_desc_t **o_td, const char* i_comp, /*------------------------------------------------------------------------*/ if(*o_td == NULL) { - if(g_trac_global == NULL) - { - // TODO - How do I make this pre-emption/mutli-threading safe? - g_trac_mutex = mutex_create(); - - printk("Global trace buffer is NULL so create and init it!\n"); - - g_trac_global = (trace_desc_t *)(malloc(PAGE_SIZE)); - char l_g_comp[TRAC_COMP_SIZE] = "GLOBAL"; - trace_init_values_buffer(g_trac_global, - l_g_comp); - - } - // Just assign it to the global buffer since we only have // one buffer *o_td = g_trac_global; - printk("Assigned input trace descriptor to global buffer\n"); } - printk("*td = %lu\n",(unsigned long int)*o_td); - return; } /******************************************************************************/ -// trace_init_values_buffer +// initValuesBuffer /******************************************************************************/ -void trace_init_values_buffer(trace_desc_t *o_buf,const char *i_comp) +void Trace::initValuesBuffer(trace_desc_t *o_buf,const char *i_comp) { /*------------------------------------------------------------------------*/ /* Local Variables */ @@ -102,16 +103,16 @@ void trace_init_values_buffer(trace_desc_t *o_buf,const char *i_comp) /*------------------------------------------------------------------------*/ // Initialize it to all 0's - memset(o_buf,0,(size_t)PAGE_SIZE); + memset(o_buf,0,(size_t)TRAC_DEFAULT_BUFFER_SIZE); - (o_buf)->ver = TRACE_BUF_VERSION; - (o_buf)->hdr_len = sizeof(trace_buf_head_t); - (o_buf)->time_flg = TRAC_TIME_167MHZ; - (o_buf)->endian_flg = 'B'; // Big Endian - memcpy((o_buf)->comp,i_comp,(size_t)COMP_NAME_SIZE); - (o_buf)->size = PAGE_SIZE; - (o_buf)->times_wrap = 0; - (o_buf)->next_free = sizeof(trace_buf_head_t); + o_buf->ver = TRACE_BUF_VERSION; + o_buf->hdr_len = sizeof(trace_buf_head_t); + o_buf->time_flg = TRAC_TIME_REAL; + o_buf->endian_flg = 'B'; // Big Endian + strcpy(o_buf->comp,i_comp); + o_buf->size = TRAC_DEFAULT_BUFFER_SIZE; + o_buf->times_wrap = 0; + o_buf->next_free = sizeof(trace_buf_head_t); return; } @@ -119,11 +120,11 @@ void trace_init_values_buffer(trace_desc_t *o_buf,const char *i_comp) /******************************************************************************/ // trace_adal_write_all /******************************************************************************/ -void trace_adal_write_all(trace_desc_t *io_td, - const trace_hash_val i_hash, - const char * i_fmt, - const uint32_t i_line, - const int32_t i_type, ...) +void Trace::trace_adal_write_all(trace_desc_t *io_td, + const trace_hash_val i_hash, + const char * i_fmt, + const uint32_t i_line, + const int32_t i_type, ...) { /*------------------------------------------------------------------------*/ /* Local Variables */ @@ -146,11 +147,7 @@ void trace_adal_write_all(trace_desc_t *io_td, _fmt++; } - if(num_args > TRAC_MAX_ARGS) - { - printk ("Too many arguments: %u",num_args); - } - else if(io_td != NULL) + if((num_args <= TRAC_MAX_ARGS) && (io_td != NULL)) { // Calculate total space needed @@ -169,7 +166,7 @@ void trace_adal_write_all(trace_desc_t *io_td, l_entry_size = (l_entry_size + 3) & ~3; // Fill in the entry structure - l_entry.stamp.tid = (uint32_t)task_gettid(); // What is response to this in AME code? + l_entry.stamp.tid = static_cast<uint32_t>(task_gettid()); // Length is equal to size of data l_entry.head.length = (num_args * sizeof(uint64_t)); @@ -178,7 +175,7 @@ void trace_adal_write_all(trace_desc_t *io_td, l_entry.head.line = i_line; // Time stamp - *(l_entry.stamp.tb) = getTB(); + convertTime(&l_entry.stamp); uint64_t* data = &l_entry.args[0]; @@ -193,42 +190,37 @@ void trace_adal_write_all(trace_desc_t *io_td, // Now put total size at end of buffer // Note that fsp-trace assumes this to be a 32 bit long word - uint32_t *l_size = (uint32_t *)&(l_entry.args[num_args]); + uint32_t *l_size = reinterpret_cast<uint32_t *> + (&(l_entry.args[num_args])); *l_size = l_entry_size; - printk("l_entry_size = %u ttid = %u\n",l_entry_size,l_entry.stamp.tid); - // We now have total size and need to reserve a part of the trace // buffer for this // CRITICAL REGION START - l_rc = mutex_lock(g_trac_mutex); + l_rc = mutex_lock(iv_trac_mutex); if(l_rc != 0) { - printk("trace_adal_write_all: Failed to get mutex"); + // This will assert so we'll never hit this code. } else { // Update the entry count io_td->te_count++; - trace_write_data(io_td, - (void *)&l_entry, - l_entry_size); + writeData(io_td, + static_cast<void *>(&l_entry), + l_entry_size); - l_rc = mutex_unlock(g_trac_mutex); + l_rc = mutex_unlock(iv_trac_mutex); if(l_rc != 0) { // Badness - printk("trace_adal_write_all: Failed to release mutex"); + // This will assert so we'll never hit this code. } } // CRITICAL REGION END } - else - { - printk("trace_adal_write_all: User passed invalid parameter"); - } return; } @@ -236,11 +228,11 @@ void trace_adal_write_all(trace_desc_t *io_td, /******************************************************************************/ // trace_adal_write_bin /******************************************************************************/ -void trace_adal_write_bin(trace_desc_t *io_td,const trace_hash_val i_hash, - const uint32_t i_line, - const void *i_ptr, - const uint32_t i_size, - const int32_t type) +void Trace::trace_adal_write_bin(trace_desc_t *io_td,const trace_hash_val i_hash, + const uint32_t i_line, + const void *i_ptr, + const uint32_t i_size, + const int32_t type) { /*------------------------------------------------------------------------*/ /* Local Variables */ @@ -276,7 +268,7 @@ void trace_adal_write_bin(trace_desc_t *io_td,const trace_hash_val i_hash, l_entry_size = (l_entry_size + 3) & ~3; // Fill in the entry structure - l_entry.stamp.tid = (uint32_t)task_gettid(); // What is response to this in AME code? + l_entry.stamp.tid = static_cast<uint32_t>(task_gettid()); // Length is equal to size of data l_entry.head.length = i_size; @@ -288,41 +280,41 @@ void trace_adal_write_bin(trace_desc_t *io_td,const trace_hash_val i_hash, // buffer for this // Time stamp - *(l_entry.stamp.tb) = getTB(); + convertTime(&l_entry.stamp); // CRITICAL REGION START - l_rc = mutex_lock(g_trac_mutex); + l_rc = mutex_lock(iv_trac_mutex); if(l_rc != 0) { - printk("trace_adal_write_bin: Failed to get mutex"); + // This will assert so we'll never hit this code. } else { // Increment trace counter - io_td->te_count++;; + io_td->te_count++; // First write the header - trace_write_data(io_td, - (void *)&l_entry, - sizeof(l_entry)); + writeData(io_td, + static_cast<void *>(&l_entry), + sizeof(l_entry)); // Now write the actual binary data - trace_write_data(io_td, - i_ptr, - i_size); + writeData(io_td, + i_ptr, + i_size); // Now write the size at the end - trace_write_data(io_td, - (void *)&l_entry_size, - sizeof(l_entry_size)); + writeData(io_td, + static_cast<void *>(&l_entry_size), + sizeof(l_entry_size)); // CRITICAL REGION END - l_rc = mutex_unlock(g_trac_mutex); + l_rc = mutex_unlock(iv_trac_mutex); if(l_rc != 0) { // Badness - printk("trace_adal_write_bin: Failed to release mutex"); + // This will assert so we'll never hit this code. } } @@ -332,9 +324,9 @@ void trace_adal_write_bin(trace_desc_t *io_td,const trace_hash_val i_hash, } /******************************************************************************/ -// trace_write_data +// writeData /******************************************************************************/ -void trace_write_data(trace_desc_t *io_td, +void Trace::writeData(trace_desc_t *io_td, const void *i_ptr, const uint32_t i_size) { @@ -344,6 +336,7 @@ void trace_write_data(trace_desc_t *io_td, uint32_t l_total_size = i_size; void *l_buf_ptr = NULL; uint32_t l_offset = 0; + uint64_t l_align = 0; /*------------------------------------------------------------------------*/ /* Code */ @@ -352,19 +345,26 @@ void trace_write_data(trace_desc_t *io_td, do { - if(i_size > PAGE_SIZE) + if(i_size > (io_td->size-sizeof(trace_buf_head_t))) { - printk("trace_write_data: Input size to large!"); break; } - if((io_td->next_free + l_total_size) > PAGE_SIZE) + + if((io_td->next_free + l_total_size) > io_td->size) { - // copy what we can to end - l_buf_ptr = (char *)io_td + io_td->next_free; - l_buf_ptr = (void *) ( ((uint64_t) l_buf_ptr + 3) & ~3); - l_offset = PAGE_SIZE-io_td->next_free; - memcpy(l_buf_ptr,i_ptr,(size_t)l_offset); + // Get the pointer to current location in buffer + l_buf_ptr = reinterpret_cast<char *>(io_td) + io_td->next_free; + // Figure out the alignment + l_align = ( (reinterpret_cast<uint64_t>(l_buf_ptr) + 3) & ~3) - + reinterpret_cast<uint64_t>(l_buf_ptr); + // Add on the alignment + l_buf_ptr = reinterpret_cast<void *>(reinterpret_cast<uint64_t> + (l_buf_ptr) + l_align); + // Ensure offset accounts for the alignment + l_offset = io_td->size-io_td->next_free - l_align; + // Copy in what fits + memcpy(l_buf_ptr,i_ptr,static_cast<size_t>(l_offset)); l_total_size -= l_offset; @@ -373,17 +373,23 @@ void trace_write_data(trace_desc_t *io_td, io_td->next_free = io_td->hdr_len; } - l_buf_ptr = (char *)io_td + io_td->next_free; - - // Word align the write - total size includes this allignment - l_buf_ptr = (void *) ( ((uint64_t) l_buf_ptr + 3) & ~3); + // Get the pointer to current location in buffer + l_buf_ptr = reinterpret_cast<char *>(io_td) + io_td->next_free; + // Figure out the alignment + l_align = ( (reinterpret_cast<uint64_t>(l_buf_ptr) + 3) & ~3) - + reinterpret_cast<uint64_t>(l_buf_ptr); + // Add on the alignment + l_buf_ptr = reinterpret_cast<void *>(reinterpret_cast<uint64_t> + (l_buf_ptr) + l_align); - memcpy(l_buf_ptr,(char *)i_ptr + l_offset,l_total_size); + memcpy(l_buf_ptr,reinterpret_cast<const char *>(i_ptr) + l_offset, + l_total_size); - // Make sure size is correct for word allignment + // Make sure size is correct for word alignment // Note that this works with binary trace because only the binary data // has the potential to be un-word aligned. If two parts of the binary // trace had this problem then this code would not work. + // Note that fsp-trace will ignore garbage data in the unaligned areas. l_total_size = (l_total_size + 3) & ~3; io_td->next_free += l_total_size; @@ -394,9 +400,34 @@ void trace_write_data(trace_desc_t *io_td, } /******************************************************************************/ -// TRAC_get_td - TODO +// convertTime +/******************************************************************************/ +void Trace::convertTime(trace_entry_stamp_t *o_entry) +{ + /*------------------------------------------------------------------------*/ + /* Local Variables */ + /*------------------------------------------------------------------------*/ + + /*------------------------------------------------------------------------*/ + /* Code */ + /*------------------------------------------------------------------------*/ + + // TODO - Future Sprint will collect proc frequency and correctly + // calculate this. + uint64_t l_time = getTB(); + //o_entry->tbh = l_time && 0xFFFFFFFF00000000; + //o_entry->tbl = l_time && 0x00000000FFFFFFFF; + + // This basically supports SIMICS, but will look weird on real hw + o_entry->tbh = (l_time / 512000000); + o_entry->tbl = ((l_time - (o_entry->tbh * 512000000)) / 512); + +} + +/******************************************************************************/ +// getTd - TODO /******************************************************************************/ -trace_desc_t * trace_get_td(const char *i_comp) +trace_desc_t * Trace::getTd(const char *i_comp) { /*------------------------------------------------------------------------*/ /* Local Variables */ @@ -427,9 +458,9 @@ trace_desc_t * trace_get_td(const char *i_comp) } /******************************************************************************/ -// trace_get_buffer - TODO +// getBuffer - TODO /******************************************************************************/ -int32_t trace_get_buffer(const trace_desc_t *i_td_ptr, +int32_t Trace::getBuffer(const trace_desc_t *i_td_ptr, void *o_data) { /*------------------------------------------------------------------------*/ @@ -446,11 +477,10 @@ int32_t trace_get_buffer(const trace_desc_t *i_td_ptr, // Get the lock // TODO Mutex #if 0 - l_rc = UTIL_MUTEX_GET(&g_trac_mutex,TRAC_INTF_MUTEX_TIMEOUT); + l_rc = UTIL_MUTEX_GET(&iv_trac_mutex,TRAC_INTF_MUTEX_TIMEOUT); if(l_rc != 0) { // Badness - printk("TRAC_get_buffer: Failed to get mutex"); } else { @@ -458,15 +488,11 @@ int32_t trace_get_buffer(const trace_desc_t *i_td_ptr, } #endif // Copy it's buffer into temp one - memcpy(o_data,i_td_ptr,(size_t)PAGE_SIZE); + memcpy(o_data,i_td_ptr,(size_t)TRAC_DEFAULT_BUFFER_SIZE); // Always try to release even if error above // TODO - mutex - //UTIL_MUTEX_PUT(&g_trac_mutex); - } - else - { - printk("TRAC_get_buffer: Invalid parameter passed by caller"); + //UTIL_MUTEX_PUT(&iv_trac_mutex); } return(l_rc); @@ -474,10 +500,10 @@ int32_t trace_get_buffer(const trace_desc_t *i_td_ptr, #if 0 /******************************************************************************/ -// trace_get_buffer_partial - TODO +// getBufferPartial - TODO /******************************************************************************/ // TODO -int32_t trace_get_buffer_partial(const trace_desc_t *i_td_ptr, +int32_t Trace::getBufferPartial(const trace_desc_t *i_td_ptr, void *o_data, uint32_t *io_size) { @@ -633,9 +659,9 @@ int32_t trace_get_buffer_partial(const trace_desc_t *i_td_ptr, #endif /******************************************************************************/ -// trace_reset_buf - TODO +// resetBuf - TODO /******************************************************************************/ -int32_t trace_reset_buf() +int32_t Trace::resetBuf() { /*------------------------------------------------------------------------*/ /* Local Variables */ @@ -651,7 +677,7 @@ int32_t trace_reset_buf() // Get mutex so no one traces #if 0 // TODO - l_rc = UTIL_MUTEX_GET(&g_trac_mutex,TRAC_INTF_MUTEX_TIMEOUT); + l_rc = UTIL_MUTEX_GET(&iv_trac_mutex,TRAC_INTF_MUTEX_TIMEOUT); if(l_rc != TX_SUCCESS) { printk("trace_reset_buf: Failure trying to get mutex"); @@ -677,7 +703,7 @@ int32_t trace_reset_buf() #endif // Always try to release even if fail above // TODO - mutex - //UTIL_MUTEX_PUT(&g_trac_mutex); + //UTIL_MUTEX_PUT(&iv_trac_mutex); return(l_rc); } diff --git a/src/usr/trace/trace.H b/src/usr/trace/trace.H deleted file mode 100644 index 8087e6c32..000000000 --- a/src/usr/trace/trace.H +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @file trace.H - * - * @brief Internal trace definitions and functions -*/ - -#ifndef __TRACE_TRACE_H -#define __TRACE_TRACE_H - -/******************************************************************************/ -// Includes -/******************************************************************************/ -#include <stdint.h> -#include <trace/interface.H> - -namespace TRACE -{ - -/******************************************************************************/ -// Globals/Constants -/******************************************************************************/ - -#define TRACE_BUF_VERSION 0x01; // Trace buffer version -#define TRACE_FIELDTRACE 0x4654 // Field Trace - "FT" -#define TRACE_FIELDBIN 0x4644 // Binary Field Trace - "FD" - -#define TRACE_DEBUG_ON 1 //Set to this when debug trace on -#define TRACE_DEBUG_OFF 0 //Set to this when debug trace off - - -/******************************************************************************/ -// Typedef/Enumerations -/******************************************************************************/ - -/******************************************************************************/ -// Function Prototypes -/******************************************************************************/ - -/** - * @brief Initialize a new trace buffer - * - * Internal function responsible setting up the defaults in a newly created - * trace buffer. - * - * @param[out] o_buf Trace descriptor of component buffer to initialize. - * @param[in] i_comp Component name - * - * @return void - * - */ -void trace_init_values_buffer(trace_desc_t *o_buf, - const char *i_comp); - - -/** - * @brief Write the trace data into the buffer - * - * Internal function responsible for copying the trace data into the appropriate - * buffer. - * - * @param[inout] io_td Trace descriptor of component buffer to write to. - * @param[in] i_ptr Pointer to data to copy into the trace buffer. - * @param[in] i_size Size of the i_ptr data to copy into the buffer. - * - * @return void - * - */ -void trace_write_data(trace_desc_t * io_td, - const void *i_ptr, - const uint32_t i_size); - - -/** - * @brief Retrieve full trace buffer for component i_comp - * - * This function assumes memory has already been allocated for - * the full trace buffer in o_data. - * - * @param i_td_ptr Trace descriptor of buffer to retrieve. - * @param o_data Pre-allocated pointer to where data will be stored. - * - * TODO - Not Supported Yet - * - * @return Non-zero return code on error - */ -int32_t trace_get_buffer(const trace_desc_t * i_td_ptr, - void *o_data); - -/** - * @brief Retrieve partial trace buffer for component i_comp - * - * This function assumes memory has already been allocated for - * the trace buffer (size io_size). This function will copy - * in up to io_size in bytes to the buffer and set io_size - * to the exact size that is copied in. - * - * TODO - Not Supported Yet - * - * @param i_td_ptr Trace descriptor of buffer to retrieve. - * @param o_data Pre-allocated pointer to where data will be stored. - * @param io_size Size of trace data to retrieve (input) - * Actual size of trace data stored (output) - * - * @return Non-zero return code on error - */ -int32_t trace_get_buffer_partial(const trace_desc_t * i_td_ptr, - void *o_data, - uint32_t *io_size); - -/** - * @brief Retrieve trace descriptor for input component name - * - * @param i_comp Component name to retrieve trace descriptor for. - * - * TODO - Not Supported Yet - * - * @return Valid trace descriptor on success, NULL on failure. - */ -trace_desc_t * trace_get_td(const char *i_comp); - -/** - * @brief Reset all trace buffers - * - * TODO - Not Supported Yet - * - * @return Non-zero return code on error - */ -int32_t trace_reset_buf(void); - -} // namespace TRACE - -#endif |