blob: 680c0a1d4920945abeefdb3509274b2f5bf6a995 [file] [log] [blame]
Haojian Zhuang5f281b32017-05-24 08:45:05 +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>
9#include "../hikey_def.h"
10
11 .globl plat_my_core_pos
12 .globl platform_mem_init
13 .globl plat_crash_console_init
14 .globl plat_crash_console_putc
15 .globl plat_report_exception
16 .globl plat_reset_handler
17
18func plat_my_core_pos
19 mrs x0, mpidr_el1
20 and x1, x0, #MPIDR_CPU_MASK
21 and x0, x0, #MPIDR_CLUSTER_MASK
22 add x0, x1, x0, LSR #6
23 ret
24endfunc plat_my_core_pos
25
26 /* -----------------------------------------------------
27 * void platform_mem_init(void);
28 *
29 * We don't need to carry out any memory initialization
30 * on HIKEY. The Secure RAM is accessible straight away.
31 * -----------------------------------------------------
32 */
33func platform_mem_init
34 ret
35endfunc platform_mem_init
36
37 /* ---------------------------------------------
38 * int plat_crash_console_init(void)
39 * Function to initialize the crash console
40 * without a C Runtime to print crash report.
41 * Clobber list : x0, x1, x2
42 * ---------------------------------------------
43 */
44func plat_crash_console_init
45 mov_imm x0, CRASH_CONSOLE_BASE
46 mov_imm x1, PL011_UART_CLK_IN_HZ
47 mov_imm x2, PL011_BAUDRATE
48 b console_core_init
49endfunc plat_crash_console_init
50
51 /* ---------------------------------------------
52 * int plat_crash_console_putc(int c)
53 * Function to print a character on the crash
54 * console without a C Runtime.
55 * Clobber list : x1, x2
56 * ---------------------------------------------
57 */
58func plat_crash_console_putc
59 mov_imm x1, CRASH_CONSOLE_BASE
60 b console_core_putc
61endfunc plat_crash_console_putc
62
63 /* ---------------------------------------------
64 * void plat_report_exception(unsigned int type)
65 * Function to report an unhandled exception
66 * with platform-specific means.
67 * On HIKEY platform, it updates the LEDs
68 * to indicate where we are
69 * ---------------------------------------------
70 */
71func plat_report_exception
72 mov x8, x30
73
74 /* Turn on LED according to x0 (0 -- f) */
75 ldr x2, =0xf7020000
76 and x1, x0, #1
77 str w1, [x2, #4]
78 and x1, x0, #2
79 str w1, [x2, #8]
80 and x1, x0, #4
81 str w1, [x2, #16]
82 and x1, x0, #8
83 str w1, [x2, #32]
84
85 mrs x2, currentel
86 and x2, x2, #0xc0
87 /* Check EL1 */
88 cmp x2, #0x04
89 beq plat_report_el1
90
91 adr x4, plat_err_str
92 bl asm_print_str
93
94 adr x4, esr_el3_str
95 bl asm_print_str
96
97 mrs x4, esr_el3
98 bl asm_print_hex
99
100 adr x4, elr_el3_str
101 bl asm_print_str
102
103 mrs x4, elr_el3
104 bl asm_print_hex
105 b plat_report_end
106
107plat_report_el1:
108 adr x4, plat_err_str
109 bl asm_print_str
110
111 adr x4, esr_el1_str
112 bl asm_print_str
113
114 mrs x4, esr_el1
115 bl asm_print_hex
116
117 adr x4, elr_el1_str
118 bl asm_print_str
119
120 mrs x4, elr_el1
121 bl asm_print_hex
122plat_report_end:
123 mov x30, x8
124 ret
125endfunc plat_report_exception
126
127 /* -----------------------------------------------------
128 * void plat_reset_handler(void);
129 * -----------------------------------------------------
130 */
131func plat_reset_handler
132 ret
133endfunc plat_reset_handler
134
135.section .rodata.rev_err_str, "aS"
136plat_err_str:
137 .asciz "\nPlatform exception reporting:"
138esr_el3_str:
139 .asciz "\nESR_EL3: "
140elr_el3_str:
141 .asciz "\nELR_EL3: "
142esr_el1_str:
143 .asciz "\nESR_EL1: "
144elr_el1_str:
145 .asciz "\nELR_EL1: "