os161-1.99
 All Data Structures
trapframe.h
00001 /*
00002  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
00003  *      The President and Fellows of Harvard College.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 #ifndef _MIPS_TRAPFRAME_H_
00031 #define _MIPS_TRAPFRAME_H_
00032 
00033 /*
00034  * Structure describing what is saved on the stack during entry to
00035  * the exception handler.
00036  *
00037  * This must agree with the code in exception.S.
00038  */
00039 
00040 struct trapframe {
00041         uint32_t tf_vaddr;      /* coprocessor 0 vaddr register */
00042         uint32_t tf_status;     /* coprocessor 0 status register */
00043         uint32_t tf_cause;      /* coprocessor 0 cause register */
00044         uint32_t tf_lo;
00045         uint32_t tf_hi;
00046         uint32_t tf_ra;         /* Saved register 31 */
00047         uint32_t tf_at;         /* Saved register 1 (AT) */
00048         uint32_t tf_v0;         /* Saved register 2 (v0) */
00049         uint32_t tf_v1;         /* etc. */
00050         uint32_t tf_a0;
00051         uint32_t tf_a1;
00052         uint32_t tf_a2;
00053         uint32_t tf_a3;
00054         uint32_t tf_t0;
00055         uint32_t tf_t1;
00056         uint32_t tf_t2;
00057         uint32_t tf_t3;
00058         uint32_t tf_t4;
00059         uint32_t tf_t5;
00060         uint32_t tf_t6;
00061         uint32_t tf_t7;
00062         uint32_t tf_s0;
00063         uint32_t tf_s1;
00064         uint32_t tf_s2;
00065         uint32_t tf_s3;
00066         uint32_t tf_s4;
00067         uint32_t tf_s5;
00068         uint32_t tf_s6;
00069         uint32_t tf_s7;
00070         uint32_t tf_t8;
00071         uint32_t tf_t9;
00072         uint32_t tf_k0;         /* dummy (see exception.S comments) */
00073         uint32_t tf_k1;         /* dummy */
00074         uint32_t tf_gp;
00075         uint32_t tf_sp;
00076         uint32_t tf_s8;
00077         uint32_t tf_epc;        /* coprocessor 0 epc register */
00078 };
00079 
00080 /*
00081  * MIPS exception codes.
00082  */
00083 #define EX_IRQ    0    /* Interrupt */
00084 #define EX_MOD    1    /* TLB Modify (write to read-only page) */
00085 #define EX_TLBL   2    /* TLB miss on load */
00086 #define EX_TLBS   3    /* TLB miss on store */
00087 #define EX_ADEL   4    /* Address error on load */
00088 #define EX_ADES   5    /* Address error on store */
00089 #define EX_IBE    6    /* Bus error on instruction fetch */
00090 #define EX_DBE    7    /* Bus error on data load *or* store */
00091 #define EX_SYS    8    /* Syscall */
00092 #define EX_BP     9    /* Breakpoint */
00093 #define EX_RI     10   /* Reserved (illegal) instruction */
00094 #define EX_CPU    11   /* Coprocessor unusable */
00095 #define EX_OVF    12   /* Arithmetic overflow */
00096 
00097 /*
00098  * Function to enter user mode. Does not return. The trapframe must
00099  * be on the thread's own stack or bad things will happen.
00100  */
00101 void mips_usermode(struct trapframe *tf);
00102 
00103 /*
00104  * Arrays used to load the kernel stack and curthread on trap entry.
00105  */
00106 extern vaddr_t cpustacks[];
00107 extern vaddr_t cputhreads[];
00108 
00109 
00110 #endif /* _MIPS_TRAPFRAME_H_ */
 All Data Structures