Home | History | Annotate | Line # | Download | only in booke
pmap.h revision 1.8.2.1
      1  1.8.2.1  yamt /*	$NetBSD: pmap.h,v 1.8.2.1 2012/04/17 00:06:47 yamt 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.2  matt #ifndef _POWERPC_BOOKE_PMAP_H_
     37      1.2  matt #define _POWERPC_BOOKE_PMAP_H_
     38      1.2  matt 
     39      1.2  matt #ifdef _LOCORE
     40      1.2  matt #error use assym.h instead
     41      1.2  matt #endif
     42      1.2  matt 
     43      1.6  matt #if defined(_MODULE)
     44      1.6  matt #error this file should not be included by loadable kernel modules
     45      1.6  matt #endif
     46      1.6  matt 
     47  1.8.2.1  yamt #ifdef _KERNEL_OPT
     48  1.8.2.1  yamt #include "opt_pmap.h"
     49  1.8.2.1  yamt #endif
     50  1.8.2.1  yamt 
     51      1.2  matt #include <sys/cpu.h>
     52      1.2  matt #include <sys/kcore.h>
     53      1.2  matt #include <uvm/uvm_page.h>
     54      1.5  matt #ifdef __PMAP_PRIVATE
     55      1.2  matt #include <powerpc/booke/cpuvar.h>
     56      1.5  matt #include <powerpc/cpuset.h>
     57      1.4  matt #endif
     58      1.2  matt 
     59      1.3  matt #define	PMAP_NEED_PROCWR
     60      1.2  matt 
     61      1.6  matt #include <common/pmap/tlb/vmpagemd.h>
     62      1.6  matt 
     63      1.2  matt #include <powerpc/booke/pte.h>
     64      1.2  matt 
     65      1.2  matt #define	NBSEG		(NBPG*NPTEPG)
     66      1.2  matt #define	SEGSHIFT	(PGSHIFT + PGSHIFT - 2)
     67      1.2  matt #define SEGOFSET	((1 << SEGSHIFT) - 1)
     68      1.2  matt #define PMAP_SEGTABSIZE	(1 << (32 - SEGSHIFT))
     69      1.2  matt #define	NPTEPG		(NBPG >> 2)
     70      1.2  matt 
     71      1.2  matt #define	KERNEL_PID	0
     72      1.2  matt 
     73      1.2  matt #define	PMAP_TLB_NUM_PIDS		256
     74      1.2  matt #define	PMAP_INVALID_SEGTAB_ADDRESS	((struct pmap_segtab *)0xfeeddead)
     75      1.2  matt 
     76      1.2  matt #define	pmap_phys_address(x)		(x)
     77      1.2  matt 
     78      1.2  matt void	pmap_procwr(struct proc *, vaddr_t, size_t);
     79      1.2  matt #define	PMAP_NEED_PROCWR
     80      1.2  matt 
     81      1.7  matt #ifdef __PMAP_PRIVATE
     82      1.2  matt struct vm_page *
     83      1.2  matt 	pmap_md_alloc_poolpage(int flags);
     84  1.8.2.1  yamt vaddr_t	pmap_md_map_poolpage(paddr_t, vsize_t);
     85  1.8.2.1  yamt void	pmap_md_unmap_poolpage(vaddr_t, vsize_t);
     86      1.2  matt bool	pmap_md_direct_mapped_vaddr_p(vaddr_t);
     87      1.2  matt bool	pmap_md_io_vaddr_p(vaddr_t);
     88      1.2  matt paddr_t	pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t);
     89      1.2  matt vaddr_t	pmap_md_direct_map_paddr(paddr_t);
     90      1.2  matt void	pmap_md_init(void);
     91      1.2  matt 
     92      1.7  matt bool	pmap_md_tlb_check_entry(void *, vaddr_t, tlb_asid_t, pt_entry_t);
     93  1.8.2.1  yamt 
     94  1.8.2.1  yamt #ifdef PMAP_MINIMALTLB
     95  1.8.2.1  yamt vaddr_t	pmap_kvptefill(vaddr_t, vaddr_t, pt_entry_t);
     96  1.8.2.1  yamt #endif
     97      1.7  matt #endif
     98      1.7  matt 
     99      1.5  matt void	pmap_md_page_syncicache(struct vm_page *, __cpuset_t);
    100  1.8.2.1  yamt vaddr_t	pmap_bootstrap(vaddr_t, vaddr_t, phys_ram_seg_t *, size_t);
    101      1.2  matt bool	pmap_extract(struct pmap *, vaddr_t, paddr_t *);
    102      1.2  matt 
    103      1.2  matt static inline paddr_t vtophys(vaddr_t);
    104      1.2  matt 
    105      1.2  matt static inline paddr_t
    106      1.2  matt vtophys(vaddr_t va)
    107      1.2  matt {
    108      1.2  matt 	paddr_t pa;
    109      1.2  matt 
    110      1.2  matt 	if (pmap_extract(pmap_kernel(), va, &pa))
    111      1.2  matt 		return pa;
    112      1.2  matt 	KASSERT(0);
    113      1.2  matt 	return (paddr_t) -1;
    114      1.2  matt }
    115      1.2  matt 
    116      1.7  matt #ifdef __PMAP_PRIVATE
    117      1.2  matt /*
    118      1.2  matt  * Virtual Cache Alias helper routines.  Not a problem for Booke CPUs.
    119      1.2  matt  */
    120      1.2  matt static inline bool
    121      1.2  matt pmap_md_vca_add(struct vm_page *pg, vaddr_t va, pt_entry_t *nptep)
    122      1.2  matt {
    123      1.2  matt 	return false;
    124      1.2  matt }
    125      1.2  matt 
    126      1.2  matt static inline void
    127      1.2  matt pmap_md_vca_remove(struct vm_page *pg, vaddr_t va)
    128      1.2  matt {
    129      1.2  matt 
    130      1.2  matt }
    131      1.2  matt 
    132      1.2  matt static inline void
    133      1.2  matt pmap_md_vca_clean(struct vm_page *pg, vaddr_t va, int op)
    134      1.2  matt {
    135      1.2  matt }
    136      1.2  matt 
    137      1.7  matt static inline size_t
    138      1.7  matt pmap_md_tlb_asid_max(void)
    139      1.7  matt {
    140      1.7  matt 	return PMAP_TLB_NUM_PIDS - 1;
    141      1.7  matt }
    142      1.7  matt #endif
    143      1.7  matt 
    144      1.2  matt #define	POOL_VTOPHYS(va)	((paddr_t)(vaddr_t)(va))
    145      1.2  matt #define	POOL_PHYSTOV(pa)	((vaddr_t)(paddr_t)(pa))
    146      1.2  matt 
    147      1.2  matt #include <common/pmap/tlb/pmap.h>
    148      1.2  matt 
    149      1.2  matt #endif /* !_POWERPC_BOOKE_PMAP_H_ */
    150