1 /* $OpenBSD: pmap.h,v 1.5 2008/06/26 05:42:12 ray Exp $ */ 2 /* $NetBSD: pmap.h,v 1.28 2006/04/10 23:12:11 uwe Exp $ */ 3 4 /*- 5 * Copyright (c) 2002 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by UCHIYAMA Yasushi. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * OpenBSD/sh pmap: 35 * pmap.pm_ptp[512] ... 512 slot of page table page 36 * page table page contains 1024 PTEs. (PAGE_SIZE / sizeof(pt_entry_t)) 37 * | PTP 11bit | PTOFSET 10bit | PGOFSET 12bit | 38 */ 39 40 #ifndef _SH_PMAP_H_ 41 #define _SH_PMAP_H_ 42 #include <sys/queue.h> 43 #include <sh/pte.h> 44 45 #ifdef _KERNEL 46 47 #define PMAP_STEAL_MEMORY 48 #define PMAP_GROWKERNEL 49 50 #define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */ 51 typedef struct pmap { 52 pt_entry_t **pm_ptp; 53 int pm_asid; 54 int pm_refcnt; 55 struct pmap_statistics pm_stats; /* pmap statistics */ 56 } *pmap_t; 57 extern struct pmap __pmap_kernel; 58 59 void pmap_bootstrap(void); 60 void pmap_proc_iflush(struct proc *, vaddr_t, size_t); 61 #define pmap_unuse_final(p) do { /* nothing */ } while (0) 62 #define pmap_remove_holes(map) do { /* nothing */ } while (0) 63 #define pmap_kernel() (&__pmap_kernel) 64 #define pmap_deactivate(pmap) do { /* nothing */ } while (0) 65 #define pmap_update(pmap) do { /* nothing */ } while (0) 66 #define pmap_copy(dp,sp,d,l,s) do { /* nothing */ } while (0) 67 #define pmap_collect(pmap) do { /* nothing */ } while (0) 68 #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 69 #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 70 #define pmap_phys_address(frame) ((paddr_t)(ptoa(frame))) 71 72 /* ARGSUSED */ 73 static __inline void 74 pmap_remove_all(struct pmap *pmap) 75 { 76 /* Nothing. */ 77 } 78 79 /* 80 * pmap_prefer() helps to avoid virtual cache aliases on SH4 CPUs 81 * which have the virtually-indexed cache. 82 */ 83 #ifdef SH4 84 #define PMAP_PREFER(pa, va) pmap_prefer((pa), (va)) 85 void pmap_prefer(vaddr_t, vaddr_t *); 86 #endif /* SH4 */ 87 88 #define __HAVE_PMAP_DIRECT 89 #define pmap_map_direct(pg) SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg)) 90 #define pmap_unmap_direct(va) PHYS_TO_VM_PAGE(SH3_P1SEG_TO_PHYS((va))) 91 92 /* MD pmap utils. */ 93 pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); 94 pt_entry_t *__pmap_kpte_lookup(vaddr_t); 95 boolean_t __pmap_pte_load(pmap_t, vaddr_t, int); 96 97 #endif /* !_KERNEL */ 98 #endif /* !_SH_PMAP_H_ */ 99