summaryrefslogtreecommitdiffstats
path: root/src/kernel/idebug.C
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2011-11-21 15:44:52 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-12-06 16:11:44 -0600
commit7799749ee2db86f4fb66c4a7a69fb9fb0b46334e (patch)
treef50027f990e1db0ea79fabb1b8a9afa1a172dfd1 /src/kernel/idebug.C
parentc761a76534988071d0988daa77b8c51526e2d9f4 (diff)
downloadtalos-hostboot-7799749ee2db86f4fb66c4a7a69fb9fb0b46334e.tar.gz
talos-hostboot-7799749ee2db86f4fb66c4a7a69fb9fb0b46334e.zip
Interactive debug tool.
- Modify debug fw to support writing data. - Modify debug fw to support clocking model forward. - Add simics environment support for both. - Kernel support to start a task when directed. - Write debug tool to modify kernel structure for debug. Change-Id: Ic001dfd45f91392aefbc9d5096c5344018d5190e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/518 Tested-by: Jenkins Server Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/kernel/idebug.C')
-rw-r--r--src/kernel/idebug.C89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/kernel/idebug.C b/src/kernel/idebug.C
new file mode 100644
index 000000000..673ecb149
--- /dev/null
+++ b/src/kernel/idebug.C
@@ -0,0 +1,89 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/kernel/idebug.C $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// 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 other-
+// wise divested of its trade secrets, irrespective of what has
+// been deposited with the U.S. Copyright Office.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+#include <kernel/idebug.H>
+#include <kernel/console.H>
+#include <kernel/cpumgr.H>
+#include <kernel/scheduler.H>
+#include <sys/task.h>
+
+ // Set Ready = 0, Running = 1, Complete = 0.
+static const uint64_t IDEBUG_RUNNING_STATE = 0x0001000000000000ull;
+ // Set Ready = 0, Running = 0, Complete = 1.
+static const uint64_t IDEBUG_COMPLETE_STATE = 0x0000010000000000ull;
+
+void InteractiveDebug::startDebugTask()
+{
+ // Atomically set state to 'running'.
+ // Set Ready = 0, Running = 1, Complete = 0.
+ __sync_lock_test_and_set(&state_value, IDEBUG_RUNNING_STATE);
+
+ // Create userspace task to execute function.
+ task_t* t = TaskManager::createTask(&debugEntryPoint, this, true);
+ CpuManager::getCurrentCPU()->scheduler->addTask(t);
+
+ return;
+}
+
+void InteractiveDebug::debugEntryPoint(void* i_idObject)
+{
+ // Detach task so it is cleaned up properly once it exits.
+ task_detach();
+
+ // Get interactive debug structure from cast of input paramater.
+ InteractiveDebug* interactiveDebug =
+ static_cast<InteractiveDebug*>(i_idObject);
+
+ // Get function pointer from 'entry_point_toc'.
+ typedef uint64_t(*func)(uint64_t,uint64_t,uint64_t,uint64_t,
+ uint64_t,uint64_t,uint64_t,uint64_t);
+ func entry_point =
+ reinterpret_cast<func>(interactiveDebug->entry_point_toc);
+
+ // Call function with parameters.
+ // Due to the PowerABI, parameters get passed in r3-r10 and any
+ // unused parameters are ignored by the called function. You can
+ // therefore treat every function as if it has 8 parameters, even
+ // if it has fewer, and the calling conventions are the same from
+ // an assembly perspective.
+ interactiveDebug->return_value =
+ entry_point(interactiveDebug->parms[0],
+ interactiveDebug->parms[1],
+ interactiveDebug->parms[2],
+ interactiveDebug->parms[3],
+ interactiveDebug->parms[4],
+ interactiveDebug->parms[5],
+ interactiveDebug->parms[6],
+ interactiveDebug->parms[7]);
+
+ // Atomically set state to 'complete'.
+ // This must be proceeded by a sync to ensure all memory operations
+ // and instructions have fully completed prior to setting the complete
+ // state (due to weak consistency).
+ // Set Ready = 0, Running = 0, Complete = 1.
+ __sync_synchronize();
+ __sync_lock_test_and_set(&interactiveDebug->state_value,
+ IDEBUG_COMPLETE_STATE);
+
+ task_end();
+}
+
OpenPOWER on IntegriCloud