Home | History | Annotate | Line # | Download | only in oea
pmap.h revision 1.9
      1 /*	$NetBSD: pmap.h,v 1.9 2006/08/05 21:26:49 sanjayl Exp $	*/
      2 
      3 /*-
      4  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5  * Copyright (C) 1995, 1996 TooLs GmbH.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by TooLs GmbH.
     19  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #ifndef	_POWERPC_OEA_PMAP_H_
     35 #define	_POWERPC_OEA_PMAP_H_
     36 
     37 #include <powerpc/oea/pte.h>
     38 
     39 #ifndef _LOCORE
     40 /*
     41  * Pmap stuff
     42  */
     43 struct pmap {
     44 #ifdef PPC_OEA64
     45 	struct steg *pm_steg_table;		/* segment table pointer */
     46 	/* XXX need way to track exec pages */
     47 #endif
     48 
     49 #if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE)
     50 	register_t pm_sr[16];			/* segments used in this pmap */
     51 	int pm_exec[16];			/* counts of exec mappings */
     52 #endif
     53 	register_t pm_vsid;			/* VSID bits */
     54 	int pm_refs;				/* ref count */
     55 	struct pmap_statistics pm_stats;	/* pmap statistics */
     56 	unsigned int pm_evictions;		/* pvo's not in page table */
     57 
     58 #ifdef PPC_OEA64
     59 	unsigned int pm_ste_evictions;
     60 #endif
     61 };
     62 
     63 typedef	struct pmap *pmap_t;
     64 
     65 #ifdef	_KERNEL
     66 #include <sys/param.h>
     67 #include <sys/systm.h>
     68 
     69 #if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
     70 extern register_t iosrtable[];
     71 #endif
     72 extern int pmap_use_altivec;
     73 extern struct pmap kernel_pmap_;
     74 #define	pmap_kernel()	(&kernel_pmap_)
     75 
     76 #define pmap_clear_modify(pg)		(pmap_clear_bit((pg), PTE_CHG))
     77 #define	pmap_clear_reference(pg)	(pmap_clear_bit((pg), PTE_REF))
     78 #define	pmap_is_modified(pg)		(pmap_query_bit((pg), PTE_CHG))
     79 #define	pmap_is_referenced(pg)		(pmap_query_bit((pg), PTE_REF))
     80 
     81 #define	pmap_phys_address(x)		(x)
     82 
     83 #define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
     84 #define	pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
     85 
     86 /* ARGSUSED */
     87 static inline void
     88 pmap_remove_all(struct pmap *pmap)
     89 {
     90 	/* Nothing. */
     91 }
     92 
     93 void pmap_bootstrap (vaddr_t, vaddr_t);
     94 boolean_t pmap_extract (struct pmap *, vaddr_t, paddr_t *);
     95 boolean_t pmap_query_bit (struct vm_page *, int);
     96 boolean_t pmap_clear_bit (struct vm_page *, int);
     97 void pmap_real_memory (paddr_t *, psize_t *);
     98 void pmap_pinit (struct pmap *);
     99 boolean_t pmap_pageidlezero (paddr_t);
    100 void pmap_syncicache (paddr_t, psize_t);
    101 #ifdef PPC_OEA64
    102 vaddr_t pmap_setusr (vaddr_t);
    103 vaddr_t pmap_unsetusr (void);
    104 #endif
    105 
    106 #define PMAP_NEED_PROCWR
    107 void pmap_procwr(struct proc *, vaddr_t, size_t);
    108 
    109 int pmap_pte_spill(struct pmap *, vaddr_t, boolean_t);
    110 
    111 #define	PMAP_NC			0x1000
    112 
    113 #define PMAP_STEAL_MEMORY
    114 static inline paddr_t vtophys (vaddr_t);
    115 
    116 /*
    117  * Alternate mapping hooks for pool pages.  Avoids thrashing the TLB.
    118  *
    119  * Note: This won't work if we have more memory than can be direct-mapped
    120  * VA==PA all at once.  But pmap_copy_page() and pmap_zero_page() will have
    121  * this problem, too.
    122  */
    123 #if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE)
    124 #define	PMAP_MAP_POOLPAGE(pa)	(pa)
    125 #define	PMAP_UNMAP_POOLPAGE(pa)	(pa)
    126 #define POOL_VTOPHYS(va)	vtophys((vaddr_t) va)
    127 #endif
    128 
    129 static inline paddr_t
    130 vtophys(vaddr_t va)
    131 {
    132 	paddr_t pa;
    133 
    134 	if (pmap_extract(pmap_kernel(), va, &pa))
    135 		return pa;
    136 	KASSERT(0);
    137 	return (paddr_t) -1;
    138 }
    139 
    140 #endif	/* _KERNEL */
    141 #endif	/* _LOCORE */
    142 
    143 #endif	/* _POWERPC_OEA_PMAP_H_ */
    144