/* fault_s.S - fault handlers for ARCv2 */ /* * Copyright (c) 2014 Wind River Systems, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1) Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3) Neither the name of Wind River Systems nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * DESCRIPTION * Fault handlers for ARCv2 processors. */ #define _ASMLANGUAGE #include #include #include #include "swap_macros.h" GTEXT(_Fault) GTEXT(__reset) GTEXT(__memory_error) GTEXT(__instruction_error) GTEXT(__ev_machine_check) GTEXT(__ev_tlb_miss_i) GTEXT(__ev_tlb_miss_d) GTEXT(__ev_prot_v) GTEXT(__ev_privilege_v) GTEXT(__ev_swi) GTEXT(__ev_trap) GTEXT(__ev_extension) GTEXT(__ev_div_zero) GTEXT(__ev_dc_error) GTEXT(__ev_maligned) GDATA(_firq_stack) SECTION_VAR(BSS, saved_stack_pointer) .word 0 /* * @brief Fault handler installed in the fault and reserved vectors */ SECTION_SUBSEC_FUNC(TEXT,__fault,__memory_error) SECTION_SUBSEC_FUNC(TEXT,__fault,__instruction_error) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_machine_check) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_tlb_miss_i) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_tlb_miss_d) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_prot_v) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_privilege_v) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_swi) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_trap) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_extension) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_div_zero) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_dc_error) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_maligned) /* * Before invoking exception handler, the kernel switches to an exception * stack, which is really the FIRQ stack, to save the faulting thread's * registers. It can use the FIRQ stack because it knows it is unused * since it is save to assume that if an exception has happened in FIRQ * handler, the problem is fatal and all the kernel can do is just print * a diagnostic message and halt. */ st sp, [saved_stack_pointer] mov_s sp, _firq_stack add sp, sp, CONFIG_FIRQ_STACK_SIZE /* save caller saved registers */ _create_irq_stack_frame jl _Fault /* if _Fault returns, restore the registers */ _pop_irq_stack_frame /* now restore the stack */ ld sp,[saved_stack_pointer] rtie