Annotation of sys/arch/mips64/include/pmap.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: pmap.h,v 1.12 2007/04/27 18:14:11 miod Exp $ */
2:
3: /*
4: * Copyright (c) 1987 Carnegie-Mellon University
5: * Copyright (c) 1992, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * This code is derived from software contributed to Berkeley by
9: * Ralph Campbell.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: * 3. Neither the name of the University nor the names of its contributors
20: * may be used to endorse or promote products derived from this software
21: * without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33: * SUCH DAMAGE.
34: *
35: * from: @(#)pmap.h 8.1 (Berkeley) 6/10/93
36: */
37:
38: #ifndef _MIPS_PMAP_H_
39: #define _MIPS_PMAP_H_
40:
41: #ifdef _KERNEL
42:
43: /*
44: * The user address space is 2Gb (0x0 - 0x80000000).
45: * User programs are laid out in memory as follows:
46: * address
47: * USRTEXT 0x00400000
48: * USRDATA 0x10000000
49: * USRSTACK 0x7FFFFFFF
50: *
51: * The user address space is mapped using a two level structure where
52: * virtual address bits 30..22 are used to index into a segment table which
53: * points to a page worth of PTEs (4096 page can hold 1024 PTEs).
54: * Bits 21..12 are then used to index a PTE which describes a page within
55: * a segment.
56: *
57: * The wired entries in the TLB will contain the following:
58: * 0-1 (UPAGES) for curproc user struct and kernel stack.
59: *
60: * Note: The kernel doesn't use the same data structures as user programs.
61: * All the PTE entries are stored in a single array in Sysmap which is
62: * dynamically allocated at boot time.
63: */
64:
65: #define mips_trunc_seg(x) ((vaddr_t)(x) & ~SEGOFSET)
66: #define mips_round_seg(x) (((vaddr_t)(x) + SEGOFSET) & ~SEGOFSET)
67: #define pmap_segmap(m, v) ((m)->pm_segtab->seg_tab[((v) >> SEGSHIFT)])
68:
69: #define PMAP_SEGTABSIZE 512
70:
71: union pt_entry;
72:
73: struct segtab {
74: union pt_entry *seg_tab[PMAP_SEGTABSIZE];
75: };
76:
77: /*
78: * Machine dependent pmap structure.
79: */
80: typedef struct pmap {
81: int pm_count; /* pmap reference count */
82: simple_lock_data_t pm_lock; /* lock on pmap */
83: struct pmap_statistics pm_stats; /* pmap statistics */
84: int pm_tlbpid; /* address space tag */
85: u_int pm_tlbgen; /* TLB PID generation number */
86: struct segtab *pm_segtab; /* pointers to pages of PTEs */
87: } *pmap_t;
88:
89:
90: /* flags for pv_entry */
91: #define PV_UNCACHED PG_PMAP0 /* Page is mapped unchached */
92: #define PV_CACHED PG_PMAP1 /* Page has been cached */
93: #define PV_ATTR_MOD PG_PMAP2
94: #define PV_ATTR_REF PG_PMAP3
95: #define PV_PRESERVE (PV_ATTR_MOD | PV_ATTR_REF)
96:
97: extern struct pmap kernel_pmap_store;
98:
99: #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
100: #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
101: #define pmap_kernel() (&kernel_pmap_store)
102: #define pmap_phys_address(ppn) ptoa(ppn)
103:
104: #define PMAP_STEAL_MEMORY /* Enable 'stealing' during boot */
105:
106: #define PMAP_PREFER(pa, va) pmap_prefer(pa, va)
107:
108: #define pmap_update(x) do { /* nothing */ } while (0)
109:
110: void pmap_bootstrap(void);
111: int pmap_is_page_ro( pmap_t, vaddr_t, int);
112: void pmap_kenter_cache(vaddr_t va, paddr_t pa, vm_prot_t prot, int cache);
113: void pmap_prefer(vaddr_t, vaddr_t *);
114: void pmap_set_modify(vm_page_t);
115: void pmap_page_cache(vm_page_t, int);
116:
117: #define pmap_collect(x) do { /* nothing */ } while (0)
118: #define pmap_proc_iflush(p,va,len) do { /* nothing yet (handled in trap now) */ } while (0)
119: #define pmap_unuse_final(p) do { /* nothing yet */ } while (0)
120:
121: #endif /* _KERNEL */
122:
123: #endif /* !_MIPS_PMAP_H_ */
CVSweb