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