Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
ar_asm_macros.h
1 /*
2  * Copyright (c) 2013-2015 Immo Software
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of the copyright holder nor the names of its contributors may
16  * be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(_ar_asm_macros_h_)
31 
32 #if defined(__IASMARM__)
33 /*
34  * IAR assembler
35  */
36 
37 #define _CODE_SECTION(name) section name : CODE(4)
38 #define _DATA_SECTION(name) section name : DATA(4)
39 #define _THUMB thumb
40 #define _IMPORT(name) import name
41 #define _EXPORT(name) \
42 public \
43  name
44 #define _LABEL(name) name
45 #define _END end
46 #define _FN_BEGIN(name) CFI Block CFIBlock_##name Using CFICommon0
47 #define _FN_LABEL(name) _LABEL(name)
48 #define _FN_DECL(name) CFI Function name
49 #define _FN_BEGIN_POST
50 #define _FN_CANT_UNWIND
51 #define _FN_END(name) CFI EndBlock CFIBlock_##name
52 #define _FN_SIZE(name)
53 #define _EQU(name, value) name equ value
54 #define _ALIGN(n) alignrom n
55 
56 /* Insert CFI annotation definitions at top of file */
57 /* clang-format off */
58  CFI Names CFINames0
59  CFI StackFrame CFA R13 DATA
60  CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32
61  CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, R13:32, R14:32
62  CFI EndNames CFINames0
63 
64  CFI Common CFICommon0 Using CFINames0
65  CFI CodeAlign 2
66  CFI DataAlign 4
67  CFI ReturnAddress R14 CODE
68  CFI CFA R13+0
69  CFI R0 SameValue
70  CFI R1 SameValue
71  CFI R2 SameValue
72  CFI R3 SameValue
73  CFI R4 SameValue
74  CFI R5 SameValue
75  CFI R6 SameValue
76  CFI R7 SameValue
77  CFI R8 SameValue
78  CFI R9 SameValue
79  CFI R10 SameValue
80  CFI R11 SameValue
81  CFI R12 SameValue
82  CFI R14 SameValue
83  CFI EndCommon CFICommon0
84 /* clang-format on */
85 #elif defined(__CC_ARM)
86 /*
87  * ARM assembler
88  */
89 
90 #define _CODE_SECTION(name) AREA | name |, CODE, READONLY
91 #define _DATA_SECTION(name) AREA | name |, DATA, READONLY
92 #define _THUMB THUMB
93 #define _IMPORT(name) IMPORT name
94 #define _EXPORT(name) EXPORT name
95 #define _LABEL(name) name
96 #define _END END
97 #define _FN_BEGIN(name) EXPORT name
98 #define _FN_LABEL(name) name FUNCTION
99 #define _FN_DECL(name)
100 #define _FN_BEGIN_POST
101 #define _FN_CANT_UNWIND FRAME UNWIND OFF
102 #define _FN_END(name) ENDFUNC
103 #define _FN_SIZE(name)
104 #define _EQU(name, value) name EQU value
105 #define _ALIGN(n) align n
106 
107 #elif defined(__GNUC__)
108 /*
109  * GNU assembler
110  */
111 
112 #define _CODE_SECTION(name) .section name
113 #define _DATA_SECTION(name) .section name
114 #define _THUMB .thumb
115 #define _IMPORT(name) .extern name
116 #define _EXPORT(name) .global name
117 #define _LABEL(name) name:
118 #define _END .end
119 #define _FN_BEGIN(name) .thumb_func
120 #define _FN_LABEL(name) _LABEL(name)
121 #define _FN_DECL(name) .type name, % function
122 #define _FN_BEGIN_POST .fnstart
123 #define _FN_CANT_UNWIND .cantunwind
124 #define _FN_END(name) .fnend
125 #define _FN_SIZE(name) .size name, .- name
126 #define _EQU(name, value) .equ name, value
127 #define _ALIGN(n) .balign n
128 
129 .syntax unified
130 
131 #else
132 #error "Unsupported assembler"
133 #endif
134 
135 #endif // __ar_asm_macros_h__