/*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_VM_H_30#define _MIPS_VM_H_3132struct addrspace; /* opaque */3334/*35* Machine-dependent VM system definitions.36*/3738#define PAGE_SIZE 4096 /* size of VM page */39#define PAGE_FRAME 0xfffff000 /* mask for getting page number from addr */4041/*42* MIPS-I hardwired memory layout:43* 0xc0000000 - 0xffffffff kseg2 (kernel, tlb-mapped)44* 0xa0000000 - 0xbfffffff kseg1 (kernel, unmapped, uncached)45* 0x80000000 - 0x9fffffff kseg0 (kernel, unmapped, cached)46* 0x00000000 - 0x7fffffff kuseg (user, tlb-mapped)47*48* (mips32 is a little different)49*/5051#define MIPS_KUSEG 0x0000000052#define MIPS_KSEG0 0x8000000053#define MIPS_KSEG1 0xa000000054#define MIPS_KSEG2 0xc00000005556/*57* The first 512 megs of physical space can be addressed in both kseg0 and58* kseg1. We use kseg0 for the kernel. This macro returns the kernel virtual59* address of a given physical address within that range. (We assume we're60* not using systems with more physical space than that anyway.)61*62* N.B. If you, say, call a function that returns a paddr or 0 on error,63* check the paddr for being 0 *before* you use this macro. While paddr 064* is not legal for memory allocation or memory management (it holds65* exception handler code) when converted to a vaddr it's *not* NULL, *is*66* a valid address, and will make a *huge* mess if you scribble on it.67*/68#define PADDR_TO_KVADDR(paddr) ((paddr)+MIPS_KSEG0)69#define KVADDR_TO_PADDR(vaddr) ((vaddr)-MIPS_KSEG0)7071/*72* The top of user space. (Actually, the address immediately above the73* last valid user address.)74*/75#define USERSPACETOP MIPS_KSEG07677/*78* The starting value for the stack pointer at user level. Because79* the stack is subtract-then-store, this can start as the next80* address after the stack area.81*82* We put the stack at the very top of user virtual memory because it83* grows downwards.84*/85#define USERSTACK USERSPACETOP86#define USERSTACKSIZE (256 * PAGE_SIZE)87#define USERSTACKBASE (USERSTACK - USERSTACKSIZE)88#define INVALID_VADDR 0xcafebabe8990/*91* Interface to the low-level module that looks after the amount of92* physical memory we have.93*94* ram_getsize returns the lowest valid physical address, and one past95* the highest valid physical address. (Both are page-aligned.) This96* is the memory that is available for use during operation, and97* excludes the memory the kernel is loaded into and memory that is98* grabbed in the very early stages of bootup.99*100* ram_stealmem can be used before ram_getsize is called to allocate101* memory that cannot be freed later. This is intended for use early102* in bootup before VM initialization is complete.103*/104105void ram_bootstrap(void);106paddr_t ram_stealmem(unsigned long npages);107void ram_getsize(paddr_t *lo, paddr_t *hi);108109void vm_map( vaddr_t, paddr_t, int );110void vm_unmap( vaddr_t );111112113/*114* TLB shootdown bits.115*116* We'll take up to 16 invalidations before just flushing the whole TLB.117*/118119struct tlbshootdown {120int ts_tlb_ix;121unsigned ts_cme_ix;122};123124#define TLBSHOOTDOWN_MAX 16125126127#endif /* _MIPS_VM_H_ */128129130