| /* |
| * Copyright (c) 2013-2014 Wind River Systems, Inc. |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| /** |
| * @file |
| * @brief Reset handler |
| * |
| * Reset handler that prepares the system for running C code. |
| */ |
| |
| #include <toolchain.h> |
| #include <linker/sections.h> |
| #include <arch/cpu.h> |
| #include "vector_table.h" |
| |
| _ASM_FILE_PROLOGUE |
| |
| GTEXT(__reset) |
| #if defined(CONFIG_PLATFORM_SPECIFIC_INIT) |
| GTEXT(_PlatformInit) |
| #endif |
| |
| /** |
| * |
| * @brief Reset vector |
| * |
| * Ran when the system comes out of reset. The processor is in thread mode with |
| * privileged level. At this point, the main stack pointer (MSP) is already |
| * pointing to a valid area in SRAM. |
| * |
| * Locking interrupts prevents anything but NMIs and hard faults from |
| * interrupting the CPU. A default NMI handler is already in place in the |
| * vector table, and the boot code should not generate hard fault, or we're in |
| * deep trouble. |
| * |
| * We want to use the process stack pointer (PSP) instead of the MSP, since the |
| * MSP is to be set up to point to the one-and-only interrupt stack during later |
| * boot. That would not be possible if in use for running C code. |
| * |
| * When these steps are completed, jump to _PrepC(), which will finish setting |
| * up the system for running C code. |
| * |
| * @return N/A |
| */ |
| |
| SECTION_SUBSEC_FUNC(TEXT,_reset_section,__reset) |
| |
| /* |
| * The entry point is located at the __reset symbol, which |
| * is fetched by a XIP image playing the role of a bootloader, which jumps to |
| * it, not through the reset vector mechanism. Such bootloaders might want to |
| * search for a __start symbol instead, so create that alias here. |
| */ |
| SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start) |
| |
| #if defined(CONFIG_PLATFORM_SPECIFIC_INIT) |
| bl _PlatformInit |
| #endif |
| |
| /* lock interrupts: will get unlocked when switch to main task */ |
| bl lock_interrupts |
| #ifdef CONFIG_WDOG_INIT |
| /* board-specific watchdog initialization is necessary */ |
| bl _WdogInit |
| #endif |
| |
| /* |
| * 'bl' jumps the furthest of the branch instructions that are |
| * supported on all platforms. So it is used when jumping to _PrepC |
| * (even though we do not intend to return). |
| */ |
| bl _PrepC |