19a527560SKonstantin Belousov /*- 29a527560SKonstantin Belousov * SPDX-License-Identifier: BSD-3-Clause 39a527560SKonstantin Belousov * 49a527560SKonstantin Belousov * Copyright (c) 1991 Regents of the University of California. 59a527560SKonstantin Belousov * All rights reserved. 69a527560SKonstantin Belousov * 79a527560SKonstantin Belousov * Copyright (c) 2018 The FreeBSD Foundation 89a527560SKonstantin Belousov * All rights reserved. 99a527560SKonstantin Belousov * 109a527560SKonstantin Belousov * This code is derived from software contributed to Berkeley by 119a527560SKonstantin Belousov * the Systems Programming Group of the University of Utah Computer 129a527560SKonstantin Belousov * Science Department and William Jolitz of UUNET Technologies Inc. 139a527560SKonstantin Belousov * 149a527560SKonstantin Belousov * Portions of this software were developed by 159a527560SKonstantin Belousov * Konstantin Belousov <kib@FreeBSD.org> under sponsorship from 169a527560SKonstantin Belousov * the FreeBSD Foundation. 179a527560SKonstantin Belousov * 189a527560SKonstantin Belousov * Redistribution and use in source and binary forms, with or without 199a527560SKonstantin Belousov * modification, are permitted provided that the following conditions 209a527560SKonstantin Belousov * are met: 219a527560SKonstantin Belousov * 1. Redistributions of source code must retain the above copyright 229a527560SKonstantin Belousov * notice, this list of conditions and the following disclaimer. 239a527560SKonstantin Belousov * 2. Redistributions in binary form must reproduce the above copyright 249a527560SKonstantin Belousov * notice, this list of conditions and the following disclaimer in the 259a527560SKonstantin Belousov * documentation and/or other materials provided with the distribution. 269a527560SKonstantin Belousov * 3. Neither the name of the University nor the names of its contributors 279a527560SKonstantin Belousov * may be used to endorse or promote products derived from this software 289a527560SKonstantin Belousov * without specific prior written permission. 299a527560SKonstantin Belousov * 309a527560SKonstantin Belousov * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 319a527560SKonstantin Belousov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 329a527560SKonstantin Belousov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 339a527560SKonstantin Belousov * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 349a527560SKonstantin Belousov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 359a527560SKonstantin Belousov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 369a527560SKonstantin Belousov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 379a527560SKonstantin Belousov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 389a527560SKonstantin Belousov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 399a527560SKonstantin Belousov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 409a527560SKonstantin Belousov * SUCH DAMAGE. 419a527560SKonstantin Belousov * 429a527560SKonstantin Belousov * Derived from hp300 version by Mike Hibler, this version by William 439a527560SKonstantin Belousov * Jolitz uses a recursive map [a pde points to the page directory] to 449a527560SKonstantin Belousov * map the page tables using the pagetables themselves. This is done to 459a527560SKonstantin Belousov * reduce the impact on kernel virtual memory for lots of sparse address 469a527560SKonstantin Belousov * space, and to reduce the cost of memory to each process. 479a527560SKonstantin Belousov */ 489a527560SKonstantin Belousov 499a527560SKonstantin Belousov #ifndef _MACHINE_PMAP_NOPAE_H 509a527560SKonstantin Belousov #define _MACHINE_PMAP_NOPAE_H 519a527560SKonstantin Belousov 529a527560SKonstantin Belousov #define NTRPPTD 1 539a527560SKonstantin Belousov #define LOWPTDI 1 549a527560SKonstantin Belousov #define KERNPTDI 2 559a527560SKonstantin Belousov 569a527560SKonstantin Belousov #define NPGPTD 1 579a527560SKonstantin Belousov #define NPGPTD_SHIFT 10 589a527560SKonstantin Belousov #undef PDRSHIFT 599a527560SKonstantin Belousov #define PDRSHIFT PDRSHIFT_NOPAE 609a527560SKonstantin Belousov #undef NBPDR 619a527560SKonstantin Belousov #define NBPDR (1 << PDRSHIFT_NOPAE) /* bytes/page dir */ 629a527560SKonstantin Belousov 639a527560SKonstantin Belousov #define PG_FRAME PG_FRAME_NOPAE 649a527560SKonstantin Belousov #define PG_PS_FRAME PG_PS_FRAME_NOPAE 659a527560SKonstantin Belousov 669a527560SKonstantin Belousov #define KVA_PAGES (256*4) 679a527560SKonstantin Belousov 689a527560SKonstantin Belousov #ifndef NKPT 699a527560SKonstantin Belousov #define NKPT 30 709a527560SKonstantin Belousov #endif 719a527560SKonstantin Belousov 729a527560SKonstantin Belousov typedef uint32_t pd_entry_t; 739a527560SKonstantin Belousov typedef uint32_t pt_entry_t; 749a527560SKonstantin Belousov typedef uint32_t pdpt_entry_t; /* Only to keep struct pmap layout. */ 759a527560SKonstantin Belousov 769a527560SKonstantin Belousov #define PTESHIFT (2) 779a527560SKonstantin Belousov #define PDESHIFT (2) 789a527560SKonstantin Belousov 799a527560SKonstantin Belousov #define pde_cmpset(pdep, old, new) atomic_cmpset_int(pdep, old, new) 809a527560SKonstantin Belousov #define pte_load_store(ptep, pte) atomic_swap_int(ptep, pte) 819a527560SKonstantin Belousov #define pte_load_clear(ptep) atomic_swap_int(ptep, 0) 829a527560SKonstantin Belousov #define pte_store(ptep, pte) do { \ 839a527560SKonstantin Belousov *(u_int *)(ptep) = (u_int)(pte); \ 849a527560SKonstantin Belousov } while (0) 85*d5f2c1e4SKonstantin Belousov #define pte_store_zero(ptep, pte) pte_store(ptep, pte) 869a527560SKonstantin Belousov #define pte_load(ptep) atomic_load_int(ptep) 879a527560SKonstantin Belousov 889a527560SKonstantin Belousov extern pt_entry_t PTmap[]; 899a527560SKonstantin Belousov extern pd_entry_t PTD[]; 909a527560SKonstantin Belousov extern pd_entry_t PTDpde[]; 919a527560SKonstantin Belousov extern pd_entry_t *IdlePTD_nopae; 929a527560SKonstantin Belousov extern pt_entry_t *KPTmap_nopae; 939a527560SKonstantin Belousov 949a527560SKonstantin Belousov struct pmap; 959a527560SKonstantin Belousov pt_entry_t *__CONCAT(PMTYPE, pmap_pte)(struct pmap *, vm_offset_t) __pure2; 969a527560SKonstantin Belousov 979a527560SKonstantin Belousov #endif 98