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