Home | History | Annotate | Line # | Download | only in oea
pmap.h revision 1.20
      1  1.20      matt /*	$NetBSD: pmap.h,v 1.20 2011/01/18 01:02:55 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.15        he #ifdef _KERNEL_OPT
     38  1.12   garbled #include "opt_ppcarch.h"
     39  1.15        he #endif
     40   1.1      matt #include <powerpc/oea/pte.h>
     41   1.1      matt 
     42   1.1      matt #ifndef _LOCORE
     43   1.1      matt /*
     44   1.1      matt  * Pmap stuff
     45   1.1      matt  */
     46   1.1      matt struct pmap {
     47   1.6      matt #ifdef PPC_OEA64
     48   1.6      matt 	struct steg *pm_steg_table;		/* segment table pointer */
     49   1.6      matt 	/* XXX need way to track exec pages */
     50   1.6      matt #endif
     51   1.9   sanjayl 
     52   1.9   sanjayl #if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE)
     53   1.2      matt 	register_t pm_sr[16];			/* segments used in this pmap */
     54   1.5       chs 	int pm_exec[16];			/* counts of exec mappings */
     55   1.6      matt #endif
     56   1.6      matt 	register_t pm_vsid;			/* VSID bits */
     57   1.2      matt 	int pm_refs;				/* ref count */
     58   1.1      matt 	struct pmap_statistics pm_stats;	/* pmap statistics */
     59   1.2      matt 	unsigned int pm_evictions;		/* pvo's not in page table */
     60   1.9   sanjayl 
     61   1.6      matt #ifdef PPC_OEA64
     62   1.6      matt 	unsigned int pm_ste_evictions;
     63   1.6      matt #endif
     64   1.1      matt };
     65   1.1      matt 
     66  1.12   garbled struct pmap_ops {
     67  1.12   garbled 	int (*pmapop_pte_spill)(struct pmap *, vaddr_t, bool);
     68  1.12   garbled 	void (*pmapop_real_memory)(paddr_t *, psize_t *);
     69  1.12   garbled 	void (*pmapop_init)(void);
     70  1.12   garbled 	void (*pmapop_virtual_space)(vaddr_t *, vaddr_t *);
     71  1.12   garbled 	pmap_t (*pmapop_create)(void);
     72  1.12   garbled 	void (*pmapop_reference)(pmap_t);
     73  1.12   garbled 	void (*pmapop_destroy)(pmap_t);
     74  1.12   garbled 	void (*pmapop_copy)(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t);
     75  1.12   garbled 	void (*pmapop_update)(pmap_t);
     76  1.16    cegger 	int (*pmapop_enter)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int);
     77  1.12   garbled 	void (*pmapop_remove)(pmap_t, vaddr_t, vaddr_t);
     78  1.18    cegger 	void (*pmapop_kenter_pa)(vaddr_t, paddr_t, vm_prot_t, u_int);
     79  1.12   garbled 	void (*pmapop_kremove)(vaddr_t, vsize_t);
     80  1.12   garbled 	bool (*pmapop_extract)(pmap_t, vaddr_t, paddr_t *);
     81  1.12   garbled 
     82  1.12   garbled 	void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
     83  1.12   garbled 	void (*pmapop_unwire)(pmap_t, vaddr_t);
     84  1.12   garbled 	void (*pmapop_page_protect)(struct vm_page *, vm_prot_t);
     85  1.12   garbled 	bool (*pmapop_query_bit)(struct vm_page *, int);
     86  1.12   garbled 	bool (*pmapop_clear_bit)(struct vm_page *, int);
     87  1.12   garbled 
     88  1.12   garbled 	void (*pmapop_activate)(struct lwp *);
     89  1.12   garbled 	void (*pmapop_deactivate)(struct lwp *);
     90  1.12   garbled 
     91  1.12   garbled 	void (*pmapop_pinit)(pmap_t);
     92  1.12   garbled 	void (*pmapop_procwr)(struct proc *, vaddr_t, size_t);
     93  1.12   garbled 
     94  1.12   garbled 	void (*pmapop_pte_print)(volatile struct pte *);
     95  1.12   garbled 	void (*pmapop_pteg_check)(void);
     96  1.12   garbled 	void (*pmapop_print_mmuregs)(void);
     97  1.12   garbled 	void (*pmapop_print_pte)(pmap_t, vaddr_t);
     98  1.12   garbled 	void (*pmapop_pteg_dist)(void);
     99  1.12   garbled 	void (*pmapop_pvo_verify)(void);
    100  1.12   garbled 	vaddr_t (*pmapop_steal_memory)(vsize_t, vaddr_t *, vaddr_t *);
    101  1.12   garbled 	void (*pmapop_bootstrap)(paddr_t, paddr_t);
    102  1.12   garbled };
    103  1.12   garbled 
    104   1.1      matt #ifdef	_KERNEL
    105  1.12   garbled #include <sys/cdefs.h>
    106  1.12   garbled __BEGIN_DECLS
    107   1.6      matt #include <sys/param.h>
    108   1.4      matt #include <sys/systm.h>
    109   1.4      matt 
    110   1.9   sanjayl #if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
    111   1.2      matt extern register_t iosrtable[];
    112   1.6      matt #endif
    113   1.1      matt extern int pmap_use_altivec;
    114   1.1      matt 
    115   1.1      matt #define pmap_clear_modify(pg)		(pmap_clear_bit((pg), PTE_CHG))
    116   1.1      matt #define	pmap_clear_reference(pg)	(pmap_clear_bit((pg), PTE_REF))
    117   1.1      matt #define	pmap_is_modified(pg)		(pmap_query_bit((pg), PTE_CHG))
    118   1.1      matt #define	pmap_is_referenced(pg)		(pmap_query_bit((pg), PTE_REF))
    119   1.1      matt 
    120   1.1      matt #define	pmap_phys_address(x)		(x)
    121   1.1      matt 
    122   1.1      matt #define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
    123   1.1      matt #define	pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
    124   1.1      matt 
    125   1.3      matt /* ARGSUSED */
    126   1.8     perry static inline void
    127   1.1      matt pmap_remove_all(struct pmap *pmap)
    128   1.1      matt {
    129   1.1      matt 	/* Nothing. */
    130   1.1      matt }
    131   1.1      matt 
    132  1.13      matt #if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) != 1
    133  1.12   garbled #define	PMAP_EXCLUDE_DECLS
    134   1.6      matt #endif
    135   1.1      matt 
    136  1.12   garbled #ifndef PMAP_NOOPNAMES
    137  1.11   garbled 
    138  1.12   garbled #if !defined(PMAP_EXCLUDE_DECLS)
    139  1.12   garbled void pmap_bootstrap(vaddr_t, vaddr_t);
    140  1.12   garbled bool pmap_extract(pmap_t, vaddr_t, paddr_t *);
    141  1.12   garbled bool pmap_query_bit(struct vm_page *, int);
    142  1.12   garbled bool pmap_clear_bit(struct vm_page *, int);
    143  1.12   garbled void pmap_real_memory(paddr_t *, psize_t *);
    144   1.5       chs void pmap_procwr(struct proc *, vaddr_t, size_t);
    145  1.12   garbled int pmap_pte_spill(pmap_t, vaddr_t, bool);
    146  1.12   garbled void pmap_pinit(pmap_t);
    147   1.1      matt 
    148  1.12   garbled #else
    149  1.12   garbled #define	PMAPOPNAME(name) (*pmapops->pmapop_##name)
    150  1.12   garbled extern const struct pmap_ops *pmapops;
    151  1.12   garbled #define	pmap_pte_spill		PMAPOPNAME(pte_spill)
    152  1.12   garbled #define	pmap_real_memory	PMAPOPNAME(real_memory)
    153  1.12   garbled #define	pmap_init		PMAPOPNAME(init)
    154  1.12   garbled #define	pmap_virtual_space	PMAPOPNAME(virtual_space)
    155  1.12   garbled #define	pmap_create		PMAPOPNAME(create)
    156  1.12   garbled #define	pmap_reference		PMAPOPNAME(reference)
    157  1.12   garbled #define	pmap_destroy		PMAPOPNAME(destroy)
    158  1.12   garbled #define	pmap_copy		PMAPOPNAME(copy)
    159  1.12   garbled #define	pmap_update		PMAPOPNAME(update)
    160  1.12   garbled #define	pmap_enter		PMAPOPNAME(enter)
    161  1.12   garbled #define	pmap_remove		PMAPOPNAME(remove)
    162  1.12   garbled #define	pmap_kenter_pa		PMAPOPNAME(kenter_pa)
    163  1.12   garbled #define	pmap_kremove		PMAPOPNAME(kremove)
    164  1.12   garbled #define	pmap_extract		PMAPOPNAME(extract)
    165  1.12   garbled #define	pmap_protect		PMAPOPNAME(protect)
    166  1.12   garbled #define	pmap_unwire		PMAPOPNAME(unwire)
    167  1.12   garbled #define	pmap_page_protect	PMAPOPNAME(page_protect)
    168  1.12   garbled #define	pmap_query_bit		PMAPOPNAME(query_bit)
    169  1.12   garbled #define	pmap_clear_bit		PMAPOPNAME(clear_bit)
    170  1.12   garbled 
    171  1.12   garbled #define	pmap_activate		PMAPOPNAME(activate)
    172  1.12   garbled #define	pmap_deactivate		PMAPOPNAME(deactivate)
    173  1.12   garbled 
    174  1.12   garbled #define	pmap_pinit		PMAPOPNAME(pinit)
    175  1.12   garbled #define	pmap_procwr		PMAPOPNAME(procwr)
    176  1.12   garbled 
    177  1.12   garbled #define	pmap_pte_print		PMAPOPNAME(pte_print)
    178  1.12   garbled #define	pmap_pteg_check		PMAPOPNAME(pteg_check)
    179  1.12   garbled #define	pmap_print_mmuregs	PMAPOPNAME(print_mmuregs)
    180  1.12   garbled #define	pmap_print_pte		PMAPOPNAME(print_pte)
    181  1.12   garbled #define	pmap_pteg_dist		PMAPOPNAME(pteg_dist)
    182  1.12   garbled #define	pmap_pvo_verify		PMAPOPNAME(pvo_verify)
    183  1.12   garbled #define	pmap_steal_memory	PMAPOPNAME(steal_memory)
    184  1.12   garbled #define	pmap_bootstrap		PMAPOPNAME(bootstrap)
    185  1.12   garbled #endif /* PMAP_EXCLUDE_DECLS */
    186   1.1      matt 
    187   1.8     perry static inline paddr_t vtophys (vaddr_t);
    188   1.4      matt 
    189   1.1      matt /*
    190   1.1      matt  * Alternate mapping hooks for pool pages.  Avoids thrashing the TLB.
    191   1.1      matt  *
    192   1.1      matt  * Note: This won't work if we have more memory than can be direct-mapped
    193   1.1      matt  * VA==PA all at once.  But pmap_copy_page() and pmap_zero_page() will have
    194   1.1      matt  * this problem, too.
    195   1.1      matt  */
    196   1.9   sanjayl #if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE)
    197   1.1      matt #define	PMAP_MAP_POOLPAGE(pa)	(pa)
    198   1.1      matt #define	PMAP_UNMAP_POOLPAGE(pa)	(pa)
    199   1.4      matt #define POOL_VTOPHYS(va)	vtophys((vaddr_t) va)
    200   1.6      matt #endif
    201   1.1      matt 
    202   1.8     perry static inline paddr_t
    203   1.1      matt vtophys(vaddr_t va)
    204   1.1      matt {
    205   1.1      matt 	paddr_t pa;
    206   1.1      matt 
    207   1.1      matt 	if (pmap_extract(pmap_kernel(), va, &pa))
    208   1.1      matt 		return pa;
    209   1.4      matt 	KASSERT(0);
    210   1.4      matt 	return (paddr_t) -1;
    211   1.1      matt }
    212   1.1      matt 
    213  1.12   garbled extern const struct pmap_ops *pmapops;
    214  1.12   garbled extern const struct pmap_ops pmap32_ops;
    215  1.12   garbled extern const struct pmap_ops pmap64_ops;
    216  1.12   garbled extern const struct pmap_ops pmap64bridge_ops;
    217  1.12   garbled 
    218  1.12   garbled static inline void
    219  1.12   garbled pmap_setup32(void)
    220  1.12   garbled {
    221  1.12   garbled 	pmapops = &pmap32_ops;
    222  1.12   garbled }
    223  1.12   garbled 
    224  1.12   garbled static inline void
    225  1.12   garbled pmap_setup64(void)
    226  1.12   garbled {
    227  1.12   garbled 	pmapops = &pmap64_ops;
    228  1.12   garbled }
    229  1.12   garbled 
    230  1.12   garbled static inline void
    231  1.12   garbled pmap_setup64bridge(void)
    232  1.12   garbled {
    233  1.12   garbled 	pmapops = &pmap64bridge_ops;
    234  1.12   garbled }
    235  1.12   garbled 
    236  1.12   garbled #endif /* !PMAP_NOOPNAMES */
    237  1.12   garbled 
    238  1.12   garbled bool pmap_pageidlezero (paddr_t);
    239  1.12   garbled void pmap_syncicache (paddr_t, psize_t);
    240  1.12   garbled #ifdef PPC_OEA64
    241  1.12   garbled vaddr_t pmap_setusr (vaddr_t);
    242  1.12   garbled vaddr_t pmap_unsetusr (void);
    243  1.12   garbled #endif
    244  1.12   garbled 
    245  1.12   garbled #ifdef PPC_OEA64_BRIDGE
    246  1.12   garbled int pmap_setup_segment0_map(int use_large_pages, ...);
    247  1.12   garbled #endif
    248  1.12   garbled 
    249  1.20      matt #define PMAP_MD_NOCACHE			0x1000000
    250  1.12   garbled #define PMAP_STEAL_MEMORY
    251  1.12   garbled #define PMAP_NEED_PROCWR
    252  1.12   garbled 
    253  1.12   garbled void pmap_zero_page(paddr_t);
    254  1.12   garbled void pmap_copy_page(paddr_t, paddr_t);
    255  1.12   garbled 
    256  1.19  uebayasi LIST_HEAD(pvo_head, pvo_entry);
    257  1.19  uebayasi 
    258  1.19  uebayasi #define	__HAVE_VM_PAGE_MD
    259  1.19  uebayasi 
    260  1.19  uebayasi struct vm_page_md {
    261  1.19  uebayasi 	struct pvo_head mdpg_pvoh;
    262  1.19  uebayasi 	unsigned int mdpg_attrs;
    263  1.19  uebayasi };
    264  1.19  uebayasi 
    265  1.19  uebayasi #define	VM_MDPAGE_INIT(pg) do {			\
    266  1.19  uebayasi 	LIST_INIT(&(pg)->mdpage.mdpg_pvoh);	\
    267  1.19  uebayasi 	(pg)->mdpage.mdpg_attrs = 0;		\
    268  1.19  uebayasi } while (/*CONSTCOND*/0)
    269  1.19  uebayasi 
    270  1.12   garbled __END_DECLS
    271   1.1      matt #endif	/* _KERNEL */
    272   1.1      matt #endif	/* _LOCORE */
    273   1.1      matt 
    274   1.1      matt #endif	/* _POWERPC_OEA_PMAP_H_ */
    275