/*1* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 20092* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _MIPS_TLB_H_30#define _MIPS_TLB_H_3132/*33* MIPS-specific TLB access functions.34*35* tlb_random: write the TLB entry specified by ENTRYHI and ENTRYLO36* into a "random" TLB slot chosen by the processor.37*38* IMPORTANT NOTE: never write more than one TLB entry with the39* same virtual page field.40*41* tlb_write: same as tlb_random, but you choose the slot.42*43* tlb_read: read a TLB entry out of the TLB into ENTRYHI and ENTRYLO.44* INDEX specifies which one to get.45*46* tlb_probe: look for an entry matching the virtual page in ENTRYHI.47* Returns the index, or a negative number if no matching entry48* was found. ENTRYLO is not actually used, but must be set; 049* should be passed.50*51* IMPORTANT NOTE: An entry may be matching even if the valid bit52* is not set. To completely invalidate the TLB, load it with53* translations for addresses in one of the unmapped address54* ranges - these will never be matched.55*/5657void tlb_random(uint32_t entryhi, uint32_t entrylo);58void tlb_write(uint32_t entryhi, uint32_t entrylo, uint32_t index);59void tlb_read(uint32_t *entryhi, uint32_t *entrylo, uint32_t index);60int tlb_probe(uint32_t entryhi, uint32_t entrylo);6162void tlb_unmap( vaddr_t );63void tlb_invalidate( int );64void tlb_clear(void);65void tlb_invalidate_coremap_entry( unsigned );66int tlb_get_free_slot(void);67int tlb_evict(void);68void tlb_shootdown_wait( void );6970/*71* TLB entry fields.72*73* Note that the MIPS has support for a 6-bit address space ID. In the74* interests of simplicity, we don't use it. The fields related to it75* (TLBLO_GLOBAL and TLBHI_PID) can be left always zero, as can the76* bits that aren't assigned a meaning.77*78* The TLBLO_DIRTY bit is actually a write privilege bit - it is not79* ever set by the processor. If you set it, writes are permitted. If80* you don't set it, you'll get a "TLB Modify" exception when a write81* is attempted.82*83* There is probably no reason in the course of CS161 to use TLBLO_NOCACHE.84*/8586/* Fields in the high-order word */87#define TLBHI_VPAGE 0xfffff00088/* TLBHI_PID 0x00000fc0 */8990/* Fields in the low-order word */91#define TLBLO_PPAGE 0xfffff00092#define TLBLO_NOCACHE 0x0000080093#define TLBLO_DIRTY 0x0000040094#define TLBLO_VALID 0x0000020095/* TLBLO_GLOBAL 0x00000100 */9697/*98* Values for completely invalid TLB entries. The TLB entry index should99* be passed to TLBHI_INVALID; this prevents loading the same invalid100* entry into multiple TLB slots.101*/102#define TLBHI_INVALID(entryno) ((0x80000+(entryno))<<12)103#define TLBLO_INVALID() (0)104105/*106* Number of TLB entries in the processor.107*/108109#define NUM_TLB 64110111112#endif /* _MIPS_TLB_H_ */113114115