1*9a527560SKonstantin Belousov /*- 2*9a527560SKonstantin Belousov * SPDX-License-Identifier: BSD-3-Clause 3*9a527560SKonstantin Belousov * 4*9a527560SKonstantin Belousov * Copyright (c) 1991 Regents of the University of California. 5*9a527560SKonstantin Belousov * All rights reserved. 6*9a527560SKonstantin Belousov * 7*9a527560SKonstantin Belousov * Copyright (c) 2018 The FreeBSD Foundation 8*9a527560SKonstantin Belousov * All rights reserved. 9*9a527560SKonstantin Belousov * 10*9a527560SKonstantin Belousov * This code is derived from software contributed to Berkeley by 11*9a527560SKonstantin Belousov * the Systems Programming Group of the University of Utah Computer 12*9a527560SKonstantin Belousov * Science Department and William Jolitz of UUNET Technologies Inc. 13*9a527560SKonstantin Belousov * 14*9a527560SKonstantin Belousov * Portions of this software were developed by 15*9a527560SKonstantin Belousov * Konstantin Belousov <kib@FreeBSD.org> under sponsorship from 16*9a527560SKonstantin Belousov * the FreeBSD Foundation. 17*9a527560SKonstantin Belousov * 18*9a527560SKonstantin Belousov * Redistribution and use in source and binary forms, with or without 19*9a527560SKonstantin Belousov * modification, are permitted provided that the following conditions 20*9a527560SKonstantin Belousov * are met: 21*9a527560SKonstantin Belousov * 1. Redistributions of source code must retain the above copyright 22*9a527560SKonstantin Belousov * notice, this list of conditions and the following disclaimer. 23*9a527560SKonstantin Belousov * 2. Redistributions in binary form must reproduce the above copyright 24*9a527560SKonstantin Belousov * notice, this list of conditions and the following disclaimer in the 25*9a527560SKonstantin Belousov * documentation and/or other materials provided with the distribution. 26*9a527560SKonstantin Belousov * 3. Neither the name of the University nor the names of its contributors 27*9a527560SKonstantin Belousov * may be used to endorse or promote products derived from this software 28*9a527560SKonstantin Belousov * without specific prior written permission. 29*9a527560SKonstantin Belousov * 30*9a527560SKonstantin Belousov * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 31*9a527560SKonstantin Belousov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32*9a527560SKonstantin Belousov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33*9a527560SKonstantin Belousov * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 34*9a527560SKonstantin Belousov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35*9a527560SKonstantin Belousov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36*9a527560SKonstantin Belousov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37*9a527560SKonstantin Belousov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38*9a527560SKonstantin Belousov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39*9a527560SKonstantin Belousov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40*9a527560SKonstantin Belousov * SUCH DAMAGE. 41*9a527560SKonstantin Belousov * 42*9a527560SKonstantin Belousov * Derived from hp300 version by Mike Hibler, this version by William 43*9a527560SKonstantin Belousov * Jolitz uses a recursive map [a pde points to the page directory] to 44*9a527560SKonstantin Belousov * map the page tables using the pagetables themselves. This is done to 45*9a527560SKonstantin Belousov * reduce the impact on kernel virtual memory for lots of sparse address 46*9a527560SKonstantin Belousov * space, and to reduce the cost of memory to each process. 47*9a527560SKonstantin Belousov * 48*9a527560SKonstantin Belousov * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 49*9a527560SKonstantin Belousov * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 50*9a527560SKonstantin Belousov * $FreeBSD$ 51*9a527560SKonstantin Belousov */ 52*9a527560SKonstantin Belousov 53*9a527560SKonstantin Belousov #ifndef _MACHINE_PMAP_NOPAE_H 54*9a527560SKonstantin Belousov #define _MACHINE_PMAP_NOPAE_H 55*9a527560SKonstantin Belousov 56*9a527560SKonstantin Belousov #define NTRPPTD 1 57*9a527560SKonstantin Belousov #define LOWPTDI 1 58*9a527560SKonstantin Belousov #define KERNPTDI 2 59*9a527560SKonstantin Belousov 60*9a527560SKonstantin Belousov #define NPGPTD 1 61*9a527560SKonstantin Belousov #define NPGPTD_SHIFT 10 62*9a527560SKonstantin Belousov #undef PDRSHIFT 63*9a527560SKonstantin Belousov #define PDRSHIFT PDRSHIFT_NOPAE 64*9a527560SKonstantin Belousov #undef NBPDR 65*9a527560SKonstantin Belousov #define NBPDR (1 << PDRSHIFT_NOPAE) /* bytes/page dir */ 66*9a527560SKonstantin Belousov 67*9a527560SKonstantin Belousov #define PG_FRAME PG_FRAME_NOPAE 68*9a527560SKonstantin Belousov #define PG_PS_FRAME PG_PS_FRAME_NOPAE 69*9a527560SKonstantin Belousov 70*9a527560SKonstantin Belousov #define KVA_PAGES (256*4) 71*9a527560SKonstantin Belousov 72*9a527560SKonstantin Belousov #ifndef NKPT 73*9a527560SKonstantin Belousov #define NKPT 30 74*9a527560SKonstantin Belousov #endif 75*9a527560SKonstantin Belousov 76*9a527560SKonstantin Belousov typedef uint32_t pd_entry_t; 77*9a527560SKonstantin Belousov typedef uint32_t pt_entry_t; 78*9a527560SKonstantin Belousov typedef uint32_t pdpt_entry_t; /* Only to keep struct pmap layout. */ 79*9a527560SKonstantin Belousov 80*9a527560SKonstantin Belousov #define PTESHIFT (2) 81*9a527560SKonstantin Belousov #define PDESHIFT (2) 82*9a527560SKonstantin Belousov 83*9a527560SKonstantin Belousov #define pde_cmpset(pdep, old, new) atomic_cmpset_int(pdep, old, new) 84*9a527560SKonstantin Belousov #define pte_load_store(ptep, pte) atomic_swap_int(ptep, pte) 85*9a527560SKonstantin Belousov #define pte_load_clear(ptep) atomic_swap_int(ptep, 0) 86*9a527560SKonstantin Belousov #define pte_store(ptep, pte) do { \ 87*9a527560SKonstantin Belousov *(u_int *)(ptep) = (u_int)(pte); \ 88*9a527560SKonstantin Belousov } while (0) 89*9a527560SKonstantin Belousov #define pte_load(ptep) atomic_load_int(ptep) 90*9a527560SKonstantin Belousov 91*9a527560SKonstantin Belousov extern pt_entry_t PTmap[]; 92*9a527560SKonstantin Belousov extern pd_entry_t PTD[]; 93*9a527560SKonstantin Belousov extern pd_entry_t PTDpde[]; 94*9a527560SKonstantin Belousov extern pd_entry_t *IdlePTD_nopae; 95*9a527560SKonstantin Belousov extern pt_entry_t *KPTmap_nopae; 96*9a527560SKonstantin Belousov 97*9a527560SKonstantin Belousov struct pmap; 98*9a527560SKonstantin Belousov pt_entry_t *__CONCAT(PMTYPE, pmap_pte)(struct pmap *, vm_offset_t) __pure2; 99*9a527560SKonstantin Belousov 100*9a527560SKonstantin Belousov #endif 101