summaryrefslogtreecommitdiffstats
path: root/pk/trace
diff options
context:
space:
mode:
Diffstat (limited to 'pk/trace')
-rw-r--r--pk/trace/Makefile26
-rw-r--r--pk/trace/pk_trace.h279
-rw-r--r--pk/trace/pk_trace_big.c92
-rw-r--r--pk/trace/pk_trace_binary.c91
-rw-r--r--pk/trace/pk_trace_core.c119
-rw-r--r--pk/trace/pktracefiles.mk39
6 files changed, 0 insertions, 646 deletions
diff --git a/pk/trace/Makefile b/pk/trace/Makefile
deleted file mode 100644
index 69e95ebd..00000000
--- a/pk/trace/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# This Makefile is designed to be invoked with the -I argument set to
-# the location of the "pk.mk" for the build
-
-include img_defs.mk
-include pktracefiles.mk
-
-ifeq "$(PK_TIMER_SUPPORT)" "1"
-PKTRACE_OBJECTS += ${PKTRACE-TIMER-C-SOURCES:.c=.o} ${PKTRACE-TIMER-S-SOURCES:.S=.o}
-endif
-
-ifeq "$(PK_THREAD_SUPPORT)" "1"
-PKTRACE_OBJECTS += ${PKTRACE-THREAD-C-SOURCES:.c=.o} ${PKTRACE-THREAD-S-SOURCES:.S=.o}
-endif
-
-OBJS := $(addprefix $(OBJDIR)/, $(PKTRACE_OBJECTS))
-
-all: $(OBJS)
-
-$(OBJS) $(OBJS:.o=.d): | $(OBJDIR)
-
-$(OBJDIR):
- mkdir -p $(OBJDIR)
-
-ifneq ($(MAKECMDGOALS),clean)
-include $(OBJS:.o=.d)
-endif
diff --git a/pk/trace/pk_trace.h b/pk/trace/pk_trace.h
deleted file mode 100644
index b19a5193..00000000
--- a/pk/trace/pk_trace.h
+++ /dev/null
@@ -1,279 +0,0 @@
-#ifndef __PK_TRACE_H__
-#define __PK_TRACE_H__
-//-----------------------------------------------------------------------------
-// *! (C) Copyright International Business Machines Corp. 2014
-// *! All Rights Reserved -- Property of IBM
-// *! *** IBM Confidential ***
-//-----------------------------------------------------------------------------
-
-/// \file pk_trace.h
-/// \brief Macros and declarations for the PK Firmware Tracing Facility.
-///
-
-#include <stdint.h>
-
-#define PK_TRACE_VERSION 2
-
-#ifndef PK_TRACE_SZ
-#define PK_TRACE_SZ 1024
-#endif
-
-//Fail compilation if size is not a power of 2
-#if ((PK_TRACE_SZ - 1) & PK_TRACE_SZ)
-#error "PK_TRACE_SZ is not a power of two!!!"
-#endif
-
-//Fail compilation if size is smaller than 64 bytes
-#if (PK_TRACE_SZ < 64)
-#error "PK_TRACE_SZ must be at least 64 bytes!!!"
-#endif
-
-//Mask for calculating offsets into the trace circular buffer
-#define PK_TRACE_CB_MASK (PK_TRACE_SZ - 1)
-
-#define STRINGIFY_HELPER(x) #x
-#define STRINGIFY(x) STRINGIFY_HELPER(x)
-
-#define PPE_IMG_STRING STRINGIFY(IMAGE_NAME)
-
-#ifdef PK_TRACE_HASH_PREFIX
-#if (PK_TRACE_HASH_PREFIX > 0xffff)
-#error PK_TRACE_HASH_PREFIX must be defined as a 16 bit constant value
-#endif
-#endif //PK_TRACE_HASH_PREFIX
-
-//This provides a 128ns tick (assuming a 32ns clock period)
-//and 4 different format values
-#define PK_TRACE_TS_BITS 30
-
-#define PK_TRACE_FORMAT_BITS (32 - PK_TRACE_TS_BITS)
-
-#define PK_TRACE_TS_MASK (0xfffffffful << PK_TRACE_FORMAT_BITS)
-#define PK_TRACE_FORMAT_MASK (~PK_TRACE_TS_MASK)
-
-#define PK_GET_TRACE_FORMAT(w32) (PK_TRACE_FORMAT_MASK & w32)
-#define PK_GET_TRACE_TIME(w32) (PK_TRACE_TS_MASK & w32)
-
-//Set the trace timer period to be the maximum
-//32 bit time minus 2 seconds (assuming a 32ns tick)
-//This allows for up to 1 second of interrupt latency +
-//1 second for PK_TRACE_MTBT while only requiring a trace
-//every 135 seconds in order to maintain the 64bit timebase.
-#define PK_TRACE_TIMER_PERIOD (0xfffffffful - 62500000)
-
-//The Maximum Time Between Traces. In order to reduce the time that interrupts
-//are disabled for tracing, reading of the time stamp is not done atomically
-//with alocating an entry in the circular buffer. This means that the
-//timestamps might not appear in order in the trace buffer. This is a
-//problem because our calculation of the 64 bit timebase uses the unsigned
-//difference of the current 32bit timestamp and the previous one and if they
-//are out of order it will result in a very large difference. To solve this
-//problem, any time that the parser code sees a very large difference (larger
-//than PK_TRACE_MTBT) it will treat it as a negative number.
-#define PK_TRACE_MTBT (0xfffffffful - 31250000)
-
-#define PK_TRACE_MAX_PARMS 4
-
-//This is the maximum number of bytes allowed to be traced in a binary trace
-//entry.
-//The trace version needs to change if this changes.
-#define PK_TRACE_MAX_BINARY 256
-
-//clip the largest binary trace according to the trace buffer size.
-//(The trace version does not need to change if this changes as long
-// as it remains less than PK_TRACE_MAX_BINARY)
-#if (PK_TRACE_SZ <= 256)
-#define PK_TRACE_CLIPPED_BINARY_SZ PK_TRACE_SZ / 2
-#else
-#define PK_TRACE_CLIPPED_BINARY_SZ PK_TRACE_MAX_BINARY
-#endif
-
-//Trace formats that are supported
-typedef enum
-{
- PK_TRACE_FORMAT_EMPTY,
- PK_TRACE_FORMAT_TINY,
- PK_TRACE_FORMAT_BIG,
- PK_TRACE_FORMAT_BINARY,
-}PkTraceFormat; //pk_trace_format_t;
-
-//This combines the timestamp and the format bits into a
-//single 32 bit word.
-typedef union
-{
- struct
- {
- uint32_t timestamp : PK_TRACE_TS_BITS;
- uint32_t format : PK_TRACE_FORMAT_BITS;
- };
- uint32_t word32;
-}PkTraceTime; //pk_trace_time_t;
-
-//PK trace uses a 16 bit string format hash value
-typedef uint16_t PkTraceHash; //pk_trace_hash_t;
-
-//The constant 16 bit hash value is combined with a
-//16 bit parameter value when doing a tiny trace
-typedef union
-{
- struct
- {
- PkTraceHash string_id;
- uint16_t parm;
- };
- uint32_t word32;
-}PkTraceTinyParms; //pk_trace_tiny_parms_t;
-
-//A tiny trace fits within a single 8 byte word. This includes
-//the timestamp, format bits, hash id, and a 16 bit parameter.
-typedef union
-{
- struct
- {
- PkTraceTinyParms parms;
- PkTraceTime time_format;
- };
- uint64_t word64;
-}PkTraceTiny; //pk_trace_tiny_t;
-
-//Larger traces that require a 32 bit parameter or more than one
-//parameter use the big trace format. The number of parms and
-//the 'complete' flag are combined with the hash id. 'complete'
-//is set to 0 initially and set to one only after all of the trace
-//data has been written.
-typedef union
-{
- struct
- {
- PkTraceHash string_id;
- uint8_t complete;
- uint8_t num_parms;
- };
- uint32_t word32;
-}PkTraceBigParms; //pk_trace_big_parms_t;
-
-typedef union
-{
- struct
- {
- PkTraceBigParms parms;
- PkTraceTime time_format;
- };
- uint64_t word64;
-}PkTraceBig; //pk_trace_big_t;
-
-//Binary traces are handled in a similar fashion to big traces, except
-//that instead of having a number of parameters, we have number of bytes.
-typedef union
-{
- struct
- {
- PkTraceHash string_id;
- uint8_t complete;
- uint8_t num_bytes;
- };
- uint32_t word32;
-}PkTraceBinaryParms; //pk_trace_binary_parms_t;
-
-typedef union
-{
- struct
- {
- PkTraceBinaryParms parms;
- PkTraceTime time_format;
- };
- uint64_t word64;
-}PkTraceBinary; //pk_trace_binary_t;
-
-//This is a generic structure that can be used to retrieve data
-//for tiny, big, and binary formatted entries.
-typedef union
-{
- struct
- {
- PkTraceHash string_id;
- union
- {
- uint16_t parm16;
- struct
- {
- uint8_t complete;
- uint8_t bytes_or_parms_count;
- };
- };
- PkTraceTime time_format;
- };
- uint64_t word64;
-}PkTraceGeneric; //pk_trace_generic_t;
-
-//This is a format that might be used in the future for tracing
-//a 64 bit timestamp so that we don't fill up the buffer with periodic
-//timer traces. It is not currently used.
-#if 0
-typedef union
-{
- struct
- {
- uint32_t upper32;
- PkTraceTime time_format;
- };
- uint64_t word64;
-}PkTraceTime64; //pk_trace_time64_t;
-#endif
-
-//It would probably be more accurate to call this a footer since it
-//actually resides at the highest address of each trace entry. These eight
-//bytes contain information that allow us to walk the trace buffer from the
-//most recent entry to the oldest entry.
-typedef union
-{
- PkTraceGeneric generic;
- PkTraceBinary binary;
- PkTraceBig big;
- PkTraceTiny small;
-}PkTraceEntryFooter; //pk_trace_entry_header_t;
-
-
-//This is the data that is updated (in the buffer header) every time we add
-//a new entry to the buffer.
-typedef union
-{
- struct
- {
- uint32_t tbu32;
- uint32_t offset;
- };
- uint64_t word64;
-}PkTraceState; //pk_trace_state_t;
-
-#define PK_TRACE_IMG_STR_SZ 16
-
-//Header data for the trace buffer that is used for parsing the data.
-//Note: pk_trace_state_t contains a uint64_t which is required to be
-//placed on an 8-byte boundary according to the EABI Spec. This also
-//causes cb to start on an 8-byte boundary.
-typedef struct
-{
- //these values are needed by the parser
- uint16_t version;
- uint16_t rsvd;
- char image_str[PK_TRACE_IMG_STR_SZ];
- uint16_t instance_id;
- uint16_t partial_trace_hash;
- uint16_t hash_prefix;
- uint16_t size;
- uint32_t max_time_change;
- uint32_t hz;
- uint32_t pad;
- uint64_t time_adj64;
-
- //updated with each new trace entry
- PkTraceState state;
-
- //circular trace buffer
- uint8_t cb[PK_TRACE_SZ];
-}PkTraceBuffer; //pk_trace_buffer_t;
-
-extern PkTraceBuffer g_pk_trace_buf;
-
-#endif /* __PK_TRACE_H__ */
diff --git a/pk/trace/pk_trace_big.c b/pk/trace/pk_trace_big.c
deleted file mode 100644
index 4ba212da..00000000
--- a/pk/trace/pk_trace_big.c
+++ /dev/null
@@ -1,92 +0,0 @@
-//-----------------------------------------------------------------------------
-// *! (C) Copyright International Business Machines Corp. 2014
-// *! All Rights Reserved -- Property of IBM
-// *! *** IBM Confidential ***
-//-----------------------------------------------------------------------------
-
-/// \file pk_trace_big.c
-/// \brief PK Trace function that supports up to four 32-bit parameters
-///
-/// The pk_trace_big function is only called (via some macro magic) if the
-/// caller passes in a single parameter (not including the format string)
-/// that is larger than 16 bits to the PK_TRACE(...) macro.
-///
-
-#include "pk.h"
-#include "pk_trace.h"
-
-#if (PK_TRACE_SUPPORT && PK_TIMER_SUPPORT)
-void pk_trace_big(uint32_t i_hash_and_count,
- uint64_t i_parm1, uint64_t i_parm2)
-{
- PkTraceBig footer;
- PkTraceBig* footer_ptr;
- PkTraceState state;
- uint64_t* ptr64;
- uint64_t tb64;
- PkMachineContext ctx;
- uint32_t parm_size;
- uint32_t cur_offset;
- uint32_t footer_offset;
-
- //fill in the footer data
- tb64 = pk_timebase_get();
- footer.parms.word32 = i_hash_and_count; //this has the parm count and hash
- state.tbu32 = tb64 >> 32;
- footer.time_format.word32 = tb64 & 0x00000000ffffffffull;
- footer.time_format.format = PK_TRACE_FORMAT_BIG;
-
- //round up to 8 byte boundary
- if(footer.parms.num_parms <= 2)
- {
- parm_size = 8;
- }
- else
- {
- parm_size = 16;
- }
-
- //*****The following operations must be done atomically*****
- pk_critical_section_enter(&ctx);
-
- //load in the offset in the cb for the entry we are adding
- cur_offset = g_pk_trace_buf.state.offset;
-
- //Find the offset for the footer (at the end of the entry)
- footer_offset = cur_offset + parm_size;
-
- //calculate the address of the footer
- ptr64 = (uint64_t*)&g_pk_trace_buf.cb[footer_offset & PK_TRACE_CB_MASK];
-
- //calculate the offset for the next entry in the cb
- state.offset = footer_offset + sizeof(PkTraceBig);
-
- //update the cb state (tbu and offset)
- g_pk_trace_buf.state.word64 = state.word64;
-
- //write the data to the circular buffer including the
- //timesamp, string hash, and 16bit parameter
- *ptr64 = footer.word64;
-
- //*******************exit the critical section***************
- pk_critical_section_exit(&ctx);
-
-
- //write parm values to the circular buffer
- footer_ptr = (PkTraceBig*)ptr64;
- ptr64 = (uint64_t*)&g_pk_trace_buf.cb[cur_offset & PK_TRACE_CB_MASK];
- *ptr64 = i_parm1;
- if(parm_size > 8)
- {
- ptr64 = (uint64_t*)&g_pk_trace_buf.cb[(cur_offset + 8) & PK_TRACE_CB_MASK];
- *ptr64 = i_parm2;
- }
-
- //Mark the trace entry update as being completed
- footer_ptr->parms.complete = 1;
-
-}
-
-#endif
-
-
diff --git a/pk/trace/pk_trace_binary.c b/pk/trace/pk_trace_binary.c
deleted file mode 100644
index 58b417a3..00000000
--- a/pk/trace/pk_trace_binary.c
+++ /dev/null
@@ -1,91 +0,0 @@
-//-----------------------------------------------------------------------------
-// *! (C) Copyright International Business Machines Corp. 2014
-// *! All Rights Reserved -- Property of IBM
-// *! *** IBM Confidential ***
-//-----------------------------------------------------------------------------
-
-/// \file pk_trace_binary.c
-/// \brief PK Trace function for dumping memory contents
-///
-/// The pk_trace_binary function is called by the PK_TRACE_BINARY() macro.
-///
-
-
-#include "pk.h"
-#include "pk_trace.h"
-
-#if (PK_TRACE_SUPPORT && PK_TIMER_SUPPORT)
-void pk_trace_binary(uint32_t i_hash_and_size, void* bufp)
-{
- PkTraceBinary footer;
- PkTraceBinary* footer_ptr;
- PkTraceState state;
- uint64_t* ptr64;
- uint64_t tb64;
- PkMachineContext ctx;
- uint32_t data_size;
- uint32_t cb_offset;
- uint32_t footer_offset;
- uint8_t* dest;
- uint8_t* src;
- uint32_t index;
-
- //fill in the footer data
- tb64 = pk_timebase_get();
- footer.parms.word32 = i_hash_and_size; //this has the size and hash
- state.tbu32 = tb64 >> 32;
- footer.time_format.word32 = tb64 & 0x00000000ffffffffull;
- footer.time_format.format = PK_TRACE_FORMAT_BINARY;
-
- //round up to 8 byte boundary
- data_size = (footer.parms.num_bytes + 7) & ~0x00000007ul;
-
- //limit data size
- if(data_size > PK_TRACE_CLIPPED_BINARY_SZ)
- {
- data_size = PK_TRACE_CLIPPED_BINARY_SZ;
- }
-
- //*****The following operations must be done atomically*****
- pk_critical_section_enter(&ctx);
-
- //load in the offset in the cb for the entry we are adding
- cb_offset = g_pk_trace_buf.state.offset;
-
- //Find the offset for the footer (at the end of the entry)
- footer_offset = cb_offset + data_size;
-
- //calculate the address of the footer
- ptr64 = (uint64_t*)&g_pk_trace_buf.cb[footer_offset & PK_TRACE_CB_MASK];
-
- //calculate the offset for the next entry in the cb
- state.offset = footer_offset + sizeof(PkTraceBinary);
-
- //update the cb state (tbu and offset)
- g_pk_trace_buf.state.word64 = state.word64;
-
- //write the footer data to the circular buffer including the
- //timesamp, string hash and data size
- *ptr64 = footer.word64;
-
- //*******************exit the critical section***************
- pk_critical_section_exit(&ctx);
-
- //write data to the circular buffer
- for(src = bufp, index = 0;
- index < data_size;
- index++)
- {
- dest = &g_pk_trace_buf.cb[(cb_offset + index) & PK_TRACE_CB_MASK];
- *dest = *(src++);
- }
-
- //Mark the trace entry update as being completed
- footer_ptr = (PkTraceBinary*)ptr64;
- footer_ptr->parms.complete = 1;
-
-}
-
-#endif
-
-
diff --git a/pk/trace/pk_trace_core.c b/pk/trace/pk_trace_core.c
deleted file mode 100644
index 429679db..00000000
--- a/pk/trace/pk_trace_core.c
+++ /dev/null
@@ -1,119 +0,0 @@
-//-----------------------------------------------------------------------------
-// *! (C) Copyright International Business Machines Corp. 2014
-// *! All Rights Reserved -- Property of IBM
-// *! *** IBM Confidential ***
-//-----------------------------------------------------------------------------
-
-/// \file pk_trace_core.c
-/// \brief PK Trace core data and code.
-///
-/// This file includes the minimal code/data required to do minimal tracing.
-/// This includes the periodic timer initialization and the pk_trace_tiny
-/// function. The pk_trace_tiny function is called by the PK_TRACE() macro
-/// when there is one or less parameters (not including the format string)
-/// and the parameter size is 16 bits or smaller.
-///
-
-#include "pk.h"
-#include "pk_trace.h"
-
-void pk_trace_timer_callback(void* arg);
-
-#if (PK_TRACE_SUPPORT && PK_TIMER_SUPPORT)
-
-//Static initialization of the trace timer
-PkTimer g_pk_trace_timer = {
- .deque = PK_DEQUE_ELEMENT_INIT(),
- .timeout = 0,
- .callback = pk_trace_timer_callback,
- .arg = 0,
-};
-
-//Static initialization of the pk trace buffer
-PkTraceBuffer g_pk_trace_buf =
-{
- .version = PK_TRACE_VERSION,
- .image_str = PPE_IMG_STRING,
- .hash_prefix = PK_TRACE_HASH_PREFIX,
- .partial_trace_hash = trace_ppe_hash("PARTIAL TRACE ENTRY. HASH_ID = %d", PK_TRACE_HASH_PREFIX),
- .size = PK_TRACE_SZ,
- .max_time_change = PK_TRACE_MTBT,
- .hz = 500000000, //default value. Actual value is set in pk_init.c
- .time_adj64 = 0,
- .state.word64 = 0,
- .cb = {0}
-};
-
-//Needed for buffer extraction in simics for now
-PkTraceBuffer* g_pk_trace_buf_ptr = &g_pk_trace_buf;
-
-// Creates an 8 byte entry in the trace buffer that includes a timestamp,
-// a format string hash value and a 16 bit parameter.
-//
-// i_parm has the hash value combined with the 16 bit parameter
-void pk_trace_tiny(uint32_t i_parm)
-{
- PkTraceTiny footer;
- PkTraceState state;
- uint64_t* ptr64;
- uint64_t tb64;
- PkMachineContext ctx;
-
- //fill in the footer data
- footer.parms.word32 = i_parm;
- tb64 = pk_timebase_get();
- state.tbu32 = tb64 >> 32;
- footer.time_format.word32 = tb64 & 0x00000000ffffffffull;
-
- footer.time_format.format = PK_TRACE_FORMAT_TINY;
-
- //The following operations must be done atomically
- pk_critical_section_enter(&ctx);
-
- //load the current byte count and calculate the address for this
- //entry in the cb
- ptr64 = (uint64_t*)&g_pk_trace_buf.cb[g_pk_trace_buf.state.offset & PK_TRACE_CB_MASK];
-
- //calculate the offset for the next entry in the cb
- state.offset = g_pk_trace_buf.state.offset + sizeof(PkTraceTiny);
-
- //update the cb state (tbu and offset)
- g_pk_trace_buf.state.word64 = state.word64;
-
- //write the data to the circular buffer including the
- //timesamp, string hash, and 16bit parameter
- *ptr64 = footer.word64;
-
- //exit the critical section
- pk_critical_section_exit(&ctx);
-}
-
-
-// This function is called periodically in order to ensure that the max ticks
-// between trace entries is no more than what will fit inside a 32bit value.
-#ifndef PK_TRACE_TIMER_OUTPUT
-#define PK_TRACE_TIMER_OUTPUT 1
-#endif
-void pk_trace_timer_callback(void* arg)
-{
-#if PK_TRACE_TIMER_OUTPUT
- // guarantee at least one trace before the lower 32bit timebase flips
- PK_TRACE("PERIODIC TIMESTAMPING TRACE");
-#endif
- // restart the timer
- pk_timer_schedule(&g_pk_trace_timer,
- PK_TRACE_TIMER_PERIOD);
-}
-
-// Use this function to synchronize the timebase between multiple PPEs.
-// PPE A can send PPE B it's current timebase and then PPE B can set that
-// as the current timebase for tracing purposes. It can also be used
-// to set the current time to 0. This function changes the timebase for
-// all entries that are currently in the trace buffer. Setting the current
-// timebase to 0 will cause previous traces to have very large timestamps.
-void pk_trace_set_timebase(PkTimebase timebase)
-{
- g_pk_trace_buf.time_adj64 = timebase - pk_timebase_get();
-}
-
-#endif
diff --git a/pk/trace/pktracefiles.mk b/pk/trace/pktracefiles.mk
deleted file mode 100644
index e3aede76..00000000
--- a/pk/trace/pktracefiles.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# @file pkppe42files.mk
-#
-# @brief mk for including ppe42 object files
-#
-# @page ChangeLogs Change Logs
-# @section pkppe42files.mk
-# @verbatim
-#
-#
-# Change Log ******************************************************************
-# Flag Defect/Feature User Date Description
-# ------ -------------- ---------- ------------ -----------
-#
-# @endverbatim
-#
-##########################################################################
-# Include Files
-##########################################################################
-
-
-
-##########################################################################
-# Object Files
-##########################################################################
-PKTRACE-C-SOURCES = pk_trace_core.c pk_trace_big.c pk_trace_binary.c
-
-PKTRACE-S-SOURCES =
-
-PKTRACE-TIMER-C-SOURCES =
-PKTRACE-TIMER-S-SOURCES =
-
-PKTRACE-THREAD-C-SOURCES +=
-PKTRACE-THREAD-S-SOURCES +=
-
-
-PKTRACE_OBJECTS += $(PKTRACE-C-SOURCES:.c=.o) $(PKTRACE-S-SOURCES:.S=.o)
-
-
-
OpenPOWER on IntegriCloud