[rtems commit] bsps: Shared ARMv7-M interrupt support
Sebastian Huber
sebh at rtems.org
Sat Mar 24 21:50:51 UTC 2012
Module: rtems
Branch: master
Commit: bd0fb473c33949eb402914975a00a4c33f1f422d
Changeset: http://git.rtems.org/rtems/commit/?id=bd0fb473c33949eb402914975a00a4c33f1f422d
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Sat Mar 24 22:53:07 2012 +0100
bsps: Shared ARMv7-M interrupt support
---
c/src/lib/libbsp/arm/lm3s69xx/Makefile.am | 4 +-
c/src/lib/libbsp/arm/lm3s69xx/irq/irq.c | 47 ----------
c/src/lib/libbsp/arm/lm3s69xx/preinstall.am | 4 +
c/src/lib/libbsp/arm/lpc24xx/Makefile.am | 3 +
c/src/lib/libbsp/arm/lpc24xx/include/irq.h | 2 -
c/src/lib/libbsp/arm/lpc24xx/irq/irq-dispatch.c | 35 +++-----
c/src/lib/libbsp/arm/lpc24xx/irq/irq.c | 91 +++++++-------------
c/src/lib/libbsp/arm/lpc24xx/preinstall.am | 4 +
.../libbsp/arm/shared/armv7m/include/armv7m-irq.h | 28 ++++++
.../arm/shared/armv7m/irq/armv7m-irq-dispatch.c | 32 +++++++
.../lib/libbsp/arm/shared/armv7m/irq/armv7m-irq.c | 63 ++++++++++++++
11 files changed, 184 insertions(+), 129 deletions(-)
diff --git a/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am b/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
index 669e303..b6ff658 100644
--- a/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
+++ b/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
@@ -42,6 +42,7 @@ include_bsp_HEADERS += ../../shared/include/irq-info.h
include_bsp_HEADERS += ../../shared/include/stackalloc.h
include_bsp_HEADERS += ../../shared/tod.h
include_bsp_HEADERS += ../shared/include/start.h
+include_bsp_HEADERS += ../shared/armv7m/include/armv7m-irq.h
include_bsp_HEADERS += include/irq.h
include_bsp_HEADERS += include/uart.h
include_bsp_HEADERS += include/lm3s69xx.h
@@ -82,7 +83,8 @@ libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
libbsp_a_SOURCES += ../../shared/src/irq-server.c
libbsp_a_SOURCES += ../../shared/src/irq-shell.c
-libbsp_a_SOURCES += irq/irq.c
+libbsp_a_SOURCES += ../shared/armv7m/irq/armv7m-irq.c
+libbsp_a_SOURCES += ../shared/armv7m/irq/armv7m-irq-dispatch.c
# Console
libbsp_a_SOURCES += ../../shared/console.c
diff --git a/c/src/lib/libbsp/arm/lm3s69xx/irq/irq.c b/c/src/lib/libbsp/arm/lm3s69xx/irq/irq.c
deleted file mode 100644
index bb0d05b..0000000
--- a/c/src/lib/libbsp/arm/lm3s69xx/irq/irq.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011 Sebastian Huber. All rights reserved.
- *
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * 82178 Puchheim
- * Germany
- * <rtems at embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <string.h>
-
-#include <rtems/score/armv7m.h>
-
-#include <bsp.h>
-#include <bsp/irq.h>
-#include <bsp/irq-generic.h>
-#include <bsp/lm3s69xx.h>
-
-static __attribute__((aligned(128))) ARMV7M_Exception_handler
- lm3s69xx_vector_table [BSP_INTERRUPT_VECTOR_MAX + 1];
-
-void bsp_interrupt_dispatch(void)
-{
-}
-
-rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
-{
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
-{
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code bsp_interrupt_facility_initialize(void)
-{
- memcpy(&lm3s69xx_vector_table [0], (void *) 0, sizeof(lm3s69xx_vector_table));
- _ARMV7M_SCB->vtor = &lm3s69xx_vector_table [0];
-
- return RTEMS_SUCCESSFUL;
-}
diff --git a/c/src/lib/libbsp/arm/lm3s69xx/preinstall.am b/c/src/lib/libbsp/arm/lm3s69xx/preinstall.am
index 9cb64b1..d2fdfd2 100644
--- a/c/src/lib/libbsp/arm/lm3s69xx/preinstall.am
+++ b/c/src/lib/libbsp/arm/lm3s69xx/preinstall.am
@@ -89,6 +89,10 @@ $(PROJECT_INCLUDE)/bsp/start.h: ../shared/include/start.h $(PROJECT_INCLUDE)/bsp
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/start.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/start.h
+$(PROJECT_INCLUDE)/bsp/armv7m-irq.h: ../shared/armv7m/include/armv7m-irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/armv7m-irq.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/armv7m-irq.h
+
$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
diff --git a/c/src/lib/libbsp/arm/lpc24xx/Makefile.am b/c/src/lib/libbsp/arm/lpc24xx/Makefile.am
index da13c53..78cb766 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/Makefile.am
+++ b/c/src/lib/libbsp/arm/lpc24xx/Makefile.am
@@ -39,6 +39,7 @@ include_bsp_HEADERS += ../shared/lpc/include/lpc-i2s.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-emc.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-dma.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-lcd.h
+include_bsp_HEADERS += ../shared/armv7m/include/armv7m-irq.h
include_bsp_HEADERS += include/dma.h
include_bsp_HEADERS += include/i2c.h
include_bsp_HEADERS += include/io.h
@@ -112,6 +113,8 @@ libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
libbsp_a_SOURCES += ../../shared/src/irq-server.c
libbsp_a_SOURCES += ../../shared/src/irq-shell.c
+libbsp_a_SOURCES += ../shared/armv7m/irq/armv7m-irq.c
+libbsp_a_SOURCES += ../shared/armv7m/irq/armv7m-irq-dispatch.c
libbsp_a_SOURCES += irq/irq.c
libbsp_a_SOURCES += irq/irq-dispatch.c
diff --git a/c/src/lib/libbsp/arm/lpc24xx/include/irq.h b/c/src/lib/libbsp/arm/lpc24xx/include/irq.h
index 60fdb34..988d6e9 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/include/irq.h
+++ b/c/src/lib/libbsp/arm/lpc24xx/include/irq.h
@@ -133,8 +133,6 @@ void lpc24xx_irq_set_priority(rtems_vector_number vector, unsigned priority);
unsigned lpc24xx_irq_get_priority(rtems_vector_number vector);
-void bsp_interrupt_dispatch(void);
-
#endif /* ASM */
/** @} */
diff --git a/c/src/lib/libbsp/arm/lpc24xx/irq/irq-dispatch.c b/c/src/lib/libbsp/arm/lpc24xx/irq/irq-dispatch.c
index 94c346c..2f8a23c 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/irq/irq-dispatch.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/irq/irq-dispatch.c
@@ -20,36 +20,29 @@
* http://www.rtems.com/license/LICENSE.
*/
-#include <rtems/score/armv7m.h>
-
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/irq-generic.h>
#include <bsp/lpc24xx.h>
+#ifdef ARM_MULTILIB_ARCH_V4
+
void bsp_interrupt_dispatch(void)
{
- #ifdef ARM_MULTILIB_ARCH_V4
- /* Read current vector number */
- rtems_vector_number vector = VICVectAddr;
+ /* Read current vector number */
+ rtems_vector_number vector = VICVectAddr;
- /* Enable interrupts in program status register */
- uint32_t psr = arm_status_irq_enable();
+ /* Enable interrupts in program status register */
+ uint32_t psr = arm_status_irq_enable();
- /* Dispatch interrupt handlers */
- bsp_interrupt_handler_dispatch(vector);
+ /* Dispatch interrupt handlers */
+ bsp_interrupt_handler_dispatch(vector);
- /* Restore program status register */
- arm_status_restore(psr);
+ /* Restore program status register */
+ arm_status_restore(psr);
- /* Acknowledge interrupt */
- VICVectAddr = 0;
- #else
- rtems_vector_number vector =
- ARMV7M_SCB_ICSR_VECTACTIVE_GET(_ARMV7M_SCB->icsr);
-
- _ARMV7M_Interrupt_service_enter();
- bsp_interrupt_handler_dispatch(ARMV7M_IRQ_OF_VECTOR(vector));
- _ARMV7M_Interrupt_service_leave();
- #endif
+ /* Acknowledge interrupt */
+ VICVectAddr = 0;
}
+
+#endif /* ARM_MULTILIB_ARCH_V4 */
diff --git a/c/src/lib/libbsp/arm/lpc24xx/irq/irq.c b/c/src/lib/libbsp/arm/lpc24xx/irq/irq.c
index 3009e3f..f99ce46 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/irq/irq.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/irq/irq.c
@@ -61,86 +61,61 @@ unsigned lpc24xx_irq_get_priority(rtems_vector_number vector)
}
}
+#ifdef ARM_MULTILIB_ARCH_V4
+
rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
{
- #ifdef ARM_MULTILIB_ARCH_V4
- VICIntEnable = 1U << vector;
- #else
- _ARMV7M_NVIC_Set_enable((int) vector);
- #endif
+ VICIntEnable = 1U << vector;
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
{
- #ifdef ARM_MULTILIB_ARCH_V4
- VICIntEnClear = 1U << vector;
- #else
- _ARMV7M_NVIC_Clear_enable((int) vector);
- #endif
+ VICIntEnClear = 1U << vector;
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_facility_initialize(void)
{
- #ifdef ARM_MULTILIB_ARCH_V4
- volatile uint32_t *addr = VICVectAddrBase;
- volatile uint32_t *prio = VICVectPriorityBase;
- rtems_vector_number i = 0;
-
- /* Disable all interrupts */
- VICIntEnClear = 0xffffffff;
+ volatile uint32_t *addr = VICVectAddrBase;
+ volatile uint32_t *prio = VICVectPriorityBase;
+ rtems_vector_number i = 0;
- /* Clear all software interrupts */
- VICSoftIntClear = 0xffffffff;
+ /* Disable all interrupts */
+ VICIntEnClear = 0xffffffff;
- /* Use IRQ category */
- VICIntSelect = 0;
+ /* Clear all software interrupts */
+ VICSoftIntClear = 0xffffffff;
- for (i = BSP_INTERRUPT_VECTOR_MIN; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
- /* Use the vector address register to store the vector number */
- addr [i] = i;
+ /* Use IRQ category */
+ VICIntSelect = 0;
- /* Give vector lowest priority */
- prio [i] = 15;
- }
+ for (i = BSP_INTERRUPT_VECTOR_MIN; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+ /* Use the vector address register to store the vector number */
+ addr [i] = i;
- /* Reset priority mask register */
- VICSWPrioMask = 0xffff;
+ /* Give vector lowest priority */
+ prio [i] = 15;
+ }
- /* Acknowledge interrupts for all priorities */
- for (
- i = LPC24XX_IRQ_PRIORITY_VALUE_MIN;
- i <= LPC24XX_IRQ_PRIORITY_VALUE_MAX;
- ++i
- ) {
- VICVectAddr = 0;
- }
+ /* Reset priority mask register */
+ VICSWPrioMask = 0xffff;
- /* Install the IRQ exception handler */
- _CPU_ISR_install_vector(ARM_EXCEPTION_IRQ, arm_exc_interrupt, NULL);
- #else
- rtems_vector_number i = 0;
- ARMV7M_Exception_handler *vector_table =
- (ARMV7M_Exception_handler *) bsp_vector_table_begin;
-
- memcpy(
- vector_table,
- bsp_start_vector_table_begin,
- (size_t) bsp_vector_table_size
- );
-
- for (i = BSP_INTERRUPT_VECTOR_MIN; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
- vector_table [ARMV7M_VECTOR_IRQ(i)] = bsp_interrupt_dispatch;
- _ARMV7M_NVIC_Clear_enable(i);
- _ARMV7M_NVIC_Clear_pending(i);
- lpc24xx_irq_set_priority(i, LPC24XX_IRQ_PRIORITY_VALUE_MAX - 1);
- }
+ /* Acknowledge interrupts for all priorities */
+ for (
+ i = LPC24XX_IRQ_PRIORITY_VALUE_MIN;
+ i <= LPC24XX_IRQ_PRIORITY_VALUE_MAX;
+ ++i
+ ) {
+ VICVectAddr = 0;
+ }
- _ARMV7M_SCB->vtor = vector_table;
- #endif
+ /* Install the IRQ exception handler */
+ _CPU_ISR_install_vector(ARM_EXCEPTION_IRQ, arm_exc_interrupt, NULL);
return RTEMS_SUCCESSFUL;
}
+
+#endif /* ARM_MULTILIB_ARCH_V4 */
diff --git a/c/src/lib/libbsp/arm/lpc24xx/preinstall.am b/c/src/lib/libbsp/arm/lpc24xx/preinstall.am
index a9ddc4d..a65f0fa 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/preinstall.am
+++ b/c/src/lib/libbsp/arm/lpc24xx/preinstall.am
@@ -101,6 +101,10 @@ $(PROJECT_INCLUDE)/bsp/lpc-lcd.h: ../shared/lpc/include/lpc-lcd.h $(PROJECT_INCL
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc-lcd.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc-lcd.h
+$(PROJECT_INCLUDE)/bsp/armv7m-irq.h: ../shared/armv7m/include/armv7m-irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/armv7m-irq.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/armv7m-irq.h
+
$(PROJECT_INCLUDE)/bsp/dma.h: include/dma.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/dma.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/dma.h
diff --git a/c/src/lib/libbsp/arm/shared/armv7m/include/armv7m-irq.h b/c/src/lib/libbsp/arm/shared/armv7m/include/armv7m-irq.h
new file mode 100644
index 0000000..80af772
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/armv7m/include/armv7m-irq.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012 Sebastian Huber. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef LIBBSP_ARM_SHARED_ARMV7M_IRQ_H
+#define LIBBSP_ARM_SHARED_ARMV7M_IRQ_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void _ARMV7M_NVIC_Interrupt_dispatch(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LIBBSP_ARM_SHARED_ARMV7M_IRQ_H */
diff --git a/c/src/lib/libbsp/arm/shared/armv7m/irq/armv7m-irq-dispatch.c b/c/src/lib/libbsp/arm/shared/armv7m/irq/armv7m-irq-dispatch.c
new file mode 100644
index 0000000..c183d3c
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/armv7m/irq/armv7m-irq-dispatch.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011-2012 Sebastian Huber. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/score/armv7m.h>
+
+#include <bsp/irq-generic.h>
+#include <bsp/armv7m-irq.h>
+
+#ifdef ARM_MULTILIB_ARCH_V7M
+
+void _ARMV7M_NVIC_Interrupt_dispatch(void)
+{
+ rtems_vector_number vector =
+ ARMV7M_SCB_ICSR_VECTACTIVE_GET(_ARMV7M_SCB->icsr);
+
+ _ARMV7M_Interrupt_service_enter();
+ bsp_interrupt_handler_dispatch(ARMV7M_IRQ_OF_VECTOR(vector));
+ _ARMV7M_Interrupt_service_leave();
+}
+
+#endif /* ARM_MULTILIB_ARCH_V7M */
diff --git a/c/src/lib/libbsp/arm/shared/armv7m/irq/armv7m-irq.c b/c/src/lib/libbsp/arm/shared/armv7m/irq/armv7m-irq.c
new file mode 100644
index 0000000..901034c
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/armv7m/irq/armv7m-irq.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011-2012 Sebastian Huber. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/score/armv7m.h>
+
+#include <bsp.h>
+#include <bsp/irq.h>
+#include <bsp/irq-generic.h>
+#include <bsp/linker-symbols.h>
+#include <bsp/armv7m-irq.h>
+
+#ifdef ARM_MULTILIB_ARCH_V7M
+
+rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
+{
+ _ARMV7M_NVIC_Set_enable((int) vector);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
+{
+ _ARMV7M_NVIC_Clear_enable((int) vector);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code bsp_interrupt_facility_initialize(void)
+{
+ int i;
+ ARMV7M_Exception_handler *vector_table =
+ (ARMV7M_Exception_handler *) bsp_vector_table_begin;
+
+ memcpy(
+ vector_table,
+ bsp_start_vector_table_begin,
+ (size_t) bsp_vector_table_size
+ );
+
+ for (i = BSP_INTERRUPT_VECTOR_MIN; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+ vector_table [ARMV7M_VECTOR_IRQ(i)] = _ARMV7M_NVIC_Interrupt_dispatch;
+ _ARMV7M_NVIC_Clear_enable(i);
+ _ARMV7M_NVIC_Clear_pending(i);
+ _ARMV7M_NVIC_Set_priority(i, ARMV7M_EXCEPTION_PRIORITY_LOWEST);
+ }
+
+ _ARMV7M_SCB->vtor = vector_table;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+#endif /* ARM_MULTILIB_ARCH_V7M */
More information about the vc
mailing list