1/* $OpenBSD: pmap.h,v 1.21 2023/12/11 22:12:53 kettenis 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. */ 54typedef 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; 60extern struct pmap __pmap_kernel; 61 62void pmap_bootstrap(void); 63#define pmap_init_percpu() do { /* nothing */ } while (0) 64#define pmap_unuse_final(p) do { /* nothing */ } while (0) 65#define pmap_remove_holes(vm) do { /* nothing */ } while (0) 66#define pmap_kernel() (&__pmap_kernel) 67#define pmap_deactivate(pmap) do { /* nothing */ } while (0) 68#define pmap_update(pmap) do { /* nothing */ } while (0) 69#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 70#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 71 72static __inline void 73pmap_remove_all(struct pmap *pmap) 74{ 75 /* Nothing. */ 76} 77 78/* 79 * Avoid virtual cache aliases on SH4 CPUs 80 * which have the virtually-indexed cache. 81 */ 82#ifdef SH4 83#define PMAP_PREFER 84vaddr_t pmap_prefer_align(void); 85vaddr_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 94vaddr_t pmap_map_direct(vm_page_t); 95vm_page_t pmap_unmap_direct(vaddr_t); 96 97/* MD pmap utils. */ 98pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); 99pt_entry_t *__pmap_kpte_lookup(vaddr_t); 100boolean_t __pmap_pte_load(pmap_t, vaddr_t, int); 101 102#endif /* !_KERNEL */ 103 104#define PG_PMAP_REF PG_PMAP0 105#define PG_PMAP_MOD PG_PMAP1 106 107#ifndef _LOCORE 108struct pv_entry; 109struct vm_page_md { 110 SLIST_HEAD(, pv_entry) pvh_head; 111}; 112 113#define VM_MDPAGE_INIT(pg) \ 114do { \ 115 struct vm_page_md *pvh = &(pg)->mdpage; \ 116 SLIST_INIT(&pvh->pvh_head); \ 117} while (/*CONSTCOND*/0) 118#endif /* _LOCORE */ 119 120#endif /* !_SH_PMAP_H_ */ 121