#include <cfg/log.h> /* LOG_ERR() */
#include <cpu/irq.h>
+
+#ifdef __IAR_SYSTEMS_ICC__
+#pragma data_alignment=0x400
+static void (*irq_table[NUM_INTERRUPTS])(void);
+#else
static void (*irq_table[NUM_INTERRUPTS])(void)
__attribute__((section("vtable")));
+#endif
/* Priority register / IRQ number table */
static const uint32_t nvic_prio_reg[] =
{
register uint32_t reg;
+#ifdef __IAR_SYSTEMS_ICC__
+ reg = CPU_READ_IPSR();
+#else
asm volatile ("mrs %0, ipsr" : "=r"(reg));
+#endif
LOG_ERR("unhandled IRQ %lu\n", reg);
while (1)
PAUSE;
#include <cfg/cfg_debug.h>
#include <cfg/macros.h> /* for BV() */
+#include <cpu/types.h>
+
#include <io/sam3.h>
--- /dev/null
+ MODULE ?cstartup
+
+CONTROL_UNPRIVILEGED SET 1
+CONTROL_PSP SET 2
+
+ AAPCS INTERWORK, VFP_COMPATIBLE, ROPI
+ PRESERVE8
+
+ SECTION .vtable:CODE:NOROOT(3)
+
+ RSEG IRQ_STACK:DATA(3)
+ RSEG CSTACK:DATA(3)
+ RSEG DATABSS:DATA(3)
+
+ EXTERN __cmain
+ EXTERN __init2
+ EXTERN __region_RAM_end__
+ PUBLIC __iar_program_start
+
+ SECTION .text:CODE:REORDER(2)
+
+ PUBWEAK __dummy_init
+ __dummy_init:
+ bx lr
+
+ THUMB
+ __iar_program_start:
+ cpsid i
+ ldr r0, =__region_RAM_end__
+ sub r0, r0, #16
+ msr psp, r0
+
+ movs r0, #CONTROL_PSP
+ msr control, r0
+ isb
+
+ bl __init2
+
+ cpsie i
+ mov r0, #0
+ mov r1, #0
+ bl __cmain
+ end:
+ wfi
+ b end
+
+ END
--- /dev/null
+ SECTION .text:CODE(2)
+
+ ; Exported functions
+ EXPORT CPU_READ_IPSR
+ EXPORT irq_running
+ EXPORT asm_switch_context
+
+ CPU_READ_IPSR:
+ mrs r0, ipsr
+ bx lr
+
+ irq_running:
+ mrs r0, msp
+ cmp sp, r0
+ ite ne
+ movne r0, #0x0
+ moveq r0, #0x1
+ bx lr
+
+ asm_switch_context:
+ mrs r12, psp
+ stmdb r12!, {r4-r11, lr}
+ str r12, [r1]
+ ldr r12, [r0]
+ ldmia r12!, {r4-r11, lr}
+ msr psp, r12
+ bx lr
+ END
#include <io/cm3.h>
+#ifndef __IAR_SYSTEMS_ICC__
extern size_t __text_end, __data_start, __data_end, __bss_start, __bss_end;
+#endif
extern void __init2(void);
: "memory");
}
#else /* !CONFIG_KERN_PREEMPT */
+#ifdef __IAR_SYSTEMS_ICC__
+#else /* __IAR_SYSTEMS_ICC__ */
void NAKED asm_switch_context(cpu_stack_t **new_sp, cpu_stack_t **old_sp)
{
register cpu_stack_t **_new_sp asm("r0") = new_sp;
"bx lr"
: : "r"(_new_sp), "r"(_old_sp) : "ip", "memory");
}
+#endif /* __IAR_SYSTEMS_ICC__ */
#endif /* CONFIG_KERN_PREEMPT */
--- /dev/null
+ MODULE ?vectors
+
+ AAPCS INTERWORK, VFP_COMPATIBLE, RWPI_COMPATIBLE
+ PRESERVE8
+
+ SECTION IRQSTACK:DATA:NOROOT(3)
+ SECTION .vtable:CODE:NOROOT(3)
+
+ EXTERN __iar_program_start
+ PUBLIC __vector_table
+
+ DATA
+
+__vector_table:
+ DCD SFE(IRQSTACK)
+ DCD __iar_program_start
+ DCD default_isr
+ DCD default_isr
+
+ SECTION .text:CODE:REORDER(1)
+ THUMB
+
+default_isr:
+ wfi
+ b default_isr
+
+ END