pmap.h revision 1.3 1 1.1 deraadt /*
2 1.1 deraadt * Copyright (c) 1987 Carnegie-Mellon University
3 1.3 glass * Copyright (c) 1992, 1993
4 1.3 glass * The Regents of the University of California. All rights reserved.
5 1.1 deraadt *
6 1.1 deraadt * This code is derived from software contributed to Berkeley by
7 1.1 deraadt * Ralph Campbell.
8 1.1 deraadt *
9 1.1 deraadt * Redistribution and use in source and binary forms, with or without
10 1.1 deraadt * modification, are permitted provided that the following conditions
11 1.1 deraadt * are met:
12 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
13 1.1 deraadt * notice, this list of conditions and the following disclaimer.
14 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
16 1.1 deraadt * documentation and/or other materials provided with the distribution.
17 1.1 deraadt * 3. All advertising materials mentioning features or use of this software
18 1.1 deraadt * must display the following acknowledgement:
19 1.1 deraadt * This product includes software developed by the University of
20 1.1 deraadt * California, Berkeley and its contributors.
21 1.1 deraadt * 4. Neither the name of the University nor the names of its contributors
22 1.1 deraadt * may be used to endorse or promote products derived from this software
23 1.1 deraadt * without specific prior written permission.
24 1.1 deraadt *
25 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.1 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 deraadt * SUCH DAMAGE.
36 1.1 deraadt *
37 1.3 glass * from: @(#)pmap.h 8.1 (Berkeley) 6/10/93
38 1.3 glass * $Id: pmap.h,v 1.3 1994/05/27 08:40:50 glass Exp $
39 1.1 deraadt */
40 1.1 deraadt
41 1.1 deraadt #ifndef _PMAP_MACHINE_
42 1.1 deraadt #define _PMAP_MACHINE_
43 1.1 deraadt
44 1.1 deraadt /*
45 1.3 glass * The user address space is 2Gb (0x0 - 0x80000000).
46 1.3 glass * User programs are laid out in memory as follows:
47 1.3 glass * address
48 1.3 glass * USRTEXT 0x00001000
49 1.3 glass * USRDATA USRTEXT + text_size
50 1.3 glass * USRSTACK 0x7FFFFFFF
51 1.3 glass *
52 1.3 glass * The user address space is mapped using a two level structure where
53 1.3 glass * virtual address bits 30..22 are used to index into a segment table which
54 1.3 glass * points to a page worth of PTEs (4096 page can hold 1024 PTEs).
55 1.3 glass * Bits 21..12 are then used to index a PTE which describes a page within
56 1.3 glass * a segment.
57 1.3 glass *
58 1.1 deraadt * The wired entries in the TLB will contain the following:
59 1.3 glass * 0-1 (UPAGES) for curproc user struct and kernel stack.
60 1.3 glass *
61 1.3 glass * Note: The kernel doesn't use the same data structures as user programs.
62 1.3 glass * All the PTE entries are stored in a single array in Sysmap which is
63 1.3 glass * dynamically allocated at boot time.
64 1.1 deraadt */
65 1.1 deraadt
66 1.3 glass #define pmax_trunc_seg(x) ((vm_offset_t)(x) & ~SEGOFSET)
67 1.3 glass #define pmax_round_seg(x) (((vm_offset_t)(x) + SEGOFSET) & ~SEGOFSET)
68 1.3 glass #define pmap_segmap(m, v) ((m)->pm_segtab->seg_tab[((v) >> SEGSHIFT)])
69 1.3 glass
70 1.3 glass #define PMAP_SEGTABSIZE 512
71 1.3 glass
72 1.3 glass union pt_entry;
73 1.3 glass
74 1.3 glass struct segtab {
75 1.3 glass union pt_entry *seg_tab[PMAP_SEGTABSIZE];
76 1.3 glass };
77 1.1 deraadt
78 1.1 deraadt /*
79 1.1 deraadt * Machine dependent pmap structure.
80 1.1 deraadt */
81 1.3 glass typedef struct pmap {
82 1.1 deraadt int pm_count; /* pmap reference count */
83 1.1 deraadt simple_lock_data_t pm_lock; /* lock on pmap */
84 1.1 deraadt struct pmap_statistics pm_stats; /* pmap statistics */
85 1.1 deraadt int pm_tlbpid; /* address space tag */
86 1.3 glass u_int pm_tlbgen; /* TLB PID generation number */
87 1.3 glass struct segtab *pm_segtab; /* pointers to pages of PTEs */
88 1.3 glass } *pmap_t;
89 1.1 deraadt
90 1.1 deraadt /*
91 1.1 deraadt * Defines for pmap_attributes[phys_mach_page];
92 1.1 deraadt */
93 1.1 deraadt #define PMAP_ATTR_MOD 0x01 /* page has been modified */
94 1.1 deraadt #define PMAP_ATTR_REF 0x02 /* page has been referenced */
95 1.1 deraadt
96 1.1 deraadt #ifdef KERNEL
97 1.1 deraadt extern char *pmap_attributes; /* reference and modify bits */
98 1.3 glass extern struct pmap kernel_pmap_store;
99 1.3 glass #define kernel_pmap (&kernel_pmap_store)
100 1.3 glass #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
101 1.3 glass #endif /* KERNEL */
102 1.3 glass
103 1.3 glass #endif /* _PMAP_MACHINE_ */
104