xref: /illumos-gate/usr/src/uts/common/vm/hat.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
32*7c478bd9Sstevel@tonic-gate  * The Regents of the University of California
33*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
36*7c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
37*7c478bd9Sstevel@tonic-gate  * contributors.
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifndef	_VM_HAT_H
41*7c478bd9Sstevel@tonic-gate #define	_VM_HAT_H
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
46*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
47*7c478bd9Sstevel@tonic-gate #include <vm/faultcode.h>
48*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
49*7c478bd9Sstevel@tonic-gate #include <sys/siginfo.h>
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
52*7c478bd9Sstevel@tonic-gate extern "C" {
53*7c478bd9Sstevel@tonic-gate #endif
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate /*
56*7c478bd9Sstevel@tonic-gate  * VM - Hardware Address Translation management.
57*7c478bd9Sstevel@tonic-gate  *
58*7c478bd9Sstevel@tonic-gate  * This file describes the machine independent interfaces to
59*7c478bd9Sstevel@tonic-gate  * the hardware address translation management routines.  Other
60*7c478bd9Sstevel@tonic-gate  * machine specific interfaces and structures are defined
61*7c478bd9Sstevel@tonic-gate  * in <vm/hat_xxx.h>.  The hat layer manages the address
62*7c478bd9Sstevel@tonic-gate  * translation hardware as a cache driven by calls from the
63*7c478bd9Sstevel@tonic-gate  * higher levels of the VM system.
64*7c478bd9Sstevel@tonic-gate  */
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate struct hat;
67*7c478bd9Sstevel@tonic-gate struct kpme;
68*7c478bd9Sstevel@tonic-gate struct memseg;
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate #include <vm/page.h>
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate  * a callback used with hat_unload_callback()
74*7c478bd9Sstevel@tonic-gate  * start and end mark are set to a range of unloaded addresses
75*7c478bd9Sstevel@tonic-gate  * and the function is invoked with a pointer to this data structure
76*7c478bd9Sstevel@tonic-gate  */
77*7c478bd9Sstevel@tonic-gate typedef struct hat_callback {
78*7c478bd9Sstevel@tonic-gate 	caddr_t	hcb_start_addr;
79*7c478bd9Sstevel@tonic-gate 	caddr_t hcb_end_addr;
80*7c478bd9Sstevel@tonic-gate 	void	(*hcb_function)(struct hat_callback *);
81*7c478bd9Sstevel@tonic-gate 	void	*hcb_data;
82*7c478bd9Sstevel@tonic-gate } hat_callback_t;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate /*
87*7c478bd9Sstevel@tonic-gate  * One time hat initialization
88*7c478bd9Sstevel@tonic-gate  */
89*7c478bd9Sstevel@tonic-gate void	hat_init(void);
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate /*
92*7c478bd9Sstevel@tonic-gate  * Notify hat of a system dump
93*7c478bd9Sstevel@tonic-gate  */
94*7c478bd9Sstevel@tonic-gate void	hat_dump(void);
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate /*
97*7c478bd9Sstevel@tonic-gate  * Operations on an address space:
98*7c478bd9Sstevel@tonic-gate  *
99*7c478bd9Sstevel@tonic-gate  * struct hat *hat_alloc(as)
100*7c478bd9Sstevel@tonic-gate  *	allocated a hat structure for as.
101*7c478bd9Sstevel@tonic-gate  *
102*7c478bd9Sstevel@tonic-gate  * void hat_free_start(hat)
103*7c478bd9Sstevel@tonic-gate  *	informs hat layer process has finished executing but as has not
104*7c478bd9Sstevel@tonic-gate  *	been cleaned up yet.
105*7c478bd9Sstevel@tonic-gate  *
106*7c478bd9Sstevel@tonic-gate  * void hat_free_end(hat)
107*7c478bd9Sstevel@tonic-gate  *	informs hat layer as is being destroyed.  hat layer cannot use as
108*7c478bd9Sstevel@tonic-gate  *	pointer after this call.
109*7c478bd9Sstevel@tonic-gate  *
110*7c478bd9Sstevel@tonic-gate  * void hat_swapin(hat)
111*7c478bd9Sstevel@tonic-gate  *	allocate any hat resources required for process being swapped in.
112*7c478bd9Sstevel@tonic-gate  *
113*7c478bd9Sstevel@tonic-gate  * void hat_swapout(hat)
114*7c478bd9Sstevel@tonic-gate  *	deallocate hat resources for process being swapped out.
115*7c478bd9Sstevel@tonic-gate  *
116*7c478bd9Sstevel@tonic-gate  * size_t hat_get_mapped_size(hat)
117*7c478bd9Sstevel@tonic-gate  *	returns number of bytes that have valid mappings in hat.
118*7c478bd9Sstevel@tonic-gate  *
119*7c478bd9Sstevel@tonic-gate  * void hat_stats_enable(hat)
120*7c478bd9Sstevel@tonic-gate  * void hat_stats_disable(hat)
121*7c478bd9Sstevel@tonic-gate  *	enables/disables collection of stats for hat.
122*7c478bd9Sstevel@tonic-gate  *
123*7c478bd9Sstevel@tonic-gate  * int hat_dup(parenthat, childhat, addr, len, flags)
124*7c478bd9Sstevel@tonic-gate  *	Duplicate address translations of the parent to the child.  Supports
125*7c478bd9Sstevel@tonic-gate  *	the entire address range or a range depending on flag,
126*7c478bd9Sstevel@tonic-gate  *	zero returned on success, non-zero on error
127*7c478bd9Sstevel@tonic-gate  *
128*7c478bd9Sstevel@tonic-gate  * void hat_thread_exit(thread)
129*7c478bd9Sstevel@tonic-gate  *	Notifies the HAT that a thread is exiting, called after it has been
130*7c478bd9Sstevel@tonic-gate  *	reassigned to the kernel AS.
131*7c478bd9Sstevel@tonic-gate  */
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate struct hat *hat_alloc(struct as *);
134*7c478bd9Sstevel@tonic-gate void	hat_free_start(struct hat *);
135*7c478bd9Sstevel@tonic-gate void	hat_free_end(struct hat *);
136*7c478bd9Sstevel@tonic-gate int	hat_dup(struct hat *, struct hat *, caddr_t, size_t, uint_t);
137*7c478bd9Sstevel@tonic-gate void	hat_swapin(struct hat *);
138*7c478bd9Sstevel@tonic-gate void	hat_swapout(struct hat *);
139*7c478bd9Sstevel@tonic-gate size_t	hat_get_mapped_size(struct hat *);
140*7c478bd9Sstevel@tonic-gate int	hat_stats_enable(struct hat *);
141*7c478bd9Sstevel@tonic-gate void	hat_stats_disable(struct hat *);
142*7c478bd9Sstevel@tonic-gate void	hat_thread_exit(kthread_t *);
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate  * Operations on a named address within a segment:
146*7c478bd9Sstevel@tonic-gate  *
147*7c478bd9Sstevel@tonic-gate  * void hat_memload(hat, addr, pp, attr, flags)
148*7c478bd9Sstevel@tonic-gate  *	load/lock the given page struct
149*7c478bd9Sstevel@tonic-gate  *
150*7c478bd9Sstevel@tonic-gate  * void hat_memload_array(hat, addr, len, ppa, attr, flags)
151*7c478bd9Sstevel@tonic-gate  *	load/lock the given array of page structs
152*7c478bd9Sstevel@tonic-gate  *
153*7c478bd9Sstevel@tonic-gate  * void hat_devload(hat, addr, len, pf, attr, flags)
154*7c478bd9Sstevel@tonic-gate  *	load/lock the given page frame number
155*7c478bd9Sstevel@tonic-gate  *
156*7c478bd9Sstevel@tonic-gate  * void hat_unlock(hat, addr, len)
157*7c478bd9Sstevel@tonic-gate  *	unlock a given range of addresses
158*7c478bd9Sstevel@tonic-gate  *
159*7c478bd9Sstevel@tonic-gate  * void hat_unload(hat, addr, len, flags)
160*7c478bd9Sstevel@tonic-gate  * void hat_unload_callback(hat, addr, len, flags, callback)
161*7c478bd9Sstevel@tonic-gate  *	unload a given range of addresses (has optional callback)
162*7c478bd9Sstevel@tonic-gate  *
163*7c478bd9Sstevel@tonic-gate  * void hat_sync(hat, addr, len, flags)
164*7c478bd9Sstevel@tonic-gate  *	synchronize mapping with software data structures
165*7c478bd9Sstevel@tonic-gate  *
166*7c478bd9Sstevel@tonic-gate  * void	hat_map(hat, addr, len, flags)
167*7c478bd9Sstevel@tonic-gate  *
168*7c478bd9Sstevel@tonic-gate  * void hat_setattr(hat, addr, len, attr)
169*7c478bd9Sstevel@tonic-gate  * void hat_clrattr(hat, addr, len, attr)
170*7c478bd9Sstevel@tonic-gate  * void hat_chgattr(hat, addr, len, attr)
171*7c478bd9Sstevel@tonic-gate  *	modify attributes for a range of addresses. skips any invalid mappings
172*7c478bd9Sstevel@tonic-gate  *
173*7c478bd9Sstevel@tonic-gate  * uint_t hat_getattr(hat, addr, *attr)
174*7c478bd9Sstevel@tonic-gate  *	returns attr for <hat,addr> in *attr.  returns 0 if there was a
175*7c478bd9Sstevel@tonic-gate  *	mapping and *attr is valid, nonzero if there was no mapping and
176*7c478bd9Sstevel@tonic-gate  *	*attr is not valid.
177*7c478bd9Sstevel@tonic-gate  *
178*7c478bd9Sstevel@tonic-gate  * size_t hat_getpagesize(hat, addr)
179*7c478bd9Sstevel@tonic-gate  *	returns pagesize in bytes for <hat, addr>. returns -1 if there is
180*7c478bd9Sstevel@tonic-gate  *	no mapping. This is an advisory call.
181*7c478bd9Sstevel@tonic-gate  *
182*7c478bd9Sstevel@tonic-gate  * pfn_t hat_getpfnum(hat, addr)
183*7c478bd9Sstevel@tonic-gate  *	returns pfn for <hat, addr> or PFN_INVALID if mapping is invalid.
184*7c478bd9Sstevel@tonic-gate  *
185*7c478bd9Sstevel@tonic-gate  * pfn_t hat_getkpfnum(addr)
186*7c478bd9Sstevel@tonic-gate  *	returns pfn for non-memory mapped addr in kernel address space
187*7c478bd9Sstevel@tonic-gate  *	or PFN_INVALID if mapping is invalid or is kernel memory.
188*7c478bd9Sstevel@tonic-gate  *
189*7c478bd9Sstevel@tonic-gate  * int hat_probe(hat, addr)
190*7c478bd9Sstevel@tonic-gate  *	return 0 if no valid mapping is present.  Faster version
191*7c478bd9Sstevel@tonic-gate  *	of hat_getattr in certain architectures.
192*7c478bd9Sstevel@tonic-gate  *
193*7c478bd9Sstevel@tonic-gate  * int hat_share(dhat, daddr, shat, saddr, len, szc)
194*7c478bd9Sstevel@tonic-gate  *
195*7c478bd9Sstevel@tonic-gate  * void hat_unshare(hat, addr, len, szc)
196*7c478bd9Sstevel@tonic-gate  *
197*7c478bd9Sstevel@tonic-gate  * void hat_chgprot(hat, addr, len, vprot)
198*7c478bd9Sstevel@tonic-gate  *	This is a deprecated call.  New segment drivers should store
199*7c478bd9Sstevel@tonic-gate  *	all attributes and use hat_*attr calls.
200*7c478bd9Sstevel@tonic-gate  *	Change the protections in the virtual address range
201*7c478bd9Sstevel@tonic-gate  *	given to the specified virtual protection.  If vprot is ~PROT_WRITE,
202*7c478bd9Sstevel@tonic-gate  *	then remove write permission, leaving the other permissions
203*7c478bd9Sstevel@tonic-gate  *	unchanged.  If vprot is ~PROT_USER, remove user permissions.
204*7c478bd9Sstevel@tonic-gate  */
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate void	hat_memload(struct hat *, caddr_t, struct page *, uint_t, uint_t);
207*7c478bd9Sstevel@tonic-gate void	hat_memload_array(struct hat *, caddr_t, size_t, struct page **,
208*7c478bd9Sstevel@tonic-gate 		uint_t, uint_t);
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate void	hat_devload(struct hat *, caddr_t, size_t, pfn_t, uint_t, int);
211*7c478bd9Sstevel@tonic-gate void	hat_unlock(struct hat *, caddr_t, size_t);
212*7c478bd9Sstevel@tonic-gate void	hat_unload(struct hat *, caddr_t, size_t, uint_t);
213*7c478bd9Sstevel@tonic-gate void	hat_unload_callback(struct hat *, caddr_t, size_t, uint_t,
214*7c478bd9Sstevel@tonic-gate 		hat_callback_t *);
215*7c478bd9Sstevel@tonic-gate void	hat_sync(struct hat *, caddr_t, size_t, uint_t);
216*7c478bd9Sstevel@tonic-gate void	hat_map(struct hat *, caddr_t, size_t, uint_t);
217*7c478bd9Sstevel@tonic-gate void	hat_setattr(struct hat *, caddr_t, size_t, uint_t);
218*7c478bd9Sstevel@tonic-gate void	hat_clrattr(struct hat *, caddr_t, size_t, uint_t);
219*7c478bd9Sstevel@tonic-gate void	hat_chgattr(struct hat *, caddr_t, size_t, uint_t);
220*7c478bd9Sstevel@tonic-gate uint_t	hat_getattr(struct hat *, caddr_t, uint_t *);
221*7c478bd9Sstevel@tonic-gate ssize_t	hat_getpagesize(struct hat *, caddr_t);
222*7c478bd9Sstevel@tonic-gate pfn_t	hat_getpfnum(struct hat *, caddr_t);
223*7c478bd9Sstevel@tonic-gate int	hat_probe(struct hat *, caddr_t);
224*7c478bd9Sstevel@tonic-gate int	hat_share(struct hat *, caddr_t, struct hat *, caddr_t, size_t, uint_t);
225*7c478bd9Sstevel@tonic-gate void	hat_unshare(struct hat *, caddr_t, size_t, uint_t);
226*7c478bd9Sstevel@tonic-gate void	hat_chgprot(struct hat *, caddr_t, size_t, uint_t);
227*7c478bd9Sstevel@tonic-gate void	hat_reserve(struct as *, caddr_t, size_t);
228*7c478bd9Sstevel@tonic-gate pfn_t	va_to_pfn(void *);
229*7c478bd9Sstevel@tonic-gate uint64_t va_to_pa(void *);
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate /*
232*7c478bd9Sstevel@tonic-gate  * hat_getkpfnum() is never supported on amd64 and will be
233*7c478bd9Sstevel@tonic-gate  * removed from other platforms in future release
234*7c478bd9Sstevel@tonic-gate  */
235*7c478bd9Sstevel@tonic-gate #if !defined(__amd64)
236*7c478bd9Sstevel@tonic-gate pfn_t	hat_getkpfnum(caddr_t);
237*7c478bd9Sstevel@tonic-gate #endif
238*7c478bd9Sstevel@tonic-gate 
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /*
241*7c478bd9Sstevel@tonic-gate  * Kernel Physical Mapping (segkpm) hat interface routines.
242*7c478bd9Sstevel@tonic-gate  */
243*7c478bd9Sstevel@tonic-gate caddr_t	hat_kpm_mapin(struct page *, struct kpme *);
244*7c478bd9Sstevel@tonic-gate void	hat_kpm_mapout(struct page *, struct kpme *, caddr_t);
245*7c478bd9Sstevel@tonic-gate caddr_t	hat_kpm_page2va(struct page *, int);
246*7c478bd9Sstevel@tonic-gate struct page *hat_kpm_vaddr2page(caddr_t);
247*7c478bd9Sstevel@tonic-gate int	hat_kpm_fault(struct hat *, caddr_t);
248*7c478bd9Sstevel@tonic-gate void	hat_kpm_mseghash_clear(int);
249*7c478bd9Sstevel@tonic-gate void	hat_kpm_mseghash_update(pgcnt_t, struct memseg *);
250*7c478bd9Sstevel@tonic-gate void	hat_kpm_addmem_mseg_update(struct memseg *, pgcnt_t, offset_t);
251*7c478bd9Sstevel@tonic-gate void	hat_kpm_addmem_mseg_insert(struct memseg *);
252*7c478bd9Sstevel@tonic-gate void	hat_kpm_addmem_memsegs_update(struct memseg *);
253*7c478bd9Sstevel@tonic-gate caddr_t hat_kpm_mseg_reuse(struct memseg *);
254*7c478bd9Sstevel@tonic-gate void	hat_kpm_delmem_mseg_update(struct memseg *, struct memseg **);
255*7c478bd9Sstevel@tonic-gate void	hat_kpm_split_mseg_update(struct memseg *, struct memseg **,
256*7c478bd9Sstevel@tonic-gate 			struct memseg *, struct memseg *, struct memseg *);
257*7c478bd9Sstevel@tonic-gate void	hat_kpm_walk(void (*)(void *, void *, size_t), void *);
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate /*
260*7c478bd9Sstevel@tonic-gate  * Operations on all translations for a given page(s)
261*7c478bd9Sstevel@tonic-gate  *
262*7c478bd9Sstevel@tonic-gate  * void hat_page_setattr(pp, flag)
263*7c478bd9Sstevel@tonic-gate  * void hat_page_clrattr(pp, flag)
264*7c478bd9Sstevel@tonic-gate  *	used to set/clr red/mod bits.
265*7c478bd9Sstevel@tonic-gate  *
266*7c478bd9Sstevel@tonic-gate  * uint hat_page_getattr(pp, flag)
267*7c478bd9Sstevel@tonic-gate  *	If flag is specified, returns 0 if attribute is disabled
268*7c478bd9Sstevel@tonic-gate  *	and non zero if enabled.  If flag specifes multiple attributs
269*7c478bd9Sstevel@tonic-gate  *	then returns 0 if ALL atriibutes are disabled.  This is an advisory
270*7c478bd9Sstevel@tonic-gate  *	call.
271*7c478bd9Sstevel@tonic-gate  *
272*7c478bd9Sstevel@tonic-gate  * int hat_pageunload(pp, forceflag)
273*7c478bd9Sstevel@tonic-gate  *	unload all translations attached to pp.
274*7c478bd9Sstevel@tonic-gate  *
275*7c478bd9Sstevel@tonic-gate  * uint_t hat_pagesync(pp, flags)
276*7c478bd9Sstevel@tonic-gate  *	get hw stats from hardware into page struct and reset hw stats
277*7c478bd9Sstevel@tonic-gate  *	returns attributes of page
278*7c478bd9Sstevel@tonic-gate  *
279*7c478bd9Sstevel@tonic-gate  * ulong_t hat_page_getshare(pp)
280*7c478bd9Sstevel@tonic-gate  *	returns approx number of mappings to this pp.  A return of 0 implies
281*7c478bd9Sstevel@tonic-gate  *	there are no mappings to the page.
282*7c478bd9Sstevel@tonic-gate  *
283*7c478bd9Sstevel@tonic-gate  * faultcode_t hat_softlock(hat, addr, lenp, ppp, flags);
284*7c478bd9Sstevel@tonic-gate  *	called to softlock pages for zero copy tcp
285*7c478bd9Sstevel@tonic-gate  *
286*7c478bd9Sstevel@tonic-gate  * void hat_page_demote(pp);
287*7c478bd9Sstevel@tonic-gate  *	unload all large mappings to pp and decrease p_szc of all
288*7c478bd9Sstevel@tonic-gate  *	constituent pages according to the remaining mappings.
289*7c478bd9Sstevel@tonic-gate  */
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate void	hat_page_setattr(struct page *, uint_t);
292*7c478bd9Sstevel@tonic-gate void	hat_page_clrattr(struct page *, uint_t);
293*7c478bd9Sstevel@tonic-gate uint_t	hat_page_getattr(struct page *, uint_t);
294*7c478bd9Sstevel@tonic-gate int	hat_pageunload(struct page *, uint_t);
295*7c478bd9Sstevel@tonic-gate uint_t	hat_pagesync(struct page *, uint_t);
296*7c478bd9Sstevel@tonic-gate ulong_t	hat_page_getshare(struct page *);
297*7c478bd9Sstevel@tonic-gate faultcode_t hat_softlock(struct hat *, caddr_t, size_t *,
298*7c478bd9Sstevel@tonic-gate 			struct page **, uint_t);
299*7c478bd9Sstevel@tonic-gate void	hat_page_demote(struct page *);
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate /*
302*7c478bd9Sstevel@tonic-gate  * Rountine to expose supported HAT features to PIM.
303*7c478bd9Sstevel@tonic-gate  */
304*7c478bd9Sstevel@tonic-gate enum hat_features {
305*7c478bd9Sstevel@tonic-gate 	HAT_SHARED_PT,		/* Shared page tables */
306*7c478bd9Sstevel@tonic-gate 	HAT_DYNAMIC_ISM_UNMAP,	/* hat_pageunload() handles ISM pages */
307*7c478bd9Sstevel@tonic-gate 	HAT_VMODSORT		/* support for VMODSORT flag of vnode */
308*7c478bd9Sstevel@tonic-gate };
309*7c478bd9Sstevel@tonic-gate 
310*7c478bd9Sstevel@tonic-gate int hat_supported(enum hat_features, void *);
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate /*
313*7c478bd9Sstevel@tonic-gate  * Services provided to the hat:
314*7c478bd9Sstevel@tonic-gate  *
315*7c478bd9Sstevel@tonic-gate  * void as_signal_proc(as, siginfo)
316*7c478bd9Sstevel@tonic-gate  *	deliver signal to all processes that have this as.
317*7c478bd9Sstevel@tonic-gate  *
318*7c478bd9Sstevel@tonic-gate  * int hat_setstat(as, addr, len, rmbits)
319*7c478bd9Sstevel@tonic-gate  *	informs hatstat layer that ref/mod bits need to be updated for
320*7c478bd9Sstevel@tonic-gate  *	address range. Returns 0 on success, 1 for failure.
321*7c478bd9Sstevel@tonic-gate  */
322*7c478bd9Sstevel@tonic-gate void	as_signal_proc(struct as *, k_siginfo_t *siginfo);
323*7c478bd9Sstevel@tonic-gate void	hat_setstat(struct as *, caddr_t, size_t, uint_t);
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate /*
326*7c478bd9Sstevel@tonic-gate  * Flags to pass to hat routines.
327*7c478bd9Sstevel@tonic-gate  *
328*7c478bd9Sstevel@tonic-gate  * Certain flags only apply to some interfaces:
329*7c478bd9Sstevel@tonic-gate  *
330*7c478bd9Sstevel@tonic-gate  * 	HAT_LOAD	Default flags to load a translation to the page.
331*7c478bd9Sstevel@tonic-gate  * 	HAT_LOAD_LOCK	Lock down mapping resources; hat_map(), hat_memload(),
332*7c478bd9Sstevel@tonic-gate  *			and hat_devload().
333*7c478bd9Sstevel@tonic-gate  *	HAT_LOAD_ADV	Advisory load - Load translation if and only if
334*7c478bd9Sstevel@tonic-gate  *			sufficient MMU resources exist (i.e., do not steal).
335*7c478bd9Sstevel@tonic-gate  *	HAT_LOAD_SHARE	A flag to hat_memload() to indicate h/w page tables
336*7c478bd9Sstevel@tonic-gate  *			that map some user pages (not kas) is shared by more
337*7c478bd9Sstevel@tonic-gate  *			than one process (eg. ISM).
338*7c478bd9Sstevel@tonic-gate  *	HAT_LOAD_CONTIG	Pages are contigous
339*7c478bd9Sstevel@tonic-gate  *	HAT_LOAD_NOCONSIST Do not add mapping to mapping list.
340*7c478bd9Sstevel@tonic-gate  *	HAT_LOAD_REMAP	Reload a valid pte with a different page frame.
341*7c478bd9Sstevel@tonic-gate  *	HAT_RELOAD_SHARE Reload a shared page table entry. Some platforms
342*7c478bd9Sstevel@tonic-gate  *			 may require different actions than on the first
343*7c478bd9Sstevel@tonic-gate  *			 load of a shared mapping.
344*7c478bd9Sstevel@tonic-gate  *	HAT_NO_KALLOC	Do not kmem_alloc while creating the mapping; at this
345*7c478bd9Sstevel@tonic-gate  *			point, it's setting up mapping to allocate internal
346*7c478bd9Sstevel@tonic-gate  *			hat layer data structures.  This flag forces hat layer
347*7c478bd9Sstevel@tonic-gate  *			to tap its reserves in order to prevent infinite
348*7c478bd9Sstevel@tonic-gate  *			recursion.
349*7c478bd9Sstevel@tonic-gate  *	HAT_LOAD_AUTOLPG Get MMU specific disable_auto_large_pages
350*7c478bd9Sstevel@tonic-gate  */
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate /*
353*7c478bd9Sstevel@tonic-gate  * Flags for hat_memload/hat_devload
354*7c478bd9Sstevel@tonic-gate  */
355*7c478bd9Sstevel@tonic-gate #define	HAT_FLAGS_RESV		0xFF000000	/* resv for hat impl */
356*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD		0x00
357*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_LOCK		0x01
358*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_ADV		0x04
359*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_CONTIG		0x10
360*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_NOCONSIST	0x20
361*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_SHARE		0x40
362*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_REMAP		0x80
363*7c478bd9Sstevel@tonic-gate #define	HAT_RELOAD_SHARE	0x100
364*7c478bd9Sstevel@tonic-gate #define	HAT_NO_KALLOC		0x200
365*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_TEXT		0x400
366*7c478bd9Sstevel@tonic-gate #define	HAT_LOAD_AUTOLPG	0x800
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate /*
369*7c478bd9Sstevel@tonic-gate  * Attributes for hat_memload/hat_devload/hat_*attr
370*7c478bd9Sstevel@tonic-gate  * are a superset of prot flags defined in mman.h.
371*7c478bd9Sstevel@tonic-gate  */
372*7c478bd9Sstevel@tonic-gate #define	HAT_PLAT_ATTR_MASK	0xF00000
373*7c478bd9Sstevel@tonic-gate #define	HAT_PROT_MASK		0x0F
374*7c478bd9Sstevel@tonic-gate 
375*7c478bd9Sstevel@tonic-gate #define	HAT_NOFAULT		0x10
376*7c478bd9Sstevel@tonic-gate #define	HAT_NOSYNC		0x20
377*7c478bd9Sstevel@tonic-gate 
378*7c478bd9Sstevel@tonic-gate /*
379*7c478bd9Sstevel@tonic-gate  * Advisory ordering attributes. Apply only to device mappings.
380*7c478bd9Sstevel@tonic-gate  *
381*7c478bd9Sstevel@tonic-gate  * HAT_STRICTORDER: the CPU must issue the references in order, as the
382*7c478bd9Sstevel@tonic-gate  *	programmer specified.  This is the default.
383*7c478bd9Sstevel@tonic-gate  * HAT_UNORDERED_OK: the CPU may reorder the references (this is all kinds
384*7c478bd9Sstevel@tonic-gate  *	of reordering; store or load with store or load).
385*7c478bd9Sstevel@tonic-gate  * HAT_MERGING_OK: merging and batching: the CPU may merge individual stores
386*7c478bd9Sstevel@tonic-gate  *	to consecutive locations (for example, turn two consecutive byte
387*7c478bd9Sstevel@tonic-gate  *	stores into one halfword store), and it may batch individual loads
388*7c478bd9Sstevel@tonic-gate  *	(for example, turn two consecutive byte loads into one halfword load).
389*7c478bd9Sstevel@tonic-gate  *	This also implies re-ordering.
390*7c478bd9Sstevel@tonic-gate  * HAT_LOADCACHING_OK: the CPU may cache the data it fetches and reuse it
391*7c478bd9Sstevel@tonic-gate  *	until another store occurs.  The default is to fetch new data
392*7c478bd9Sstevel@tonic-gate  *	on every load.  This also implies merging.
393*7c478bd9Sstevel@tonic-gate  * HAT_STORECACHING_OK: the CPU may keep the data in the cache and push it to
394*7c478bd9Sstevel@tonic-gate  *	the device (perhaps with other data) at a later time.  The default is
395*7c478bd9Sstevel@tonic-gate  *	to push the data right away.  This also implies load caching.
396*7c478bd9Sstevel@tonic-gate  */
397*7c478bd9Sstevel@tonic-gate #define	HAT_STRICTORDER		0x0000
398*7c478bd9Sstevel@tonic-gate #define	HAT_UNORDERED_OK	0x0100
399*7c478bd9Sstevel@tonic-gate #define	HAT_MERGING_OK		0x0200
400*7c478bd9Sstevel@tonic-gate #define	HAT_LOADCACHING_OK	0x0300
401*7c478bd9Sstevel@tonic-gate #define	HAT_STORECACHING_OK	0x0400
402*7c478bd9Sstevel@tonic-gate #define	HAT_ORDER_MASK		0x0700
403*7c478bd9Sstevel@tonic-gate 
404*7c478bd9Sstevel@tonic-gate /* endian attributes */
405*7c478bd9Sstevel@tonic-gate #define	HAT_NEVERSWAP		0x0000
406*7c478bd9Sstevel@tonic-gate #define	HAT_STRUCTURE_BE	0x1000
407*7c478bd9Sstevel@tonic-gate #define	HAT_STRUCTURE_LE	0x2000
408*7c478bd9Sstevel@tonic-gate #define	HAT_ENDIAN_MASK		0x3000
409*7c478bd9Sstevel@tonic-gate 
410*7c478bd9Sstevel@tonic-gate /* flags for hat_softlock */
411*7c478bd9Sstevel@tonic-gate #define	HAT_COW			0x0001
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate /*
414*7c478bd9Sstevel@tonic-gate  * Flags for hat_unload
415*7c478bd9Sstevel@tonic-gate  */
416*7c478bd9Sstevel@tonic-gate #define	HAT_UNLOAD		0x00
417*7c478bd9Sstevel@tonic-gate #define	HAT_UNLOAD_NOSYNC	0x02
418*7c478bd9Sstevel@tonic-gate #define	HAT_UNLOAD_UNLOCK	0x04
419*7c478bd9Sstevel@tonic-gate #define	HAT_UNLOAD_OTHER	0x08
420*7c478bd9Sstevel@tonic-gate #define	HAT_UNLOAD_UNMAP	0x10
421*7c478bd9Sstevel@tonic-gate 
422*7c478bd9Sstevel@tonic-gate /*
423*7c478bd9Sstevel@tonic-gate  * Flags for hat_pagesync, hat_getstat, hat_sync
424*7c478bd9Sstevel@tonic-gate  */
425*7c478bd9Sstevel@tonic-gate #define	HAT_SYNC_DONTZERO	0x00
426*7c478bd9Sstevel@tonic-gate #define	HAT_SYNC_ZERORM		0x01
427*7c478bd9Sstevel@tonic-gate /* Additional flags for hat_pagesync */
428*7c478bd9Sstevel@tonic-gate #define	HAT_SYNC_STOPON_REF	0x02
429*7c478bd9Sstevel@tonic-gate #define	HAT_SYNC_STOPON_MOD	0x04
430*7c478bd9Sstevel@tonic-gate #define	HAT_SYNC_STOPON_RM	(HAT_SYNC_STOPON_REF | HAT_SYNC_STOPON_MOD)
431*7c478bd9Sstevel@tonic-gate #define	HAT_SYNC_STOPON_SHARED	0x08
432*7c478bd9Sstevel@tonic-gate 
433*7c478bd9Sstevel@tonic-gate /*
434*7c478bd9Sstevel@tonic-gate  * Flags for hat_dup
435*7c478bd9Sstevel@tonic-gate  *
436*7c478bd9Sstevel@tonic-gate  * HAT_DUP_ALL dup entire address space
437*7c478bd9Sstevel@tonic-gate  * HAT_DUP_COW dup plus hat_clrattr(..PROT_WRITE) on newas
438*7c478bd9Sstevel@tonic-gate  */
439*7c478bd9Sstevel@tonic-gate #define	HAT_DUP_ALL		1
440*7c478bd9Sstevel@tonic-gate #define	HAT_DUP_COW		2
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate 
443*7c478bd9Sstevel@tonic-gate /*
444*7c478bd9Sstevel@tonic-gate  * Flags for hat_map
445*7c478bd9Sstevel@tonic-gate  */
446*7c478bd9Sstevel@tonic-gate #define	HAT_MAP			0x00
447*7c478bd9Sstevel@tonic-gate 
448*7c478bd9Sstevel@tonic-gate /*
449*7c478bd9Sstevel@tonic-gate  * Flag for hat_pageunload
450*7c478bd9Sstevel@tonic-gate  */
451*7c478bd9Sstevel@tonic-gate #define	HAT_ADV_PGUNLOAD	0x00
452*7c478bd9Sstevel@tonic-gate #define	HAT_FORCE_PGUNLOAD	0x01
453*7c478bd9Sstevel@tonic-gate 
454*7c478bd9Sstevel@tonic-gate /*
455*7c478bd9Sstevel@tonic-gate  * Attributes for hat_page_*attr, hat_setstats and
456*7c478bd9Sstevel@tonic-gate  * returned by hat_pagesync.
457*7c478bd9Sstevel@tonic-gate  */
458*7c478bd9Sstevel@tonic-gate #define	P_MOD	0x1		/* the modified bit */
459*7c478bd9Sstevel@tonic-gate #define	P_REF	0x2		/* the referenced bit */
460*7c478bd9Sstevel@tonic-gate #define	P_RO	0x4		/* Read only page */
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate #define	hat_ismod(pp)		(hat_page_getattr(pp, P_MOD))
463*7c478bd9Sstevel@tonic-gate #define	hat_isref(pp)		(hat_page_getattr(pp, P_REF))
464*7c478bd9Sstevel@tonic-gate #define	hat_isro(pp)		(hat_page_getattr(pp, P_RO))
465*7c478bd9Sstevel@tonic-gate 
466*7c478bd9Sstevel@tonic-gate #define	hat_setmod(pp)		(hat_page_setattr(pp, P_MOD))
467*7c478bd9Sstevel@tonic-gate #define	hat_setref(pp)		(hat_page_setattr(pp, P_REF))
468*7c478bd9Sstevel@tonic-gate #define	hat_setrefmod(pp)	(hat_page_setattr(pp, P_REF|P_MOD))
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate #define	hat_clrmod(pp)		(hat_page_clrattr(pp, P_MOD))
471*7c478bd9Sstevel@tonic-gate #define	hat_clrref(pp)		(hat_page_clrattr(pp, P_REF))
472*7c478bd9Sstevel@tonic-gate #define	hat_clrrefmod(pp)	(hat_page_clrattr(pp, P_REF|P_MOD))
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate #define	hat_page_is_mapped(pp)	(hat_page_getshare(pp))
475*7c478bd9Sstevel@tonic-gate 
476*7c478bd9Sstevel@tonic-gate /*
477*7c478bd9Sstevel@tonic-gate  * hat_setup is being used in sparc/os/sundep.c
478*7c478bd9Sstevel@tonic-gate  */
479*7c478bd9Sstevel@tonic-gate void	hat_setup(struct hat *, int);
480*7c478bd9Sstevel@tonic-gate 
481*7c478bd9Sstevel@tonic-gate /*
482*7c478bd9Sstevel@tonic-gate  * Flags for hat_setup
483*7c478bd9Sstevel@tonic-gate  */
484*7c478bd9Sstevel@tonic-gate #define	HAT_DONTALLOC		0
485*7c478bd9Sstevel@tonic-gate #define	HAT_ALLOC		1
486*7c478bd9Sstevel@tonic-gate #define	HAT_INIT		2
487*7c478bd9Sstevel@tonic-gate 
488*7c478bd9Sstevel@tonic-gate /*
489*7c478bd9Sstevel@tonic-gate  * Other routines, for statistics
490*7c478bd9Sstevel@tonic-gate  */
491*7c478bd9Sstevel@tonic-gate int	hat_startstat(struct as *);
492*7c478bd9Sstevel@tonic-gate void	hat_getstat(struct as *, caddr_t, size_t, uint_t, char *, int);
493*7c478bd9Sstevel@tonic-gate void	hat_freestat(struct as *, int);
494*7c478bd9Sstevel@tonic-gate void	hat_resvstat(size_t, struct as *, caddr_t);
495*7c478bd9Sstevel@tonic-gate 
496*7c478bd9Sstevel@tonic-gate /*
497*7c478bd9Sstevel@tonic-gate  * Transitionary routine while we still allow hat_getkpfnum(caddr_t)
498*7c478bd9Sstevel@tonic-gate  * to return a pfn for kernel memory, but want to warn the user that
499*7c478bd9Sstevel@tonic-gate  * it isn't supported.
500*7c478bd9Sstevel@tonic-gate  */
501*7c478bd9Sstevel@tonic-gate void	hat_getkpfnum_badcall(void *caller);
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate /*
504*7c478bd9Sstevel@tonic-gate  * Relocation callback routines. Currently only sfmmu HAT supports
505*7c478bd9Sstevel@tonic-gate  * these.
506*7c478bd9Sstevel@tonic-gate  */
507*7c478bd9Sstevel@tonic-gate extern int	hat_add_callback(id_t, caddr_t, uint_t, uint_t, void *,
508*7c478bd9Sstevel@tonic-gate 	pfn_t *);
509*7c478bd9Sstevel@tonic-gate extern id_t	hat_register_callback(
510*7c478bd9Sstevel@tonic-gate 	int (*prehandler)(caddr_t, uint_t, uint_t, void *),
511*7c478bd9Sstevel@tonic-gate 	int (*posthandler)(caddr_t, uint_t, uint_t, void *, pfn_t),
512*7c478bd9Sstevel@tonic-gate 	int (*errhandler)(caddr_t, uint_t, uint_t, void *), int);
513*7c478bd9Sstevel@tonic-gate extern void	hat_delete_callback(caddr_t, uint_t, void *, uint_t);
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate /*
516*7c478bd9Sstevel@tonic-gate  * hat_add_callback()/hat_delete_callback() flags.
517*7c478bd9Sstevel@tonic-gate  */
518*7c478bd9Sstevel@tonic-gate #define	HAC_NOSLEEP	0x0
519*7c478bd9Sstevel@tonic-gate #define	HAC_SLEEP	0x1
520*7c478bd9Sstevel@tonic-gate #define	HAC_PAGELOCK	0x2
521*7c478bd9Sstevel@tonic-gate 
522*7c478bd9Sstevel@tonic-gate /*
523*7c478bd9Sstevel@tonic-gate  * Suspend/unsuspend handler callback arguments.
524*7c478bd9Sstevel@tonic-gate  */
525*7c478bd9Sstevel@tonic-gate #define	HAT_SUSPEND		0x0010
526*7c478bd9Sstevel@tonic-gate #define	HAT_UNSUSPEND		0x0010
527*7c478bd9Sstevel@tonic-gate #define	HAT_PRESUSPEND		0x0020
528*7c478bd9Sstevel@tonic-gate #define	HAT_POSTUNSUSPEND	0x0020
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate /*
531*7c478bd9Sstevel@tonic-gate  * Error handler callback arguments. See the block comments
532*7c478bd9Sstevel@tonic-gate  * before the implementation of hat_add_callback() for an
533*7c478bd9Sstevel@tonic-gate  * explanation of what these mean.
534*7c478bd9Sstevel@tonic-gate  */
535*7c478bd9Sstevel@tonic-gate #define	HAT_CB_ERR_LEAKED	0x1
536*7c478bd9Sstevel@tonic-gate 
537*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
538*7c478bd9Sstevel@tonic-gate 
539*7c478bd9Sstevel@tonic-gate /*
540*7c478bd9Sstevel@tonic-gate  * The size of the bit array for ref and mod bit storage must be a power of 2.
541*7c478bd9Sstevel@tonic-gate  * 2 bits are collected for each page.  Below the power used is 4,
542*7c478bd9Sstevel@tonic-gate  * which is 16 8-bit characters = 128 bits, ref and mod bit information
543*7c478bd9Sstevel@tonic-gate  * for 64 pages.
544*7c478bd9Sstevel@tonic-gate  */
545*7c478bd9Sstevel@tonic-gate #define	HRM_SHIFT		4
546*7c478bd9Sstevel@tonic-gate #define	HRM_BYTES		(1 << HRM_SHIFT)
547*7c478bd9Sstevel@tonic-gate #define	HRM_PAGES		((HRM_BYTES * NBBY) / 2)
548*7c478bd9Sstevel@tonic-gate #define	HRM_PGPERBYTE		(NBBY/2)
549*7c478bd9Sstevel@tonic-gate #define	HRM_PGBYTEMASK		(HRM_PGPERBYTE-1)
550*7c478bd9Sstevel@tonic-gate 
551*7c478bd9Sstevel@tonic-gate #define	HRM_PGOFFMASK		((HRM_PGPERBYTE-1) << MMU_PAGESHIFT)
552*7c478bd9Sstevel@tonic-gate #define	HRM_BASEOFFSET		(((MMU_PAGESIZE * HRM_PAGES) - 1))
553*7c478bd9Sstevel@tonic-gate #define	HRM_BASEMASK		(~(HRM_BASEOFFSET))
554*7c478bd9Sstevel@tonic-gate 
555*7c478bd9Sstevel@tonic-gate #define	HRM_BASESHIFT		(MMU_PAGESHIFT + (HRM_SHIFT + 2))
556*7c478bd9Sstevel@tonic-gate #define	HRM_PAGEMASK		(MMU_PAGEMASK ^ HRM_BASEMASK)
557*7c478bd9Sstevel@tonic-gate 
558*7c478bd9Sstevel@tonic-gate #define	HRM_HASHSIZE		0x200
559*7c478bd9Sstevel@tonic-gate #define	HRM_HASHMASK		(HRM_HASHSIZE - 1)
560*7c478bd9Sstevel@tonic-gate 
561*7c478bd9Sstevel@tonic-gate #define	HRM_BLIST_INCR		0x200
562*7c478bd9Sstevel@tonic-gate 
563*7c478bd9Sstevel@tonic-gate /*
564*7c478bd9Sstevel@tonic-gate  * The structure for maintaining referenced and modified information
565*7c478bd9Sstevel@tonic-gate  */
566*7c478bd9Sstevel@tonic-gate struct hrmstat {
567*7c478bd9Sstevel@tonic-gate 	struct as	*hrm_as;	/* stat block belongs to this as */
568*7c478bd9Sstevel@tonic-gate 	uintptr_t	hrm_base;	/* base of block */
569*7c478bd9Sstevel@tonic-gate 	ushort_t	hrm_id;		/* opaque identifier, one of a_vbits */
570*7c478bd9Sstevel@tonic-gate 	struct hrmstat	*hrm_anext;	/* as statistics block list */
571*7c478bd9Sstevel@tonic-gate 	struct hrmstat	*hrm_hnext;	/* list for hashed blocks */
572*7c478bd9Sstevel@tonic-gate 	uchar_t		hrm_bits[HRM_BYTES]; /* the ref and mod bits */
573*7c478bd9Sstevel@tonic-gate };
574*7c478bd9Sstevel@tonic-gate 
575*7c478bd9Sstevel@tonic-gate /*
576*7c478bd9Sstevel@tonic-gate  * For global monitoring of the reference and modified bits
577*7c478bd9Sstevel@tonic-gate  * of all address spaces we reserve one id bit.
578*7c478bd9Sstevel@tonic-gate  */
579*7c478bd9Sstevel@tonic-gate #define	HRM_SWSMONID	1
580*7c478bd9Sstevel@tonic-gate 
581*7c478bd9Sstevel@tonic-gate 
582*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
583*7c478bd9Sstevel@tonic-gate 
584*7c478bd9Sstevel@tonic-gate /*
585*7c478bd9Sstevel@tonic-gate  * Hat locking functions
586*7c478bd9Sstevel@tonic-gate  * XXX - these two functions are currently being used by hatstats
587*7c478bd9Sstevel@tonic-gate  * 	they can be removed by using a per-as mutex for hatstats.
588*7c478bd9Sstevel@tonic-gate  */
589*7c478bd9Sstevel@tonic-gate void	hat_enter(struct hat *);
590*7c478bd9Sstevel@tonic-gate void	hat_exit(struct hat *);
591*7c478bd9Sstevel@tonic-gate 
592*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
593*7c478bd9Sstevel@tonic-gate 
594*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
595*7c478bd9Sstevel@tonic-gate }
596*7c478bd9Sstevel@tonic-gate #endif
597*7c478bd9Sstevel@tonic-gate 
598*7c478bd9Sstevel@tonic-gate #endif	/* _VM_HAT_H */
599