Home | History | Annotate | Line # | Download | only in booke
pmap.h revision 1.24
      1  1.24     skrll /*	$NetBSD: pmap.h,v 1.24 2020/12/20 16:38:25 skrll Exp $	*/
      2   1.2      matt /*-
      3   1.2      matt  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
      4   1.2      matt  * All rights reserved.
      5   1.2      matt  *
      6   1.2      matt  * This code is derived from software contributed to The NetBSD Foundation
      7   1.2      matt  * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
      8   1.2      matt  * Agency and which was developed by Matt Thomas of 3am Software Foundry.
      9   1.2      matt  *
     10   1.2      matt  * This material is based upon work supported by the Defense Advanced Research
     11   1.2      matt  * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
     12   1.2      matt  * Contract No. N66001-09-C-2073.
     13   1.2      matt  * Approved for Public Release, Distribution Unlimited
     14   1.2      matt  *
     15   1.2      matt  * Redistribution and use in source and binary forms, with or without
     16   1.2      matt  * modification, are permitted provided that the following conditions
     17   1.2      matt  * are met:
     18   1.2      matt  * 1. Redistributions of source code must retain the above copyright
     19   1.2      matt  *    notice, this list of conditions and the following disclaimer.
     20   1.2      matt  * 2. Redistributions in binary form must reproduce the above copyright
     21   1.2      matt  *    notice, this list of conditions and the following disclaimer in the
     22   1.2      matt  *    documentation and/or other materials provided with the distribution.
     23   1.2      matt  *
     24   1.2      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25   1.2      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26   1.2      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27   1.2      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28   1.2      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29   1.2      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30   1.2      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31   1.2      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32   1.2      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33   1.2      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34   1.2      matt  * POSSIBILITY OF SUCH DAMAGE.
     35   1.2      matt  */
     36  1.22       rin 
     37   1.2      matt #ifndef _POWERPC_BOOKE_PMAP_H_
     38   1.2      matt #define _POWERPC_BOOKE_PMAP_H_
     39   1.2      matt 
     40   1.2      matt #ifdef _LOCORE
     41   1.2      matt #error use assym.h instead
     42   1.2      matt #endif
     43   1.2      matt 
     44   1.6      matt #if defined(_MODULE)
     45   1.6      matt #error this file should not be included by loadable kernel modules
     46   1.6      matt #endif
     47   1.6      matt 
     48   1.9      matt #ifdef _KERNEL_OPT
     49  1.20   thorpej #include "opt_multiprocessor.h"
     50   1.9      matt #include "opt_pmap.h"
     51   1.9      matt #endif
     52   1.9      matt 
     53   1.2      matt #include <sys/cpu.h>
     54   1.2      matt #include <sys/kcore.h>
     55   1.2      matt #include <uvm/uvm_page.h>
     56  1.17    cherry #include <uvm/uvm_physseg.h>
     57   1.5      matt #ifdef __PMAP_PRIVATE
     58   1.2      matt #include <powerpc/booke/cpuvar.h>
     59   1.4      matt #endif
     60   1.2      matt 
     61   1.3      matt #define	PMAP_NEED_PROCWR
     62   1.2      matt 
     63  1.11  christos #include <uvm/pmap/vmpagemd.h>
     64   1.6      matt 
     65   1.2      matt #include <powerpc/booke/pte.h>
     66   1.2      matt 
     67   1.2      matt #define	NBSEG		(NBPG*NPTEPG)
     68   1.2      matt #define	SEGSHIFT	(PGSHIFT + PGSHIFT - 2)
     69   1.2      matt #define SEGOFSET	((1 << SEGSHIFT) - 1)
     70   1.2      matt #define PMAP_SEGTABSIZE	(1 << (32 - SEGSHIFT))
     71   1.2      matt #define	NPTEPG		(NBPG >> 2)
     72   1.2      matt 
     73   1.2      matt #define	KERNEL_PID	0
     74   1.2      matt 
     75   1.2      matt #define	PMAP_TLB_NUM_PIDS		256
     76  1.12      matt #define	PMAP_TLB_MAX			1
     77  1.10      matt #define	PMAP_INVALID_SEGTAB_ADDRESS	((pmap_segtab_t *)0xfeeddead)
     78  1.14      matt #define	PMAP_TLB_FLUSH_ASID_ON_RESET	false
     79   1.2      matt 
     80   1.2      matt #define	pmap_phys_address(x)		(x)
     81   1.2      matt 
     82   1.2      matt void	pmap_procwr(struct proc *, vaddr_t, size_t);
     83   1.2      matt #define	PMAP_NEED_PROCWR
     84   1.2      matt 
     85   1.7      matt #ifdef __PMAP_PRIVATE
     86   1.2      matt struct vm_page *
     87   1.2      matt 	pmap_md_alloc_poolpage(int flags);
     88   1.9      matt vaddr_t	pmap_md_map_poolpage(paddr_t, vsize_t);
     89   1.9      matt void	pmap_md_unmap_poolpage(vaddr_t, vsize_t);
     90   1.2      matt bool	pmap_md_direct_mapped_vaddr_p(vaddr_t);
     91   1.2      matt bool	pmap_md_io_vaddr_p(vaddr_t);
     92   1.2      matt paddr_t	pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t);
     93   1.2      matt vaddr_t	pmap_md_direct_map_paddr(paddr_t);
     94   1.2      matt void	pmap_md_init(void);
     95   1.2      matt 
     96   1.7      matt bool	pmap_md_tlb_check_entry(void *, vaddr_t, tlb_asid_t, pt_entry_t);
     97   1.9      matt 
     98  1.15    nonaka #ifdef MULTIPROCESSOR
     99  1.19   thorpej #define	PMAP_NEED_TLB_MISS_LOCK
    100  1.15    nonaka #endif	/* MULTIPROCESSOR */
    101  1.15    nonaka 
    102   1.9      matt #ifdef PMAP_MINIMALTLB
    103   1.9      matt vaddr_t	pmap_kvptefill(vaddr_t, vaddr_t, pt_entry_t);
    104   1.9      matt #endif
    105   1.7      matt #endif
    106   1.7      matt 
    107  1.24     skrll void	pmap_md_page_syncicache(struct vm_page_md *, const kcpuset_t *);
    108   1.9      matt vaddr_t	pmap_bootstrap(vaddr_t, vaddr_t, phys_ram_seg_t *, size_t);
    109   1.2      matt bool	pmap_extract(struct pmap *, vaddr_t, paddr_t *);
    110   1.2      matt 
    111  1.18  christos static __inline paddr_t vtophys(vaddr_t);
    112   1.2      matt 
    113  1.18  christos static __inline paddr_t
    114   1.2      matt vtophys(vaddr_t va)
    115   1.2      matt {
    116   1.2      matt 	paddr_t pa;
    117   1.2      matt 
    118   1.2      matt 	if (pmap_extract(pmap_kernel(), va, &pa))
    119   1.2      matt 		return pa;
    120   1.2      matt 	KASSERT(0);
    121   1.2      matt 	return (paddr_t) -1;
    122   1.2      matt }
    123   1.2      matt 
    124   1.7      matt #ifdef __PMAP_PRIVATE
    125   1.2      matt /*
    126   1.2      matt  * Virtual Cache Alias helper routines.  Not a problem for Booke CPUs.
    127   1.2      matt  */
    128  1.18  christos static __inline bool
    129  1.24     skrll pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep)
    130   1.2      matt {
    131   1.2      matt 	return false;
    132   1.2      matt }
    133   1.2      matt 
    134  1.18  christos static __inline void
    135  1.24     skrll pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va, bool dirty)
    136   1.2      matt {
    137   1.2      matt 
    138   1.2      matt }
    139   1.2      matt 
    140  1.18  christos static __inline void
    141  1.24     skrll pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op)
    142   1.2      matt {
    143   1.2      matt }
    144   1.2      matt 
    145  1.18  christos static __inline size_t
    146   1.7      matt pmap_md_tlb_asid_max(void)
    147   1.7      matt {
    148   1.7      matt 	return PMAP_TLB_NUM_PIDS - 1;
    149   1.7      matt }
    150  1.16      matt 
    151  1.16      matt struct vm_physseg;
    152  1.18  christos static __inline bool
    153  1.17    cherry pmap_md_ok_to_steal_p(const uvm_physseg_t bank, size_t npgs)
    154  1.16      matt {
    155  1.16      matt 	return true;
    156  1.16      matt }
    157  1.23     skrll 
    158  1.23     skrll static __inline void
    159  1.23     skrll pmap_md_xtab_activate(struct pmap *pm, struct lwp *l)
    160  1.23     skrll {
    161  1.23     skrll 
    162  1.23     skrll 	/* nothing */
    163  1.23     skrll }
    164  1.23     skrll 
    165  1.23     skrll static __inline void
    166  1.23     skrll pmap_md_xtab_deactivate(struct pmap *pm)
    167  1.23     skrll {
    168  1.23     skrll 
    169  1.23     skrll 	/* nothing */
    170  1.23     skrll }
    171  1.23     skrll 
    172   1.7      matt #endif
    173   1.7      matt 
    174   1.2      matt #define	POOL_VTOPHYS(va)	((paddr_t)(vaddr_t)(va))
    175   1.2      matt #define	POOL_PHYSTOV(pa)	((vaddr_t)(paddr_t)(pa))
    176   1.2      matt 
    177  1.11  christos #include <uvm/pmap/pmap.h>
    178   1.2      matt 
    179   1.2      matt #endif /* !_POWERPC_BOOKE_PMAP_H_ */
    180