blob: d38dcce714a1765434636ebf8024d89f914643db [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __ASM_MACROS_COMMON_S__
8#define __ASM_MACROS_COMMON_S__
9
10 /*
11 * This macro is used to create a function label and place the
12 * code into a separate text section based on the function name
13 * to enable elimination of unused code during linking. It also adds
14 * basic debug information to enable call stack printing most of the
15 * time.
16 */
17 .macro func _name
18 /*
19 * Add Call Frame Information entry in the .debug_frame section for
20 * debugger consumption. This enables callstack printing in debuggers.
21 * This does not use any space in the final loaded binary, only in the
22 * ELF file.
23 * Note that a function manipulating the CFA pointer location (i.e. the
24 * x29 frame pointer on AArch64) should declare it using the
25 * appropriate .cfi* directives, or be prepared to have a degraded
26 * debugging experience.
27 */
28 .cfi_sections .debug_frame
29 .section .text.\_name, "ax"
30 .type \_name, %function
31 .func \_name
32 /*
33 * .cfi_startproc and .cfi_endproc are needed to output entries in
34 * .debug_frame
35 */
36 .cfi_startproc
37 \_name:
38 .endm
39
40 /*
41 * This macro is used to mark the end of a function.
42 */
43 .macro endfunc _name
44 .endfunc
45 .cfi_endproc
46 .size \_name, . - \_name
47 .endm
48
49 /*
50 * This macro declares an array of 1 or more stacks, properly
51 * aligned and in the requested section
52 */
53#define STACK_ALIGN 6
54
55 .macro declare_stack _name, _section, _size, _count
56 .if ((\_size & ((1 << STACK_ALIGN) - 1)) <> 0)
57 .error "Stack size not correctly aligned"
58 .endif
59 .section \_section, "aw", %nobits
60 .align STACK_ALIGN
61 \_name:
62 .space ((\_count) * (\_size)), 0
63 .endm
64
65#endif /* __ASM_MACROS_COMMON_S__ */
66