Home | History | Annotate | Line # | Download | only in include
pmap.h revision 1.1
      1  1.1  deraadt /*
      2  1.1  deraadt  * Copyright (c) 1987 Carnegie-Mellon University
      3  1.1  deraadt  * Copyright (c) 1992 Regents of the University of California.
      4  1.1  deraadt  * 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.1  deraadt  * from: @(#)pmap.h	7.6 (Berkeley) 2/4/93
     38  1.1  deraadt  * $Id: pmap.h,v 1.1 1993/10/12 03:22:39 deraadt 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.1  deraadt  * TLB hash table values.
     46  1.1  deraadt  * SHIFT2 should shift virtual address bit 22 to the high bit of the index.
     47  1.1  deraadt  *			address:	index:
     48  1.1  deraadt  *	USRTEXT		0x00400000	10xxxxxxx
     49  1.1  deraadt  *	USRDATA		0x10000000	00xxxxxxx
     50  1.1  deraadt  *	USRSTACK	0x7FFFFFFF	11xxxxxxx
     51  1.1  deraadt  * This gives 1/2 the table to data, 1/4 for text and 1/4 for stack.
     52  1.1  deraadt  * Note: the current process has its hash table mapped at PMAP_HASH_UADDR.
     53  1.1  deraadt  *	the kernel's hash table is mapped at PMAP_HASH_KADDR.
     54  1.1  deraadt  *	The size of the hash table is known in locore.s.
     55  1.1  deraadt  * The wired entries in the TLB will contain the following:
     56  1.1  deraadt  *	UPAGES			(for curproc)
     57  1.1  deraadt  *	PMAP_HASH_UPAGES	(for curproc)
     58  1.1  deraadt  *	PMAP_HASH_KPAGES	(for kernel)
     59  1.1  deraadt  * The kernel doesn't actually use a pmap_hash_t, the pm_hash field is NULL and
     60  1.1  deraadt  * all the PTE entries are stored in a single array at PMAP_HASH_KADDR.
     61  1.1  deraadt  * If we need more KPAGES that the TLB has wired entries, then we can switch
     62  1.1  deraadt  * to a global pointer for the kernel TLB table.
     63  1.1  deraadt  * If we try to use a hash table for the kernel, wired TLB entries become a
     64  1.1  deraadt  * problem.
     65  1.1  deraadt  * Note: PMAP_HASH_UPAGES should be a multiple of MACH pages (see pmap_enter()).
     66  1.1  deraadt  */
     67  1.1  deraadt #define PMAP_HASH_UPAGES	1
     68  1.1  deraadt #define PMAP_HASH_KPAGES	5
     69  1.1  deraadt #define PMAP_HASH_UADDR		(UADDR - PMAP_HASH_UPAGES * NBPG)
     70  1.1  deraadt #define PMAP_HASH_KADDR		(UADDR - (PMAP_HASH_UPAGES + PMAP_HASH_KPAGES) * NBPG)
     71  1.1  deraadt #define PMAP_HASH_NUM_ENTRIES	256
     72  1.1  deraadt #define PMAP_HASH_SIZE_SHIFT	4
     73  1.1  deraadt #define PMAP_HASH_SHIFT1	12
     74  1.1  deraadt #define PMAP_HASH_SHIFT2	21
     75  1.1  deraadt #define PMAP_HASH_MASK1		0x07f
     76  1.1  deraadt #define PMAP_HASH_MASK2		0x080
     77  1.1  deraadt #define PMAP_HASH_SIZE		(PMAP_HASH_NUM_ENTRIES*sizeof(struct pmap_hash))
     78  1.1  deraadt 
     79  1.1  deraadt /* compute pointer to pmap hash table */
     80  1.1  deraadt #define PMAP_HASH(va) \
     81  1.1  deraadt 	((((va) >> PMAP_HASH_SHIFT1) & PMAP_HASH_MASK1) | \
     82  1.1  deraadt 	 (((va) >> PMAP_HASH_SHIFT2) & PMAP_HASH_MASK2))
     83  1.1  deraadt 
     84  1.1  deraadt /*
     85  1.1  deraadt  * A TLB hash entry.
     86  1.1  deraadt  */
     87  1.1  deraadt typedef struct pmap_hash {
     88  1.1  deraadt 	struct {
     89  1.1  deraadt 		u_int	low;		/* The TLB low register value. */
     90  1.1  deraadt 		u_int	high;		/* The TLB high register value. */
     91  1.1  deraadt 	} pmh_pte[2];
     92  1.1  deraadt } *pmap_hash_t;
     93  1.1  deraadt 
     94  1.1  deraadt /*
     95  1.1  deraadt  * Machine dependent pmap structure.
     96  1.1  deraadt  */
     97  1.1  deraadt typedef struct pmap {
     98  1.1  deraadt 	int			pm_count;	/* pmap reference count */
     99  1.1  deraadt 	simple_lock_data_t	pm_lock;	/* lock on pmap */
    100  1.1  deraadt 	struct pmap_statistics	pm_stats;	/* pmap statistics */
    101  1.1  deraadt 	int			pm_flags;	/* see below */
    102  1.1  deraadt 	int			pm_tlbpid;	/* address space tag */
    103  1.1  deraadt 	pmap_hash_t		pm_hash;	/* TLB cache */
    104  1.1  deraadt 	unsigned		pm_hash_ptes[PMAP_HASH_UPAGES];
    105  1.1  deraadt } *pmap_t;
    106  1.1  deraadt 
    107  1.1  deraadt #define PM_MODIFIED	1		/* flush tlbpid before resume() */
    108  1.1  deraadt 
    109  1.1  deraadt /*
    110  1.1  deraadt  * Defines for pmap_attributes[phys_mach_page];
    111  1.1  deraadt  */
    112  1.1  deraadt #define PMAP_ATTR_MOD	0x01	/* page has been modified */
    113  1.1  deraadt #define PMAP_ATTR_REF	0x02	/* page has been referenced */
    114  1.1  deraadt 
    115  1.1  deraadt #ifdef	KERNEL
    116  1.1  deraadt extern struct pmap kernel_pmap_store;
    117  1.1  deraadt #define kernel_pmap (&kernel_pmap_store)
    118  1.1  deraadt extern	char *pmap_attributes;		/* reference and modify bits */
    119  1.1  deraadt #endif	KERNEL
    120  1.1  deraadt #endif	_PMAP_MACHINE_
    121