1 /* $OpenBSD: pmap.h,v 1.20 2023/04/13 15:23:22 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_CHECK_COPYIN 1 49 50 #define PMAP_STEAL_MEMORY 51 #define PMAP_GROWKERNEL 52 53 #define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */ 54 typedef struct pmap { 55 pt_entry_t **pm_ptp; 56 int pm_asid; 57 int pm_refcnt; 58 struct pmap_statistics pm_stats; /* pmap statistics */ 59 } *pmap_t; 60 extern struct pmap __pmap_kernel; 61 62 void pmap_bootstrap(void); 63 #define pmap_unuse_final(p) do { /* nothing */ } while (0) 64 #define pmap_remove_holes(vm) do { /* nothing */ } while (0) 65 #define pmap_kernel() (&__pmap_kernel) 66 #define pmap_deactivate(pmap) do { /* nothing */ } while (0) 67 #define pmap_update(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 static __inline void 72 pmap_remove_all(struct pmap *pmap) 73 { 74 /* Nothing. */ 75 } 76 77 /* 78 * Avoid virtual cache aliases on SH4 CPUs 79 * which have the virtually-indexed cache. 80 */ 81 #ifdef SH4 82 #define PMAP_PREFER 83 vaddr_t pmap_prefer_align(void); 84 vaddr_t pmap_prefer_offset(vaddr_t); 85 86 /* pmap prefer alignment */ 87 #define PMAP_PREFER_ALIGN() pmap_prefer_align() 88 /* pmap prefer offset in alignment */ 89 #define PMAP_PREFER_OFFSET(of) pmap_prefer_offset(of) 90 #endif /* SH4 */ 91 92 #define __HAVE_PMAP_DIRECT 93 vaddr_t pmap_map_direct(vm_page_t); 94 vm_page_t pmap_unmap_direct(vaddr_t); 95 96 /* MD pmap utils. */ 97 pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); 98 pt_entry_t *__pmap_kpte_lookup(vaddr_t); 99 boolean_t __pmap_pte_load(pmap_t, vaddr_t, int); 100 101 #endif /* !_KERNEL */ 102 103 #define PG_PMAP_REF PG_PMAP0 104 #define PG_PMAP_MOD PG_PMAP1 105 106 #ifndef _LOCORE 107 struct pv_entry; 108 struct vm_page_md { 109 SLIST_HEAD(, pv_entry) pvh_head; 110 }; 111 112 #define VM_MDPAGE_INIT(pg) \ 113 do { \ 114 struct vm_page_md *pvh = &(pg)->mdpage; \ 115 SLIST_INIT(&pvh->pvh_head); \ 116 } while (/*CONSTCOND*/0) 117 #endif /* _LOCORE */ 118 119 #endif /* !_SH_PMAP_H_ */ 120