common_xxx_handler.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2008 by Duane Ellis
  3. *
  4. * All rights reserved.
  5. *
  6. * The original code had been released as part of the LoastARM Project
  7. * under GPL Version 2 and is published here under the following license
  8. * with kind permission from the author:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. *
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. Neither the name of the copyright holders nor the names of
  20. * contributors may be used to endorse or promote products derived
  21. * from this software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  30. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  31. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  33. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. * SUCH DAMAGE.
  35. *
  36. * For additional information see http://lostarm.sourceforge.net/
  37. */
  38. /*!
  39. * \file arch/arm/debug/common_xxx_handler.c
  40. *
  41. * \verbatim
  42. * $Id: common_xxx_handler.c 4115 2012-04-12 21:06:13Z olereinhardt $
  43. * \endverbatim
  44. */
  45. #include <stdio.h>
  46. #include <sys/ptrace.h>
  47. #include <arch/arm/exception_c.h>
  48. static const char spinner[] = {
  49. '|',
  50. '/',
  51. '-',
  52. '\\',
  53. '|',
  54. '/',
  55. '-',
  56. '\\'
  57. };
  58. static char spinner_idx;
  59. void
  60. ARM_COMMON_Handler_crash( struct pt_regs *p, const char *name )
  61. {
  62. int x;
  63. printf("\nUnexpected: %s\n", name );
  64. ptrace_stackdump_regs( p );
  65. x = 0;
  66. for(;;){
  67. /* these numbers are all bullshit */
  68. /* We cannot depend on any hardware */
  69. /* the system has PANICed */
  70. /* We have to do this in software */
  71. /* ASSUME 50mhz CPU, a 200mhz cpu is 4x faster */
  72. /* ASSUME goal is 20 ticks per second */
  73. /* ASSUME each loop = 20 instructions */
  74. /* assume each instruction about 3 clocks */
  75. /* thus - each loop = 60 clocks */
  76. /* make the math easy - use 50 clocks */
  77. /* thus 50,000,000 / 50 => 100,000 = 1 second */
  78. /* we want 5 ticks per second, so 20,000 is good */
  79. /* power of 2 is a better thing - we'll use 32K instead */
  80. if( x == 0 ){
  81. putchar(8);
  82. x = spinner_idx;
  83. spinner_idx = (x+1) & 7;
  84. putchar(spinner[x]);
  85. x = (1<<16);
  86. }
  87. x--;
  88. }
  89. }