00001 /* 00002 * Copyright (C) 2008 by Duane Ellis 00003 * 00004 * All rights reserved. 00005 * 00006 * The original code had been released as part of the LoastARM Project 00007 * under GPL Version 2 and is published here under the following license 00008 * with kind permission from the author: 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright 00017 * notice, this list of conditions and the following disclaimer in the 00018 * documentation and/or other materials provided with the distribution. 00019 * 3. Neither the name of the copyright holders nor the names of 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00030 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00031 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00033 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00034 * SUCH DAMAGE. 00035 * 00036 * For additional information see http://lostarm.sourceforge.net/ 00037 */ 00038 00047 #include <stdio.h> 00048 #include <sys/ptrace.h> 00049 #include <arch/arm/exception_c.h> 00050 00051 static const char spinner[] = { 00052 '|', 00053 '/', 00054 '-', 00055 '\\', 00056 '|', 00057 '/', 00058 '-', 00059 '\\' 00060 }; 00061 00062 static char spinner_idx; 00063 00064 void 00065 ARM_COMMON_Handler_crash( struct pt_regs *p, const char *name ) 00066 { 00067 int x; 00068 printf("\nUnexpected: %s\n", name ); 00069 ptrace_stackdump_regs( p ); 00070 x = 0; 00071 for(;;){ 00072 /* these numbers are all bullshit */ 00073 /* We cannot depend on any hardware */ 00074 /* the system has PANICed */ 00075 /* We have to do this in software */ 00076 00077 /* ASSUME 50mhz CPU, a 200mhz cpu is 4x faster */ 00078 /* ASSUME goal is 20 ticks per second */ 00079 /* ASSUME each loop = 20 instructions */ 00080 /* assume each instruction about 3 clocks */ 00081 /* thus - each loop = 60 clocks */ 00082 /* make the math easy - use 50 clocks */ 00083 /* thus 50,000,000 / 50 => 100,000 = 1 second */ 00084 /* we want 5 ticks per second, so 20,000 is good */ 00085 /* power of 2 is a better thing - we'll use 32K instead */ 00086 00087 if( x == 0 ){ 00088 putchar(8); 00089 x = spinner_idx; 00090 spinner_idx = (x+1) & 7; 00091 putchar(spinner[x]); 00092 x = (1<<16); 00093 } 00094 x--; 00095 } 00096 }