blob: 0f59ed5e9738f47536d420e68855a3d83100fab1 [file] [log] [blame]
Soby Mathew5e5c2072014-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>
32#include <stdio.h>
33
34/******************************************************************
35* This function is invoked from assembler error handling routines and
36* prints out the string and the value in 64 bit hex format. These
37* are passed to the function as input parameters.
38********************************************************************/
39void print_string_value(char *s, unsigned long *mem)
40{
41 unsigned char i, temp;
42 unsigned long val;
43
44 while (*s) {
45 i = 16;
46 while (*s)
47 console_putc(*s++);
48
49 s++;
50
51 console_putc('\t');
52 console_putc(':');
53 console_putc('0');
54 console_putc('x');
55
56 val = *mem++;
57
58 while (i--) {
59 temp = (val >> (i << 2)) & 0xf;
60 if (temp < 0xa)
61 console_putc('0' + temp);
62 else
63 console_putc('A' + (temp - 0xa));
64 }
65 console_putc('\n');
66 }
67}
68
69/***********************************************************
70 * The common implementation of do_panic for all BL stages
71 ***********************************************************/
72
73#if DEBUG
74void __dead2 do_panic(const char *file, int line)
75{
76 printf("PANIC in file: %s line: %d\n", file, line);
77 while (1)
78 ;
79}
80#else
81void __dead2 do_panic(void)
82{
83 unsigned long pc_reg;
84 __asm__ volatile("mov %0, x30\n"
85 : "=r" (pc_reg) : );
86
87 /* x30 reports the next eligible instruction whereas we want the
88 * place where panic() is invoked. Hence decrement by 4.
89 */
90 printf("PANIC in PC location 0x%016X\n", pc_reg - 0x4);
91 while (1)
92 ;
93
94}
95#endif