trapframe.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
  3. * The President and Fellows of Harvard College.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. #ifndef _MIPS_TRAPFRAME_H_
  30. #define _MIPS_TRAPFRAME_H_
  31. /*
  32. * Structure describing what is saved on the stack during entry to
  33. * the exception handler.
  34. *
  35. * This must agree with the code in exception.S.
  36. */
  37. struct trapframe {
  38. uint32_t tf_vaddr; /* coprocessor 0 vaddr register */
  39. uint32_t tf_status; /* coprocessor 0 status register */
  40. uint32_t tf_cause; /* coprocessor 0 cause register */
  41. uint32_t tf_lo;
  42. uint32_t tf_hi;
  43. uint32_t tf_ra; /* Saved register 31 */
  44. uint32_t tf_at; /* Saved register 1 (AT) */
  45. uint32_t tf_v0; /* Saved register 2 (v0) */
  46. uint32_t tf_v1; /* etc. */
  47. uint32_t tf_a0;
  48. uint32_t tf_a1;
  49. uint32_t tf_a2;
  50. uint32_t tf_a3;
  51. uint32_t tf_t0;
  52. uint32_t tf_t1;
  53. uint32_t tf_t2;
  54. uint32_t tf_t3;
  55. uint32_t tf_t4;
  56. uint32_t tf_t5;
  57. uint32_t tf_t6;
  58. uint32_t tf_t7;
  59. uint32_t tf_s0;
  60. uint32_t tf_s1;
  61. uint32_t tf_s2;
  62. uint32_t tf_s3;
  63. uint32_t tf_s4;
  64. uint32_t tf_s5;
  65. uint32_t tf_s6;
  66. uint32_t tf_s7;
  67. uint32_t tf_t8;
  68. uint32_t tf_t9;
  69. uint32_t tf_k0; /* dummy (see exception.S comments) */
  70. uint32_t tf_k1; /* dummy */
  71. uint32_t tf_gp;
  72. uint32_t tf_sp;
  73. uint32_t tf_s8;
  74. uint32_t tf_epc; /* coprocessor 0 epc register */
  75. };
  76. /*
  77. * MIPS exception codes.
  78. */
  79. #define EX_IRQ 0 /* Interrupt */
  80. #define EX_MOD 1 /* TLB Modify (write to read-only page) */
  81. #define EX_TLBL 2 /* TLB miss on load */
  82. #define EX_TLBS 3 /* TLB miss on store */
  83. #define EX_ADEL 4 /* Address error on load */
  84. #define EX_ADES 5 /* Address error on store */
  85. #define EX_IBE 6 /* Bus error on instruction fetch */
  86. #define EX_DBE 7 /* Bus error on data load *or* store */
  87. #define EX_SYS 8 /* Syscall */
  88. #define EX_BP 9 /* Breakpoint */
  89. #define EX_RI 10 /* Reserved (illegal) instruction */
  90. #define EX_CPU 11 /* Coprocessor unusable */
  91. #define EX_OVF 12 /* Arithmetic overflow */
  92. /*
  93. * Function to enter user mode. Does not return. The trapframe must
  94. * be on the thread's own stack or bad things will happen.
  95. */
  96. void mips_usermode(struct trapframe *tf);
  97. /*
  98. * Arrays used to load the kernel stack and curthread on trap entry.
  99. */
  100. extern vaddr_t cpustacks[];
  101. extern vaddr_t cputhreads[];
  102. #endif /* _MIPS_TRAPFRAME_H_ */