From 2bc361ef3389104059fa35eda66c08e390c06aee Mon Sep 17 00:00:00 2001 From: Glenn Miles Date: Wed, 15 Apr 2015 17:38:13 -0500 Subject: Support for kernel debug pointers Change-Id: I5d41ff0390ec0b2c453bd7072777e58c81a0eeb5 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/17336 Reviewed-by: Richard J. Knight Reviewed-by: Glenn R. Miles Reviewed-by: Thi N. Tran Tested-by: Thi N. Tran --- pk/kernel/pk_debug_ptrs.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ pk/kernel/pk_debug_ptrs.h | 39 +++++++++++++++++++++++++++++++++ pk/kernel/pk_init.c | 17 +++++++++------ pk/kernel/pkkernelfiles.mk | 2 +- pk/ppe42/ppe42_exceptions.S | 7 ++++++ 5 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 pk/kernel/pk_debug_ptrs.c create mode 100644 pk/kernel/pk_debug_ptrs.h (limited to 'pk') diff --git a/pk/kernel/pk_debug_ptrs.c b/pk/kernel/pk_debug_ptrs.c new file mode 100644 index 00000000..0ed540f4 --- /dev/null +++ b/pk/kernel/pk_debug_ptrs.c @@ -0,0 +1,53 @@ +//----------------------------------------------------------------------------- +// *! (C) Copyright International Business Machines Corp. 2015 +// *! All Rights Reserved -- Property of IBM +// *! *** IBM Confidential *** +//----------------------------------------------------------------------------- + +/// \file pk_debug_ptrs.c +/// \brief Defines a table of pointers to important kernel debug data. +/// +/// This table is placed in a special section named .debug_ptrs which can be +/// placed at a well-known memory location for tools to find. +/// + +#include "pk.h" +#include "pk_trace.h" +#include "pk_debug_ptrs.h" + +extern PkTimebase ppe42_64bit_timebase; + +#if PK_TRACE_SUPPORT +extern PkTraceBuffer g_pk_trace_buf; +#endif + +pk_debug_ptrs_t pk_debug_ptrs SECTION_ATTRIBUTE(".debug_ptrs") = +{ + .debug_ptrs_size = sizeof(pk_debug_ptrs), + .debug_ptrs_version = PK_DEBUG_PTRS_VERSION, + +#if PK_TRACE_SUPPORT + .debug_trace_ptr = &g_pk_trace_buf, + .debug_trace_size = sizeof(g_pk_trace_buf), +#else + .debug_trace_ptr = 0, + .debug_trace_size = 0, +#endif /* PK_TRACE_SUPPORT */ + +#if PK_THREAD_SUPPORT + .debug_thread_table_ptr = &__pk_priority_map, + .debug_thread_table_size = sizeof(__pk_priority_map), + .debug_thread_runq_ptr = (void*)&__pk_run_queue, + .debug_thread_runq_size = sizeof(__pk_run_queue), +#else + .debug_thread_table_ptr = 0, + .debug_thread_table_size = 0, + .debug_thread_runq_ptr = 0, + .debug_thread_runq_size = 0, +#endif /* PK_THREAD_SUPPORT */ + + .debug_timebase_ptr = &ppe42_64bit_timebase, + .debug_timebase_size = sizeof(ppe42_64bit_timebase), + +}; + diff --git a/pk/kernel/pk_debug_ptrs.h b/pk/kernel/pk_debug_ptrs.h new file mode 100644 index 00000000..62a36839 --- /dev/null +++ b/pk/kernel/pk_debug_ptrs.h @@ -0,0 +1,39 @@ +#ifndef __PK_DEBUG_PTRS_H__ +#define __PK_DEBUG_PTRS_H__ +//----------------------------------------------------------------------------- +// *! (C) Copyright International Business Machines Corp. 2015 +// *! All Rights Reserved -- Property of IBM +// *! *** IBM Confidential *** +//----------------------------------------------------------------------------- + +/// \file pk_debug_ptrs.h +/// \brief Structure for a table of pointers to kernel debug data +/// + +#define PK_DEBUG_PTRS_VERSION 1 + +typedef struct +{ + // The size and version of this structure + unsigned short debug_ptrs_size; + unsigned short debug_ptrs_version; + + // Trace buffer location and size + void* debug_trace_ptr; + unsigned long debug_trace_size; + + // Thread table location and size + void* debug_thread_table_ptr; + unsigned long debug_thread_table_size; + + // Thread run queue location and size + void* debug_thread_runq_ptr; + unsigned long debug_thread_runq_size; + + // Emulated timebase location and size + void* debug_timebase_ptr; + unsigned long debug_timebase_size; + +} pk_debug_ptrs_t; + +#endif /*__PK_DEBUG_PTRS_H__*/ diff --git a/pk/kernel/pk_init.c b/pk/kernel/pk_init.c index 4c7cd138..ebd6323a 100644 --- a/pk/kernel/pk_init.c +++ b/pk/kernel/pk_init.c @@ -64,7 +64,7 @@ void pk_set_timebase_rshift(uint32_t timebase_freq_hz) /// interrupt and bottom-half handlers. /// /// \param initial_timebase The initial value of the PK timebase. -/// argument is given as the special value \c PK_TIMEBASE_CONTINUE, then the +/// If the argument is given as the special value \c PK_TIMEBASE_CONTINUES, then the /// timebase is not reset. /// /// \param timebase_frequency_hz The frequency of the PK timebase in Hz. @@ -88,10 +88,10 @@ void pk_set_timebase_rshift(uint32_t timebase_freq_hz) // reset everything at initialization. int -pk_initialize(PkAddress kernel_stack, - size_t kernel_stack_size, - PkTimebase initial_timebase, - uint32_t timebase_frequency_hz) +pk_initialize(PkAddress kernel_stack, + size_t kernel_stack_size, + PkTimebase initial_timebase, + uint32_t timebase_frequency_hz) { int rc; @@ -133,8 +133,11 @@ extern PkTraceBuffer g_pk_trace_buf; //timebase frequency (versus what was hardcoded) pk_set_timebase_rshift(timebase_frequency_hz); - //set the timebase ajdustment for trace synchronization - pk_trace_set_timebase(initial_timebase); + if(initial_timebase != PK_TIMEBASE_CONTINUES) + { + //set the timebase ajdustment for trace synchronization + pk_trace_set_timebase(initial_timebase); + } // Schedule the timer that puts a 64bit timestamp in the trace buffer // periodically. This allows us to use 32bit timestamps. diff --git a/pk/kernel/pkkernelfiles.mk b/pk/kernel/pkkernelfiles.mk index bb1c310b..df7872bd 100644 --- a/pk/kernel/pkkernelfiles.mk +++ b/pk/kernel/pkkernelfiles.mk @@ -21,7 +21,7 @@ ########################################################################## # Object Files ########################################################################## -PK-C-SOURCES = pk_core.c pk_init.c pk_stack_init.c pk_bh_core.c +PK-C-SOURCES = pk_core.c pk_init.c pk_stack_init.c pk_bh_core.c pk_debug_ptrs.c PK-TIMER-C-SOURCES += pk_timer_core.c pk_timer_init.c diff --git a/pk/ppe42/ppe42_exceptions.S b/pk/ppe42/ppe42_exceptions.S index b3ce3551..272c0e41 100644 --- a/pk/ppe42/ppe42_exceptions.S +++ b/pk/ppe42/ppe42_exceptions.S @@ -125,6 +125,13 @@ __watchdog_interrupt: _pk_ctx_push_as_needed watchdog_handler +### **************************************************************************** +### The rest of the code in this file doesn't have to be placed anywhere +### special, so just place it in the .text section. +### **************************************************************************** + + .section .text, "ax", @progbits + ## The idle thread has no permanent register context. The idle thread ## entry point is re-entered whenever the idle thread is scheduled. -- cgit v1.2.1