From 43f18a14aeb46a5856d50a4d422b3d86d431d4e8 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Fri, 6 May 2016 17:40:22 +1000 Subject: [PATCH] bsp/shared: Add bsp_interrupt_handler_is_empty. --- c/src/lib/libbsp/shared/include/irq-generic.h | 15 ++++++++++++++- c/src/lib/libbsp/shared/src/irq-generic.c | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/c/src/lib/libbsp/shared/include/irq-generic.h b/c/src/lib/libbsp/shared/include/irq-generic.h index 389bd5a2bf..4e89d74ab3 100644 --- a/c/src/lib/libbsp/shared/include/irq-generic.h +++ b/c/src/lib/libbsp/shared/include/irq-generic.h @@ -17,6 +17,8 @@ * Germany * * + * Copyright (c) 2016 Chris Johns + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -106,7 +108,7 @@ static inline rtems_vector_number bsp_interrupt_handler_index( * @defgroup bsp_interrupt BSP Interrupt Support * * @ingroup bsp_shared - * + * * @brief Generic BSP Interrupt Support * * The BSP interrupt support manages a sequence of interrupt vector numbers @@ -272,6 +274,17 @@ static inline void bsp_interrupt_handler_dispatch(rtems_vector_number vector) } } +/** + * @brief Is interrupt handler empty. + * + * This routine returns true if the handler is empty and has not been + * initialised else false is returned. The interrupt lock is not used + * so this call can be used from within interrupts. + * + * @return If empty true shall be returned else false is returned. + */ +bool bsp_interrupt_handler_is_empty(rtems_vector_number vector); + /** @} */ /* For internal use only */ diff --git a/c/src/lib/libbsp/shared/src/irq-generic.c b/c/src/lib/libbsp/shared/src/irq-generic.c index 19b52afb53..c62a75602e 100644 --- a/c/src/lib/libbsp/shared/src/irq-generic.c +++ b/c/src/lib/libbsp/shared/src/irq-generic.c @@ -566,3 +566,22 @@ rtems_status_code rtems_interrupt_handler_iterate( { return bsp_interrupt_handler_iterate(vector, routine, arg); } + +bool bsp_interrupt_handler_is_empty(rtems_vector_number vector) +{ + rtems_vector_number index = 0; + bsp_interrupt_handler_entry *head = NULL; + bool empty; + + /* For use in interrupts so no lock. */ + + /* Get handler table index */ + index = bsp_interrupt_handler_index(vector); + + /* Get head entry of the handler list for the vector */ + head = &bsp_interrupt_handler_table [index]; + + empty = bsp_interrupt_is_empty_handler_entry(head); + + return empty; +}