xref: /rk3399_ARM-atf/include/plat/arm/common/aarch64/arm_macros.S (revision f14d188681b2c6f49ccd22595b112da7b02798f8)
1b4315306SDan Handley/*
2b4315306SDan Handley * Copyright (c) 2015, 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
33b4315306SDan Handley#include <cci.h>
34*f14d1886SSoby Mathew#include <gic_common.h>
35*f14d1886SSoby Mathew#include <gicv2.h>
36*f14d1886SSoby Mathew#include <gicv3.h>
37b4315306SDan Handley#include <platform_def.h>
38b4315306SDan Handley
39b4315306SDan Handley.section .rodata.gic_reg_name, "aS"
40*f14d1886SSoby Mathew/* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */
41b4315306SDan Handleygicc_regs:
42b4315306SDan Handley	.asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
43*f14d1886SSoby Mathew
44*f14d1886SSoby Mathew/* Applicable only to GICv3 with SRE enabled */
45*f14d1886SSoby Mathewicc_regs:
46*f14d1886SSoby Mathew	.asciz "icc_hppir0_el1", "icc_hppir1_el1", "icc_ctlr_el3", ""
47*f14d1886SSoby Mathew
48*f14d1886SSoby Mathew/* Registers common to both GICv2 and GICv3 */
49b4315306SDan Handleygicd_pend_reg:
50b4315306SDan Handley	.asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n"	\
51b4315306SDan Handley		" Offset:\t\t\tvalue\n"
52b4315306SDan Handleynewline:
53b4315306SDan Handley	.asciz "\n"
54b4315306SDan Handleyspacer:
55b4315306SDan Handley	.asciz ":\t\t0x"
56b4315306SDan Handley
57b4315306SDan Handley	/* ---------------------------------------------
58b4315306SDan Handley	 * The below utility macro prints out relevant GIC
59b4315306SDan Handley	 * registers whenever an unhandled exception is
60b4315306SDan Handley	 * taken in BL3-1 on ARM standard platforms.
61b4315306SDan Handley	 * Expects: GICD base in x16, GICC base in x17
62b4315306SDan Handley	 * Clobbers: x0 - x10, sp
63b4315306SDan Handley	 * ---------------------------------------------
64b4315306SDan Handley	 */
65b4315306SDan Handley	.macro arm_print_gic_regs
66*f14d1886SSoby Mathew	/* Check for GICv3 system register access */
67*f14d1886SSoby Mathew	mrs	x7, id_aa64pfr0_el1
68*f14d1886SSoby Mathew	ubfx	x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH
69*f14d1886SSoby Mathew	cmp	x7, #1
70*f14d1886SSoby Mathew	b.ne	print_gicv2
71*f14d1886SSoby Mathew
72*f14d1886SSoby Mathew	/* Check for SRE enable */
73*f14d1886SSoby Mathew	mrs	x8, ICC_SRE_EL3
74*f14d1886SSoby Mathew	tst	x8, #ICC_SRE_SRE_BIT
75*f14d1886SSoby Mathew	b.eq	print_gicv2
76*f14d1886SSoby Mathew
77*f14d1886SSoby Mathew	/* Load the icc reg list to x6 */
78*f14d1886SSoby Mathew	adr	x6, icc_regs
79*f14d1886SSoby Mathew	/* Load the icc regs to gp regs used by str_in_crash_buf_print */
80*f14d1886SSoby Mathew	mrs	x8, ICC_HPPIR0_EL1
81*f14d1886SSoby Mathew	mrs	x9, ICC_HPPIR1_EL1
82*f14d1886SSoby Mathew	mrs	x10, ICC_CTLR_EL3
83*f14d1886SSoby Mathew	/* Store to the crash buf and print to console */
84*f14d1886SSoby Mathew	bl	str_in_crash_buf_print
85*f14d1886SSoby Mathew	b	print_gic_common
86*f14d1886SSoby Mathew
87*f14d1886SSoby Mathewprint_gicv2:
88b4315306SDan Handley	/* Load the gicc reg list to x6 */
89b4315306SDan Handley	adr	x6, gicc_regs
90b4315306SDan Handley	/* Load the gicc regs to gp regs used by str_in_crash_buf_print */
91b4315306SDan Handley	ldr	w8, [x17, #GICC_HPPIR]
92b4315306SDan Handley	ldr	w9, [x17, #GICC_AHPPIR]
93b4315306SDan Handley	ldr	w10, [x17, #GICC_CTLR]
94b4315306SDan Handley	/* Store to the crash buf and print to console */
95b4315306SDan Handley	bl	str_in_crash_buf_print
96b4315306SDan Handley
97*f14d1886SSoby Mathewprint_gic_common:
98b4315306SDan Handley	/* Print the GICD_ISPENDR regs */
99b4315306SDan Handley	add	x7, x16, #GICD_ISPENDR
100b4315306SDan Handley	adr	x4, gicd_pend_reg
101b4315306SDan Handley	bl	asm_print_str
102b4315306SDan Handleygicd_ispendr_loop:
103b4315306SDan Handley	sub	x4, x7, x16
104b4315306SDan Handley	cmp	x4, #0x280
105b4315306SDan Handley	b.eq	exit_print_gic_regs
106b4315306SDan Handley	bl	asm_print_hex
107b4315306SDan Handley
108b4315306SDan Handley	adr	x4, spacer
109b4315306SDan Handley	bl	asm_print_str
110b4315306SDan Handley
111b4315306SDan Handley	ldr	x4, [x7], #8
112b4315306SDan Handley	bl	asm_print_hex
113b4315306SDan Handley
114b4315306SDan Handley	adr	x4, newline
115b4315306SDan Handley	bl	asm_print_str
116b4315306SDan Handley	b	gicd_ispendr_loop
117b4315306SDan Handleyexit_print_gic_regs:
118b4315306SDan Handley	.endm
119b4315306SDan Handley
120b4315306SDan Handley
121b4315306SDan Handley.section .rodata.cci_reg_name, "aS"
122b4315306SDan Handleycci_iface_regs:
123b4315306SDan Handley	.asciz "cci_snoop_ctrl_cluster0", "cci_snoop_ctrl_cluster1" , ""
124b4315306SDan Handley
125b4315306SDan Handley	/* ------------------------------------------------
126b4315306SDan Handley	 * The below required platform porting macro prints
127b4315306SDan Handley	 * out relevant interconnect registers whenever an
128b4315306SDan Handley	 * unhandled exception is taken in BL3-1.
129b4315306SDan Handley	 * Clobbers: x0 - x9, sp
130b4315306SDan Handley	 * ------------------------------------------------
131b4315306SDan Handley	 */
132b4315306SDan Handley	.macro plat_print_interconnect_regs
133b4315306SDan Handley	adr	x6, cci_iface_regs
134b4315306SDan Handley	/* Store in x7 the base address of the first interface */
135b4315306SDan Handley	mov_imm	x7, (PLAT_ARM_CCI_BASE + SLAVE_IFACE_OFFSET(	\
136b4315306SDan Handley			PLAT_ARM_CCI_CLUSTER0_SL_IFACE_IX))
137b4315306SDan Handley	ldr	w8, [x7, #SNOOP_CTRL_REG]
138b4315306SDan Handley	/* Store in x7 the base address of the second interface */
139b4315306SDan Handley	mov_imm	x7, (PLAT_ARM_CCI_BASE + SLAVE_IFACE_OFFSET(	\
140b4315306SDan Handley			PLAT_ARM_CCI_CLUSTER1_SL_IFACE_IX))
141b4315306SDan Handley	ldr	w9, [x7, #SNOOP_CTRL_REG]
142b4315306SDan Handley	/* Store to the crash buf and print to console */
143b4315306SDan Handley	bl	str_in_crash_buf_print
144b4315306SDan Handley	.endm
145b4315306SDan Handley
146b4315306SDan Handley
147b4315306SDan Handley#endif /* __ARM_MACROS_S__ */
148