[processor-sdk/pdk.git] / packages / ti / utils / profiling / src / profilingHooksArmV7_AAssembly.asm
1 @******************************************************************************
2 @
3 @ \file profilingHooksArmV7_AAssembly.asm
4 @
5 @ \brief proliling hooks function.
6 @
7 @******************************************************************************
8 @ Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
9 @
10 @
11 @ Redistribution and use in source and binary forms, with or without
12 @ modification, are permitted provided that the following conditions
13 @ are met:
14 @
15 @ Redistributions of source code must retain the above copyright
16 @ notice, this list of conditions and the following disclaimer.
17 @
18 @ Redistributions in binary form must reproduce the above copyright
19 @ notice, this list of conditions and the following disclaimer in the
20 @ documentation and/or other materials provided with the
21 @ distribution.
22 @
23 @ Neither the name of Texas Instruments Incorporated nor the names of
24 @ its contributors may be used to endorse or promote products derived
25 @ from this software without specific prior written permission.
26 @
27 @ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 @ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 @ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 @ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 @ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 @ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 @ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 @ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 @ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 @ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 @ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 @
39 @******************************************************************************
41 @******************************************************************************
42 @* INCLUDE FILES
43 @******************************************************************************
45 @******************************************************************************
46 @* SYMBOLS
47 @******************************************************************************
49 .global __cyg_profile_func_enter
50 .global __cyg_profile_func_exit
51 .global mySwitch
52 .global elemlog
53 .global log_idx
55 @******************************************************************************
56 @* CODE SECTION
57 @******************************************************************************
58 .text
60 @ This code is assembled for ARM instructions
61 .code 32
63 @******************************************************************************
64 @* ASSEMBLY ROUTINES
65 @******************************************************************************
67 @*****************************************************************************
68 @ This API logs the entry hooks.
69 @*****************************************************************************
70 __cyg_profile_func_enter:
71 mov ip, sp
72 stmfd sp!, {r4, r5, r6, r7, fp, ip, lr, pc}
73 sub fp, ip, #4
74 mov r7, r0
75 mov r6, r1
76 MRC p15, 0, r5, c9, c13, 0
77 movw r4, #:lower16:log_idx
78 movt r4, #:upper16:log_idx
79 ldr r3, [r4]
80 cmp r3, #0
81 beq .L5
82 .L2:
83 cmp r3, #1048576
84 bcs .L1
85 movw r2, #:lower16:elemlog
86 mov r0, #1
87 movt r2, #:upper16:elemlog
88 add r1, r3, r0
89 add ip, r2, r3, asl #4
90 str r0, [r2, r3, asl #4]
91 str r1, [r4]
92 str r7, [ip, #4]
93 str r6, [ip, #8]
94 str r5, [ip, #12]
95 .L1:
96 sub sp, fp, #28
97 ldmfd sp, {r4, r5, r6, r7, fp, sp, pc}
98 .L5:
99 bl profiling_init
100 ldr r3, [r4]
101 b .L2
103 @*****************************************************************************
104 @ This API logs the exit hooks.
105 @*****************************************************************************
106 __cyg_profile_func_exit:
107 stmfd sp!, {r4, r5, lr}
108 MRC p15, 0, lr, c9, c13, 0
109 movw r3, #:lower16:log_idx
110 movt r3, #:upper16:log_idx
111 ldr r2, [r3]
112 cmp r2, #1048576
113 bcs .L17
114 movw r1, #:lower16:elemlog
115 mov r5, #0
116 movt r1, #:upper16:elemlog
117 add r4, r2, #1
118 add ip, r1, r2, asl #4
119 str r5, [r1, r2, asl #4]
120 str r4, [r3]
121 str r0, [ip, #4]
122 str lr, [ip, #12]
123 .L17:
124 ldrd r4, [sp]
125 add sp, sp, #8
126 ldr pc, [sp], #4
129 @*****************************************************************************
130 @ This API logs the task switch hooks.
131 @*****************************************************************************
132 mySwitch:
133 stmfd sp!, {r4, r5, r6, lr}
134 MRC p15, 0, r4, c9, c13, 0
135 movw r3, #:lower16:log_idx
136 movt r3, #:upper16:log_idx
137 ldr r2, [r3]
138 cmp r2, #1048576
139 bcs .L21
140 movw ip, #:lower16:elemlog
141 mov r6, #3
142 movt ip, #:upper16:elemlog
143 add r5, r2, #1
144 add lr, ip, r2, asl #4
145 str r6, [ip, r2, asl #4]
146 str r5, [r3]
147 str r1, [lr, #4]
148 str r0, [lr, #8]
149 str r4, [lr, #12]
150 .L21:
151 ldrd r4, [sp]
152 ldr r6, [sp, #8]
153 add sp, sp, #12
154 ldr pc, [sp], #4
156 @******************************************************************************
157 @* LABELS
158 @******************************************************************************
160 .end