xref: /rk3399_ARM-atf/include/plat/arm/common/aarch64/arm_macros.S (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
1b4315306SDan Handley/*
26355f234SVikram Kanigiri * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3b4315306SDan Handley *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5b4315306SDan Handley */
6c3cf06f1SAntonio Nino Diaz#ifndef ARM_MACROS_S
7c3cf06f1SAntonio Nino Diaz#define ARM_MACROS_S
8b4315306SDan Handley
9*09d40e0eSAntonio Nino Diaz#include <drivers/arm/gic_common.h>
10*09d40e0eSAntonio Nino Diaz#include <drivers/arm/gicv2.h>
11*09d40e0eSAntonio Nino Diaz#include <drivers/arm/gicv3.h>
12b4315306SDan Handley#include <platform_def.h>
13b4315306SDan Handley
14b4315306SDan Handley.section .rodata.gic_reg_name, "aS"
15f14d1886SSoby Mathew/* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */
16b4315306SDan Handleygicc_regs:
17b4315306SDan Handley	.asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
18f14d1886SSoby Mathew
19f14d1886SSoby Mathew/* Applicable only to GICv3 with SRE enabled */
20f14d1886SSoby Mathewicc_regs:
21f14d1886SSoby Mathew	.asciz "icc_hppir0_el1", "icc_hppir1_el1", "icc_ctlr_el3", ""
22f14d1886SSoby Mathew
23f14d1886SSoby Mathew/* Registers common to both GICv2 and GICv3 */
24b4315306SDan Handleygicd_pend_reg:
25be7d7f9fSRoberto Vargas	.asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n Offset:\t\t\tvalue\n"
26b4315306SDan Handleynewline:
27b4315306SDan Handley	.asciz "\n"
28b4315306SDan Handleyspacer:
29b4315306SDan Handley	.asciz ":\t\t0x"
30b4315306SDan Handley
31b4315306SDan Handley	/* ---------------------------------------------
32b4315306SDan Handley	 * The below utility macro prints out relevant GIC
33b4315306SDan Handley	 * registers whenever an unhandled exception is
34d178637dSJuan Castillo	 * taken in BL31 on ARM standard platforms.
35b4315306SDan Handley	 * Expects: GICD base in x16, GICC base in x17
36b4315306SDan Handley	 * Clobbers: x0 - x10, sp
37b4315306SDan Handley	 * ---------------------------------------------
38b4315306SDan Handley	 */
39b4315306SDan Handley	.macro arm_print_gic_regs
40f14d1886SSoby Mathew	/* Check for GICv3 system register access */
41f14d1886SSoby Mathew	mrs	x7, id_aa64pfr0_el1
42f14d1886SSoby Mathew	ubfx	x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH
43f14d1886SSoby Mathew	cmp	x7, #1
44f14d1886SSoby Mathew	b.ne	print_gicv2
45f14d1886SSoby Mathew
46f14d1886SSoby Mathew	/* Check for SRE enable */
47f14d1886SSoby Mathew	mrs	x8, ICC_SRE_EL3
48f14d1886SSoby Mathew	tst	x8, #ICC_SRE_SRE_BIT
49f14d1886SSoby Mathew	b.eq	print_gicv2
50f14d1886SSoby Mathew
51f14d1886SSoby Mathew	/* Load the icc reg list to x6 */
52f14d1886SSoby Mathew	adr	x6, icc_regs
53f14d1886SSoby Mathew	/* Load the icc regs to gp regs used by str_in_crash_buf_print */
54f14d1886SSoby Mathew	mrs	x8, ICC_HPPIR0_EL1
55f14d1886SSoby Mathew	mrs	x9, ICC_HPPIR1_EL1
56f14d1886SSoby Mathew	mrs	x10, ICC_CTLR_EL3
57f14d1886SSoby Mathew	/* Store to the crash buf and print to console */
58f14d1886SSoby Mathew	bl	str_in_crash_buf_print
59f14d1886SSoby Mathew	b	print_gic_common
60f14d1886SSoby Mathew
61f14d1886SSoby Mathewprint_gicv2:
62b4315306SDan Handley	/* Load the gicc reg list to x6 */
63b4315306SDan Handley	adr	x6, gicc_regs
64b4315306SDan Handley	/* Load the gicc regs to gp regs used by str_in_crash_buf_print */
65b4315306SDan Handley	ldr	w8, [x17, #GICC_HPPIR]
66b4315306SDan Handley	ldr	w9, [x17, #GICC_AHPPIR]
67b4315306SDan Handley	ldr	w10, [x17, #GICC_CTLR]
68b4315306SDan Handley	/* Store to the crash buf and print to console */
69b4315306SDan Handley	bl	str_in_crash_buf_print
70b4315306SDan Handley
71f14d1886SSoby Mathewprint_gic_common:
72b4315306SDan Handley	/* Print the GICD_ISPENDR regs */
73b4315306SDan Handley	add	x7, x16, #GICD_ISPENDR
74b4315306SDan Handley	adr	x4, gicd_pend_reg
75b4315306SDan Handley	bl	asm_print_str
76b4315306SDan Handleygicd_ispendr_loop:
77b4315306SDan Handley	sub	x4, x7, x16
78b4315306SDan Handley	cmp	x4, #0x280
79b4315306SDan Handley	b.eq	exit_print_gic_regs
80b4315306SDan Handley	bl	asm_print_hex
81b4315306SDan Handley
82b4315306SDan Handley	adr	x4, spacer
83b4315306SDan Handley	bl	asm_print_str
84b4315306SDan Handley
85b4315306SDan Handley	ldr	x4, [x7], #8
86b4315306SDan Handley	bl	asm_print_hex
87b4315306SDan Handley
88b4315306SDan Handley	adr	x4, newline
89b4315306SDan Handley	bl	asm_print_str
90b4315306SDan Handley	b	gicd_ispendr_loop
91b4315306SDan Handleyexit_print_gic_regs:
92b4315306SDan Handley	.endm
93b4315306SDan Handley
94c3cf06f1SAntonio Nino Diaz#endif /* ARM_MACROS_S */
95