xref: /freebsd/sys/i386/include/pmap_base.h (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
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  * $FreeBSD$
31  */
32 
33 #ifndef _MACHINE_PMAP_BASE_H_
34 #define	_MACHINE_PMAP_BASE_H_
35 
36 /* Internal flags for pmap_mapdev_attr(). */
37 #define	MAPDEV_SETATTR		0x0000001	/* Modify existing attrs. */
38 
39 struct pmap_methods {
40 	void (*pm_ksetrw)(vm_offset_t);
41 	void (*pm_remap_lower)(bool);
42 	void (*pm_remap_lowptdi)(bool);
43 	void (*pm_align_superpage)(vm_object_t object, vm_ooffset_t offset,
44 	    vm_offset_t *addr, vm_size_t size);
45 	vm_offset_t (*pm_quick_enter_page)(vm_page_t m);
46 	void (*pm_quick_remove_page)(vm_offset_t addr);
47 	void *(*pm_trm_alloc)(size_t size, int flags);
48 	void (*pm_trm_free)(void *addr, size_t size);
49 	vm_offset_t (*pm_get_map_low)(void);
50 	vm_offset_t (*pm_get_vm_maxuser_address)(void);
51 	vm_paddr_t (*pm_kextract)(vm_offset_t va);
52 	vm_paddr_t (*pm_pg_frame)(vm_paddr_t pa);
53 	void (*pm_sf_buf_map)(struct sf_buf *sf);
54 	void (*pm_cp_slow0_map)(vm_offset_t kaddr, int plen, vm_page_t *ma);
55 	u_int (*pm_get_kcr3)(void);
56 	u_int (*pm_get_cr3)(pmap_t);
57 	caddr_t (*pm_cmap3)(vm_paddr_t pa, u_int pte_flags);
58 	void (*pm_basemem_setup)(u_int basemem);
59 	void (*pm_set_nx)(void);
60 	void *(*pm_bios16_enter)(void);
61 	void (*pm_bios16_leave)(void *handle);
62 	void (*pm_bootstrap)(vm_paddr_t firstaddr);
63 	boolean_t (*pm_is_valid_memattr)(pmap_t, vm_memattr_t);
64 	int (*pm_cache_bits)(pmap_t, int, boolean_t);
65 	bool (*pm_ps_enabled)(pmap_t);
66 	void (*pm_pinit0)(pmap_t);
67 	int (*pm_pinit)(pmap_t);
68 	void (*pm_activate)(struct thread *);
69 	void (*pm_activate_boot)(pmap_t);
70 	void (*pm_advise)(pmap_t, vm_offset_t, vm_offset_t, int);
71 	void (*pm_clear_modify)(vm_page_t);
72 	int (*pm_change_attr)(vm_offset_t, vm_size_t, int);
73 	int (*pm_mincore)(pmap_t, vm_offset_t, vm_paddr_t *);
74 	void (*pm_copy)(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t);
75 	void (*pm_copy_page)(vm_page_t, vm_page_t);
76 	void (*pm_copy_pages)(vm_page_t [], vm_offset_t, vm_page_t [],
77 	    vm_offset_t, int);
78 	void (*pm_zero_page)(vm_page_t);
79 	void (*pm_zero_page_area)(vm_page_t, int, int);
80 	int (*pm_enter)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t, u_int,
81 	    int8_t);
82 	void (*pm_enter_object)(pmap_t, vm_offset_t, vm_offset_t,
83 	    vm_page_t, vm_prot_t);
84 	void (*pm_enter_quick)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t);
85 	void *(*pm_kenter_temporary)(vm_paddr_t pa, int);
86 	void (*pm_object_init_pt)(pmap_t, vm_offset_t, vm_object_t,
87 	    vm_pindex_t, vm_size_t);
88 	void (*pm_unwire)(pmap_t, vm_offset_t, vm_offset_t);
89 	boolean_t (*pm_page_exists_quick)(pmap_t, vm_page_t);
90 	int (*pm_page_wired_mappings)(vm_page_t);
91 	boolean_t (*pm_page_is_mapped)(vm_page_t);
92 	void (*pm_remove_pages)(pmap_t);
93 	boolean_t (*pm_is_modified)(vm_page_t);
94 	boolean_t (*pm_is_prefaultable)(pmap_t, vm_offset_t);
95 	boolean_t (*pm_is_referenced)(vm_page_t);
96 	void (*pm_remove_write)(vm_page_t);
97 	int (*pm_ts_referenced)(vm_page_t);
98 	void *(*pm_mapdev_attr)(vm_paddr_t, vm_size_t, int, int);
99 	void (*pm_unmapdev)(void *, vm_size_t);
100 	void (*pm_page_set_memattr)(vm_page_t, vm_memattr_t);
101 	vm_paddr_t (*pm_extract)(pmap_t, vm_offset_t);
102 	vm_page_t (*pm_extract_and_hold)(pmap_t, vm_offset_t, vm_prot_t);
103 	vm_offset_t (*pm_map)(vm_offset_t *, vm_paddr_t, vm_paddr_t, int);
104 	void (*pm_qenter)(vm_offset_t sva, vm_page_t *, int);
105 	void (*pm_qremove)(vm_offset_t, int);
106 	void (*pm_release)(pmap_t);
107 	void (*pm_protect)(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t);
108 	void (*pm_remove)(pmap_t, vm_offset_t, vm_offset_t);
109 	void (*pm_remove_all)(vm_page_t);
110 	void (*pm_init)(void);
111 	void (*pm_init_pat)(void);
112 	void (*pm_growkernel)(vm_offset_t);
113 	void (*pm_invalidate_page)(pmap_t, vm_offset_t);
114 	void (*pm_invalidate_range)(pmap_t, vm_offset_t, vm_offset_t);
115 	void (*pm_invalidate_all)(pmap_t);
116 	void (*pm_invalidate_cache)(void);
117 	void (*pm_flush_page)(vm_page_t);
118 	void (*pm_kenter)(vm_offset_t, vm_paddr_t);
119 	void (*pm_kremove)(vm_offset_t);
120 	int (*pm_sysctl_kmaps)(SYSCTL_HANDLER_ARGS);
121 };
122 
123 void	pmap_cold(void);
124 void	pmap_pae_cold(void);
125 void	pmap_nopae_cold(void);
126 
127 #endif
128