blob: d18399fbf788f209de53323a6872511c3576f0ec [file] [log] [blame]
Haojian Zhuang602362d2017-06-01 12:15:14 +08001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
Haojian Zhuang1b5c2252017-06-01 15:20:46 +08009#include <cortex_a53.h>
10#include <cortex_a73.h>
Haojian Zhuang602362d2017-06-01 12:15:14 +080011#include "../hikey960_def.h"
12
13 .globl plat_my_core_pos
14 .globl platform_mem_init
15 .globl plat_crash_console_init
16 .globl plat_crash_console_putc
17 .globl plat_report_exception
18 .globl plat_reset_handler
Haojian Zhuang1b5c2252017-06-01 15:20:46 +080019 .globl clr_ex
20 .globl nop
Haojian Zhuang602362d2017-06-01 12:15:14 +080021
22func plat_my_core_pos
23 mrs x0, mpidr_el1
24 and x1, x0, #MPIDR_CPU_MASK
25 and x0, x0, #MPIDR_CLUSTER_MASK
26 add x0, x1, x0, LSR #6
27 ret
28endfunc plat_my_core_pos
29
30 /* -----------------------------------------------------
31 * void platform_mem_init(void);
32 *
33 * We don't need to carry out any memory initialization
34 * on HIKEY. The Secure RAM is accessible straight away.
35 * -----------------------------------------------------
36 */
37func platform_mem_init
38 ret
39endfunc platform_mem_init
40
41 /* ---------------------------------------------
42 * int plat_crash_console_init(void)
43 * Function to initialize the crash console
44 * without a C Runtime to print crash report.
45 * Clobber list : x0, x1, x2
46 * ---------------------------------------------
47 */
48func plat_crash_console_init
49 mov_imm x0, CRASH_CONSOLE_BASE
50 mov_imm x1, PL011_UART_CLK_IN_HZ
51 mov_imm x2, PL011_BAUDRATE
52 b console_core_init
53endfunc plat_crash_console_init
54
55 /* ---------------------------------------------
56 * int plat_crash_console_putc(int c)
57 * Function to print a character on the crash
58 * console without a C Runtime.
59 * Clobber list : x1, x2
60 * ---------------------------------------------
61 */
62func plat_crash_console_putc
63 mov_imm x1, CRASH_CONSOLE_BASE
64 b console_core_putc
65endfunc plat_crash_console_putc
66
67 /* ---------------------------------------------
68 * void plat_report_exception(unsigned int type)
69 * Function to report an unhandled exception
70 * with platform-specific means.
71 * On HIKEY platform, it updates the LEDs
72 * to indicate where we are
73 * ---------------------------------------------
74 */
75func plat_report_exception
76 mov x8, x30
77
78 /* Turn on LED according to x0 (0 -- f) */
79 ldr x2, =0xf7020000
80 and x1, x0, #1
81 str w1, [x2, #4]
82 and x1, x0, #2
83 str w1, [x2, #8]
84 and x1, x0, #4
85 str w1, [x2, #16]
86 and x1, x0, #8
87 str w1, [x2, #32]
88
89 mrs x2, currentel
90 and x2, x2, #0x0c
91 /* Check EL1 */
92 cmp x2, #0x04
93 beq plat_report_el1
94
95 adr x4, plat_err_str
96 bl asm_print_str
97
98 adr x4, esr_el3_str
99 bl asm_print_str
100
101 mrs x4, esr_el3
102 bl asm_print_hex
103
104 adr x4, elr_el3_str
105 bl asm_print_str
106
107 mrs x4, elr_el3
108 bl asm_print_hex
109 b plat_report_end
110
111plat_report_el1:
112 adr x4, plat_err_str
113 bl asm_print_str
114
115 adr x4, esr_el1_str
116 bl asm_print_str
117
118 mrs x4, esr_el1
119 bl asm_print_hex
120
121 adr x4, elr_el1_str
122 bl asm_print_str
123
124 mrs x4, elr_el1
125 bl asm_print_hex
126plat_report_end:
127 mov x30, x8
128 ret
129endfunc plat_report_exception
130
131 /* -----------------------------------------------------
132 * void plat_reset_handler(void);
133 * -----------------------------------------------------
134 */
135func plat_reset_handler
136 ret
137endfunc plat_reset_handler
138
Haojian Zhuang1b5c2252017-06-01 15:20:46 +0800139 /* -----------------------------------------------------
Haojian Zhuang1b5c2252017-06-01 15:20:46 +0800140 * void clrex(void);
141 * -----------------------------------------------------
142 */
143func clr_ex
144 clrex
145 ret
146endfunc clr_ex
147
148 /* -----------------------------------------------------
149 * void nop(void);
150 * -----------------------------------------------------
151 */
152func nop
153 nop
154 ret
155endfunc nop
156
Haojian Zhuang602362d2017-06-01 12:15:14 +0800157.section .rodata.rev_err_str, "aS"
158plat_err_str:
159 .asciz "\nPlatform exception reporting:"
160esr_el3_str:
161 .asciz "\nESR_EL3: "
162elr_el3_str:
163 .asciz "\nELR_EL3: "
164esr_el1_str:
165 .asciz "\nESR_EL1: "
166elr_el1_str:
167 .asciz "\nELR_EL1: "