1/* 2 * Copyright (c) 2018 Ding Tao <miyatsu@qq.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7/** 8 * @file irq_relay.S 9 * 10 * @brief IRQ relay vector table and relay handler for Cortex-M0 or 11 * Armv8-M baseline SoCs 12 * 13 * In certain ARMv6-M and Armv8-M baseline cores the vector table address can 14 * not be changed. Once the * vector table is occupied by bootloader, there 15 * will be no IRQ support in the chainloaded image. 16 * 17 * This program will link into bootloader, once an interrupt is coming, 18 * the bootloader can forward the interrupt to the chainloaded image. This 19 * will support DFU on those cores. 20 * 21 * Note: Currently support mcuboot only. 22 * */ 23 24#include <toolchain.h> 25#include <linker/sections.h> 26 27_ASM_FILE_PROLOGUE 28 29GDATA(_vector_table_pointer) 30GDATA(z_main_stack) 31 32SECTION_FUNC(TEXT, __vector_relay_handler) 33 mrs r0, ipsr; 34 lsls r0, r0, $0x02; 35 36 ldr r1, =_vector_table_pointer; 37 ldr r1, [r1]; 38 adds r1, r1, r0; 39 ldr r1, [r1]; 40 41 /** 42 * The size of IRQ vector is 4 bytes, the offset within vector table 43 * is the IRQ number times 4 (aka r0 << 2). As know as the r1 stored 44 * the offset of real vector table, thus the (r1 = r1 + r0 << 2) will 45 * be the real irq handle vector. 46 * */ 47 48 bx r1; 49 50GTEXT(__vector_relay_handler) 51 52SECTION_FUNC(vector_relay_table, __vector_relay_table) 53 .word z_main_stack + CONFIG_MAIN_STACK_SIZE 54 55 .word z_arm_reset 56 57 .word __vector_relay_handler /* nmi */ 58 .word __vector_relay_handler /* hard fault */ 59 .word __vector_relay_handler 60 .word __vector_relay_handler 61 .word __vector_relay_handler 62 .word __vector_relay_handler 63 .word __vector_relay_handler 64 .word __vector_relay_handler 65 .word __vector_relay_handler 66 .word __vector_relay_handler /* svc */ 67 .word __vector_relay_handler 68 .word __vector_relay_handler 69 .word __vector_relay_handler /* pendsv */ 70 .word __vector_relay_handler 71 /* End of system exception */ 72 73 .rept CONFIG_NUM_IRQS 74 .word __vector_relay_handler 75 .endr 76 77GDATA(__vector_relay_table) 78