blob: 4294be4408e862141ac97bdef8bea8f20c0fb623 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 .macro func_prologue
32 stp x29, x30, [sp, #-0x10]!
33 mov x29,sp
34 .endm
35
36 .macro func_epilogue
37 ldp x29, x30, [sp], #0x10
38 .endm
39
40
41 .macro dcache_line_size reg, tmp
42 mrs \tmp, ctr_el0
43 ubfx \tmp, \tmp, #16, #4
44 mov \reg, #4
45 lsl \reg, \reg, \tmp
46 .endm
47
48
49 .macro icache_line_size reg, tmp
50 mrs \tmp, ctr_el0
51 and \tmp, \tmp, #0xf
52 mov \reg, #4
53 lsl \reg, \reg, \tmp
54 .endm
55
56
57 .macro exception_entry func
Achin Gupta4a826dd2013-11-25 14:00:56 +000058 stp x29, x30, [sp, #-(SIZEOF_GPREGS - GPREGS_FP_OFF)]!
Achin Gupta4f6ad662013-10-25 09:08:21 +010059 bl \func
60 .endm
61
62
63 .macro exception_exit func
64 bl \func
Achin Gupta4a826dd2013-11-25 14:00:56 +000065 ldp x29, x30, [sp], #(SIZEOF_GPREGS - GPREGS_FP_OFF)
Achin Gupta4f6ad662013-10-25 09:08:21 +010066 .endm
67
68
69 .macro smc_check label
70 bl read_esr
71 ubfx x0, x0, #ESR_EC_SHIFT, #ESR_EC_LENGTH
72 cmp x0, #EC_AARCH64_SMC
73 b.ne $label
74 .endm
75
76
77 .macro setup_dcsw_op_args start_level, end_level, clidr, shift, fw, ls
78 mrs \clidr, clidr_el1
79 mov \start_level, xzr
80 ubfx \end_level, \clidr, \shift, \fw
81 lsl \end_level, \end_level, \ls
82 .endm