irq: make utility functions private

irq_handler_set, irq_priority_set and irq_disconnect have been made
private by prepending an underscore to their names:

	irq_handler_set -> irq_handler_set
	irq_priority_set -> irq_priority_set
	irq_disconnect -> irq_disconnect

The prototypes have been removed from header files when possible, and
extern statements used in C code where they were called.

_irq_priority_set() for ARM is still in the header file because
IRQ_CONFIG() relies on it.

Change-Id: I2ad585f8156ff80250f6d9eeca4a249a4477fd9d
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
Benjamin Walsh 2015-08-12 15:15:48 -04:00 committed by Anas Nashif
commit c1f9fd888d
10 changed files with 39 additions and 51 deletions

View file

@ -52,6 +52,8 @@
#include <sw_isr_table.h> #include <sw_isr_table.h>
/* /*
* @internal
*
* @brief Replace an interrupt handler by another * @brief Replace an interrupt handler by another
* *
* An interrupt's ISR can be replaced at runtime. Care must be taken that the * An interrupt's ISR can be replaced at runtime. Care must be taken that the
@ -63,7 +65,7 @@
* @return N/A * @return N/A
*/ */
void irq_handler_set( void _irq_handler_set(
unsigned int irq, unsigned int irq,
void (*old)(void *arg), void (*old)(void *arg),
void (*new)(void *arg), void (*new)(void *arg),
@ -120,6 +122,8 @@ void irq_disable(unsigned int irq)
} }
/* /*
* @internal
*
* @brief Set an interrupt's priority * @brief Set an interrupt's priority
* *
* Valid values are from 0 to 15. Interrupts of priority 1 are not masked when * Valid values are from 0 to 15. Interrupts of priority 1 are not masked when
@ -131,7 +135,7 @@ void irq_disable(unsigned int irq)
* @return N/A * @return N/A
*/ */
void irq_priority_set( void _irq_priority_set(
unsigned int irq, unsigned int irq,
unsigned int prio unsigned int prio
) )
@ -182,12 +186,14 @@ int irq_connect(
void *arg void *arg
) )
{ {
irq_handler_set(irq, _irq_spurious, isr, arg); _irq_handler_set(irq, _irq_spurious, isr, arg);
irq_priority_set(irq, prio); _irq_priority_set(irq, prio);
return irq; return irq;
} }
/* /*
* @internal
*
* @brief Disconnect an ISR from an interrupt line * @brief Disconnect an ISR from an interrupt line
* *
* Interrupt line <irq> is disconnected from its ISR and the latter is * Interrupt line <irq> is disconnected from its ISR and the latter is
@ -197,9 +203,9 @@ int irq_connect(
* @return N/A * @return N/A
*/ */
void irq_disconnect(unsigned int irq) void _irq_disconnect(unsigned int irq)
{ {
int index = irq - 16; int index = irq - 16;
irq_handler_set(irq, _sw_isr_table[index].isr, _irq_spurious, NULL); _irq_handler_set(irq, _sw_isr_table[index].isr, _irq_spurious, NULL);
} }

View file

@ -47,6 +47,7 @@ SW_ISR_TABLE_DYNAMIC has to be enabled for connecting ISRs at runtime.
extern void __reserved(void); extern void __reserved(void);
/** /**
* @internal
* *
* @brief Replace an interrupt handler by another * @brief Replace an interrupt handler by another
* *
@ -59,7 +60,7 @@ extern void __reserved(void);
* @return N/A * @return N/A
*/ */
void irq_handler_set(unsigned int irq, void _irq_handler_set(unsigned int irq,
void (*old)(void *arg), void (*old)(void *arg),
void (*new)(void *arg), void (*new)(void *arg),
void *arg) void *arg)
@ -110,6 +111,7 @@ void irq_disable(unsigned int irq)
} }
/** /**
* @internal
* *
* @brief Set an interrupt's priority * @brief Set an interrupt's priority
* *
@ -124,7 +126,7 @@ void irq_disable(unsigned int irq)
* @return N/A * @return N/A
*/ */
void irq_priority_set(unsigned int irq, void _irq_priority_set(unsigned int irq,
unsigned int prio) unsigned int prio)
{ {
__ASSERT(prio > 0 && prio < 256, "invalid priority!"); __ASSERT(prio > 0 && prio < 256, "invalid priority!");
@ -167,12 +169,14 @@ int irq_connect(unsigned int irq,
void (*isr)(void *arg), void (*isr)(void *arg),
void *arg) void *arg)
{ {
irq_handler_set(irq, _irq_spurious, isr, arg); _irq_handler_set(irq, _irq_spurious, isr, arg);
irq_priority_set(irq, prio); _irq_priority_set(irq, prio);
return irq; return irq;
} }
/** /**
*
* @internal
* *
* @brief Disconnect an ISR from an interrupt line * @brief Disconnect an ISR from an interrupt line
* *
@ -183,7 +187,7 @@ int irq_connect(unsigned int irq,
* @return N/A * @return N/A
*/ */
void irq_disconnect(unsigned int irq) void _irq_disconnect(unsigned int irq)
{ {
irq_handler_set(irq, _sw_isr_table[irq].isr, _irq_spurious, NULL); _irq_handler_set(irq, _sw_isr_table[irq].isr, _irq_spurious, NULL);
} }

View file

@ -32,7 +32,7 @@
/* /*
* DESCRIPTION * DESCRIPTION
* This module contains the irq_handler_set() API. This routine is closely * This module contains the _irq_handler_set() API. This routine is closely
* associated with irq_connect(), and any changes to the layout of the * associated with irq_connect(), and any changes to the layout of the
* constructed interrupt stub must be reflected in both places. * constructed interrupt stub must be reflected in both places.
* *
@ -58,6 +58,7 @@ extern unsigned char _idt_base_address[];
#define FIRST_OPT_OPCODE_OFF 5 #define FIRST_OPT_OPCODE_OFF 5
/** /**
* @internal
* *
* @brief Set the handler in an already connected stub * @brief Set the handler in an already connected stub
* *
@ -67,7 +68,7 @@ extern unsigned char _idt_base_address[];
* WARNINGS: * WARNINGS:
* *
* A fully constructed interrupt stub is generated via irq_connect(), i.e. * A fully constructed interrupt stub is generated via irq_connect(), i.e.
* the irq_handler_set() function must only be called after invoking * the _irq_handler_set() function must only be called after invoking
* irq_connect(). * irq_connect().
* *
* The caller must ensure that the associated interrupt does not occur while * The caller must ensure that the associated interrupt does not occur while
@ -80,7 +81,7 @@ extern unsigned char _idt_base_address[];
* *
*/ */
void irq_handler_set(unsigned int vector, void _irq_handler_set(unsigned int vector,
void (*oldRoutine)(void *parameter), void (*oldRoutine)(void *parameter),
void (*newRoutine)(void *parameter), void (*newRoutine)(void *parameter),
void *parameter) void *parameter)

View file

@ -345,10 +345,8 @@ an ISR or to set the priority of an interrupt, use low numbers.
For example, if 3 bits are implemented, use 1, 2, and 3, For example, if 3 bits are implemented, use 1, 2, and 3,
not 0x20h, 0x40h, and 0x60h. not 0x20h, 0x40h, and 0x60h.
Interrupt priority is set using the *prio* Interrupt priority is set using the *prio* parameter of
parameter of :c:func:`irq_connect()`, or the :c:func:`irq_connect()`.
:c:func:`irq_priority_set()` API when not connecting
interrupt handlers dynamically.
The number of available priorities are: The number of available priorities are:
@ -361,9 +359,7 @@ The number of available priorities are:
Interrupt locking is done by setting :envvar:`BASEPRI` to 1, setting Interrupt locking is done by setting :envvar:`BASEPRI` to 1, setting
exceptions 4, 5, 6, and 11 to priority 0, and setting all exceptions 4, 5, 6, and 11 to priority 0, and setting all
other exceptions, including interrupts, to a lower priority other exceptions, including interrupts, to a lower priority
(1+). The result is that the :c:func:`irq_priority_set()` API can set (1+).
the interrupt priority to 1+ (if it has not already been
installed through :c:func:`irq_connect()`).

View file

@ -44,31 +44,21 @@
GTEXT(_irq_exit); GTEXT(_irq_exit);
GTEXT(irq_lock) GTEXT(irq_lock)
GTEXT(irq_unlock) GTEXT(irq_unlock)
GTEXT(irq_handler_set)
GTEXT(irq_connect) GTEXT(irq_connect)
GTEXT(irq_disconnect)
GTEXT(irq_enable) GTEXT(irq_enable)
GTEXT(irq_disable) GTEXT(irq_disable)
GTEXT(irq_priority_set)
#else #else
extern int irq_lock(void); extern int irq_lock(void);
extern void irq_unlock(int key); extern void irq_unlock(int key);
extern void irq_handler_set(unsigned int irq,
void (*old)(void *arg),
void (*new)(void *arg),
void *arg);
extern int irq_connect(unsigned int irq, extern int irq_connect(unsigned int irq,
unsigned int prio, unsigned int prio,
void (*isr)(void *arg), void (*isr)(void *arg),
void *arg); void *arg);
extern void irq_disconnect(unsigned int irq);
extern void irq_enable(unsigned int irq); extern void irq_enable(unsigned int irq);
extern void irq_disable(unsigned int irq); extern void irq_disable(unsigned int irq);
extern void irq_priority_set(unsigned int irq, unsigned int prio);
extern void _irq_exit(void); extern void _irq_exit(void);
/** /**

View file

@ -45,31 +45,21 @@ ARM-specific nanokernel interrupt handling interface. Included by ARM/arch.h.
GTEXT(_IntExit); GTEXT(_IntExit);
GTEXT(irq_lock) GTEXT(irq_lock)
GTEXT(irq_unlock) GTEXT(irq_unlock)
GTEXT(irq_handler_set)
GTEXT(irq_connect) GTEXT(irq_connect)
GTEXT(irq_disconnect)
GTEXT(irq_enable) GTEXT(irq_enable)
GTEXT(irq_disable) GTEXT(irq_disable)
GTEXT(irq_priority_set)
#else #else
extern int irq_lock(void); extern int irq_lock(void);
extern void irq_unlock(int key); extern void irq_unlock(int key);
extern void irq_handler_set(unsigned int irq,
void (*old)(void *arg),
void (*new)(void *arg),
void *arg);
extern int irq_connect(unsigned int irq, extern int irq_connect(unsigned int irq,
unsigned int prio, unsigned int prio,
void (*isr)(void *arg), void (*isr)(void *arg),
void *arg); void *arg);
extern void irq_disconnect(unsigned int irq);
extern void irq_enable(unsigned int irq); extern void irq_enable(unsigned int irq);
extern void irq_disable(unsigned int irq); extern void irq_disable(unsigned int irq);
extern void irq_priority_set(unsigned int irq, unsigned int prio);
extern void _IntExit(void); extern void _IntExit(void);
/* macros convert value of it's argument to a string */ /* macros convert value of it's argument to a string */
@ -97,6 +87,9 @@ extern void _IntExit(void);
__attribute__ ((section (TOSTR(CONCAT(.gnu.linkonce.isr_irq, irq))))) = \ __attribute__ ((section (TOSTR(CONCAT(.gnu.linkonce.isr_irq, irq))))) = \
{parameter, isr} {parameter, isr}
/* internal routine documented in C file, needed by IRQ_CONFIG macro */
extern void _irq_priority_set(unsigned int irq, unsigned int prio);
/** /**
* *
* @brief Configure interrupt for the device * @brief Configure interrupt for the device
@ -107,7 +100,7 @@ extern void _IntExit(void);
* @return N/A * @return N/A
* *
*/ */
#define IRQ_CONFIG(device, irq) irq_priority_set(irq, _##device##_int_priority) #define IRQ_CONFIG(device, irq) _irq_priority_set(irq, _##device##_int_priority)
#endif /* _ASMLANGUAGE */ #endif /* _ASMLANGUAGE */

View file

@ -392,11 +392,6 @@ extern unsigned int find_first_set(unsigned int op);
extern unsigned int find_last_set(unsigned int op); extern unsigned int find_last_set(unsigned int op);
extern void irq_handler_set(unsigned int vector,
void (*oldRoutine)(void *parameter),
void (*newRoutine)(void *parameter),
void *parameter);
extern int irq_connect(unsigned int irq, extern int irq_connect(unsigned int irq,
unsigned int priority, unsigned int priority,
void (*routine)(void *parameter), void (*routine)(void *parameter),

View file

@ -93,7 +93,8 @@ static struct task_irq_info task_irq_object[MAX_TASK_IRQS] = {
#elif defined(CONFIG_CPU_CORTEX_M3_M4) #elif defined(CONFIG_CPU_CORTEX_M3_M4)
#include <arch/cpu.h> #include <arch/cpu.h>
#define RELEASE_VECTOR(v) irq_disconnect(v) extern void _irq_disconnect(unsigned int irq);
#define RELEASE_VECTOR(v) _irq_disconnect(v)
#else #else
#error "Unknown target" #error "Unknown target"
#endif #endif

View file

@ -93,7 +93,9 @@ int initSwInterrupt(ptestIsr pIsrHdlr)
void setSwInterrupt(ptestIsr pIsrHdlr) void setSwInterrupt(ptestIsr pIsrHdlr)
{ {
irq_handler_set(vector, pcurrIsrFunc, pIsrHdlr, (void *)0); extern void _irq_handler_set(unsigned int irq, void (*old)(void *arg),
void (*new)(void *arg), void *arg);
_irq_handler_set(vector, pcurrIsrFunc, pIsrHdlr, (void *)0);
pcurrIsrFunc = pIsrHdlr; pcurrIsrFunc = pIsrHdlr;
} }

View file

@ -104,7 +104,7 @@ void main(void)
for (int ii = 0; ii < 3; ii++) { for (int ii = 0; ii < 3; ii++) {
irq_enable(ii); irq_enable(ii);
irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO); _irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO);
nano_sem_init(&sem[ii]); nano_sem_init(&sem[ii]);
} }