/* [<][>][^][v][top][bottom][index][help] */
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
30 #ifndef _MIPS_TRAPFRAME_H_
31 #define _MIPS_TRAPFRAME_H_
32
33 /*
34 * Structure describing what is saved on the stack during entry to
35 * the exception handler.
36 *
37 * This must agree with the code in exception.S.
38 */
39
40 struct trapframe {
41 uint32_t tf_vaddr; /* coprocessor 0 vaddr register */
42 uint32_t tf_status; /* coprocessor 0 status register */
43 uint32_t tf_cause; /* coprocessor 0 cause register */
44 uint32_t tf_lo;
45 uint32_t tf_hi;
46 uint32_t tf_ra; /* Saved register 31 */
47 uint32_t tf_at; /* Saved register 1 (AT) */
48 uint32_t tf_v0; /* Saved register 2 (v0) */
49 uint32_t tf_v1; /* etc. */
50 uint32_t tf_a0;
51 uint32_t tf_a1;
52 uint32_t tf_a2;
53 uint32_t tf_a3;
54 uint32_t tf_t0;
55 uint32_t tf_t1;
56 uint32_t tf_t2;
57 uint32_t tf_t3;
58 uint32_t tf_t4;
59 uint32_t tf_t5;
60 uint32_t tf_t6;
61 uint32_t tf_t7;
62 uint32_t tf_s0;
63 uint32_t tf_s1;
64 uint32_t tf_s2;
65 uint32_t tf_s3;
66 uint32_t tf_s4;
67 uint32_t tf_s5;
68 uint32_t tf_s6;
69 uint32_t tf_s7;
70 uint32_t tf_t8;
71 uint32_t tf_t9;
72 uint32_t tf_k0; /* dummy (see exception.S comments) */
73 uint32_t tf_k1; /* dummy */
74 uint32_t tf_gp;
75 uint32_t tf_sp;
76 uint32_t tf_s8;
77 uint32_t tf_epc; /* coprocessor 0 epc register */
78 };
79
80 /*
81 * MIPS exception codes.
82 */
83 #define EX_IRQ 0 /* Interrupt */
84 #define EX_MOD 1 /* TLB Modify (write to read-only page) */
85 #define EX_TLBL 2 /* TLB miss on load */
86 #define EX_TLBS 3 /* TLB miss on store */
87 #define EX_ADEL 4 /* Address error on load */
88 #define EX_ADES 5 /* Address error on store */
89 #define EX_IBE 6 /* Bus error on instruction fetch */
90 #define EX_DBE 7 /* Bus error on data load *or* store */
91 #define EX_SYS 8 /* Syscall */
92 #define EX_BP 9 /* Breakpoint */
93 #define EX_RI 10 /* Reserved (illegal) instruction */
94 #define EX_CPU 11 /* Coprocessor unusable */
95 #define EX_OVF 12 /* Arithmetic overflow */
96
97 /*
98 * Function to enter user mode. Does not return. The trapframe must
99 * be on the thread's own stack or bad things will happen.
100 */
101 void mips_usermode(struct trapframe *tf);
102
103 /*
104 * Arrays used to load the kernel stack and curthread on trap entry.
105 */
106 extern vaddr_t cpustacks[];
107 extern vaddr_t cputhreads[];
108
109
110 #endif /* _MIPS_TRAPFRAME_H_ */