* 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.
This commit is contained in:
Joel Sherrill
2008-12-19 15:00:09 +00:00
parent eb96196183
commit 51a6fd555d
6 changed files with 205 additions and 23 deletions

View File

@@ -1,3 +1,9 @@
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.
2008-12-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* bootcard.c: Eliminate pointers to API configuration tables in the

View File

@@ -75,13 +75,6 @@ static inline rtems_vector_number bsp_interrupt_handler_index( rtems_vector_numb
#endif /* BSP_INTERRUPT_USE_INDEX_TABLE */
}
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)
{
return e->handler == bsp_interrupt_handler_empty;
}
/**
* @defgroup bsp_interrupt BSP Interrupt Support
*
@@ -217,17 +210,12 @@ rtems_status_code bsp_interrupt_vector_disable( rtems_vector_number vector);
static inline void bsp_interrupt_handler_dispatch( rtems_vector_number vector)
{
if (bsp_interrupt_is_valid_vector( vector)) {
bsp_interrupt_handler_entry *head = &bsp_interrupt_handler_table [bsp_interrupt_handler_index( vector)];
bsp_interrupt_handler_entry *current = head;
bsp_interrupt_handler_entry *e = &bsp_interrupt_handler_table [bsp_interrupt_handler_index( vector)];
do {
current->handler( vector, current->arg);
current = current->next;
} while (current != NULL);
if (bsp_interrupt_is_empty_handler_entry( head)) {
bsp_interrupt_handler_default( vector);
}
e->handler( vector, e->arg);
e = e->next;
} while (e != NULL);
} else {
bsp_interrupt_handler_default( vector);
}

View File

@@ -0,0 +1,51 @@
/**
* @file
*
* @ingroup bsp_interrupt
*
* @brief Header file for generic BSP interrupt information.
*/
/*
* 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.
*/
#ifndef LIBBSP_SHARED_IRQ_INFO_H
#define LIBBSP_SHARED_IRQ_INFO_H
#include <rtems/shell.h>
#include <rtems/bspIo.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @defgroup bsp_interrupt BSP Interrupt Information
*
* @ingroup rtems_interrupt_extension
*
* @{
*/
void bsp_interrupt_report_with_plugin( void *context, rtems_printk_plugin_t print);
void bsp_interrupt_report( void);
extern struct rtems_shell_cmd_tt bsp_interrupt_shell_command;
/** @} */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_SHARED_IRQ_INFO_H */

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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
};