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