blob: 2edf5b9002ae121bbf53b61b52730c9539595fd0 [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_S__
8#define __ASM_MACROS_S__
9
10#include <arch.h>
11#include <asm_macros_common.S>
12
13#define TLB_INVALIDATE(_reg, _coproc) \
14 stcopr _reg, _coproc
15
16 /*
17 * Co processor register accessors
18 */
19 .macro ldcopr reg, coproc, opc1, CRn, CRm, opc2
20 mrc \coproc, \opc1, \reg, \CRn, \CRm, \opc2
21 .endm
22
23 .macro ldcopr16 reg1, reg2, coproc, opc1, CRm
24 mrrc \coproc, \opc1, \reg1, \reg2, \CRm
25 .endm
26
27 .macro stcopr reg, coproc, opc1, CRn, CRm, opc2
28 mcr \coproc, \opc1, \reg, \CRn, \CRm, \opc2
29 .endm
30
31 .macro stcopr16 reg1, reg2, coproc, opc1, CRm
32 mcrr \coproc, \opc1, \reg1, \reg2, \CRm
33 .endm
34
35 /* Cache line size helpers */
36 .macro dcache_line_size reg, tmp
37 ldcopr \tmp, CTR
38 ubfx \tmp, \tmp, #16, #4
39 mov \reg, #4
40 lsl \reg, \reg, \tmp
41 .endm
42
43 .macro icache_line_size reg, tmp
44 ldcopr \tmp, CTR
45 and \tmp, \tmp, #0xf
46 mov \reg, #4
47 lsl \reg, \reg, \tmp
48 .endm
49
50 /*
51 * Declare the exception vector table, enforcing it is aligned on a
52 * 32 byte boundary.
53 */
54 .macro vector_base label
55 .section .vectors, "ax"
56 .align 5
57 \label:
58 .endm
59
60 /*
61 * This macro calculates the base address of an MP stack using the
62 * platform_get_core_pos() index, the name of the stack storage and
63 * the size of each stack
64 * Out: r0 = physical address of stack base
65 * Clobber: r14, r1, r2
66 */
67 .macro get_mp_stack _name, _size
68 bl platform_get_core_pos
69 ldr r2, =(\_name + \_size)
70 mov r1, #\_size
71 mla r0, r0, r1, r2
72 .endm
73
74 /*
75 * This macro calculates the base address of a uniprocessor(UP) stack
76 * using the name of the stack storage and the size of the stack
77 * Out: r0 = physical address of stack base
78 */
79 .macro get_up_stack _name, _size
80 ldr r0, =(\_name + \_size)
81 .endm
82
83#endif /* __ASM_MACROS_S__ */
84