/* [<][>][^][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_VM_H_
31 #define _MIPS_VM_H_
32
33
34 /*
35 * Machine-dependent VM system definitions.
36 */
37
38 #define PAGE_SIZE 4096 /* size of VM page */
39 #define PAGE_FRAME 0xfffff000 /* mask for getting page number from addr */
40
41 /*
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 */
50
51 #define MIPS_KUSEG 0x00000000
52 #define MIPS_KSEG0 0x80000000
53 #define MIPS_KSEG1 0xa0000000
54 #define MIPS_KSEG2 0xc0000000
55
56 /*
57 * The first 512 megs of physical space can be addressed in both kseg0 and
58 * kseg1. We use kseg0 for the kernel. This macro returns the kernel virtual
59 * address of a given physical address within that range. (We assume we're
60 * 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 0
64 * is not legal for memory allocation or memory management (it holds
65 * 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
70 /*
71 * The top of user space. (Actually, the address immediately above the
72 * last valid user address.)
73 */
74 #define USERSPACETOP MIPS_KSEG0
75
76 /*
77 * The starting value for the stack pointer at user level. Because
78 * the stack is subtract-then-store, this can start as the next
79 * address after the stack area.
80 *
81 * We put the stack at the very top of user virtual memory because it
82 * grows downwards.
83 */
84 #define USERSTACK USERSPACETOP
85
86 /*
87 * Interface to the low-level module that looks after the amount of
88 * physical memory we have.
89 *
90 * ram_getsize returns the lowest valid physical address, and one past
91 * the highest valid physical address. (Both are page-aligned.) This
92 * is the memory that is available for use during operation, and
93 * excludes the memory the kernel is loaded into and memory that is
94 * grabbed in the very early stages of bootup.
95 *
96 * ram_stealmem can be used before ram_getsize is called to allocate
97 * memory that cannot be freed later. This is intended for use early
98 * in bootup before VM initialization is complete.
99 */
100
101 void ram_bootstrap(void);
102 paddr_t ram_stealmem(unsigned long npages);
103 void ram_getsize(paddr_t *lo, paddr_t *hi);
104
105 /*
106 * TLB shootdown bits.
107 *
108 * We'll take up to 16 invalidations before just flushing the whole TLB.
109 */
110
111 struct tlbshootdown {
112 /*
113 * Change this to what you need for your VM design.
114 */
115 struct addrspace *ts_addrspace;
116 vaddr_t ts_vaddr;
117 };
118
119 #define TLBSHOOTDOWN_MAX 16
120
121
122 #endif /* _MIPS_VM_H_ */