[PATCH] Updating legacy code in arm nds
Vipul Nayyar
nayyar_vipul at yahoo.com
Sun Aug 18 14:34:51 UTC 2013
---
c/src/lib/libbsp/arm/gba/irq/irq.h | 2 +
c/src/lib/libbsp/arm/nds/Makefile.am | 14 +++++
c/src/lib/libbsp/arm/nds/clock/clock.c | 40 ++++++++-------
c/src/lib/libbsp/arm/nds/include/bsp.h | 5 ++
c/src/lib/libbsp/arm/nds/include/irq.h | 21 ++++++++
c/src/lib/libbsp/arm/nds/irq/irq.c | 59 ++++++++++++++++++++++
.../nds/libnds/source/common/interruptDispatcher.S | 45 ++---------------
c/src/lib/libbsp/arm/nds/preinstall.am | 12 +++++
c/src/lib/libbsp/arm/nds/startup/bspstart.c | 3 +-
9 files changed, 142 insertions(+), 59 deletions(-)
create mode 100644 c/src/lib/libbsp/arm/nds/include/irq.h
diff --git a/c/src/lib/libbsp/arm/gba/irq/irq.h b/c/src/lib/libbsp/arm/gba/irq/irq.h
index d0c841f..224cf9b 100644
--- a/c/src/lib/libbsp/arm/gba/irq/irq.h
+++ b/c/src/lib/libbsp/arm/gba/irq/irq.h
@@ -61,4 +61,6 @@
#define BSP_INTERRUPT_VECTOR_MAX (BSP_MAX_INT - 1)
+void bsp_interrupt_dispatch();
+
#endif /* _IRQ_H_ */
diff --git a/c/src/lib/libbsp/arm/nds/Makefile.am b/c/src/lib/libbsp/arm/nds/Makefile.am
index 2776974..6de2601 100644
--- a/c/src/lib/libbsp/arm/nds/Makefile.am
+++ b/c/src/lib/libbsp/arm/nds/Makefile.am
@@ -54,6 +54,20 @@ rtc_rel_SOURCES = rtc/rtc.c ../../shared/tod.c
rtc_rel_CPPFLAGS = $(AM_CPPFLAGS) -DARM9 -I$(srcdir)/libnds/include
rtc_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+include_bsp_HEADERS = ../../shared/include/irq-generic.h
+include_bsp_HEADERS += ../../shared/include/irq-info.h
+include_bsp_HEADERS += include/irq.h
+
+libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
+libbsp_a_SOURCES += ../../shared/src/irq-generic.c
+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_CPPFLAGS = $(AM_CPPFLAGS) -DARM9 -I$(srcdir)/libnds/include -I$(srcdir)/include
+libbsp_a_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
noinst_PROGRAMS += console.rel
console_rel_SOURCES = console/console.c
console_rel_CPPFLAGS = $(AM_CPPFLAGS) -DARM9 -I$(srcdir)/libnds/include -I$(srcdir)/include
diff --git a/c/src/lib/libbsp/arm/nds/clock/clock.c b/c/src/lib/libbsp/arm/nds/clock/clock.c
index b263e55..5e37941 100644
--- a/c/src/lib/libbsp/arm/nds/clock/clock.c
+++ b/c/src/lib/libbsp/arm/nds/clock/clock.c
@@ -14,13 +14,15 @@
#include <rtems.h>
#include <bsp.h>
+#include <bsp/irq.h>
#include <rtems/irq.h>
#include <nds.h>
+#include <assert.h>
/*
* forward declaration for clock isr in clockdrv_shell.h
*/
-void Clock_isr(rtems_irq_hdl_param arg);
+void Clock_isr(void * arg);
/*
* forward declarations for methods in this file
@@ -28,18 +30,6 @@ void Clock_isr(rtems_irq_hdl_param arg);
void Clock_driver_support_shutdown_hardware (void);
void Clock_driver_support_initialize_hardware (void);
-/*
- * isr registration variables.
- */
-static rtems_irq_connect_data clock_isr_data = {
- .name = IRQ_TIMER0,
- .hdl = Clock_isr,
- .handle = NULL,
- .on = NULL,
- .off = NULL,
- .isOn = NULL,
-};
-
void update_touchscreen (void);
/*
@@ -53,9 +43,17 @@ void update_touchscreen (void);
* install isr for clock driver.
*/
#define Clock_driver_support_install_isr( _new, _old ) \
- do { \
- _old = NULL; \
- BSP_install_rtems_irq_handler(&clock_isr_data); \
+ do { \
+ rtems_status_code status = RTEMS_SUCCESSFUL; \
+ _old = NULL; \
+ status = rtems_interrupt_handler_install( \
+ IRQ_TIMER0, \
+ "Clock", \
+ RTEMS_INTERRUPT_UNIQUE, \
+ Clock_isr, \
+ NULL \
+ ); \
+ assert(status == RTEMS_SUCCESSFUL); \
} while (0)
/*
@@ -63,7 +61,15 @@ void update_touchscreen (void);
*/
void Clock_driver_support_shutdown_hardware (void)
{
- BSP_remove_rtems_irq_handler (&clock_isr_data);
+ rtems_status_code status = RTEMS_SUCCESSFUL;
+
+ status = rtems_interrupt_handler_remove(
+ IRQ_TIMER0,
+ Clock_isr,
+ NULL
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+
TIMER_CR (0) &= ~(TIMER_ENABLE);
}
diff --git a/c/src/lib/libbsp/arm/nds/include/bsp.h b/c/src/lib/libbsp/arm/nds/include/bsp.h
index 3565841..3b20be2 100644
--- a/c/src/lib/libbsp/arm/nds/include/bsp.h
+++ b/c/src/lib/libbsp/arm/nds/include/bsp.h
@@ -23,6 +23,11 @@ extern "C"
#include <rtems/console.h>
#include <rtems/clockdrv.h>
+#define BSP_FEATURE_IRQ_EXTENSION
+
+#define ARM9
+//#define ARM7
+
struct rtems_bsdnet_ifconfig;
int
diff --git a/c/src/lib/libbsp/arm/nds/include/irq.h b/c/src/lib/libbsp/arm/nds/include/irq.h
new file mode 100644
index 0000000..dff89b0
--- /dev/null
+++ b/c/src/lib/libbsp/arm/nds/include/irq.h
@@ -0,0 +1,21 @@
+/**
+ * @file
+ *
+ * @ingroup bsp_interrupt
+ *
+ * @brief Nintendo DS Interrupt definitions.
+ */
+
+#ifndef LIBBSP_ARM_NDS_IRQ_H
+#define LIBBSP_ARM_NDS_IRQ_H
+
+#ifndef ASM
+ #include <rtems.h>
+ #include <rtems/irq.h>
+ #include <rtems/irq-extension.h>
+#endif
+
+#define BSP_INTERRUPT_VECTOR_MIN 0
+#define BSP_INTERRUPT_VECTOR_MAX 25
+
+#endif /* LIBBSP_ARM_NDS_IRQ_H */
diff --git a/c/src/lib/libbsp/arm/nds/irq/irq.c b/c/src/lib/libbsp/arm/nds/irq/irq.c
index 1ffcd4d..e29cac7 100644
--- a/c/src/lib/libbsp/arm/nds/irq/irq.c
+++ b/c/src/lib/libbsp/arm/nds/irq/irq.c
@@ -9,10 +9,69 @@
* http://www.rtems.com/license/LICENSE
*/
+#include <rtems/score/armv4.h>
+#include <rtems/score/armv7m.h>
+
#include <bsp.h>
#include <rtems/irq.h>
#include <nds.h>
+#include <bsp/irq.h>
+#include <bsp/irq-generic.h>
+
+void IntrMain(void); // Prototype for assembly interrupt dispatcher
+
+
+rtems_status_code bsp_interrupt_facility_initialize(void)
+{
+ /* disable all interrupts */
+ REG_IE = 0; // disable all interrupts
+ REG_IF = IRQ_ALL; // clear all pending interrupts
+ REG_IME = 1; // enable global interrupt
+
+ IRQ_HANDLER = IntrMain;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+void bsp_interrupt_handler_default(rtems_vector_number vector)
+{
+ printk("spurious interrupt: %u\n", vector);
+}
+void bsp_interrupt_dispatch(void)
+{
+ unsigned reg_ie = REG_IE;
+ unsigned reg_if = REG_IF & reg_ie;
+
+ rtems_vector_number vector = (*(vuint16*)0x04000208);
+ // not sure how to use reg_if here.
+
+ bsp_interrupt_handler_dispatch(vector);
+}
+
+rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector){
+ if (vector & IRQ_VBLANK)
+ REG_DISPSTAT |= DISP_VBLANK_IRQ ;
+ if (vector & IRQ_HBLANK)
+ REG_DISPSTAT |= DISP_HBLANK_IRQ ;
+ if (vector & IRQ_VCOUNT)
+ REG_DISPSTAT |= DISP_YTRIGGER_IRQ;
+
+ REG_IE |= vector;
+ REG_IME = 1;
+}
+
+rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector){
+
+ if (vector & IRQ_VBLANK)
+ REG_DISPSTAT &= ~DISP_VBLANK_IRQ ;
+ if (vector & IRQ_HBLANK)
+ REG_DISPSTAT &= ~DISP_HBLANK_IRQ ;
+ if (vector & IRQ_VCOUNT)
+ REG_DISPSTAT &= ~DISP_YTRIGGER_IRQ;
+
+ REG_IE &= ~vector;
+}
/*
* this function check that the value given for the irq line is valid.
*/
diff --git a/c/src/lib/libbsp/arm/nds/libnds/source/common/interruptDispatcher.S b/c/src/lib/libbsp/arm/nds/libnds/source/common/interruptDispatcher.S
index 927fa74..f1a651d 100644
--- a/c/src/lib/libbsp/arm/nds/libnds/source/common/interruptDispatcher.S
+++ b/c/src/lib/libbsp/arm/nds/libnds/source/common/interruptDispatcher.S
@@ -29,9 +29,9 @@
.section .bsp_fast_text,"ax",%progbits
#endif
- .extern irqTable
- .code 32
+ .extern bsp_interrupt_dispatch
+ .code 32
.global IntrMain
@---------------------------------------------------------------------------------
IntrMain:
@@ -43,44 +43,12 @@ IntrMain:
mrs r0, spsr
stmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
- ldr r1, [r3,#0x210] @ REG_IE
- ldr r2, [r3,#0x214] @ REG_IF
- and r1,r1,r2
-
ldr r0,=__irq_flags @ defined by linker script
ldr r2,[r0]
orr r2,r2,r1
str r2,[r0]
- ldr r2,=irqTable
- at ---------------------------------------------------------------------------------
-findIRQ:
- at ---------------------------------------------------------------------------------
- ldr r0, [r2, #4]
- cmp r0,#0
- beq no_handler
- ands r0, r0, r1
- bne jump_intr
- add r2, r2, #8
- b findIRQ
-
- at ---------------------------------------------------------------------------------
-no_handler:
- at ---------------------------------------------------------------------------------
- str r1, [r3, #0x0214] @ IF Clear
- ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
- str r1, [r3, #0x208] @ restore REG_IME
- mov pc,lr
-
- at ---------------------------------------------------------------------------------
-jump_intr:
- at ---------------------------------------------------------------------------------
- ldr r1, [r2] @ user IRQ handler address
- cmp r1, #0
- bne got_handler
- mov r1, r0
- b no_handler
@---------------------------------------------------------------------------------
got_handler:
@---------------------------------------------------------------------------------
@@ -90,18 +58,13 @@ got_handler:
orr r2, r2, #0x1f @ / --> Enable IRQ & FIQ. Set CPU mode to System.
msr cpsr,r2
- str r0, [r3, #0x0214] @ IF Clear
+ str r0, [r3, #0x0214] @ IF Clear
- push {lr}
- adr lr, IntrRet
- bx r1
+ b bsp_interrupt_dispatch
@---------------------------------------------------------------------------------
IntrRet:
@---------------------------------------------------------------------------------
- mov r3, #0x4000000 @ REG_BASE
- str r3, [r3, #0x208] @ disable IME
- pop {lr}
mrs r3, cpsr
bic r3, r3, #0xdf @ \__
diff --git a/c/src/lib/libbsp/arm/nds/preinstall.am b/c/src/lib/libbsp/arm/nds/preinstall.am
index e0555de..e36d648 100644
--- a/c/src/lib/libbsp/arm/nds/preinstall.am
+++ b/c/src/lib/libbsp/arm/nds/preinstall.am
@@ -78,6 +78,18 @@ $(PROJECT_INCLUDE)/nds/sound.h: sound/sound.h $(PROJECT_INCLUDE)/nds/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/nds/sound.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/nds/sound.h
+$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
+
+$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.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
+
$(PROJECT_INCLUDE)/libnds/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/libnds
@: > $(PROJECT_INCLUDE)/libnds/$(dirstamp)
diff --git a/c/src/lib/libbsp/arm/nds/startup/bspstart.c b/c/src/lib/libbsp/arm/nds/startup/bspstart.c
index b57d758..1914aec 100644
--- a/c/src/lib/libbsp/arm/nds/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/nds/startup/bspstart.c
@@ -23,7 +23,8 @@ extern void BSP_rtems_irq_mngt_init (void);
void bsp_start (void)
{
/* initialize irq management */
- BSP_rtems_irq_mngt_init ();
+ bsp_interrupt_initialize();
+ REG_IME = IME_ENABLE;
/* setup console mode for lower screen */
irqEnable (IRQ_VBLANK);
--
1.7.11.7
More information about the devel
mailing list