blob: be54f5def3895c9e8335057ee9189ee0d43d5169 [file] [log] [blame]
Soby Mathewa43d4312014-04-07 15:28:55 +01001/*
2 * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30#include <console.h>
31#include <debug.h>
Soby Mathewb79af932014-06-12 17:23:58 +010032#include <stdarg.h>
Soby Mathewa43d4312014-04-07 15:28:55 +010033#include <stdio.h>
34
35/******************************************************************
36* This function is invoked from assembler error handling routines and
37* prints out the string and the value in 64 bit hex format. These
38* are passed to the function as input parameters.
39********************************************************************/
40void print_string_value(char *s, unsigned long *mem)
41{
42 unsigned char i, temp;
43 unsigned long val;
44
45 while (*s) {
46 i = 16;
47 while (*s)
48 console_putc(*s++);
49
50 s++;
51
52 console_putc('\t');
53 console_putc(':');
54 console_putc('0');
55 console_putc('x');
56
57 val = *mem++;
58
59 while (i--) {
60 temp = (val >> (i << 2)) & 0xf;
61 if (temp < 0xa)
62 console_putc('0' + temp);
63 else
64 console_putc('A' + (temp - 0xa));
65 }
66 console_putc('\n');
67 }
68}
69
70/***********************************************************
71 * The common implementation of do_panic for all BL stages
72 ***********************************************************/
73
74#if DEBUG
75void __dead2 do_panic(const char *file, int line)
76{
Soby Mathewb79af932014-06-12 17:23:58 +010077 tf_printf("PANIC in file: %s line: %d\n", file, line);
Soby Mathewa43d4312014-04-07 15:28:55 +010078 while (1)
79 ;
80}
81#else
82void __dead2 do_panic(void)
83{
84 unsigned long pc_reg;
85 __asm__ volatile("mov %0, x30\n"
86 : "=r" (pc_reg) : );
87
88 /* x30 reports the next eligible instruction whereas we want the
89 * place where panic() is invoked. Hence decrement by 4.
90 */
Soby Mathewb79af932014-06-12 17:23:58 +010091 tf_printf("PANIC in PC location 0x%016X\n", pc_reg - 0x4);
Soby Mathewa43d4312014-04-07 15:28:55 +010092 while (1)
93 ;
94
95}
96#endif