1 /* $OpenBSD: pmap.h,v 1.10 2011/04/28 20:40:36 ariane 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 #define pmap_unuse_final(p) do { /* nothing */ } while (0) 61 #define pmap_remove_holes(map) do { /* nothing */ } while (0) 62 #define pmap_kernel() (&__pmap_kernel) 63 #define pmap_deactivate(pmap) do { /* nothing */ } while (0) 64 #define pmap_update(pmap) do { /* nothing */ } while (0) 65 #define pmap_copy(dp,sp,d,l,s) do { /* nothing */ } while (0) 66 #define pmap_collect(pmap) do { /* nothing */ } while (0) 67 #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 68 #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 69 70 /* ARGSUSED */ 71 static __inline void 72 pmap_remove_all(struct pmap *pmap) 73 { 74 /* Nothing. */ 75 } 76 77 /* 78 * pmap_prefer() helps to avoid virtual cache aliases on SH4 CPUs 79 * which have the virtually-indexed cache. 80 */ 81 #ifdef SH4 82 #define PMAP_PREFER(pa, va) pmap_prefer((pa), (va)) 83 vaddr_t pmap_prefer(vaddr_t, vaddr_t); 84 vaddr_t pmap_prefer_align(void); 85 vaddr_t pmap_prefer_offset(vaddr_t); 86 87 /* pmap prefer alignment */ 88 #define PMAP_PREFER_ALIGN() pmap_prefer_align() 89 /* pmap prefer offset in alignment */ 90 #define PMAP_PREFER_OFFSET(of) pmap_prefer_offset(of) 91 #endif /* SH4 */ 92 93 #define __HAVE_PMAP_DIRECT 94 vaddr_t pmap_map_direct(vm_page_t); 95 vm_page_t pmap_unmap_direct(vaddr_t); 96 97 /* MD pmap utils. */ 98 pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); 99 pt_entry_t *__pmap_kpte_lookup(vaddr_t); 100 boolean_t __pmap_pte_load(pmap_t, vaddr_t, int); 101 102 #endif /* !_KERNEL */ 103 #endif /* !_SH_PMAP_H_ */ 104