trap.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * File : trap.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-03-13 Bernard first version
  13. * 2006-05-27 Bernard add skyeye support
  14. * 2007-11-19 Yi.Qiu fix rt_hw_trap_irq function
  15. */
  16. #include <rtthread.h>
  17. #include <rthw.h>
  18. #include "s3c24x0.h"
  19. /**
  20. * @addtogroup S3C24X0
  21. */
  22. /*@{*/
  23. extern struct rt_thread *rt_current_thread;
  24. /**
  25. * this function will show registers of CPU
  26. *
  27. * @param regs the registers point
  28. */
  29. void rt_hw_show_register (struct rt_hw_register *regs)
  30. {
  31. rt_kprintf("Execption:\n");
  32. rt_kprintf("r00:0x%08x r01:0x%08x r02:0x%08x r03:0x%08x\n", regs->r0, regs->r1, regs->r2, regs->r3);
  33. rt_kprintf("r04:0x%08x r05:0x%08x r06:0x%08x r07:0x%08x\n", regs->r4, regs->r5, regs->r6, regs->r7);
  34. rt_kprintf("r08:0x%08x r09:0x%08x r10:0x%08x\n", regs->r8, regs->r9, regs->r10);
  35. rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip);
  36. rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
  37. rt_kprintf("cpsr:0x%08x\n", regs->cpsr);
  38. }
  39. /**
  40. * When ARM7TDMI comes across an instruction which it cannot handle,
  41. * it takes the undefined instruction trap.
  42. *
  43. * @param regs system registers
  44. *
  45. * @note never invoke this function in application
  46. */
  47. void rt_hw_trap_udef(struct rt_hw_register *regs)
  48. {
  49. rt_hw_show_register(regs);
  50. rt_kprintf("undefined instruction\n");
  51. rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
  52. #ifdef RT_USING_FINSH
  53. list_thread();
  54. #endif
  55. while (1);
  56. rt_hw_cpu_shutdown();
  57. }
  58. /**
  59. * The software interrupt instruction (SWI) is used for entering
  60. * Supervisor mode, usually to request a particular supervisor
  61. * function.
  62. *
  63. * @param regs system registers
  64. *
  65. * @note never invoke this function in application
  66. */
  67. void rt_hw_trap_swi(struct rt_hw_register *regs)
  68. {
  69. rt_hw_show_register(regs);
  70. rt_kprintf("software interrupt\n");
  71. rt_hw_cpu_shutdown();
  72. }
  73. /**
  74. * An abort indicates that the current memory access cannot be completed,
  75. * which occurs during an instruction prefetch.
  76. *
  77. * @param regs system registers
  78. *
  79. * @note never invoke this function in application
  80. */
  81. void rt_hw_trap_pabt(struct rt_hw_register *regs)
  82. {
  83. rt_hw_show_register(regs);
  84. rt_kprintf("prefetch abort\n");
  85. rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
  86. #ifdef RT_USING_FINSH
  87. list_thread();
  88. #endif
  89. while (1);
  90. rt_hw_cpu_shutdown();
  91. }
  92. /**
  93. * An abort indicates that the current memory access cannot be completed,
  94. * which occurs during a data access.
  95. *
  96. * @param regs system registers
  97. *
  98. * @note never invoke this function in application
  99. */
  100. void rt_hw_trap_dabt(struct rt_hw_register *regs)
  101. {
  102. rt_hw_show_register(regs);
  103. rt_kprintf("data abort\n");
  104. rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
  105. #ifdef RT_USING_FINSH
  106. list_thread();
  107. #endif
  108. while (1);
  109. rt_hw_cpu_shutdown();
  110. }
  111. /**
  112. * Normally, system will never reach here
  113. *
  114. * @param regs system registers
  115. *
  116. * @note never invoke this function in application
  117. */
  118. void rt_hw_trap_resv(struct rt_hw_register *regs)
  119. {
  120. rt_kprintf("not used\n");
  121. rt_hw_show_register(regs);
  122. rt_hw_cpu_shutdown();
  123. }
  124. extern rt_isr_handler_t isr_table[];
  125. void rt_hw_trap_irq()
  126. {
  127. unsigned long intstat;
  128. rt_isr_handler_t isr_func;
  129. intstat = INTOFFSET;
  130. if (intstat == INTGLOBAL) return;
  131. /* clear pending register */
  132. ClearPending(1 << intstat);
  133. /* get interrupt service routine */
  134. isr_func = isr_table[intstat];
  135. /* turn to interrupt service routine */
  136. isr_func(intstat);
  137. }
  138. void rt_hw_trap_fiq()
  139. {
  140. rt_kprintf("fast interrupt request\n");
  141. }
  142. /*@}*/