1 /* $OpenBSD: pmap.h,v 1.14 2015/02/15 21:34:33 miod 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 | PAGE_MASK 12bit | 38 */ 39 40 #ifndef _SH_PMAP_H_ 41 #define _SH_PMAP_H_ 42 43 #include <sh/pte.h> 44 45 #ifdef _KERNEL 46 #include <sys/queue.h> 47 48 #define PMAP_STEAL_MEMORY 49 #define PMAP_GROWKERNEL 50 51 #define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */ 52 typedef struct pmap { 53 pt_entry_t **pm_ptp; 54 int pm_asid; 55 int pm_refcnt; 56 struct pmap_statistics pm_stats; /* pmap statistics */ 57 } *pmap_t; 58 extern struct pmap __pmap_kernel; 59 60 void pmap_bootstrap(void); 61 #define pmap_unuse_final(p) do { /* nothing */ } while (0) 62 #define pmap_remove_holes(vm) 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 71 /* ARGSUSED */ 72 static __inline void 73 pmap_remove_all(struct pmap *pmap) 74 { 75 /* Nothing. */ 76 } 77 78 /* 79 * pmap_prefer() helps to avoid virtual cache aliases on SH4 CPUs 80 * which have the virtually-indexed cache. 81 */ 82 #ifdef SH4 83 #define PMAP_PREFER(pa, va) pmap_prefer((pa), (va)) 84 vaddr_t pmap_prefer(vaddr_t, vaddr_t); 85 vaddr_t pmap_prefer_align(void); 86 vaddr_t pmap_prefer_offset(vaddr_t); 87 88 /* pmap prefer alignment */ 89 #define PMAP_PREFER_ALIGN() pmap_prefer_align() 90 /* pmap prefer offset in alignment */ 91 #define PMAP_PREFER_OFFSET(of) pmap_prefer_offset(of) 92 #endif /* SH4 */ 93 94 #define __HAVE_PMAP_DIRECT 95 vaddr_t pmap_map_direct(vm_page_t); 96 vm_page_t pmap_unmap_direct(vaddr_t); 97 98 /* MD pmap utils. */ 99 pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); 100 pt_entry_t *__pmap_kpte_lookup(vaddr_t); 101 boolean_t __pmap_pte_load(pmap_t, vaddr_t, int); 102 103 #endif /* !_KERNEL */ 104 105 #define PVH_REFERENCED 1 106 #define PVH_MODIFIED 2 107 108 #ifndef _LOCORE 109 struct pv_entry; 110 struct vm_page_md { 111 SLIST_HEAD(, pv_entry) pvh_head; 112 int pvh_flags; 113 }; 114 115 #define VM_MDPAGE_INIT(pg) \ 116 do { \ 117 struct vm_page_md *pvh = &(pg)->mdpage; \ 118 SLIST_INIT(&pvh->pvh_head); \ 119 pvh->pvh_flags = 0; \ 120 } while (/*CONSTCOND*/0) 121 #endif /* _LOCORE */ 122 123 #endif /* !_SH_PMAP_H_ */ 124