bsps/irq: Add rtems_interrupt_entry_install()

Add rtems_interrupt_entry_remove().  Split up irq-generic.c into several files.
In particular, place all functions which use dynamic memory into their own
file.

Add optional macros to let the BSP customize the vector installation after
installing the first entry and the vector removal before removing the last
entry:

* bsp_interrupt_vector_install()

* bsp_interrupt_vector_remove()

Use these new customization options in the m68k/genmcf548x BSP so re-use the
generic interrupt controller support.

Update #3269.
This commit is contained in:
Sebastian Huber
2021-07-26 19:57:31 +02:00
parent 70357f1731
commit e518323872
17 changed files with 683 additions and 543 deletions
+1 -7
View File
@@ -353,13 +353,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
static bool bsp_interrupt_handler_is_empty(rtems_vector_number vector)
{
rtems_vector_number index;
rtems_interrupt_entry *head;
index = bsp_interrupt_handler_index(vector);
head = &bsp_interrupt_handler_table[index];
return bsp_interrupt_is_empty_handler_entry(head);
return bsp_interrupt_entry_load_first(vector) == NULL;
}
/*
+169 -45
View File
@@ -12,7 +12,7 @@
/*
* Copyright (C) 2016 Chris Johns <chrisj@rtems.org>
*
* Copyright (C) 2008, 2017 embedded brains GmbH (http://www.embedded-brains.de)
* Copyright (C) 2008, 2021 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -70,20 +70,13 @@ extern "C" {
#define BSP_INTERRUPT_HANDLER_TABLE_SIZE BSP_INTERRUPT_VECTOR_COUNT
#endif
/* Internal macros for SMP support, do not use externally */
#ifdef RTEMS_SMP
#define bsp_interrupt_disable(level) do { (void) level; } while (0)
#define bsp_interrupt_enable(level) do { } while (0)
#define bsp_interrupt_fence(order) _Atomic_Fence(order)
#else
#define bsp_interrupt_disable(level) rtems_interrupt_disable(level)
#define bsp_interrupt_enable(level) rtems_interrupt_enable(level)
#define bsp_interrupt_fence(order) do { } while (0)
#endif
#define bsp_interrupt_assert(e) _Assert(e)
extern rtems_interrupt_entry bsp_interrupt_handler_table [];
/**
* @brief Each member of this table references the first installed entry at the
* corresponding interrupt vector or is NULL.
*/
extern rtems_interrupt_entry *bsp_interrupt_handler_table[];
#ifdef BSP_INTERRUPT_USE_INDEX_TABLE
#if BSP_INTERRUPT_HANDLER_TABLE_SIZE < 0x100
@@ -141,6 +134,12 @@ static inline rtems_vector_number bsp_interrupt_handler_index(
* - bsp_interrupt_vector_disable()
* - bsp_interrupt_handler_default()
*
* Optionally, the BSP may define the following macros to customize the vector
* installation after installing the first entry and the vector removal before
* removing the last entry:
* - bsp_interrupt_vector_install()
* - bsp_interrupt_vector_remove()
*
* The following now deprecated functions are provided for backward
* compatibility:
* - BSP_get_current_rtems_irq_handler()
@@ -362,14 +361,114 @@ rtems_status_code bsp_interrupt_raise_on(
*/
rtems_status_code bsp_interrupt_clear( rtems_vector_number vector );
#if defined(RTEMS_SMP)
/**
* @brief Handles a spurious interrupt.
*
* @param vector is the vector number.
*/
void bsp_interrupt_spurious( rtems_vector_number vector );
#endif
/**
* @brief Loads the interrupt entry with atomic acquire semantic.
*
* @param ptr is the pointer to an ::rtems_interrupt_entry pointer.
*
* @return Returns the pointer value.
*/
static inline rtems_interrupt_entry *bsp_interrupt_entry_load_acquire(
rtems_interrupt_entry * const *ptr
)
{
#if defined(RTEMS_SMP)
return (rtems_interrupt_entry *) _Atomic_Load_uintptr(
(const Atomic_Uintptr *) ptr,
ATOMIC_ORDER_ACQUIRE
);
#else
return *ptr;
#endif
}
/**
* @brief Stores the interrupt entry with atomic release semantic.
*
* @param[out] ptr is the pointer to an ::rtems_interrupt_entry pointer.
*
* @param value is the pointer value.
*/
static inline void bsp_interrupt_entry_store_release(
rtems_interrupt_entry **ptr,
rtems_interrupt_entry *value
)
{
#if defined(RTEMS_SMP)
_Atomic_Store_uintptr(
(Atomic_Uintptr *) ptr,
(Atomic_Uintptr) value,
ATOMIC_ORDER_RELEASE
);
#else
rtems_interrupt_level level;
rtems_interrupt_local_disable( level );
*ptr = value;
rtems_interrupt_local_enable( level );
#endif
}
/**
* @brief Loads the first interrupt entry installed at the interrupt vector.
*
* @param vector is the vector number.
*
* @return Returns the first entry or NULL.
*/
static inline rtems_interrupt_entry *bsp_interrupt_entry_load_first(
rtems_vector_number vector
)
{
rtems_vector_number index;
index = bsp_interrupt_handler_index( vector );
return bsp_interrupt_entry_load_acquire(
&bsp_interrupt_handler_table[ index ]
);
}
/**
* @brief Sequentially calls all interrupt handlers of the entry its
* successors.
*
* In uniprocessor configurations, you can call this function within every
* context which can be disabled via rtems_interrupt_local_disable().
*
* In SMP configurations, you can call this function in every context.
*
* @param entry is the first entry.
*/
static inline void bsp_interrupt_dispatch_entries(
const rtems_interrupt_entry *entry
)
{
do {
( *entry->handler )( entry->arg );
entry = bsp_interrupt_entry_load_acquire( &entry->next );
} while ( RTEMS_PREDICT_FALSE( entry != NULL ) );
}
/**
* @brief Sequentially calls all interrupt handlers installed at the vector.
*
* This function does not validate the vector number. If the vector number is
* out of range, then the behaviour is undefined.
*
* You can call this function within every context which can be disabled via
* rtems_interrupt_local_disable().
* In uniprocessor configurations, you can call this function within every
* context which can be disabled via rtems_interrupt_local_disable().
*
* In SMP configurations, you can call this function in every context.
*
* @param vector is the vector number.
*/
@@ -377,21 +476,19 @@ static inline void bsp_interrupt_handler_dispatch_unchecked(
rtems_vector_number vector
)
{
const rtems_interrupt_entry *e;
const rtems_interrupt_entry *entry;
e = &bsp_interrupt_handler_table[ bsp_interrupt_handler_index( vector ) ];
entry = bsp_interrupt_entry_load_first( vector );
do {
rtems_interrupt_handler handler;
void *arg;
arg = e->arg;
bsp_interrupt_fence( ATOMIC_ORDER_ACQUIRE );
handler = e->handler;
( *handler )( arg );
e = e->next;
} while ( e != NULL );
if ( RTEMS_PREDICT_TRUE( entry != NULL ) ) {
bsp_interrupt_dispatch_entries( entry );
} else {
#if defined(RTEMS_SMP)
bsp_interrupt_spurious( vector );
#else
bsp_interrupt_handler_default( vector );
#endif
}
}
/**
@@ -401,8 +498,10 @@ static inline void bsp_interrupt_handler_dispatch_unchecked(
* bsp_interrupt_handler_default() will be called with the vector number as
* argument.
*
* You can call this function within every context which can be disabled via
* rtems_interrupt_local_disable().
* In uniprocessor configurations, you can call this function within every
* context which can be disabled via rtems_interrupt_local_disable().
*
* In SMP configurations, you can call this function in every context.
*
* @param vector is the vector number.
*/
@@ -457,6 +556,21 @@ rtems_status_code bsp_interrupt_check_and_lock(
rtems_interrupt_handler handler
);
/* For internal use only */
rtems_interrupt_entry *bsp_interrupt_entry_find(
rtems_vector_number vector,
rtems_interrupt_handler routine,
void *arg,
rtems_interrupt_entry ***previous_next
);
/* For internal use only */
void bsp_interrupt_entry_remove(
rtems_vector_number vector,
rtems_interrupt_entry *entry,
rtems_interrupt_entry **previous_next
);
/**
* @brief This table contains a bit map which indicates if an entry is unique
* or shared.
@@ -488,6 +602,31 @@ static inline bool bsp_interrupt_is_handler_unique( rtems_vector_number index )
return ( bsp_interrupt_handler_unique_table[ table_index ] & bit ) != 0;
}
/**
* @brief Sets the unique status of the handler entry.
*
* @param index is the handler index.
*
* @param unique is the unique status to set.
*/
static inline void bsp_interrupt_set_handler_unique(
rtems_vector_number index,
bool unique
)
{
rtems_vector_number table_index;
uint8_t bit;
table_index = index / 8;
bit = (uint8_t) ( 1U << ( index % 8 ) );
if (unique) {
bsp_interrupt_handler_unique_table[ table_index ] |= bit;
} else {
bsp_interrupt_handler_unique_table[ table_index ] &= ~bit;
}
}
/**
* @brief Checks if the interrupt support is initialized.
*
@@ -499,21 +638,6 @@ static inline bool bsp_interrupt_is_initialized( void )
return bsp_interrupt_is_handler_unique( BSP_INTERRUPT_HANDLER_TABLE_SIZE );
}
/**
* @brief This handler routine is used for empty entries.
*/
void bsp_interrupt_handler_empty( void *arg );
/**
* @brief Checks if a handler entry is empty.
*/
static inline bool bsp_interrupt_is_empty_handler_entry(
const rtems_interrupt_entry *entry
)
{
return entry->handler == bsp_interrupt_handler_empty;
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
+8
View File
@@ -99,4 +99,12 @@ static inline bool bsp_interrupt_is_valid_vector(rtems_vector_number vector)
&& vector < (rtems_vector_number) BSP_INTERRUPT_VECTOR_COUNT;
}
void mcf548x_interrupt_vector_install(rtems_vector_number vector);
void mcf548x_interrupt_vector_remove(rtems_vector_number vector);
#define bsp_interrupt_vector_install(v) mcf548x_interrupt_vector_install(v)
#define bsp_interrupt_vector_remove(v) mcf548x_interrupt_vector_remove(v)
#endif /* LIBBSP_M68K_MCF548X_IRQ_H */
+10 -130
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
* Copyright (c) 2013, 2021 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -20,14 +20,6 @@ void asm_default_interrupt(void);
typedef void (*void_func)(void);
typedef struct {
rtems_interrupt_handler handler;
void *arg;
const char *info;
} interrupt_control;
static interrupt_control interrupt_controls[BSP_INTERRUPT_VECTOR_COUNT];
static uint32_t vector_to_reg(rtems_vector_number vector)
{
return ((vector + 32U) >> 5) & 0x1;
@@ -131,18 +123,6 @@ rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
return RTEMS_SUCCESSFUL;
}
static void_func get_exception_handler(rtems_vector_number vector)
{
void **vbr;
void_func *exception_table;
m68k_get_vbr(vbr);
exception_table = (void_func *)vbr;
return exception_table[vector_to_exception_vector(vector)];
}
static void set_exception_handler(rtems_vector_number vector, void_func handler)
{
void **vbr;
@@ -157,119 +137,19 @@ static void set_exception_handler(rtems_vector_number vector, void_func handler)
static void dispatch_handler(rtems_vector_number exception_vector)
{
const interrupt_control *ic =
&interrupt_controls[exception_vector_to_vector(exception_vector)];
(*ic->handler)(ic->arg);
bsp_interrupt_handler_dispatch_unchecked(
exception_vector_to_vector(exception_vector)
);
}
static uint8_t get_intc_icr(rtems_vector_number vector)
void mcf548x_interrupt_vector_install(rtems_vector_number vector)
{
volatile uint8_t *icr = &MCF548X_INTC_ICR0;
return icr[vector];
_ISR_Vector_table[vector_to_exception_vector(vector)]
= dispatch_handler;
set_exception_handler(vector, _ISR_Handler);
}
rtems_status_code rtems_interrupt_handler_install(
rtems_vector_number vector,
const char *info,
rtems_option options,
rtems_interrupt_handler handler,
void *arg
)
void mcf548x_interrupt_vector_remove(rtems_vector_number vector)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
if (bsp_interrupt_is_valid_vector(vector)) {
rtems_interrupt_level level;
rtems_interrupt_disable(level);
if (
get_exception_handler(vector) == asm_default_interrupt
&& get_intc_icr(vector) != 0
) {
interrupt_control *ic = &interrupt_controls[vector];
ic->handler = handler;
ic->arg = arg;
ic->info = info;
_ISR_Vector_table[vector_to_exception_vector(vector)]
= dispatch_handler;
set_exception_handler(vector, _ISR_Handler);
bsp_interrupt_vector_enable(vector);
} else {
sc = RTEMS_RESOURCE_IN_USE;
}
rtems_interrupt_enable(level);
} else {
sc = RTEMS_INVALID_ID;
}
return sc;
}
static bool is_occupied_by_us(rtems_vector_number vector)
{
return get_exception_handler(vector) == _ISR_Handler
&& _ISR_Vector_table[vector_to_exception_vector(vector)]
== dispatch_handler;
}
rtems_status_code rtems_interrupt_handler_remove(
rtems_vector_number vector,
rtems_interrupt_handler handler,
void *arg
)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
if (bsp_interrupt_is_valid_vector(vector)) {
rtems_interrupt_level level;
interrupt_control *ic = &interrupt_controls[vector];
rtems_interrupt_disable(level);
if (
is_occupied_by_us(vector)
&& ic->handler == handler
&& ic->arg == arg
) {
bsp_interrupt_vector_disable(vector);
set_exception_handler(vector, asm_default_interrupt);
memset(ic, 0, sizeof(*ic));
} else {
sc = RTEMS_UNSATISFIED;
}
rtems_interrupt_enable(level);
} else {
sc = RTEMS_INVALID_ID;
}
return sc;
}
rtems_status_code rtems_interrupt_handler_iterate(
rtems_vector_number vector,
rtems_interrupt_per_handler_routine routine,
void *arg
)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
if (bsp_interrupt_is_valid_vector(vector)) {
if (is_occupied_by_us(vector)) {
const interrupt_control *ic = &interrupt_controls[vector];
(*routine)(arg, ic->info, RTEMS_INTERRUPT_UNIQUE, ic->handler, ic->arg);
}
} else {
sc = RTEMS_INVALID_ID;
}
return sc;
set_exception_handler(vector, asm_default_interrupt);
}
+3
View File
@@ -3,8 +3,11 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-raise-clear.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-enable-disable.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-entry-remove.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-generic.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-install.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-iterate.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-remove.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-info.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-lock.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-server.c
+3
View File
@@ -1,8 +1,11 @@
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-affinity.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-raise-clear.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-enable-disable.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-entry-remove.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-generic.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-install.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-iterate.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-remove.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-info.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-legacy.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-lock.c
+115
View File
@@ -0,0 +1,115 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup bsp_interrupt
*
* @brief This source file contains the implementation of
* rtems_interrupt_entry_remove() and bsp_interrupt_entry_remove().
*/
/*
* Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <bsp/irq-generic.h>
void bsp_interrupt_entry_remove(
rtems_vector_number vector,
rtems_interrupt_entry *entry,
rtems_interrupt_entry **previous_next
)
{
rtems_vector_number index;
rtems_interrupt_entry *first;
rtems_interrupt_entry *entry_next;
index = bsp_interrupt_handler_index( vector );
first = bsp_interrupt_handler_table[ index ];
entry_next = entry->next;
if ( entry == first && entry_next == NULL ) {
/* We remove the last installed entry */
bsp_interrupt_vector_disable( vector );
#if defined(bsp_interrupt_vector_remove)
bsp_interrupt_vector_remove( vector );
#else
bsp_interrupt_vector_disable( vector );
#endif
bsp_interrupt_set_handler_unique( index, false );
#if defined(BSP_INTERRUPT_USE_INDEX_TABLE)
bsp_interrupt_handler_index_table[ vector ] = 0;
#endif
}
bsp_interrupt_entry_store_release( previous_next, entry_next );
}
static rtems_status_code bsp_interrupt_entry_do_remove(
rtems_vector_number vector,
rtems_interrupt_entry *entry
)
{
rtems_interrupt_entry *installed;
rtems_interrupt_entry **previous_next;
installed = bsp_interrupt_entry_find(
vector,
entry->handler,
entry->arg,
&previous_next
);
if ( installed != entry ) {
return RTEMS_UNSATISFIED;
}
bsp_interrupt_entry_remove( vector, entry, previous_next );
return RTEMS_SUCCESSFUL;
}
rtems_status_code rtems_interrupt_entry_remove(
rtems_vector_number vector,
rtems_interrupt_entry *entry
)
{
rtems_status_code sc;
if ( entry == NULL ) {
return RTEMS_INVALID_ADDRESS;
}
sc = bsp_interrupt_check_and_lock( vector, entry->handler );
if ( sc != RTEMS_SUCCESSFUL ) {
return sc;
}
sc = bsp_interrupt_entry_do_remove( vector, entry );
bsp_interrupt_unlock();
return sc;
}
File diff suppressed because it is too large Load Diff
+114
View File
@@ -0,0 +1,114 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup bsp_interrupt
*
* @brief This source file contains the rtems_interrupt_handler_install()
* implementation.
*/
/*
* Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <bsp/irq-generic.h>
#include <rtems/malloc.h>
#include <stdlib.h>
static rtems_status_code bsp_interrupt_handler_do_replace(
rtems_vector_number vector,
const char *info,
rtems_interrupt_handler routine,
void *arg
)
{
rtems_interrupt_entry *entry;
rtems_interrupt_entry **unused;
entry = bsp_interrupt_entry_find( vector, routine, arg, &unused );
if ( entry == NULL ) {
return RTEMS_UNSATISFIED;
}
entry->handler = routine;
entry->info = info;
return RTEMS_SUCCESSFUL;
}
static rtems_status_code bsp_interrupt_handler_replace(
rtems_vector_number vector,
const char *info,
rtems_interrupt_handler routine,
void *arg
)
{
rtems_status_code sc;
sc = bsp_interrupt_check_and_lock( vector, routine );
if ( sc != RTEMS_SUCCESSFUL ) {
return sc;
}
sc = bsp_interrupt_handler_do_replace( vector, info, routine, arg );
bsp_interrupt_unlock();
return sc;
}
rtems_status_code rtems_interrupt_handler_install(
rtems_vector_number vector,
const char *info,
rtems_option options,
rtems_interrupt_handler routine,
void *arg
)
{
rtems_interrupt_entry *entry;
rtems_status_code sc;
if ( RTEMS_INTERRUPT_IS_REPLACE( options ) ) {
return bsp_interrupt_handler_replace( vector, info, routine, arg );
}
entry = rtems_malloc( sizeof( *entry ) );
if ( entry == NULL ) {
return RTEMS_NO_MEMORY;
}
rtems_interrupt_entry_initialize( entry, routine, arg, info );
sc = rtems_interrupt_entry_install( vector, options, entry );
if ( sc != RTEMS_SUCCESSFUL ) {
free( entry );
}
return sc;
}
+10 -11
View File
@@ -10,7 +10,7 @@
*/
/*
* Copyright (C) 2017 embedded brains GmbH (http://www.embedded-brains.de)
* Copyright (C) 2017, 2021 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -45,7 +45,7 @@ rtems_status_code rtems_interrupt_handler_iterate(
rtems_status_code sc;
rtems_vector_number index;
rtems_option options;
rtems_interrupt_entry *current;
rtems_interrupt_entry *entry;
sc = bsp_interrupt_check_and_lock(
vector,
@@ -56,15 +56,14 @@ rtems_status_code rtems_interrupt_handler_iterate(
return sc;
}
index = bsp_interrupt_handler_index(vector);
current = &bsp_interrupt_handler_table [index];
if (!bsp_interrupt_is_empty_handler_entry(current)) {
do {
options = bsp_interrupt_is_handler_unique(index) ?
RTEMS_INTERRUPT_UNIQUE : RTEMS_INTERRUPT_SHARED;
routine(arg, current->info, options, current->handler, current->arg);
current = current->next;
} while (current != NULL);
index = bsp_interrupt_handler_index( vector );
options = bsp_interrupt_is_handler_unique( index ) ?
RTEMS_INTERRUPT_UNIQUE : RTEMS_INTERRUPT_SHARED;
entry = bsp_interrupt_handler_table[ index ];
while ( entry != NULL ) {
( *routine )( arg, entry->info, options, entry->handler, entry->arg );
entry = entry->next;
}
bsp_interrupt_unlock();
+80
View File
@@ -0,0 +1,80 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup bsp_interrupt
*
* @brief This source file contains the implementation of
* rtems_interrupt_handler_remove().
*/
/*
* Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <bsp/irq-generic.h>
#include <stdlib.h>
static rtems_status_code bsp_interrupt_handler_do_remove(
rtems_vector_number vector,
rtems_interrupt_handler routine,
void *arg
)
{
rtems_interrupt_entry *entry;
rtems_interrupt_entry **previous_next;
entry = bsp_interrupt_entry_find( vector, routine, arg, &previous_next );
if ( entry == NULL ) {
return RTEMS_UNSATISFIED;
}
bsp_interrupt_entry_remove( vector, entry, previous_next );
free( entry );
return RTEMS_SUCCESSFUL;
}
rtems_status_code rtems_interrupt_handler_remove(
rtems_vector_number vector,
rtems_interrupt_handler routine,
void *arg
)
{
rtems_status_code sc;
sc = bsp_interrupt_check_and_lock( vector, routine );
if ( sc != RTEMS_SUCCESSFUL ) {
return sc;
}
sc = bsp_interrupt_handler_do_remove( vector, routine, arg );
bsp_interrupt_unlock();
return sc;
}
+1 -9
View File
@@ -38,16 +38,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/console/console.
librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/btimer/btimer.c
# IRQ
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-affinity.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-raise-clear.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-enable-disable.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-iterate.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-info.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-legacy.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-lock.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-server.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-shell.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/irq/irq.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/irq/intc-icr-init-values.c
@@ -59,5 +50,6 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/mcdma/MCD_tasksI
librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/mcdma/mcdma_glue.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/start/cache.c
include $(srcdir)/../../../../../../bsps/shared/irq-sources.am
include $(srcdir)/../../../../../../bsps/shared/shared-sources.am
include $(srcdir)/../../../../../../bsps/m68k/genmcf548x/headers.am
@@ -51,8 +51,11 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-raise-clear.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-enable-disable.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-entry-remove.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-generic.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-install.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-iterate.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-handler-remove.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-info.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-lock.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-server.c
+2
View File
@@ -27,6 +27,8 @@ links:
uid: ../grp
- role: build-dependency
uid: ../../obj
- role: build-dependency
uid: ../../objirq
- role: build-dependency
uid: ../../optconsolebaud
- role: build-dependency
-9
View File
@@ -38,16 +38,7 @@ source:
- bsps/m68k/shared/m68kidle.c
- bsps/m68k/shared/memProbe.c
- bsps/shared/dev/getentropy/getentropy-cpucounter.c
- bsps/shared/irq/irq-affinity.c
- bsps/shared/irq/irq-raise-clear.c
- bsps/shared/irq/irq-default-handler.c
- bsps/shared/irq/irq-enable-disable.c
- bsps/shared/irq/irq-handler-iterate.c
- bsps/shared/irq/irq-info.c
- bsps/shared/irq/irq-legacy.c
- bsps/shared/irq/irq-lock.c
- bsps/shared/irq/irq-server.c
- bsps/shared/irq/irq-shell.c
- bsps/shared/start/bspfatal-default.c
- bsps/shared/start/bspgetworkarea-default.c
- bsps/shared/start/bspreset-loop.c
+3
View File
@@ -13,8 +13,11 @@ source:
- bsps/shared/irq/irq-affinity.c
- bsps/shared/irq/irq-raise-clear.c
- bsps/shared/irq/irq-enable-disable.c
- bsps/shared/irq/irq-entry-remove.c
- bsps/shared/irq/irq-generic.c
- bsps/shared/irq/irq-handler-install.c
- bsps/shared/irq/irq-handler-iterate.c
- bsps/shared/irq/irq-handler-remove.c
- bsps/shared/irq/irq-info.c
- bsps/shared/irq/irq-legacy.c
- bsps/shared/irq/irq-lock.c
@@ -72,8 +72,11 @@ source:
- bsps/shared/irq/irq-default-handler.c
- bsps/shared/irq/irq-default.c
- bsps/shared/irq/irq-enable-disable.c
- bsps/shared/irq/irq-entry-remove.c
- bsps/shared/irq/irq-generic.c
- bsps/shared/irq/irq-handler-install.c
- bsps/shared/irq/irq-handler-iterate.c
- bsps/shared/irq/irq-handler-remove.c
- bsps/shared/irq/irq-info.c
- bsps/shared/irq/irq-lock.c
- bsps/shared/irq/irq-server.c