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