xref: /rk3399_ARM-atf/include/plat/arm/common/aarch64/arm_macros.S (revision 6355f2347aec8bf6ad74867c2b0c996e10546ad4)
1b4315306SDan Handley/*
2*6355f234SVikram Kanigiri * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3b4315306SDan Handley *
4b4315306SDan Handley * Redistribution and use in source and binary forms, with or without
5b4315306SDan Handley * modification, are permitted provided that the following conditions are met:
6b4315306SDan Handley *
7b4315306SDan Handley * Redistributions of source code must retain the above copyright notice, this
8b4315306SDan Handley * list of conditions and the following disclaimer.
9b4315306SDan Handley *
10b4315306SDan Handley * Redistributions in binary form must reproduce the above copyright notice,
11b4315306SDan Handley * this list of conditions and the following disclaimer in the documentation
12b4315306SDan Handley * and/or other materials provided with the distribution.
13b4315306SDan Handley *
14b4315306SDan Handley * Neither the name of ARM nor the names of its contributors may be used
15b4315306SDan Handley * to endorse or promote products derived from this software without specific
16b4315306SDan Handley * prior written permission.
17b4315306SDan Handley *
18b4315306SDan Handley * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19b4315306SDan Handley * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20b4315306SDan Handley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21b4315306SDan Handley * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22b4315306SDan Handley * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23b4315306SDan Handley * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24b4315306SDan Handley * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25b4315306SDan Handley * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26b4315306SDan Handley * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27b4315306SDan Handley * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28b4315306SDan Handley * POSSIBILITY OF SUCH DAMAGE.
29b4315306SDan Handley */
30b4315306SDan Handley#ifndef __ARM_MACROS_S__
31b4315306SDan Handley#define __ARM_MACROS_S__
32b4315306SDan Handley
33f14d1886SSoby Mathew#include <gic_common.h>
34f14d1886SSoby Mathew#include <gicv2.h>
35f14d1886SSoby Mathew#include <gicv3.h>
36b4315306SDan Handley#include <platform_def.h>
37b4315306SDan Handley
38b4315306SDan Handley.section .rodata.gic_reg_name, "aS"
39f14d1886SSoby Mathew/* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */
40b4315306SDan Handleygicc_regs:
41b4315306SDan Handley	.asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
42f14d1886SSoby Mathew
43f14d1886SSoby Mathew/* Applicable only to GICv3 with SRE enabled */
44f14d1886SSoby Mathewicc_regs:
45f14d1886SSoby Mathew	.asciz "icc_hppir0_el1", "icc_hppir1_el1", "icc_ctlr_el3", ""
46f14d1886SSoby Mathew
47f14d1886SSoby Mathew/* Registers common to both GICv2 and GICv3 */
48b4315306SDan Handleygicd_pend_reg:
49b4315306SDan Handley	.asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n"	\
50b4315306SDan Handley		" Offset:\t\t\tvalue\n"
51b4315306SDan Handleynewline:
52b4315306SDan Handley	.asciz "\n"
53b4315306SDan Handleyspacer:
54b4315306SDan Handley	.asciz ":\t\t0x"
55b4315306SDan Handley
56b4315306SDan Handley	/* ---------------------------------------------
57b4315306SDan Handley	 * The below utility macro prints out relevant GIC
58b4315306SDan Handley	 * registers whenever an unhandled exception is
59d178637dSJuan Castillo	 * taken in BL31 on ARM standard platforms.
60b4315306SDan Handley	 * Expects: GICD base in x16, GICC base in x17
61b4315306SDan Handley	 * Clobbers: x0 - x10, sp
62b4315306SDan Handley	 * ---------------------------------------------
63b4315306SDan Handley	 */
64b4315306SDan Handley	.macro arm_print_gic_regs
65f14d1886SSoby Mathew	/* Check for GICv3 system register access */
66f14d1886SSoby Mathew	mrs	x7, id_aa64pfr0_el1
67f14d1886SSoby Mathew	ubfx	x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH
68f14d1886SSoby Mathew	cmp	x7, #1
69f14d1886SSoby Mathew	b.ne	print_gicv2
70f14d1886SSoby Mathew
71f14d1886SSoby Mathew	/* Check for SRE enable */
72f14d1886SSoby Mathew	mrs	x8, ICC_SRE_EL3
73f14d1886SSoby Mathew	tst	x8, #ICC_SRE_SRE_BIT
74f14d1886SSoby Mathew	b.eq	print_gicv2
75f14d1886SSoby Mathew
76f14d1886SSoby Mathew	/* Load the icc reg list to x6 */
77f14d1886SSoby Mathew	adr	x6, icc_regs
78f14d1886SSoby Mathew	/* Load the icc regs to gp regs used by str_in_crash_buf_print */
79f14d1886SSoby Mathew	mrs	x8, ICC_HPPIR0_EL1
80f14d1886SSoby Mathew	mrs	x9, ICC_HPPIR1_EL1
81f14d1886SSoby Mathew	mrs	x10, ICC_CTLR_EL3
82f14d1886SSoby Mathew	/* Store to the crash buf and print to console */
83f14d1886SSoby Mathew	bl	str_in_crash_buf_print
84f14d1886SSoby Mathew	b	print_gic_common
85f14d1886SSoby Mathew
86f14d1886SSoby Mathewprint_gicv2:
87b4315306SDan Handley	/* Load the gicc reg list to x6 */
88b4315306SDan Handley	adr	x6, gicc_regs
89b4315306SDan Handley	/* Load the gicc regs to gp regs used by str_in_crash_buf_print */
90b4315306SDan Handley	ldr	w8, [x17, #GICC_HPPIR]
91b4315306SDan Handley	ldr	w9, [x17, #GICC_AHPPIR]
92b4315306SDan Handley	ldr	w10, [x17, #GICC_CTLR]
93b4315306SDan Handley	/* Store to the crash buf and print to console */
94b4315306SDan Handley	bl	str_in_crash_buf_print
95b4315306SDan Handley
96f14d1886SSoby Mathewprint_gic_common:
97b4315306SDan Handley	/* Print the GICD_ISPENDR regs */
98b4315306SDan Handley	add	x7, x16, #GICD_ISPENDR
99b4315306SDan Handley	adr	x4, gicd_pend_reg
100b4315306SDan Handley	bl	asm_print_str
101b4315306SDan Handleygicd_ispendr_loop:
102b4315306SDan Handley	sub	x4, x7, x16
103b4315306SDan Handley	cmp	x4, #0x280
104b4315306SDan Handley	b.eq	exit_print_gic_regs
105b4315306SDan Handley	bl	asm_print_hex
106b4315306SDan Handley
107b4315306SDan Handley	adr	x4, spacer
108b4315306SDan Handley	bl	asm_print_str
109b4315306SDan Handley
110b4315306SDan Handley	ldr	x4, [x7], #8
111b4315306SDan Handley	bl	asm_print_hex
112b4315306SDan Handley
113b4315306SDan Handley	adr	x4, newline
114b4315306SDan Handley	bl	asm_print_str
115b4315306SDan Handley	b	gicd_ispendr_loop
116b4315306SDan Handleyexit_print_gic_regs:
117b4315306SDan Handley	.endm
118b4315306SDan Handley
119b4315306SDan Handley#endif /* __ARM_MACROS_S__ */
120