Home | History | Annotate | Line # | Download | only in booke
pmap.h revision 1.2.2.1
      1  1.2.2.1  bouyer /*	$NetBSD: pmap.h,v 1.2.2.1 2011/02/08 16:19:35 bouyer 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.2    matt #include <sys/cpu.h>
     44      1.2    matt #include <sys/kcore.h>
     45      1.2    matt #include <uvm/uvm_page.h>
     46      1.2    matt #include <powerpc/booke/cpuvar.h>
     47      1.2    matt 
     48      1.2    matt #define	PMAP_MD_NOCACHE		0x01000000
     49  1.2.2.1  bouyer #define	PMAP_NEED_PROCWR
     50      1.2    matt 
     51      1.2    matt #include <powerpc/booke/pte.h>
     52      1.2    matt 
     53      1.2    matt #define	NBSEG		(NBPG*NPTEPG)
     54      1.2    matt #define	SEGSHIFT	(PGSHIFT + PGSHIFT - 2)
     55      1.2    matt #define SEGOFSET	((1 << SEGSHIFT) - 1)
     56      1.2    matt #define PMAP_SEGTABSIZE	(1 << (32 - SEGSHIFT))
     57      1.2    matt #define	NPTEPG		(NBPG >> 2)
     58      1.2    matt 
     59      1.2    matt #define	KERNEL_PID	0
     60      1.2    matt 
     61      1.2    matt #define	PMAP_TLB_NUM_PIDS		256
     62      1.2    matt #define	PMAP_INVALID_SEGTAB_ADDRESS	((struct pmap_segtab *)0xfeeddead)
     63      1.2    matt 
     64      1.2    matt #ifndef _LOCORE
     65      1.2    matt #define	pmap_phys_address(x)		(x)
     66      1.2    matt 
     67      1.2    matt void	pmap_procwr(struct proc *, vaddr_t, size_t);
     68      1.2    matt #define	PMAP_NEED_PROCWR
     69      1.2    matt 
     70      1.2    matt struct vm_page *
     71      1.2    matt 	pmap_md_alloc_poolpage(int flags);
     72      1.2    matt vaddr_t	pmap_md_map_poolpage(paddr_t);
     73      1.2    matt bool	pmap_md_direct_mapped_vaddr_p(vaddr_t);
     74      1.2    matt bool	pmap_md_io_vaddr_p(vaddr_t);
     75      1.2    matt paddr_t	pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t);
     76      1.2    matt vaddr_t	pmap_md_direct_map_paddr(paddr_t);
     77      1.2    matt void	pmap_md_init(void);
     78      1.2    matt 
     79      1.2    matt void	pmap_md_page_syncicache(struct vm_page *);
     80      1.2    matt void	pmap_bootstrap(vaddr_t, vaddr_t, const phys_ram_seg_t *, size_t);
     81      1.2    matt bool	pmap_extract(struct pmap *, vaddr_t, paddr_t *);
     82      1.2    matt 
     83      1.2    matt static inline paddr_t vtophys(vaddr_t);
     84      1.2    matt 
     85      1.2    matt static inline paddr_t
     86      1.2    matt vtophys(vaddr_t va)
     87      1.2    matt {
     88      1.2    matt 	paddr_t pa;
     89      1.2    matt 
     90      1.2    matt 	if (pmap_extract(pmap_kernel(), va, &pa))
     91      1.2    matt 		return pa;
     92      1.2    matt 	KASSERT(0);
     93      1.2    matt 	return (paddr_t) -1;
     94      1.2    matt }
     95      1.2    matt 
     96      1.2    matt /*
     97      1.2    matt  * Virtual Cache Alias helper routines.  Not a problem for Booke CPUs.
     98      1.2    matt  */
     99      1.2    matt static inline bool
    100      1.2    matt pmap_md_vca_add(struct vm_page *pg, vaddr_t va, pt_entry_t *nptep)
    101      1.2    matt {
    102      1.2    matt 	return false;
    103      1.2    matt }
    104      1.2    matt 
    105      1.2    matt static inline void
    106      1.2    matt pmap_md_vca_remove(struct vm_page *pg, vaddr_t va)
    107      1.2    matt {
    108      1.2    matt 
    109      1.2    matt }
    110      1.2    matt 
    111      1.2    matt static inline void
    112      1.2    matt pmap_md_vca_clean(struct vm_page *pg, vaddr_t va, int op)
    113      1.2    matt {
    114      1.2    matt }
    115      1.2    matt 
    116      1.2    matt #define	POOL_VTOPHYS(va)	((paddr_t)(vaddr_t)(va))
    117      1.2    matt #define	POOL_PHYSTOV(pa)	((vaddr_t)(paddr_t)(pa))
    118      1.2    matt 
    119      1.2    matt #include <common/pmap/tlb/pmap.h>
    120      1.2    matt #endif /* _LOCORE */
    121      1.2    matt 
    122      1.2    matt #endif /* !_POWERPC_BOOKE_PMAP_H_ */
    123