1*be9c6147Sad /* $NetBSD: pmap.h,v 1.37 2020/03/14 14:05:43 ad Exp $ */
265363da2Sitojun
35cf2727aSuch /*-
45cf2727aSuch * Copyright (c) 2002 The NetBSD Foundation, Inc.
565363da2Sitojun * All rights reserved.
665363da2Sitojun *
75cf2727aSuch * This code is derived from software contributed to The NetBSD Foundation
85cf2727aSuch * by UCHIYAMA Yasushi.
95cf2727aSuch *
1065363da2Sitojun * Redistribution and use in source and binary forms, with or without
1165363da2Sitojun * modification, are permitted provided that the following conditions
1265363da2Sitojun * are met:
1365363da2Sitojun * 1. Redistributions of source code must retain the above copyright
1465363da2Sitojun * notice, this list of conditions and the following disclaimer.
1565363da2Sitojun * 2. Redistributions in binary form must reproduce the above copyright
1665363da2Sitojun * notice, this list of conditions and the following disclaimer in the
1765363da2Sitojun * documentation and/or other materials provided with the distribution.
1865363da2Sitojun *
195cf2727aSuch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
205cf2727aSuch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
215cf2727aSuch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
225cf2727aSuch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
235cf2727aSuch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
245cf2727aSuch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
255cf2727aSuch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
265cf2727aSuch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
275cf2727aSuch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
285cf2727aSuch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
295cf2727aSuch * POSSIBILITY OF SUCH DAMAGE.
3065363da2Sitojun */
3165363da2Sitojun
3265363da2Sitojun /*
335cf2727aSuch * NetBSD/sh3 pmap:
345cf2727aSuch * pmap.pm_ptp[512] ... 512 slot of page table page
355cf2727aSuch * page table page contains 1024 PTEs. (PAGE_SIZE / sizeof(pt_entry_t))
36fc61a45dSuwe * va -> [ PTP 10bit | PTOFSET 10bit | PGOFSET 12bit ]
3765363da2Sitojun */
3865363da2Sitojun
3965363da2Sitojun #ifndef _SH3_PMAP_H_
4065363da2Sitojun #define _SH3_PMAP_H_
415cf2727aSuch #include <sys/queue.h>
4290baa8b2Such #include <sh3/pte.h>
4365363da2Sitojun
445cf2727aSuch #define PMAP_NEED_PROCWR
455cf2727aSuch #define PMAP_STEAL_MEMORY
465cf2727aSuch #define PMAP_GROWKERNEL
4765363da2Sitojun
485cf2727aSuch #define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */
4929d439f8Spooka struct pmap {
505cf2727aSuch pt_entry_t **pm_ptp;
515cf2727aSuch int pm_asid;
525cf2727aSuch int pm_refcnt;
535cf2727aSuch struct pmap_statistics pm_stats; /* pmap statistics */
5429d439f8Spooka };
5565363da2Sitojun
565cf2727aSuch void pmap_bootstrap(void);
575cf2727aSuch void pmap_procwr(struct proc *, vaddr_t, size_t);
585cf2727aSuch #define pmap_update(pmap) ((void)0)
595cf2727aSuch #define pmap_copy(dp,sp,d,l,s) ((void)0)
60126ba780Sis #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
615cf2727aSuch #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
6265363da2Sitojun
63ae727708Suwe /* ARGSUSED */
64*be9c6147Sad static __inline bool
pmap_remove_all(struct pmap * pmap)65c081614eSchs pmap_remove_all(struct pmap *pmap)
6655e1f793Schs {
6755e1f793Schs /* Nothing. */
68*be9c6147Sad return false;
6955e1f793Schs }
7055e1f793Schs
71430cb190Stsutsui /*
72430cb190Stsutsui * pmap_prefer() helps to avoid virtual cache aliases on SH4 CPUs
73430cb190Stsutsui * which have the virtually-indexed cache.
74430cb190Stsutsui */
75430cb190Stsutsui #ifdef SH4
763ed49a9aSchristos #define PMAP_PREFER(pa, va, sz, td) pmap_prefer((pa), (va), (td))
773ed49a9aSchristos void pmap_prefer(vaddr_t, vaddr_t *, int);
78430cb190Stsutsui #endif /* SH4 */
79430cb190Stsutsui
805cf2727aSuch #define PMAP_MAP_POOLPAGE(pa) SH3_PHYS_TO_P1SEG((pa))
815cf2727aSuch #define PMAP_UNMAP_POOLPAGE(va) SH3_P1SEG_TO_PHYS((va))
82ef2315d2Sthorpej
835cf2727aSuch /* MD pmap utils. */
845cf2727aSuch pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t);
855cf2727aSuch pt_entry_t *__pmap_kpte_lookup(vaddr_t);
86712239e3Sthorpej bool __pmap_pte_load(pmap_t, vaddr_t, int);
875d7952a5Suebayasi
885d7952a5Suebayasi /* pmap-specific data store in the vm_page structure. */
895d7952a5Suebayasi #define __HAVE_VM_PAGE_MD
905d7952a5Suebayasi #define PVH_REFERENCED 1
915d7952a5Suebayasi #define PVH_MODIFIED 2
925d7952a5Suebayasi
935d7952a5Suebayasi struct pv_entry;
945d7952a5Suebayasi struct vm_page_md {
955d7952a5Suebayasi SLIST_HEAD(, pv_entry) pvh_head;
965d7952a5Suebayasi int pvh_flags;
975d7952a5Suebayasi };
985d7952a5Suebayasi
995d7952a5Suebayasi #define VM_MDPAGE_INIT(pg) \
1005d7952a5Suebayasi do { \
1015d7952a5Suebayasi struct vm_page_md *pvh = &(pg)->mdpage; \
1025d7952a5Suebayasi SLIST_INIT(&pvh->pvh_head); \
1035d7952a5Suebayasi pvh->pvh_flags = 0; \
1045d7952a5Suebayasi } while (/*CONSTCOND*/0)
1055cf2727aSuch #endif /* !_SH3_PMAP_H_ */
106