os161-1.99
 All Data Structures
specialreg.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_SPECIALREG_H_
00031 #define _MIPS_SPECIALREG_H_
00032 
00033 
00034 /*
00035  * Coprocessor 0 (system processor) register numbers
00036  */
00037 #define c0_index    $0          /* TLB entry index register */
00038 #define c0_random   $1          /* TLB random slot register */
00039 #define c0_entrylo  $2          /* TLB entry contents (low-order half) */
00040 /*      c0_entrylo0 $2 */       /* MIPS-II and up only */
00041 /*      c0_entrylo1 $3 */       /* MIPS-II and up only */
00042 #define c0_context  $4          /* some precomputed pagetable stuff */
00043 /*      c0_pagemask $5 */       /* MIPS-II and up only */
00044 /*      c0_wired    $6 */       /* MIPS-II and up only */
00045 #define c0_vaddr    $8          /* virtual addr of failing memory access */
00046 #define c0_count    $9          /* cycle counter (MIPS-II and up) */
00047 #define c0_entryhi  $10         /* TLB entry contents (high-order half) */
00048 #define c0_compare  $11         /* on-chip timer control (MIPS-II and up) */
00049 #define c0_status   $12         /* processor status register */
00050 #define c0_cause    $13         /* exception cause register */
00051 #define c0_epc      $14         /* exception PC register */
00052 #define c0_prid     $15         /* processor ID register */
00053 /*      c0_config   $16 */      /* MIPS-II and up only */
00054 /*      c0_lladdr   $17 */      /* MIPS-II and up only */
00055 /*      c0_watchlo  $18 */      /* MIPS-II and up only */
00056 /*      c0_watchhi  $19 */      /* MIPS-II and up only */
00057 
00058 /*
00059  * Mode bits in c0_status
00060  */
00061 #define CST_IEc      0x00000001 /* current: interrupt enable */
00062 #define CST_KUc      0x00000002 /* current: user mode */
00063 #define CST_IEp      0x00000004 /* previous: interrupt enable */
00064 #define CST_KUp      0x00000008 /* previous: user mode */
00065 #define CST_IEo      0x00000010 /* old: interrupt enable */
00066 #define CST_KUo      0x00000020 /* old: user mode */
00067 #define CST_MODEMASK 0x0000003f /* mask for the above */
00068 #define CST_IRQMASK  0x0000ff00 /* mask for the individual irq enable bits */
00069 #define CST_BEV      0x00400000 /* bootstrap exception vectors flag */
00070 
00071 /*
00072  * Fields of the c0_cause register 
00073  */
00074 #define CCA_UTLB   0x00000001   /* true if UTLB exception (set by our asm) */
00075 #define CCA_CODE   0x0000003c   /* EX_foo in trapframe.h */
00076 #define CCA_IRQS   0x0000ff00   /* Currently pending interrupts */
00077 #define CCA_COPN   0x30000000   /* Coprocessor number for EX_CPU */
00078 #define CCA_JD     0x80000000   /* True if exception happened in jump delay */
00079 
00080 #define CCA_CODESHIFT   2       /* shift for CCA_CODE field */
00081 
00082 /*
00083  * Fields of the c0_index register
00084  */
00085 #define CIN_P      0x80000000   /* nonzero -> TLB probe found nothing */
00086 #define CIN_INDEX  0x00003f00   /* 6-bit index into TLB */
00087 
00088 #define CIN_INDEXSHIFT  8       /* shift for CIN_INDEX field */
00089 
00090 /*
00091  * Fields of the c0_context register
00092  *
00093  * The intent of c0_context is that you can manage virtually-mapped
00094  * page tables in kseg2; then you load the base address of the current
00095  * page table into c0_context. On a TLB miss the failing address is
00096  * masked and shifted and appears in the VSHIFT field, and c0_context
00097  * thereby contains the address of the page table entry you need to
00098  * load into the TLB. This can be used to make TLB refill very fast.
00099  *
00100  * However, in OS/161 we use CTX_PTBASE to hold the current CPU
00101  * number. This (or something like it) is fairly important to have and
00102  * there's no other good place in the chip to put it. See discussions
00103  * elsewhere.
00104  */
00105 #define CTX_VSHIFT 0x001ffffc   /* shifted/masked copy of c0_vaddr */
00106 #define CTX_PTBASE 0xffe00000   /* page table base address */
00107 
00108 #define CTX_PTBASESHIFT  21     /* shift for CTX_PBASE field */
00109 
00110 /*
00111  * Hardwired exception handler addresses.
00112  */
00113 #define EXADDR_UTLB     0x80000000
00114 #define EXADDR_GENERAL  0x80000080
00115 
00116 
00117 #endif /* _MIPS_SPECIALREG_H_ */
 All Data Structures