X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Fat91%2Fsysirq.c;h=fc9f687fc188ddd002de35d75d4f39bf1913bf21;hb=5f3952176a4e9a00ca8dd5ec4a6b994958f89e0a;hp=b018cd620c8255cede2526cb68b4218dcce694e3;hpb=338e860b340dd66f9f6ec92e692a7aa116b0d6a8;p=bertos.git diff --git a/drv/at91/sysirq.c b/drv/at91/sysirq.c old mode 100755 new mode 100644 index b018cd62..fc9f687f --- a/drv/at91/sysirq.c +++ b/drv/at91/sysirq.c @@ -9,19 +9,19 @@ * * \author Francesco Sacchi * - * \brief System irq handler for Atmel AT91 ARM7 processors. + * \brief System IRQ handler for Atmel AT91 ARM7 processors. * * In Atmel AT91 ARM7TDMI processors, there are various * peripheral interrupt sources. * In general, every source has its own interrupt vector, so it * is possible to assign a specific handler for each interrupt - * indipendently. + * independently. * However, there are a few sources called "system sources" that - * share a common IRQ line and vector, called "system irq". - * So a unic system irq handler is implemented here. + * share a common IRQ line and vector, called "system IRQ". + * So a unique system IRQ handler is implemented here. * This module also contains an interface to manage every source - * indipendently. It is possible to assign to every system irq - * a specific irq handler. + * independently. It is possible to assign to every system IRQ + * a specific IRQ handler. * * \see sysirq_setHandler * \see sysirq_setEnable @@ -33,30 +33,11 @@ #warning Very untested! -/** - * Returns the state of the Periodic Interval Timer - * interrupt. - */ -static bool pit_enable(void) -{ - return PIT_MR & BV(PITIEN); -} - -/** - * Returns the state of the Periodic Interval Timer - * interrupt. - * \return true is PIT has triggered and interrupt, false otherwise - */ -static bool pit_trigger(void) -{ - return PIT_SR & BV(PITS); -} - /** * Enable/disable the Periodic Interrupt Timer * interrupt. */ -static void pit_setEnable(bool enable) +INLINE static void pit_setEnable(bool enable) { if (enable) PIT_MR |= BV(PITIEN); @@ -71,8 +52,7 @@ static SysIrq sysirq_tab[] = { /* PIT, Periodic Interval Timer (System timer)*/ { - .enable = pit_enable, - .trigger = pit_trigger, + .enabled = false, .setEnable = pit_setEnable, .handler = NULL, }, @@ -83,19 +63,18 @@ STATIC_ASSERT(countof(sysirq_tab) == SYSIRQ_CNT); /** - * System IRQ handler. + * System IRQ dispatcher. * This is the entry point for all system IRQs in AT91. * This function checks for interrupt enable state of * various sources (system timer, etc..) and calls * the corresponding handler. */ -static void sysirq_handler(void) +static void sysirq_dispatcher(void) { #warning TODO add IRQ prologue/epilogue for (int i = 0; i < countof(sysirq_tab); i++) { - if (sysirq_tab[i].enable() - && sysirq_tab[i].trigger() + if (sysirq_tab[i].enabled && sysirq_tab[i].handler) sysirq_tab[i].handler(); } @@ -103,8 +82,11 @@ static void sysirq_handler(void) #define SYSIRQ_PRIORITY 0 ///< default priority for system irqs. + +MOD_DEFINE(sysirq); + /** - * Init system irq handling. + * Init system IRQ handling. * \note all system interrupts are disabled. */ void sysirq_init(void) @@ -117,17 +99,19 @@ void sysirq_init(void) sysirq_tab[i].setEnable(false); /* Set the vector. */ - AIC_SVR(SYSC_ID) = sysirq_handler; - /* Initialize to edge triggered with defined priority. */ - AIC_SMR(SYSC_ID) = BV(AIC_SRCTYPE_INT_EDGE_TRIGGERED) | SYSIRQ_PRIORITY; - /* Clear interrupt */ - AIC_ICCR = BV(SYSC_ID); + AIC_SVR(SYSC_ID) = sysirq_handler; + /* Initialize to edge triggered with defined priority. */ + AIC_SMR(SYSC_ID) = BV(AIC_SRCTYPE_INT_EDGE_TRIGGERED) | SYSIRQ_PRIORITY; + /* Clear interrupt */ + AIC_ICCR = BV(SYSC_ID); + IRQ_RESTORE(flags); + MOD_INIT(sysirq); } /** - * Helper function used to set handler for system irq \a irq. + * Helper function used to set handler for system IRQ \a irq. */ void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler) { @@ -137,21 +121,23 @@ void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler) } /** - * Helper function used to enable/disable system irq \a irq. + * Helper function used to enable/disable system IRQ \a irq. */ void sysirq_setEnable(sysirq_t irq, bool enable) { ASSERT(irq >= 0); ASSERT(irq < SYSIRQ_CNT); + sysirq_tab[irq].setEnable(enable); + sysirq_enabled = enable; } /** - * Helper function used to get system irq \a irq state. + * Helper function used to get system IRQ \a irq state. */ -bool sysirq_enable(sysirq_t irq) +bool sysirq_enabled(sysirq_t irq) { ASSERT(irq >= 0); ASSERT(irq < SYSIRQ_CNT); - return sysirq_tab[irq].enable(); + return sysirq_tab[irq].enabled; }