diff options
author | Soby Mathew <soby.mathew@arm.com> | 2014-06-25 10:07:40 +0100 |
---|---|---|
committer | Soby Mathew <soby.mathew@arm.com> | 2014-07-28 11:03:20 +0100 |
commit | 626ed510f179c905a699f4663ee933c10892b4c3 (patch) | |
tree | a9328fb3d8a00b2f065be0e91ba225e46968247a /common | |
parent | bc9201289c9ae4ccfc6b11048431d47eba547a44 (diff) |
Rework the crash reporting in BL3-1 to use less stack
This patch reworks the crash reporting mechanism to further
optimise the stack and code size. The reporting makes use
of assembly console functions to avoid calling C Runtime
to report the CPU state. The crash buffer requirement is
reduced to 64 bytes with this implementation. The crash
buffer is now part of per-cpu data which makes retrieving
the crash buffer trivial.
Also now panic() will use crash reporting if
invoked from BL3-1.
Fixes ARM-software/tf-issues#199
Change-Id: I79d27a4524583d723483165dc40801f45e627da5
Diffstat (limited to 'common')
-rw-r--r-- | common/aarch64/debug.S (renamed from common/aarch64/assert.S) | 47 | ||||
-rw-r--r-- | common/debug.c | 96 |
2 files changed, 47 insertions, 96 deletions
diff --git a/common/aarch64/assert.S b/common/aarch64/debug.S index a62c8f51..b7d7ac23 100644 --- a/common/aarch64/assert.S +++ b/common/aarch64/debug.S @@ -139,3 +139,50 @@ func asm_print_hex cbnz x5, 1b ret x3 + /*********************************************************** + * The common implementation of do_panic for all BL stages + ***********************************************************/ + +.section .rodata.panic_str, "aS" + panic_msg: .asciz "PANIC at PC : 0x" + +/* --------------------------------------------------------------------------- + * do_panic assumes that it is invoked from a C Runtime Environment ie a + * valid stack exists. This call will not return. + * Clobber list : if CRASH_REPORTING is not enabled then x30, x0 - x6 + * --------------------------------------------------------------------------- + */ + +/* This is for the non el3 BL stages to compile through */ + .weak el3_panic + +func do_panic +#if CRASH_REPORTING + str x0, [sp, #-0x10]! + mrs x0, currentel + ubfx x0, x0, #2, #2 + cmp x0, #0x3 + ldr x0, [sp], #0x10 + b.eq el3_panic +#endif + +panic_common: +/* + * el3_panic will be redefined by the BL31 + * crash reporting mechanism (if enabled) + */ +el3_panic: + mov x6, x30 + bl plat_crash_console_init + /* Check if the console is initialized */ + cbz x0, _panic_loop + /* The console is initialized */ + adr x4, panic_msg + bl asm_print_str + mov x4, x6 + /* The panic location is lr -4 */ + sub x4, x4, #4 + bl asm_print_hex +_panic_loop: + b _panic_loop + diff --git a/common/debug.c b/common/debug.c deleted file mode 100644 index be54f5de..00000000 --- a/common/debug.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include <console.h> -#include <debug.h> -#include <stdarg.h> -#include <stdio.h> - -/****************************************************************** -* This function is invoked from assembler error handling routines and -* prints out the string and the value in 64 bit hex format. These -* are passed to the function as input parameters. -********************************************************************/ -void print_string_value(char *s, unsigned long *mem) -{ - unsigned char i, temp; - unsigned long val; - - while (*s) { - i = 16; - while (*s) - console_putc(*s++); - - s++; - - console_putc('\t'); - console_putc(':'); - console_putc('0'); - console_putc('x'); - - val = *mem++; - - while (i--) { - temp = (val >> (i << 2)) & 0xf; - if (temp < 0xa) - console_putc('0' + temp); - else - console_putc('A' + (temp - 0xa)); - } - console_putc('\n'); - } -} - -/*********************************************************** - * The common implementation of do_panic for all BL stages - ***********************************************************/ - -#if DEBUG -void __dead2 do_panic(const char *file, int line) -{ - tf_printf("PANIC in file: %s line: %d\n", file, line); - while (1) - ; -} -#else -void __dead2 do_panic(void) -{ - unsigned long pc_reg; - __asm__ volatile("mov %0, x30\n" - : "=r" (pc_reg) : ); - - /* x30 reports the next eligible instruction whereas we want the - * place where panic() is invoked. Hence decrement by 4. - */ - tf_printf("PANIC in PC location 0x%016X\n", pc_reg - 0x4); - while (1) - ; - -} -#endif |