trap.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. * 2008-12-11 XuXinming first version
  13. */
  14. #include <rtthread.h>
  15. #include <rthw.h>
  16. #include "LPC24xx.h"
  17. //#define BSP_INT_DEBUG
  18. /**
  19. * @addtogroup LPC2478
  20. */
  21. /*@{*/
  22. /**
  23. * this function will show registers of CPU
  24. *
  25. * @param regs the registers point
  26. */
  27. void rt_hw_show_register (struct rt_hw_register *regs)
  28. {
  29. rt_kprintf("Execption:\n");
  30. rt_kprintf("r00:0x%08x r01:0x%08x r02:0x%08x r03:0x%08x\n", regs->r0, regs->r1, regs->r2, regs->r3);
  31. rt_kprintf("r04:0x%08x r05:0x%08x r06:0x%08x r07:0x%08x\n", regs->r4, regs->r5, regs->r6, regs->r7);
  32. rt_kprintf("r08:0x%08x r09:0x%08x r10:0x%08x\n", regs->r8, regs->r9, regs->r10);
  33. rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip);
  34. rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
  35. rt_kprintf("cpsr:0x%08x\n", regs->cpsr);
  36. }
  37. /**
  38. * When ARM7TDMI comes across an instruction which it cannot handle,
  39. * it takes the undefined instruction trap.
  40. *
  41. * @param regs system registers
  42. *
  43. * @note never invoke this function in application
  44. */
  45. void rt_hw_trap_udef(struct rt_hw_register *regs)
  46. {
  47. rt_kprintf("undefined instruction\n");
  48. rt_hw_show_register(regs);
  49. rt_hw_cpu_shutdown();
  50. }
  51. /**
  52. * The software interrupt instruction (SWI) is used for entering
  53. * Supervisor mode, usually to request a particular supervisor
  54. * function.
  55. *
  56. * @param regs system registers
  57. *
  58. * @note never invoke this function in application
  59. */
  60. void rt_hw_trap_swi(struct rt_hw_register *regs)
  61. {
  62. rt_kprintf("software interrupt\n");
  63. rt_hw_show_register(regs);
  64. rt_hw_cpu_shutdown();
  65. }
  66. /**
  67. * An abort indicates that the current memory access cannot be completed,
  68. * which occurs during an instruction prefetch.
  69. *
  70. * @param regs system registers
  71. *
  72. * @note never invoke this function in application
  73. */
  74. void rt_hw_trap_pabt(struct rt_hw_register *regs)
  75. {
  76. rt_kprintf("prefetch abort\n");
  77. rt_hw_show_register(regs);
  78. rt_hw_cpu_shutdown();
  79. }
  80. /**
  81. * An abort indicates that the current memory access cannot be completed,
  82. * which occurs during a data access.
  83. *
  84. * @param regs system registers
  85. *
  86. * @note never invoke this function in application
  87. */
  88. void rt_hw_trap_dabt(struct rt_hw_register *regs)
  89. {
  90. rt_kprintf("Data Abort ");
  91. rt_hw_show_register(regs);
  92. rt_hw_cpu_shutdown();
  93. }
  94. /**
  95. * Normally, system will never reach here
  96. *
  97. * @param regs system registers
  98. *
  99. * @note never invoke this function in application
  100. */
  101. void rt_hw_trap_resv(struct rt_hw_register *regs)
  102. {
  103. rt_kprintf("not used\n");
  104. rt_hw_show_register(regs);
  105. rt_hw_cpu_shutdown();
  106. }
  107. extern rt_isr_handler_t isr_table[];
  108. void rt_hw_trap_irq()
  109. {
  110. rt_isr_handler_t isr_func;
  111. isr_func = (rt_isr_handler_t) VICVectAddr;
  112. isr_func(0);
  113. }
  114. void rt_hw_trap_fiq()
  115. {
  116. rt_kprintf("fast interrupt request\n");
  117. }
  118. /*@}*/