| /* |
| * Copyright (c) 2018 Ding Tao |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| /** |
| * @file irq_relay.S |
| * |
| * @brief IRQ relay vector table and relay handler for Cortex-M0 SoC |
| * |
| * In Cortex-M0, the vector table address can not be changed. Once the |
| * vector table is occupied by bootloader, there will be no IRQ support |
| * in chainloaded image. |
| * |
| * This program will link into bootloader, once an interrupt is coming, |
| * bootloader can forward the interrupt to the chainloaded image. This |
| * will support DFU on Cortex-M0 plantform. |
| * |
| * Note: Currently support mcuboot only. |
| * */ |
| |
| #include <board.h> |
| #include <toolchain.h> |
| #include <linker/sections.h> |
| #include <drivers/system_timer.h> |
| |
| _ASM_FILE_PROLOGUE |
| |
| #if defined(CONFIG_SW_VECTOR_RELAY) |
| |
| GDATA(_vector_table_pointer) |
| GDATA(_main_stack) |
| |
| SECTION_FUNC(vector_relay_handler, __vector_relay_handler) |
| mrs r0, ipsr; |
| lsls r0, r0, $0x02; |
| |
| ldr r1, = _vector_table_pointer; |
| ldr r1, [r1]; |
| adds r1, r1, r0; |
| ldr r1, [r1]; |
| |
| /** |
| * The size of IRQ vector is 4 bytes, the offset within vector table |
| * is the IRQ number times 4 (aka r0 << 2). As know as the r1 stored |
| * the offset of real vector table, thus the (r1 = r1 + r0 << 2) will |
| * be the real irq handle vector. |
| * */ |
| |
| bx r1; |
| |
| GTEXT(__vector_relay_handler) |
| |
| SECTION_FUNC(vector_relay_table, __vector_relay_table) |
| .word _main_stack + CONFIG_MAIN_STACK_SIZE |
| |
| .word __reset |
| |
| .word __vector_relay_handler /* nmi */ |
| .word __vector_relay_handler /* hard fault */ |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler /* svc */ |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler /* pendsv */ |
| .word __vector_relay_handler |
| /* End of system exception */ |
| |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| .word __vector_relay_handler |
| |
| #endif |