From 2eb9e3995c6ff0a76cf857d1032c79cf08ebbd30 Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Fri, 30 Nov 2007 21:40:12 +0000 Subject: 2007-11-30 Till Straumann * shared/irq/irq.h, shared/irq/irq.c, shared/irq/irq_init.c, shared/irq/irq_supp.h (added): Removed 'is_processor_irq()' from irq.c; the BSP routines BSP_enable_irq_at_pic()/BSP_disable_irq_at_pic() are required to ignore processor irqs anyways. Removed all BSP-defined constants from irq.c. This makes irq.c (almost) binary-compatible among BSPs (ultimate goal is making 'shared' a library). Added a header (irq_supp.h) defining the interface between the generic interrupt manager (irq.c) and the routines it requires to be supplied by the BSP (eventually, these should go into rtems/irq.h). --- c/src/lib/libbsp/powerpc/ChangeLog | 15 ++++++ c/src/lib/libbsp/powerpc/shared/irq/irq.c | 60 +++++++++------------- c/src/lib/libbsp/powerpc/shared/irq/irq.h | 9 +--- c/src/lib/libbsp/powerpc/shared/irq/irq_init.c | 1 + c/src/lib/libbsp/powerpc/shared/irq/irq_supp.h | 42 +++++++++++++++ .../libbsp/powerpc/shared/irq/openpic_i8259_irq.c | 1 + 6 files changed, 85 insertions(+), 43 deletions(-) create mode 100644 c/src/lib/libbsp/powerpc/shared/irq/irq_supp.h diff --git a/c/src/lib/libbsp/powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/ChangeLog index 31c19cea1a..d0bcef647f 100644 --- a/c/src/lib/libbsp/powerpc/ChangeLog +++ b/c/src/lib/libbsp/powerpc/ChangeLog @@ -1,3 +1,18 @@ +2007-11-30 Till Straumann + + * shared/irq/irq.h, shared/irq/irq.c, shared/irq/irq_init.c, + shared/irq/irq_supp.h (added): + Removed 'is_processor_irq()' from irq.c; the BSP routines + BSP_enable_irq_at_pic()/BSP_disable_irq_at_pic() are required + to ignore processor irqs anyways. Removed + all BSP-defined constants from irq.c. This makes irq.c (almost) + binary-compatible among BSPs (ultimate goal is making 'shared' + a library). + Added a header (irq_supp.h) defining the interface between + the generic interrupt manager (irq.c) and the routines it + requires to be supplied by the BSP (eventually, these + should go into rtems/irq.h). + 2007-11-30 Till Straumann * shared/irq/irq.h, shared/irq/irq_init.c: Removed the definition diff --git a/c/src/lib/libbsp/powerpc/shared/irq/irq.c b/c/src/lib/libbsp/powerpc/shared/irq/irq.c index 02646175fc..b5d1332658 100644 --- a/c/src/lib/libbsp/powerpc/shared/irq/irq.c +++ b/c/src/lib/libbsp/powerpc/shared/irq/irq.c @@ -13,8 +13,8 @@ #include -#include -#include +#include +#include #include /* for post ISR signal processing */ #include #include @@ -39,17 +39,6 @@ static rtems_irq_connect_data default_rtems_entry; static rtems_irq_global_settings* internal_config; static rtems_irq_connect_data* rtems_hdl_tbl; -/* - * Check if IRQ is a Processor IRQ - */ -static inline int is_processor_irq(const rtems_irq_number irqLine) -{ - return (((int) irqLine <= BSP_PROCESSOR_IRQ_MAX_OFFSET) & - ((int) irqLine >= BSP_PROCESSOR_IRQ_LOWEST_OFFSET) - ); -} - - /* * ------------------------ RTEMS Irq helper functions ---------------- */ @@ -61,7 +50,7 @@ static inline int is_processor_irq(const rtems_irq_number irqLine) static int isValidInterrupt(int irq) { - if ( (irq < BSP_LOWEST_OFFSET) || (irq > BSP_MAX_OFFSET)) + if ( (irq < internal_config->irqBase) || (irq >= internal_config->irqBase + internal_config->irqNb)) return 0; return 1; } @@ -100,13 +89,13 @@ int BSP_install_rtems_shared_irq_handler (const rtems_irq_connect_data* irq) /* link chain to new topmost handler */ rtems_hdl_tbl[irq->name].next_handler = (void *)vchain; - if (is_processor_irq(irq->name)) { - /* - * Enable exception at processor level - */ - } else { - BSP_enable_irq_at_pic(irq->name); - } + /* + * enable_irq_at_pic is supposed to ignore + * requests to disable interrupts outside + * of the range handled by the PIC + */ + BSP_enable_irq_at_pic(irq->name); + /* * Enable interrupt on device */ @@ -150,13 +139,13 @@ int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq) rtems_hdl_tbl[irq->name] = *irq; rtems_hdl_tbl[irq->name].next_handler = (void *)-1; - if (is_processor_irq(irq->name)) { - /* - * Enable exception at processor level - */ - } else { - BSP_enable_irq_at_pic(irq->name); - } + /* + * enable_irq_at_pic is supposed to ignore + * requests to disable interrupts outside + * of the range handled by the PIC + */ + BSP_enable_irq_at_pic(irq->name); + /* * Enable interrupt on device */ @@ -231,13 +220,12 @@ int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq) } } - if (is_processor_irq(irq->name)) { - /* - * disable exception at processor level - */ - } else { - BSP_disable_irq_at_pic(irq->name); - } + /* + * disable_irq_at_pic is supposed to ignore + * requests to disable interrupts outside + * of the range handled by the PIC + */ + BSP_disable_irq_at_pic(irq->name); /* * Disable interrupt on device @@ -301,7 +289,7 @@ int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config) return 0; } - for ( i = BSP_LOWEST_OFFSET; i <= BSP_MAX_OFFSET; i++ ) { + for ( i = config->irqBase; i < config->irqBase + config->irqNb; i++ ) { for( vchain = &rtems_hdl_tbl[i]; ((int)vchain != -1 && vchain->hdl != default_rtems_entry.hdl); vchain = (rtems_irq_connect_data*)vchain->next_handler ) diff --git a/c/src/lib/libbsp/powerpc/shared/irq/irq.h b/c/src/lib/libbsp/powerpc/shared/irq/irq.h index b1f3d26047..78ac3b7def 100644 --- a/c/src/lib/libbsp/powerpc/shared/irq/irq.h +++ b/c/src/lib/libbsp/powerpc/shared/irq/irq.h @@ -181,14 +181,9 @@ int BSP_irq_enabled_at_i8259s (const rtems_irq_number irqLine); extern void BSP_rtems_irq_mng_init(unsigned cpuId); extern void BSP_i8259s_init(void); -/* - * PIC-independent function to enable/disable interrupt lines at - * the pic. - */ -extern void BSP_enable_irq_at_pic (const rtems_irq_number irqLine); -extern void BSP_disable_irq_at_pic (const rtems_irq_number irqLine); +/* Stuff in irq_supp.h should eventually go into */ +#include -extern int BSP_setup_the_pic (rtems_irq_global_settings* config); #ifdef __cplusplus }; #endif diff --git a/c/src/lib/libbsp/powerpc/shared/irq/irq_init.c b/c/src/lib/libbsp/powerpc/shared/irq/irq_init.c index 559ee68012..4ba7d6bf2f 100644 --- a/c/src/lib/libbsp/powerpc/shared/irq/irq_init.c +++ b/c/src/lib/libbsp/powerpc/shared/irq/irq_init.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/c/src/lib/libbsp/powerpc/shared/irq/irq_supp.h b/c/src/lib/libbsp/powerpc/shared/irq/irq_supp.h new file mode 100644 index 0000000000..3359869920 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/shared/irq/irq_supp.h @@ -0,0 +1,42 @@ +#ifndef IRQ_SHARED_IRQ_C_GLUE_H +#define IRQ_SHARED_IRQ_C_GLUE_H +/* + * This header describes the routines that are needed by the shared + * version of 'irq.c' (implementing the RTEMS irq API). They + * must be provided by the BSP. + * + * The license and distribution terms for this file may be + * found in found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * PIC-independent functions to enable/disable interrupt lines at + * the pic. + * + * NOTE: the routines must ignore requests for enabling/disabling + * interrupts that are outside of the range handled by the + * PIC(s). + */ +extern void BSP_enable_irq_at_pic (const rtems_irq_number irqLine); +extern void BSP_disable_irq_at_pic (const rtems_irq_number irqLine); + +/* + * Initialize the PIC. + * Return nonzero on success, zero on failure (which will be treated + * as fatal by the manager). + */ +extern int BSP_setup_the_pic (rtems_irq_global_settings* config); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/c/src/lib/libbsp/powerpc/shared/irq/openpic_i8259_irq.c b/c/src/lib/libbsp/powerpc/shared/irq/openpic_i8259_irq.c index 5f8941df55..041c404066 100644 --- a/c/src/lib/libbsp/powerpc/shared/irq/openpic_i8259_irq.c +++ b/c/src/lib/libbsp/powerpc/shared/irq/openpic_i8259_irq.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include -- cgit v1.2.3