1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2018 The FreeBSD Foundation 5 * 6 * This software was developed by Konstantin Belousov <kib@FreeBSD.org> 7 * under sponsorship from the FreeBSD Foundation. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #ifndef _MACHINE_PMAP_BASE_H_ 32 #define _MACHINE_PMAP_BASE_H_ 33 34 /* Internal flags for pmap_mapdev_attr(). */ 35 #define MAPDEV_SETATTR 0x0000001 /* Modify existing attrs. */ 36 37 struct pmap_methods { 38 void (*pm_ksetrw)(vm_offset_t); 39 void (*pm_remap_lower)(bool); 40 void (*pm_remap_lowptdi)(bool); 41 void (*pm_align_superpage)(vm_object_t object, vm_ooffset_t offset, 42 vm_offset_t *addr, vm_size_t size); 43 vm_offset_t (*pm_quick_enter_page)(vm_page_t m); 44 void (*pm_quick_remove_page)(vm_offset_t addr); 45 void *(*pm_trm_alloc)(size_t size, int flags); 46 void (*pm_trm_free)(void *addr, size_t size); 47 vm_offset_t (*pm_get_map_low)(void); 48 vm_offset_t (*pm_get_vm_maxuser_address)(void); 49 vm_paddr_t (*pm_kextract)(vm_offset_t va); 50 vm_paddr_t (*pm_pg_frame)(vm_paddr_t pa); 51 void (*pm_sf_buf_map)(struct sf_buf *sf); 52 void (*pm_cp_slow0_map)(vm_offset_t kaddr, int plen, vm_page_t *ma); 53 u_int (*pm_get_kcr3)(void); 54 u_int (*pm_get_cr3)(pmap_t); 55 caddr_t (*pm_cmap3)(vm_paddr_t pa, u_int pte_flags); 56 void (*pm_basemem_setup)(u_int basemem); 57 void (*pm_set_nx)(void); 58 void *(*pm_bios16_enter)(void); 59 void (*pm_bios16_leave)(void *handle); 60 void (*pm_bootstrap)(vm_paddr_t firstaddr); 61 bool (*pm_is_valid_memattr)(pmap_t, vm_memattr_t); 62 int (*pm_cache_bits)(pmap_t, int, bool); 63 bool (*pm_ps_enabled)(pmap_t); 64 void (*pm_pinit0)(pmap_t); 65 int (*pm_pinit)(pmap_t); 66 void (*pm_activate)(struct thread *); 67 void (*pm_activate_boot)(pmap_t); 68 void (*pm_advise)(pmap_t, vm_offset_t, vm_offset_t, int); 69 void (*pm_clear_modify)(vm_page_t); 70 int (*pm_change_attr)(vm_offset_t, vm_size_t, int); 71 int (*pm_mincore)(pmap_t, vm_offset_t, vm_paddr_t *); 72 void (*pm_copy)(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t); 73 void (*pm_copy_page)(vm_page_t, vm_page_t); 74 void (*pm_copy_pages)(vm_page_t [], vm_offset_t, vm_page_t [], 75 vm_offset_t, int); 76 void (*pm_zero_page)(vm_page_t); 77 void (*pm_zero_page_area)(vm_page_t, int, int); 78 int (*pm_enter)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t, u_int, 79 int8_t); 80 void (*pm_enter_object)(pmap_t, vm_offset_t, vm_offset_t, 81 vm_page_t, vm_prot_t); 82 void (*pm_enter_quick)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t); 83 void *(*pm_kenter_temporary)(vm_paddr_t pa, int); 84 void (*pm_object_init_pt)(pmap_t, vm_offset_t, vm_object_t, 85 vm_pindex_t, vm_size_t); 86 void (*pm_unwire)(pmap_t, vm_offset_t, vm_offset_t); 87 bool (*pm_page_exists_quick)(pmap_t, vm_page_t); 88 int (*pm_page_wired_mappings)(vm_page_t); 89 bool (*pm_page_is_mapped)(vm_page_t); 90 void (*pm_remove_pages)(pmap_t); 91 bool (*pm_is_modified)(vm_page_t); 92 bool (*pm_is_prefaultable)(pmap_t, vm_offset_t); 93 bool (*pm_is_referenced)(vm_page_t); 94 void (*pm_remove_write)(vm_page_t); 95 int (*pm_ts_referenced)(vm_page_t); 96 void *(*pm_mapdev_attr)(vm_paddr_t, vm_size_t, int, int); 97 void (*pm_unmapdev)(void *, vm_size_t); 98 void (*pm_page_set_memattr)(vm_page_t, vm_memattr_t); 99 vm_paddr_t (*pm_extract)(pmap_t, vm_offset_t); 100 vm_page_t (*pm_extract_and_hold)(pmap_t, vm_offset_t, vm_prot_t); 101 vm_offset_t (*pm_map)(vm_offset_t *, vm_paddr_t, vm_paddr_t, int); 102 void (*pm_qenter)(vm_offset_t sva, vm_page_t *, int); 103 void (*pm_qremove)(vm_offset_t, int); 104 void (*pm_release)(pmap_t); 105 void (*pm_protect)(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t); 106 void (*pm_remove)(pmap_t, vm_offset_t, vm_offset_t); 107 void (*pm_remove_all)(vm_page_t); 108 void (*pm_init)(void); 109 void (*pm_init_pat)(void); 110 void (*pm_growkernel)(vm_offset_t); 111 void (*pm_invalidate_page)(pmap_t, vm_offset_t); 112 void (*pm_invalidate_range)(pmap_t, vm_offset_t, vm_offset_t); 113 void (*pm_invalidate_all)(pmap_t); 114 void (*pm_invalidate_cache)(void); 115 void (*pm_flush_page)(vm_page_t); 116 void (*pm_kenter)(vm_offset_t, vm_paddr_t); 117 void (*pm_kremove)(vm_offset_t); 118 int (*pm_sysctl_kmaps)(SYSCTL_HANDLER_ARGS); 119 }; 120 121 void pmap_cold(void); 122 void pmap_pae_cold(void); 123 void pmap_nopae_cold(void); 124 125 #endif 126