Home | History | Annotate | Line # | Download | only in include
pmap.h revision 1.27.2.3
      1  1.27.2.3    bouyer /*	$NetBSD: pmap.h,v 1.27.2.3 2001/04/23 09:41:53 bouyer Exp $	*/
      2       1.5       cgd 
      3      1.26    simonb /*
      4       1.1   deraadt  * Copyright (c) 1987 Carnegie-Mellon University
      5       1.3     glass  * Copyright (c) 1992, 1993
      6       1.3     glass  *	The Regents of the University of California.  All rights reserved.
      7       1.1   deraadt  *
      8       1.1   deraadt  * This code is derived from software contributed to Berkeley by
      9       1.1   deraadt  * Ralph Campbell.
     10       1.1   deraadt  *
     11       1.1   deraadt  * Redistribution and use in source and binary forms, with or without
     12       1.1   deraadt  * modification, are permitted provided that the following conditions
     13       1.1   deraadt  * are met:
     14       1.1   deraadt  * 1. Redistributions of source code must retain the above copyright
     15       1.1   deraadt  *    notice, this list of conditions and the following disclaimer.
     16       1.1   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1   deraadt  *    notice, this list of conditions and the following disclaimer in the
     18       1.1   deraadt  *    documentation and/or other materials provided with the distribution.
     19       1.1   deraadt  * 3. All advertising materials mentioning features or use of this software
     20       1.1   deraadt  *    must display the following acknowledgement:
     21       1.1   deraadt  *	This product includes software developed by the University of
     22       1.1   deraadt  *	California, Berkeley and its contributors.
     23       1.1   deraadt  * 4. Neither the name of the University nor the names of its contributors
     24       1.1   deraadt  *    may be used to endorse or promote products derived from this software
     25       1.1   deraadt  *    without specific prior written permission.
     26       1.1   deraadt  *
     27       1.1   deraadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28       1.1   deraadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29       1.1   deraadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30       1.1   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31       1.1   deraadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32       1.1   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33       1.1   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34       1.1   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35       1.1   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36       1.1   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37       1.1   deraadt  * SUCH DAMAGE.
     38       1.1   deraadt  *
     39       1.5       cgd  *	@(#)pmap.h	8.1 (Berkeley) 6/10/93
     40       1.1   deraadt  */
     41       1.1   deraadt 
     42       1.1   deraadt #ifndef	_PMAP_MACHINE_
     43       1.1   deraadt #define	_PMAP_MACHINE_
     44       1.1   deraadt 
     45      1.24    castor #include <mips/cpuregs.h>	/* for KSEG0 below */
     46      1.18   thorpej 
     47       1.1   deraadt /*
     48       1.3     glass  * The user address space is 2Gb (0x0 - 0x80000000).
     49       1.3     glass  * User programs are laid out in memory as follows:
     50       1.3     glass  *			address
     51       1.3     glass  *	USRTEXT		0x00001000
     52       1.3     glass  *	USRDATA		USRTEXT + text_size
     53       1.3     glass  *	USRSTACK	0x7FFFFFFF
     54       1.3     glass  *
     55       1.3     glass  * The user address space is mapped using a two level structure where
     56       1.3     glass  * virtual address bits 30..22 are used to index into a segment table which
     57       1.3     glass  * points to a page worth of PTEs (4096 page can hold 1024 PTEs).
     58      1.26    simonb  * Bits 21..12 are then used to index a PTE which describes a page within
     59       1.3     glass  * a segment.
     60       1.3     glass  *
     61       1.1   deraadt  * The wired entries in the TLB will contain the following:
     62       1.3     glass  *	0-1	(UPAGES)	for curproc user struct and kernel stack.
     63       1.3     glass  *
     64       1.3     glass  * Note: The kernel doesn't use the same data structures as user programs.
     65       1.3     glass  * All the PTE entries are stored in a single array in Sysmap which is
     66       1.3     glass  * dynamically allocated at boot time.
     67       1.1   deraadt  */
     68       1.1   deraadt 
     69      1.22  nisimura #define mips_trunc_seg(x)	((vaddr_t)(x) & ~SEGOFSET)
     70      1.22  nisimura #define mips_round_seg(x)	(((vaddr_t)(x) + SEGOFSET) & ~SEGOFSET)
     71       1.3     glass #define pmap_segmap(m, v)	((m)->pm_segtab->seg_tab[((v) >> SEGSHIFT)])
     72       1.3     glass 
     73       1.3     glass #define PMAP_SEGTABSIZE		512
     74       1.3     glass 
     75       1.3     glass union pt_entry;
     76       1.3     glass 
     77       1.3     glass struct segtab {
     78       1.3     glass 	union pt_entry	*seg_tab[PMAP_SEGTABSIZE];
     79       1.3     glass };
     80       1.1   deraadt 
     81       1.1   deraadt /*
     82       1.1   deraadt  * Machine dependent pmap structure.
     83       1.1   deraadt  */
     84       1.3     glass typedef struct pmap {
     85       1.1   deraadt 	int			pm_count;	/* pmap reference count */
     86       1.1   deraadt 	simple_lock_data_t	pm_lock;	/* lock on pmap */
     87       1.1   deraadt 	struct pmap_statistics	pm_stats;	/* pmap statistics */
     88      1.27  nisimura 	unsigned		pm_asid;	/* TLB address space tag */
     89      1.27  nisimura 	unsigned		pm_asidgen;	/* its generation number */
     90       1.3     glass 	struct segtab		*pm_segtab;	/* pointers to pages of PTEs */
     91       1.3     glass } *pmap_t;
     92       1.1   deraadt 
     93      1.17   thorpej /*
     94      1.17   thorpej  * For each vm_page_t, there is a list of all currently valid virtual
     95      1.17   thorpej  * mappings of that page.  An entry is a pv_entry_t, the list is pv_table.
     96      1.17   thorpej  * XXX really should do this as a part of the higher level code.
     97      1.17   thorpej  */
     98      1.17   thorpej typedef struct pv_entry {
     99      1.17   thorpej 	struct pv_entry	*pv_next;	/* next pv_entry */
    100      1.17   thorpej 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
    101      1.27  nisimura 	vaddr_t	pv_va;			/* virtual address for mapping */
    102      1.17   thorpej 	int		pv_flags;	/* some flags for the mapping */
    103      1.17   thorpej } *pv_entry_t;
    104      1.17   thorpej 
    105      1.17   thorpej #define	PV_UNCACHED	0x0001		/* page is mapped uncached */
    106      1.20    mhitch #define	PV_MODIFIED	0x0002		/* page has been modified */
    107      1.21  jonathan #define	PV_REFERENCED	0x0004		/* page has been recently referenced */
    108       1.1   deraadt 
    109      1.13  jonathan 
    110       1.8    mellon #ifdef	_KERNEL
    111      1.13  jonathan 
    112      1.27  nisimura extern char *pmap_attributes;		/* reference and modify bits */
    113      1.27  nisimura extern struct pmap kernel_pmap_store;
    114       1.7   mycroft 
    115      1.27  nisimura #define pmap_kernel()		(&kernel_pmap_store)
    116       1.3     glass #define	pmap_wired_count(pmap) 	((pmap)->pm_stats.wired_count)
    117      1.14    mhitch #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
    118  1.27.2.3    bouyer 
    119  1.27.2.3    bouyer #define	pmap_update()		/* nothing (yet) */
    120      1.12  jonathan 
    121      1.12  jonathan /*
    122      1.13  jonathan  *	Bootstrap the system enough to run with virtual memory.
    123      1.13  jonathan  */
    124      1.17   thorpej void	pmap_bootstrap __P((void));
    125      1.20    mhitch 
    126      1.22  nisimura void	pmap_set_modified __P((paddr_t));
    127      1.25        is 
    128      1.25        is void	pmap_procwr __P((struct proc *, vaddr_t, size_t));
    129      1.25        is #define	PMAP_NEED_PROCWR
    130      1.13  jonathan 
    131      1.13  jonathan /*
    132  1.27.2.1    bouyer  * pmap_prefer() helps reduce virtual-coherency exceptions in
    133      1.13  jonathan  * the virtually-indexed cache on mips3 CPUs.
    134      1.13  jonathan  */
    135      1.13  jonathan #ifdef MIPS3
    136      1.13  jonathan #define PMAP_PREFER(pa, va)             pmap_prefer((pa), (va))
    137      1.22  nisimura void	pmap_prefer __P((vaddr_t, vaddr_t *));
    138      1.13  jonathan #endif /* MIPS3 */
    139      1.13  jonathan 
    140      1.17   thorpej #define	PMAP_STEAL_MEMORY	/* enable pmap_steal_memory() */
    141      1.18   thorpej 
    142      1.18   thorpej /*
    143      1.18   thorpej  * Alternate mapping hooks for pool pages.  Avoids thrashing the TLB.
    144      1.18   thorpej  */
    145      1.18   thorpej #define	PMAP_MAP_POOLPAGE(pa)	MIPS_PHYS_TO_KSEG0((pa))
    146      1.19    simonb #define	PMAP_UNMAP_POOLPAGE(va)	MIPS_KSEG0_TO_PHYS((va))
    147  1.27.2.1    bouyer 
    148  1.27.2.1    bouyer /*
    149  1.27.2.1    bouyer  * Do idle page zero'ing uncached to avoid polluting the cache.
    150  1.27.2.1    bouyer  */
    151  1.27.2.1    bouyer boolean_t pmap_zero_page_uncached __P((paddr_t));
    152  1.27.2.1    bouyer #define PMAP_PAGEIDLEZERO(pa)	pmap_zero_page_uncached((pa))
    153      1.13  jonathan 
    154       1.6       jtc #endif	/* _KERNEL */
    155       1.3     glass #endif	/* _PMAP_MACHINE_ */
    156