Home | History | Annotate | Line # | Download | only in pmap
pmap_tlb.h revision 1.6.8.3
      1  1.6.8.2       tls /*	$NetBSD: pmap_tlb.h,v 1.6.8.3 2017/12/03 11:39:23 jdolecek Exp $	*/
      2  1.6.8.2       tls 
      3  1.6.8.2       tls /*
      4  1.6.8.2       tls  * Copyright (c) 1992, 1993
      5  1.6.8.2       tls  *	The Regents of the University of California.  All rights reserved.
      6  1.6.8.2       tls  *
      7  1.6.8.2       tls  * This code is derived from software contributed to Berkeley by
      8  1.6.8.2       tls  * Ralph Campbell.
      9  1.6.8.2       tls  *
     10  1.6.8.2       tls  * Redistribution and use in source and binary forms, with or without
     11  1.6.8.2       tls  * modification, are permitted provided that the following conditions
     12  1.6.8.2       tls  * are met:
     13  1.6.8.2       tls  * 1. Redistributions of source code must retain the above copyright
     14  1.6.8.2       tls  *    notice, this list of conditions and the following disclaimer.
     15  1.6.8.2       tls  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.6.8.2       tls  *    notice, this list of conditions and the following disclaimer in the
     17  1.6.8.2       tls  *    documentation and/or other materials provided with the distribution.
     18  1.6.8.2       tls  * 3. Neither the name of the University nor the names of its contributors
     19  1.6.8.2       tls  *    may be used to endorse or promote products derived from this software
     20  1.6.8.2       tls  *    without specific prior written permission.
     21  1.6.8.2       tls  *
     22  1.6.8.2       tls  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  1.6.8.2       tls  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.6.8.2       tls  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.6.8.2       tls  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  1.6.8.2       tls  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.6.8.2       tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.6.8.2       tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.6.8.2       tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.6.8.2       tls  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.6.8.2       tls  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.6.8.2       tls  * SUCH DAMAGE.
     33  1.6.8.2       tls  *
     34  1.6.8.2       tls  *	@(#)pmap.h	8.1 (Berkeley) 6/10/93
     35  1.6.8.2       tls  */
     36  1.6.8.2       tls 
     37  1.6.8.2       tls /*
     38  1.6.8.2       tls  * Copyright (c) 1987 Carnegie-Mellon University
     39  1.6.8.2       tls  *
     40  1.6.8.2       tls  * This code is derived from software contributed to Berkeley by
     41  1.6.8.2       tls  * Ralph Campbell.
     42  1.6.8.2       tls  *
     43  1.6.8.2       tls  * Redistribution and use in source and binary forms, with or without
     44  1.6.8.2       tls  * modification, are permitted provided that the following conditions
     45  1.6.8.2       tls  * are met:
     46  1.6.8.2       tls  * 1. Redistributions of source code must retain the above copyright
     47  1.6.8.2       tls  *    notice, this list of conditions and the following disclaimer.
     48  1.6.8.2       tls  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.6.8.2       tls  *    notice, this list of conditions and the following disclaimer in the
     50  1.6.8.2       tls  *    documentation and/or other materials provided with the distribution.
     51  1.6.8.2       tls  * 3. All advertising materials mentioning features or use of this software
     52  1.6.8.2       tls  *    must display the following acknowledgement:
     53  1.6.8.2       tls  *	This product includes software developed by the University of
     54  1.6.8.2       tls  *	California, Berkeley and its contributors.
     55  1.6.8.2       tls  * 4. Neither the name of the University nor the names of its contributors
     56  1.6.8.2       tls  *    may be used to endorse or promote products derived from this software
     57  1.6.8.2       tls  *    without specific prior written permission.
     58  1.6.8.2       tls  *
     59  1.6.8.2       tls  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     60  1.6.8.2       tls  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     61  1.6.8.2       tls  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     62  1.6.8.2       tls  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     63  1.6.8.2       tls  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     64  1.6.8.2       tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     65  1.6.8.2       tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     66  1.6.8.2       tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     67  1.6.8.2       tls  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     68  1.6.8.2       tls  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     69  1.6.8.2       tls  * SUCH DAMAGE.
     70  1.6.8.2       tls  *
     71  1.6.8.2       tls  *	@(#)pmap.h	8.1 (Berkeley) 6/10/93
     72  1.6.8.2       tls  */
     73  1.6.8.2       tls 
     74  1.6.8.3  jdolecek #ifndef	_UVM_PMAP_PMAP_TLB_H_
     75  1.6.8.3  jdolecek #define	_UVM_PMAP_PMAP_TLB_H_
     76  1.6.8.2       tls 
     77  1.6.8.3  jdolecek #include <sys/evcnt.h>
     78  1.6.8.2       tls #include <sys/kcpuset.h>
     79  1.6.8.2       tls 
     80  1.6.8.2       tls #if !defined(PMAP_TLB_MAX)
     81  1.6.8.2       tls # if defined(MULTIPROCESSOR)
     82  1.6.8.2       tls #  define PMAP_TLB_MAX		MAXCPUS
     83  1.6.8.2       tls # else
     84  1.6.8.2       tls #  define PMAP_TLB_MAX		1
     85  1.6.8.2       tls # endif
     86  1.6.8.2       tls #endif
     87  1.6.8.2       tls 
     88  1.6.8.2       tls /*
     89  1.6.8.2       tls  * Per TLB (normally same as CPU) asid info
     90  1.6.8.2       tls  */
     91  1.6.8.2       tls struct pmap_asid_info {
     92  1.6.8.2       tls 	LIST_ENTRY(pmap_asid_info) pai_link;
     93  1.6.8.2       tls 	uint32_t	pai_asid;	/* TLB address space tag */
     94  1.6.8.2       tls };
     95  1.6.8.2       tls 
     96  1.6.8.2       tls #define	TLBINFO_LOCK(ti)		mutex_spin_enter((ti)->ti_lock)
     97  1.6.8.2       tls #define	TLBINFO_UNLOCK(ti)		mutex_spin_exit((ti)->ti_lock)
     98  1.6.8.2       tls #define	PMAP_PAI_ASIDVALID_P(pai, ti)	((pai)->pai_asid != 0)
     99  1.6.8.2       tls #define	PMAP_PAI(pmap, ti)		(&(pmap)->pm_pai[tlbinfo_index(ti)])
    100  1.6.8.2       tls #define	PAI_PMAP(pai, ti)	\
    101  1.6.8.2       tls 	((pmap_t)((intptr_t)(pai) \
    102  1.6.8.2       tls 	    - offsetof(struct pmap, pm_pai[tlbinfo_index(ti)])))
    103  1.6.8.2       tls 
    104  1.6.8.2       tls enum tlb_invalidate_op {
    105  1.6.8.2       tls 	TLBINV_NOBODY=0,
    106  1.6.8.2       tls 	TLBINV_ONE=1,
    107  1.6.8.2       tls 	TLBINV_ALLUSER=2,
    108  1.6.8.2       tls 	TLBINV_ALLKERNEL=3,
    109  1.6.8.2       tls 	TLBINV_ALL=4
    110  1.6.8.2       tls };
    111  1.6.8.2       tls 
    112  1.6.8.2       tls struct pmap_tlb_info {
    113  1.6.8.2       tls 	char ti_name[8];
    114  1.6.8.2       tls 	uint32_t ti_asids_free;		/* # of ASIDs free */
    115  1.6.8.2       tls #define	tlbinfo_noasids_p(ti)	((ti)->ti_asids_free == 0)
    116  1.6.8.2       tls 	kmutex_t *ti_lock;
    117  1.6.8.2       tls 	u_int ti_wired;			/* # of wired TLB entries */
    118  1.6.8.3  jdolecek 	tlb_asid_t ti_asid_hint;	/* probable next ASID to use */
    119  1.6.8.2       tls 	tlb_asid_t ti_asid_max;
    120  1.6.8.2       tls 	LIST_HEAD(, pmap_asid_info) ti_pais; /* list of active ASIDs */
    121  1.6.8.2       tls #ifdef MULTIPROCESSOR
    122  1.6.8.2       tls 	pmap_t ti_victim;
    123  1.6.8.2       tls 	uint32_t ti_synci_page_bitmap;	/* page indices needing a syncicache */
    124  1.6.8.2       tls #if PMAP_TLB_MAX > 1
    125  1.6.8.2       tls 	kcpuset_t *ti_kcpuset;		/* bitmask of CPUs sharing this TLB */
    126  1.6.8.2       tls 	u_int ti_index;
    127  1.6.8.2       tls 	enum tlb_invalidate_op ti_tlbinvop;
    128  1.6.8.2       tls #define tlbinfo_index(ti)	((ti)->ti_index)
    129  1.6.8.2       tls #else
    130  1.6.8.2       tls #define tlbinfo_index(ti)	((void)(ti), 0)
    131  1.6.8.2       tls #endif
    132  1.6.8.2       tls 	struct evcnt ti_evcnt_synci_asts;
    133  1.6.8.2       tls 	struct evcnt ti_evcnt_synci_all;
    134  1.6.8.2       tls 	struct evcnt ti_evcnt_synci_pages;
    135  1.6.8.2       tls 	struct evcnt ti_evcnt_synci_deferred;
    136  1.6.8.2       tls 	struct evcnt ti_evcnt_synci_desired;
    137  1.6.8.2       tls 	struct evcnt ti_evcnt_synci_duplicate;
    138  1.6.8.2       tls #else
    139  1.6.8.2       tls #define tlbinfo_index(ti)	((void)(ti), 0)
    140  1.6.8.2       tls #endif
    141  1.6.8.2       tls 	struct evcnt ti_evcnt_asid_reinits;
    142  1.6.8.2       tls 	u_long ti_asid_bitmap[256 / (sizeof(u_long) * 8)];
    143  1.6.8.2       tls };
    144  1.6.8.2       tls 
    145  1.6.8.2       tls #ifdef	_KERNEL
    146  1.6.8.2       tls extern struct pmap_tlb_info pmap_tlb0_info;
    147  1.6.8.2       tls #ifdef MULTIPROCESSOR
    148  1.6.8.3  jdolecek extern struct pmap_tlb_info *pmap_tlbs[PMAP_TLB_MAX];
    149  1.6.8.2       tls extern u_int pmap_ntlbs;
    150  1.6.8.2       tls #endif
    151  1.6.8.2       tls 
    152  1.6.8.2       tls #ifndef cpu_set_tlb_info
    153  1.6.8.2       tls # define cpu_set_tlb_info(ci, ti)	((void)((ci)->ci_tlb_info = (ti)))
    154  1.6.8.2       tls #endif
    155  1.6.8.2       tls #ifndef cpu_tlb_info
    156  1.6.8.2       tls # if PMAP_TLB_MAX > 1
    157  1.6.8.2       tls #  define cpu_tlb_info(ci)		((ci)->ci_tlb_info)
    158  1.6.8.2       tls # else
    159  1.6.8.2       tls #  define cpu_tlb_info(ci)		(&pmap_tlb0_info)
    160  1.6.8.2       tls # endif
    161  1.6.8.2       tls #endif
    162  1.6.8.2       tls 
    163  1.6.8.2       tls #ifdef MULTIPROCESSOR
    164  1.6.8.2       tls void	pmap_tlb_shootdown_process(void);
    165  1.6.8.2       tls bool	pmap_tlb_shootdown_bystanders(pmap_t pmap);
    166  1.6.8.2       tls void	pmap_tlb_info_attach(struct pmap_tlb_info *, struct cpu_info *);
    167  1.6.8.2       tls void	pmap_md_tlb_info_attach(struct pmap_tlb_info *, struct cpu_info *);
    168  1.6.8.2       tls #endif
    169  1.6.8.2       tls void	pmap_tlb_info_init(struct pmap_tlb_info *);
    170  1.6.8.2       tls void	pmap_tlb_info_evcnt_attach(struct pmap_tlb_info *);
    171  1.6.8.2       tls void	pmap_tlb_asid_acquire(pmap_t, struct lwp *l);
    172  1.6.8.2       tls void	pmap_tlb_asid_deactivate(pmap_t);
    173  1.6.8.2       tls void	pmap_tlb_asid_release_all(pmap_t);
    174  1.6.8.3  jdolecek int	pmap_tlb_update_addr(pmap_t, vaddr_t, pt_entry_t, u_int);
    175  1.6.8.2       tls #define	PMAP_TLB_NEED_IPI	0x01
    176  1.6.8.2       tls #define	PMAP_TLB_INSERT		0x02
    177  1.6.8.2       tls void	pmap_tlb_invalidate_addr(pmap_t, vaddr_t);
    178  1.6.8.2       tls void	pmap_tlb_check(pmap_t, bool (*)(void *, vaddr_t, tlb_asid_t, pt_entry_t));
    179  1.6.8.2       tls void	pmap_tlb_asid_check(void);
    180  1.6.8.2       tls 
    181  1.6.8.2       tls #endif	/* _KERNEL */
    182  1.6.8.3  jdolecek #endif	/* _UVM_PMAP_PMAP_TLB_H_ */
    183