1 ;
2 ; Copyright (C) 2018-2021 Texas Instruments Incorporated
3 ;
4 ; Redistribution and use in source and binary forms, with or without
5 ; modification, are permitted provided that the following conditions
6 ; are met:
7 ;
8 ; Redistributions of source code must retain the above copyright
9 ; notice, this list of conditions and the following disclaimer.
10 ;
11 ; Redistributions in binary form must reproduce the above copyright
12 ; notice, this list of conditions and the following disclaimer in the
13 ; documentation and/or other materials provided with the
14 ; distribution.
15 ;
16 ; Neither the name of Texas Instruments Incorporated nor the names of
17 ; its contributors may be used to endorse or promote products derived
18 ; from this software without specific prior written permission.
19 ;
20 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ;
33 ;
34 ; \file SafeRTOS_Utilsasm.asm
35 ;
37 .text
38 .arm
39 .ref vDataAbort_c
40 .sect "KERNEL_FUNCTION"
42 ;------------------------------------------------------------------------------
43 ; Constant Definitions
44 ;------------------------------------------------------------------------------
47 ARM_MODE_MASK .equ ( 0x1F )
48 ISR_MODE .equ ( 0x12 )
50 TRUE .equ ( 1 )
51 FALSE .equ ( 0 )
53 ;------------------------------------------------------------------------------
54 .global ulGetDataFaultStatusRegister
55 .global ulGetDataFaultAddressRegister
56 .global ulGetInstructionFaultStatusRegister
57 .global ulGetInstructionFaultAddressRegister
59 ;-------------------------------------------------------------------------------
60 ; portUInt32Type ulGetDataFaultStatusRegister( void )
61 ;-------------------------------------------------------------------------------
62 ulGetDataFaultStatusRegister:
63 MRC p15, #0, r0, c5, c0, #0
64 BX LR
66 ;-------------------------------------------------------------------------------
67 ; portUInt32Type ulGetDataFaultAddressRegister( void )
68 ;-------------------------------------------------------------------------------
69 ulGetDataFaultAddressRegister:
70 MRC p15, #0, r0, c6, c0, #0
71 BX LR
73 ;-------------------------------------------------------------------------------
74 ; portUInt32Type ulGetInstructionFaultStatusRegister( void )
75 ;-------------------------------------------------------------------------------
76 ulGetInstructionFaultStatusRegister:
77 MRC p15, #0, r0, c5, c0, #1
78 BX LR
80 ;-------------------------------------------------------------------------------
81 ; portUInt32Type ulGetInstructionFaultAddressRegister( void )
82 ;-------------------------------------------------------------------------------
83 ulGetInstructionFaultAddressRegister:
84 MRC p15, #0, r0, c6, c0, #2
85 BX LR
87 ;-------------------------------------------------------------------------------
88 ; void vDataAbort( void )
89 ;-------------------------------------------------------------------------------
90 .global vDataAbort
91 .arm
93 vDataAbort:
94 ; Return to the instruction following the interrupted.
95 SUB lr, lr, #4
97 ; Push the return address and SPSR.
98 PUSH {lr}
99 MRS lr, SPSR
100 PUSH {lr}
102 ; Push used registers.
103 PUSH {r0-r4, r12}
105 ; Call the interrupt handler.
106 LDR r1, vApplicationDataAbortHandlerConst
107 BLX r1
109 ; Restore used registers, LR and SPSR before returning.
110 POP {r0-r4, r12}
111 POP {LR}
112 MSR SPSR_cxsf, LR
113 POP {LR}
114 MOVS PC, LR
117 vApplicationDataAbortHandlerConst: .word vDataAbort_c
119 ;-------------------------------------------------------------------------------