summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/shared/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-19 15:00:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-19 15:00:09 +0000
commit51a6fd555d2f20506b4b235b0046d0b4b57708f4 (patch)
tree15f27917466370362451e3d869860949156880e6 /c/src/lib/libbsp/shared/src
parent2008-12-19 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-51a6fd555d2f20506b4b235b0046d0b4b57708f4.tar.bz2
2008-12-19 Sebastian Huber <sebastian.huber@embedded-brains.de>
* include/irq-info.h, src/irq-info.c, src/irq-shell.c: New files. * include/irq-generic.h, src/irq-generic.c: Improved interrupt handler dispatch function.
Diffstat (limited to 'c/src/lib/libbsp/shared/src')
-rw-r--r--c/src/lib/libbsp/shared/src/irq-generic.c18
-rw-r--r--c/src/lib/libbsp/shared/src/irq-info.c88
-rw-r--r--c/src/lib/libbsp/shared/src/irq-shell.c45
3 files changed, 144 insertions, 7 deletions
diff --git a/c/src/lib/libbsp/shared/src/irq-generic.c b/c/src/lib/libbsp/shared/src/irq-generic.c
index fb6370a7da..2659001c14 100644
--- a/c/src/lib/libbsp/shared/src/irq-generic.c
+++ b/c/src/lib/libbsp/shared/src/irq-generic.c
@@ -26,6 +26,11 @@
bsp_interrupt_handler_index_type bsp_interrupt_handler_index_table [BSP_INTERRUPT_VECTOR_NUMBER];
#endif /* BSP_INTERRUPT_USE_INDEX_TABLE */
+static void bsp_interrupt_handler_empty( rtems_vector_number vector, void *arg)
+{
+ bsp_interrupt_handler_default( vector);
+}
+
bsp_interrupt_handler_entry bsp_interrupt_handler_table [BSP_INTERRUPT_HANDLER_TABLE_SIZE] = {
[0 ... BSP_INTERRUPT_HANDLER_TABLE_SIZE - 1] = {
.handler = bsp_interrupt_handler_empty,
@@ -68,9 +73,9 @@ static inline void bsp_interrupt_set_initialized(void)
bsp_interrupt_set_handler_unique( BSP_INTERRUPT_HANDLER_TABLE_SIZE, true);
}
-void bsp_interrupt_handler_empty( rtems_vector_number vector, void *arg)
+static inline bool bsp_interrupt_is_empty_handler_entry( bsp_interrupt_handler_entry *e)
{
- /* Do nothing */
+ return e->handler == bsp_interrupt_handler_empty;
}
static inline void bsp_interrupt_clear_handler_entry( bsp_interrupt_handler_entry *e)
@@ -101,7 +106,7 @@ static inline bool bsp_interrupt_allocate_handler_index( rtems_vector_number vec
#endif /* BSP_INTERRUPT_USE_INDEX_TABLE */
}
-static bsp_interrupt_handler_entry *bsp_interrupt_allocate_handler_entry()
+static bsp_interrupt_handler_entry *bsp_interrupt_allocate_handler_entry( void)
{
#ifdef BSP_INTERRUPT_NO_HEAP_USAGE
rtems_vector_number index = 0;
@@ -124,7 +129,7 @@ static void bsp_interrupt_free_handler_entry( bsp_interrupt_handler_entry *e)
#endif /* BSP_INTERRUPT_NO_HEAP_USAGE */
}
-static rtems_status_code bsp_interrupt_lock()
+static rtems_status_code bsp_interrupt_lock( void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
if (_System_state_Is_up( _System_state_Get())) {
@@ -167,7 +172,7 @@ static rtems_status_code bsp_interrupt_lock()
}
}
-static rtems_status_code bsp_interrupt_unlock()
+static rtems_status_code bsp_interrupt_unlock( void)
{
if (bsp_interrupt_mutex != RTEMS_ID_NONE) {
return rtems_semaphore_release( bsp_interrupt_mutex);
@@ -184,10 +189,9 @@ static rtems_status_code bsp_interrupt_unlock()
* function will be called after all internals are initialized. Initialization
* is complete if everything was successful.
*/
-rtems_status_code bsp_interrupt_initialize()
+rtems_status_code bsp_interrupt_initialize( void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
- rtems_vector_number index = 0;
/* Lock */
sc = bsp_interrupt_lock();
diff --git a/c/src/lib/libbsp/shared/src/irq-info.c b/c/src/lib/libbsp/shared/src/irq-info.c
new file mode 100644
index 0000000000..6736d508b7
--- /dev/null
+++ b/c/src/lib/libbsp/shared/src/irq-info.c
@@ -0,0 +1,88 @@
+/**
+ * @file
+ *
+ * @ingroup bsp_interrupt
+ *
+ * @brief Source file for generic BSP interrupt information code.
+ */
+
+/*
+ * Copyright (c) 2008
+ * Embedded Brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * rtems@embedded-brains.de
+ *
+ * The license and distribution terms for this file may be found in the file
+ * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
+ */
+
+#include <inttypes.h>
+
+#include <rtems/irq.h>
+
+#include <bsp/irq-generic.h>
+#include <bsp/irq-info.h>
+#include <bsp/irq-config.h>
+
+typedef struct {
+ void *context;
+ rtems_printk_plugin_t print;
+ rtems_vector_number vector;
+} bsp_interrupt_report_entry;
+
+static void bsp_interrupt_report_per_handler_routine(
+ void *arg,
+ const char *info,
+ rtems_option options,
+ rtems_interrupt_handler handler,
+ void *handler_arg
+)
+{
+ bsp_interrupt_report_entry *e = (bsp_interrupt_report_entry *) arg;
+ const char *opt = options == RTEMS_INTERRUPT_UNIQUE ? "UNIQUE" : "SHARED";
+
+ e->print( e->context, "%7" PRIu32 " | %-32s | %7s | %010p | %010p\n", e->vector, info, opt, handler, handler_arg);
+}
+
+/**
+ * @brief Prints interrupt information via the printk plugin @a print with the
+ * context @a context.
+ */
+void bsp_interrupt_report_with_plugin( void *context, rtems_printk_plugin_t print)
+{
+ rtems_vector_number v = 0;
+ bsp_interrupt_report_entry e = {
+ .context = context,
+ .print = print,
+ .vector = 0
+ };
+
+ print(
+ context,
+ "-------------------------------------------------------------------------------\n"
+ " INTERRUPT INFORMATION\n"
+ "--------+----------------------------------+---------+------------+------------\n"
+ " VECTOR | INFO | OPTIONS | HANDLER | ARGUMENT \n"
+ "--------+----------------------------------+---------+------------+------------\n"
+ );
+
+ for (v = BSP_INTERRUPT_VECTOR_MIN; v <= BSP_INTERRUPT_VECTOR_MAX; ++v) {
+ e.vector = v;
+ (void) rtems_interrupt_handler_iterate( v, bsp_interrupt_report_per_handler_routine, &e);
+ }
+
+ print(
+ context,
+ "--------+----------------------------------+---------+------------+------------\n"
+ );
+}
+
+/**
+ * @brief Prints interrupt information via the default printk plugin.
+ */
+void bsp_interrupt_report( void)
+{
+ bsp_interrupt_report_with_plugin( NULL, printk_plugin);
+}
diff --git a/c/src/lib/libbsp/shared/src/irq-shell.c b/c/src/lib/libbsp/shared/src/irq-shell.c
new file mode 100644
index 0000000000..341f30364a
--- /dev/null
+++ b/c/src/lib/libbsp/shared/src/irq-shell.c
@@ -0,0 +1,45 @@
+/**
+ * @file
+ *
+ * @ingroup bsp_interrupt
+ *
+ * @brief Source file for generic BSP interrupt shell code.
+ */
+
+/*
+ * Copyright (c) 2008
+ * Embedded Brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * rtems@embedded-brains.de
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <stdio.h>
+
+#include <rtems/shell.h>
+
+#include <bsp/irq-info.h>
+
+static int bsp_interrupt_shell_main( int argc, char **argv)
+{
+ bsp_interrupt_report_with_plugin( stdout, (rtems_printk_plugin_t) fprintf);
+
+ return 0;
+}
+
+/**
+ * @brief Shell command entry for interrupt information.
+ */
+struct rtems_shell_cmd_tt bsp_interrupt_shell_command = {
+ .name = "irq",
+ .usage = "Prints interrupt information",
+ .topic = "rtems",
+ .command = bsp_interrupt_shell_main,
+ .alias = NULL,
+ .next = NULL
+};