xref: /illumos-gate/usr/src/uts/common/vm/as.h (revision 284ce987)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5c6939658Ssl  * Common Development and Distribution License (the "License").
6c6939658Ssl  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22bb5ca623SVamsi Nagineni  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
26b3d32f0cSBryan Cantrill /*
27*284ce987SPatrick Mooney  * Copyright 2018 Joyent, Inc.
28b3d32f0cSBryan Cantrill  */
29b3d32f0cSBryan Cantrill 
307c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
317c478bd9Sstevel@tonic-gate /*	 All Rights Reserved   */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
357c478bd9Sstevel@tonic-gate  * The Regents of the University of California
367c478bd9Sstevel@tonic-gate  * All Rights Reserved
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
397c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
407c478bd9Sstevel@tonic-gate  * contributors.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifndef	_VM_AS_H
447c478bd9Sstevel@tonic-gate #define	_VM_AS_H
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #include <sys/watchpoint.h>
477c478bd9Sstevel@tonic-gate #include <vm/seg.h>
487c478bd9Sstevel@tonic-gate #include <vm/faultcode.h>
497c478bd9Sstevel@tonic-gate #include <vm/hat.h>
507c478bd9Sstevel@tonic-gate #include <sys/avl.h>
51c6939658Ssl #include <sys/proc.h>
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
547c478bd9Sstevel@tonic-gate extern "C" {
557c478bd9Sstevel@tonic-gate #endif
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * VM - Address spaces.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * Each address space consists of a sorted list of segments
637c478bd9Sstevel@tonic-gate  * and machine dependent address translation information.
647c478bd9Sstevel@tonic-gate  *
657c478bd9Sstevel@tonic-gate  * All the hard work is in the segment drivers and the
667c478bd9Sstevel@tonic-gate  * hardware address translation code.
677c478bd9Sstevel@tonic-gate  *
687c478bd9Sstevel@tonic-gate  * The segment list is represented as an AVL tree.
697c478bd9Sstevel@tonic-gate  *
707c478bd9Sstevel@tonic-gate  * The address space lock (a_lock) is a long term lock which serializes
717c478bd9Sstevel@tonic-gate  * access to certain operations (as_map, as_unmap) and protects the
727c478bd9Sstevel@tonic-gate  * underlying generic segment data (seg.h) along with some fields in the
737c478bd9Sstevel@tonic-gate  * address space structure as shown below:
747c478bd9Sstevel@tonic-gate  *
757c478bd9Sstevel@tonic-gate  *	address space structure 	segment structure
767c478bd9Sstevel@tonic-gate  *
777c478bd9Sstevel@tonic-gate  *	a_segtree			s_base
787c478bd9Sstevel@tonic-gate  *	a_size				s_size
797c478bd9Sstevel@tonic-gate  *	a_lastgap			s_link
807c478bd9Sstevel@tonic-gate  *	a_seglast			s_ops
817c478bd9Sstevel@tonic-gate  *					s_as
827c478bd9Sstevel@tonic-gate  *					s_data
837c478bd9Sstevel@tonic-gate  *
847c478bd9Sstevel@tonic-gate  * The address space contents lock (a_contents) is a short term
857c478bd9Sstevel@tonic-gate  * lock that protects most of the data in the address space structure.
867c478bd9Sstevel@tonic-gate  * This lock is always acquired after the "a_lock" in all situations
877c478bd9Sstevel@tonic-gate  * except while dealing with AS_CLAIMGAP to avoid deadlocks.
887c478bd9Sstevel@tonic-gate  *
897c478bd9Sstevel@tonic-gate  * The following fields are protected by this lock:
907c478bd9Sstevel@tonic-gate  *
917c478bd9Sstevel@tonic-gate  *	a_flags (AS_PAGLCK, AS_CLAIMGAP, etc.)
927c478bd9Sstevel@tonic-gate  *	a_unmapwait
937c478bd9Sstevel@tonic-gate  *	a_seglast
947c478bd9Sstevel@tonic-gate  *
957c478bd9Sstevel@tonic-gate  * The address space lock (a_lock) is always held prior to any segment
967c478bd9Sstevel@tonic-gate  * operation.  Some segment drivers use the address space lock to protect
977c478bd9Sstevel@tonic-gate  * some or all of their segment private data, provided the version of
987c478bd9Sstevel@tonic-gate  * "a_lock" (read vs. write) is consistent with the use of the data.
997c478bd9Sstevel@tonic-gate  *
1007c478bd9Sstevel@tonic-gate  * The following fields are protected by the hat layer lock:
1017c478bd9Sstevel@tonic-gate  *
1027c478bd9Sstevel@tonic-gate  *	a_vbits
1037c478bd9Sstevel@tonic-gate  *	a_hat
1047c478bd9Sstevel@tonic-gate  *	a_hrm
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate struct as {
1087c478bd9Sstevel@tonic-gate 	kmutex_t a_contents;	/* protect certain fields in the structure */
1097c478bd9Sstevel@tonic-gate 	uchar_t  a_flags;	/* as attributes */
1107c478bd9Sstevel@tonic-gate 	uchar_t	a_vbits;	/* used for collecting statistics */
1117c478bd9Sstevel@tonic-gate 	kcondvar_t a_cv;	/* used by as_rangelock */
1127c478bd9Sstevel@tonic-gate 	struct	hat *a_hat;	/* hat structure */
1137c478bd9Sstevel@tonic-gate 	struct	hrmstat *a_hrm; /* ref and mod bits */
1147c478bd9Sstevel@tonic-gate 	caddr_t	a_userlimit;	/* highest allowable address in this as */
1157c478bd9Sstevel@tonic-gate 	struct seg *a_seglast;	/* last segment hit on the addr space */
1167c478bd9Sstevel@tonic-gate 	krwlock_t a_lock;	/* protects segment related fields */
11740688216SSudheer A 	size_t	a_size;		/* total size of address space */
1187c478bd9Sstevel@tonic-gate 	struct seg *a_lastgap;	/* last seg found by as_gap() w/ AS_HI (mmap) */
1197c478bd9Sstevel@tonic-gate 	struct seg *a_lastgaphl; /* last seg saved in as_gap() either for */
1207c478bd9Sstevel@tonic-gate 				/* AS_HI or AS_LO used in as_addseg() */
1217c478bd9Sstevel@tonic-gate 	avl_tree_t a_segtree;	/* segments in this address space. (AVL tree) */
1227c478bd9Sstevel@tonic-gate 	avl_tree_t a_wpage;	/* watched pages (procfs) */
1237c478bd9Sstevel@tonic-gate 	uchar_t	a_updatedir;	/* mappings changed, rebuild a_objectdir */
1247c478bd9Sstevel@tonic-gate 	timespec_t a_updatetime;	/* time when mappings last changed */
1257c478bd9Sstevel@tonic-gate 	vnode_t	**a_objectdir;	/* object directory (procfs) */
1267c478bd9Sstevel@tonic-gate 	size_t	a_sizedir;	/* size of object directory */
1277c478bd9Sstevel@tonic-gate 	struct as_callback *a_callbacks; /* callback list */
128c6939658Ssl 	proc_t	*a_proc;	/* back pointer to proc */
12940688216SSudheer A 	size_t	a_resvsize;	/* size of reserved part of address space */
1307c478bd9Sstevel@tonic-gate };
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #define	AS_PAGLCK		0x80
1337c478bd9Sstevel@tonic-gate #define	AS_CLAIMGAP		0x40
1347c478bd9Sstevel@tonic-gate #define	AS_UNMAPWAIT		0x20
1357c478bd9Sstevel@tonic-gate #define	AS_NEEDSPURGE		0x10	/* mostly for seg_nf, see as_purge() */
136a98e9dbfSaguzovsk #define	AS_NOUNMAPWAIT		0x02
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate #define	AS_ISPGLCK(as)		((as)->a_flags & AS_PAGLCK)
1397c478bd9Sstevel@tonic-gate #define	AS_ISCLAIMGAP(as)	((as)->a_flags & AS_CLAIMGAP)
1407c478bd9Sstevel@tonic-gate #define	AS_ISUNMAPWAIT(as)	((as)->a_flags & AS_UNMAPWAIT)
141a98e9dbfSaguzovsk #define	AS_ISNOUNMAPWAIT(as)	((as)->a_flags & AS_NOUNMAPWAIT)
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate #define	AS_SETPGLCK(as)		((as)->a_flags |= AS_PAGLCK)
1447c478bd9Sstevel@tonic-gate #define	AS_SETCLAIMGAP(as)	((as)->a_flags |= AS_CLAIMGAP)
1457c478bd9Sstevel@tonic-gate #define	AS_SETUNMAPWAIT(as)	((as)->a_flags |= AS_UNMAPWAIT)
146a98e9dbfSaguzovsk #define	AS_SETNOUNMAPWAIT(as)	((as)->a_flags |= AS_NOUNMAPWAIT)
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate #define	AS_CLRPGLCK(as)		((as)->a_flags &= ~AS_PAGLCK)
1497c478bd9Sstevel@tonic-gate #define	AS_CLRCLAIMGAP(as)	((as)->a_flags &= ~AS_CLAIMGAP)
1507c478bd9Sstevel@tonic-gate #define	AS_CLRUNMAPWAIT(as)	((as)->a_flags &= ~AS_UNMAPWAIT)
151a98e9dbfSaguzovsk #define	AS_CLRNOUNMAPWAIT(as)	((as)->a_flags &= ~AS_NOUNMAPWAIT)
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #define	AS_TYPE_64BIT(as)	\
1547c478bd9Sstevel@tonic-gate 	    (((as)->a_userlimit > (caddr_t)UINT32_MAX) ? 1 : 0)
1557c478bd9Sstevel@tonic-gate 
156ec25b48fSsusans /*
157ec25b48fSsusans  * Flags for as_map/as_map_ansegs
158ec25b48fSsusans  */
159ec25b48fSsusans #define	AS_MAP_NO_LPOOB		((uint_t)-1)
160ec25b48fSsusans #define	AS_MAP_HEAP		((uint_t)-2)
161ec25b48fSsusans #define	AS_MAP_STACK		((uint_t)-3)
162ec25b48fSsusans 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * The as_callback is the basic structure which supports the ability to
1657c478bd9Sstevel@tonic-gate  * inform clients of specific events pertaining to address space management.
1667c478bd9Sstevel@tonic-gate  * A user calls as_add_callback to register an address space callback
1677c478bd9Sstevel@tonic-gate  * for a range of pages, specifying the events that need to occur.
1687c478bd9Sstevel@tonic-gate  * When as_do_callbacks is called and finds a 'matching' entry, the
1697c478bd9Sstevel@tonic-gate  * callback is called once, and the callback function MUST call
1707c478bd9Sstevel@tonic-gate  * as_delete_callback when all callback activities are complete.
1717c478bd9Sstevel@tonic-gate  * The thread calling as_do_callbacks blocks until the as_delete_callback
1727c478bd9Sstevel@tonic-gate  * is called.  This allows for asynchorous events to subside before the
1737c478bd9Sstevel@tonic-gate  * as_do_callbacks thread continues.
1747c478bd9Sstevel@tonic-gate  *
1757c478bd9Sstevel@tonic-gate  * An example of the need for this is a driver which has done long-term
1767c478bd9Sstevel@tonic-gate  * locking of memory.  Address space management operations (events) such
1777c478bd9Sstevel@tonic-gate  * as as_free, as_umap, and as_setprot will block indefinitely until the
1787c478bd9Sstevel@tonic-gate  * pertinent memory is unlocked.  The callback mechanism provides the
1797c478bd9Sstevel@tonic-gate  * way to inform the driver of the event so that the driver may do the
1807c478bd9Sstevel@tonic-gate  * necessary unlocking.
1817c478bd9Sstevel@tonic-gate  *
1827c478bd9Sstevel@tonic-gate  * The contents of this structure is protected by a_contents lock
1837c478bd9Sstevel@tonic-gate  */
1847c478bd9Sstevel@tonic-gate typedef void (*callback_func_t)(struct as *, void *, uint_t);
1857c478bd9Sstevel@tonic-gate struct as_callback {
1867c478bd9Sstevel@tonic-gate 	struct as_callback	*ascb_next;		/* list link */
1877c478bd9Sstevel@tonic-gate 	uint_t			ascb_events;		/* event types */
1887c478bd9Sstevel@tonic-gate 	callback_func_t		ascb_func;   		/* callback function */
1897c478bd9Sstevel@tonic-gate 	void			*ascb_arg;		/* callback argument */
1907c478bd9Sstevel@tonic-gate 	caddr_t			ascb_saddr;		/* start address */
1917c478bd9Sstevel@tonic-gate 	size_t			ascb_len;		/* address range */
1927c478bd9Sstevel@tonic-gate };
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * Callback events
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate #define	AS_FREE_EVENT		0x1
1977c478bd9Sstevel@tonic-gate #define	AS_SETPROT_EVENT	0x2
1987c478bd9Sstevel@tonic-gate #define	AS_UNMAP_EVENT		0x4
1997c478bd9Sstevel@tonic-gate #define	AS_CALLBACK_CALLED	((uint_t)(1U << (8 * sizeof (uint_t) - 1U)))
2007c478bd9Sstevel@tonic-gate #define	AS_UNMAPWAIT_EVENT				\
2017c478bd9Sstevel@tonic-gate 		(AS_FREE_EVENT | AS_SETPROT_EVENT | AS_UNMAP_EVENT)
2027c478bd9Sstevel@tonic-gate #define	AS_ALL_EVENT					\
2037c478bd9Sstevel@tonic-gate 		(AS_FREE_EVENT | AS_SETPROT_EVENT | AS_UNMAP_EVENT)
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /* Return code values for as_callback_delete */
2077c478bd9Sstevel@tonic-gate enum as_cbdelete_rc {
2087c478bd9Sstevel@tonic-gate 	AS_CALLBACK_DELETED,
2097c478bd9Sstevel@tonic-gate 	AS_CALLBACK_NOTFOUND,
2107c478bd9Sstevel@tonic-gate 	AS_CALLBACK_DELETE_DEFERRED
2117c478bd9Sstevel@tonic-gate };
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate  * Flags for as_gap.
2177c478bd9Sstevel@tonic-gate  */
2187c478bd9Sstevel@tonic-gate #define	AH_DIR		0x1	/* direction flag mask */
2197c478bd9Sstevel@tonic-gate #define	AH_LO		0x0	/* find lowest hole */
2207c478bd9Sstevel@tonic-gate #define	AH_HI		0x1	/* find highest hole */
2217c478bd9Sstevel@tonic-gate #define	AH_CONTAIN	0x2	/* hole must contain `addr' */
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate extern struct as kas;		/* kernel's address space */
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate /*
226b3d32f0cSBryan Cantrill  * Macros for address space locking.  Note that we use RW_READER_STARVEWRITER
227b3d32f0cSBryan Cantrill  * whenever we acquire the address space lock as reader to assure that it can
228b3d32f0cSBryan Cantrill  * be used without regard to lock order in conjunction with filesystem locks.
229b3d32f0cSBryan Cantrill  * This allows filesystems to safely induce user-level page faults with
230b3d32f0cSBryan Cantrill  * filesystem locks held while concurrently allowing filesystem entry points
231b3d32f0cSBryan Cantrill  * acquiring those same locks to be called with the address space lock held as
232b3d32f0cSBryan Cantrill  * reader.  RW_READER_STARVEWRITER thus prevents reader/reader+RW_WRITE_WANTED
233b3d32f0cSBryan Cantrill  * deadlocks in the style of fop_write()+as_fault()/as_*()+fop_putpage() and
234b3d32f0cSBryan Cantrill  * fop_read()+as_fault()/as_*()+fop_getpage().  (See the Big Theory Statement
235b3d32f0cSBryan Cantrill  * in rwlock.c for more information on the semantics of and motivation behind
236b3d32f0cSBryan Cantrill  * RW_READER_STARVEWRITER.)
2377c478bd9Sstevel@tonic-gate  */
238dc32d872SJosef 'Jeff' Sipek #define	AS_LOCK_ENTER(as, type)		rw_enter(&(as)->a_lock, \
239b3d32f0cSBryan Cantrill 	(type) == RW_READER ? RW_READER_STARVEWRITER : (type))
240dc32d872SJosef 'Jeff' Sipek #define	AS_LOCK_EXIT(as)		rw_exit(&(as)->a_lock)
241dc32d872SJosef 'Jeff' Sipek #define	AS_LOCK_DESTROY(as)		rw_destroy(&(as)->a_lock)
242dc32d872SJosef 'Jeff' Sipek #define	AS_LOCK_TRYENTER(as, type)	rw_tryenter(&(as)->a_lock, \
243b3d32f0cSBryan Cantrill 	(type) == RW_READER ? RW_READER_STARVEWRITER : (type))
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate /*
2467c478bd9Sstevel@tonic-gate  * Macros to test lock states.
2477c478bd9Sstevel@tonic-gate  */
248dc32d872SJosef 'Jeff' Sipek #define	AS_LOCK_HELD(as)		RW_LOCK_HELD(&(as)->a_lock)
249dc32d872SJosef 'Jeff' Sipek #define	AS_READ_HELD(as)		RW_READ_HELD(&(as)->a_lock)
250dc32d872SJosef 'Jeff' Sipek #define	AS_WRITE_HELD(as)		RW_WRITE_HELD(&(as)->a_lock)
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * macros to walk thru segment lists
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate #define	AS_SEGFIRST(as)		avl_first(&(as)->a_segtree)
2567c478bd9Sstevel@tonic-gate #define	AS_SEGNEXT(as, seg)	AVL_NEXT(&(as)->a_segtree, (seg))
2577c478bd9Sstevel@tonic-gate #define	AS_SEGPREV(as, seg)	AVL_PREV(&(as)->a_segtree, (seg))
2587c478bd9Sstevel@tonic-gate 
259*284ce987SPatrick Mooney typedef int (*segcreate_func_t)(struct seg **, void *);
260*284ce987SPatrick Mooney 
2617c478bd9Sstevel@tonic-gate void	as_init(void);
2627c478bd9Sstevel@tonic-gate void	as_avlinit(struct as *);
2637c478bd9Sstevel@tonic-gate struct	seg *as_segat(struct as *as, caddr_t addr);
2647c478bd9Sstevel@tonic-gate void	as_rangelock(struct as *as);
2657c478bd9Sstevel@tonic-gate void	as_rangeunlock(struct as *as);
266c6939658Ssl struct	as *as_alloc();
2677c478bd9Sstevel@tonic-gate void	as_free(struct as *as);
268bb5ca623SVamsi Nagineni int	as_dup(struct as *as, struct proc *forkedproc);
2697c478bd9Sstevel@tonic-gate struct	seg *as_findseg(struct as *as, caddr_t addr, int tail);
2707c478bd9Sstevel@tonic-gate int	as_addseg(struct as *as, struct seg *newseg);
2717c478bd9Sstevel@tonic-gate struct	seg *as_removeseg(struct as *as, struct seg *seg);
2727c478bd9Sstevel@tonic-gate faultcode_t as_fault(struct hat *hat, struct as *as, caddr_t addr, size_t size,
2737c478bd9Sstevel@tonic-gate 		enum fault_type type, enum seg_rw rw);
2747c478bd9Sstevel@tonic-gate faultcode_t as_faulta(struct as *as, caddr_t addr, size_t size);
2757c478bd9Sstevel@tonic-gate int	as_setprot(struct as *as, caddr_t addr, size_t size, uint_t prot);
2767c478bd9Sstevel@tonic-gate int	as_checkprot(struct as *as, caddr_t addr, size_t size, uint_t prot);
2777c478bd9Sstevel@tonic-gate int	as_unmap(struct as *as, caddr_t addr, size_t size);
278*284ce987SPatrick Mooney int	as_map(struct as *as, caddr_t addr, size_t size, segcreate_func_t crfp,
279*284ce987SPatrick Mooney     void *argsp);
280*284ce987SPatrick Mooney int as_map_locked(struct as *as, caddr_t addr, size_t size,
281*284ce987SPatrick Mooney     segcreate_func_t crfp, void *argsp);
2827c478bd9Sstevel@tonic-gate void	as_purge(struct as *as);
2837c478bd9Sstevel@tonic-gate int	as_gap(struct as *as, size_t minlen, caddr_t *basep, size_t *lenp,
2847c478bd9Sstevel@tonic-gate 		uint_t flags, caddr_t addr);
28546ab9534Smec int	as_gap_aligned(struct as *as, size_t minlen, caddr_t *basep,
28646ab9534Smec 	    size_t *lenp, uint_t flags, caddr_t addr, size_t align,
28746ab9534Smec 	    size_t redzone, size_t off);
28846ab9534Smec 
2897c478bd9Sstevel@tonic-gate int	as_memory(struct as *as, caddr_t *basep, size_t *lenp);
2907c478bd9Sstevel@tonic-gate size_t	as_swapout(struct as *as);
2917c478bd9Sstevel@tonic-gate int	as_incore(struct as *as, caddr_t addr, size_t size, char *vec,
2927c478bd9Sstevel@tonic-gate 		size_t *sizep);
2937c478bd9Sstevel@tonic-gate int	as_ctl(struct as *as, caddr_t addr, size_t size, int func, int attr,
2947c478bd9Sstevel@tonic-gate 		uintptr_t arg, ulong_t *lock_map, size_t pos);
2957c478bd9Sstevel@tonic-gate int	as_pagelock(struct as *as, struct page ***ppp, caddr_t addr,
2967c478bd9Sstevel@tonic-gate 		size_t size, enum seg_rw rw);
2977c478bd9Sstevel@tonic-gate void	as_pageunlock(struct as *as, struct page **pp, caddr_t addr,
2987c478bd9Sstevel@tonic-gate 		size_t size, enum seg_rw rw);
2997c478bd9Sstevel@tonic-gate int	as_setpagesize(struct as *as, caddr_t addr, size_t size, uint_t szc,
3007c478bd9Sstevel@tonic-gate 		boolean_t wait);
301ec25b48fSsusans int	as_set_default_lpsize(struct as *as, caddr_t addr, size_t size);
3027c478bd9Sstevel@tonic-gate void	as_setwatch(struct as *as);
3037c478bd9Sstevel@tonic-gate void	as_clearwatch(struct as *as);
3047c478bd9Sstevel@tonic-gate int	as_getmemid(struct as *, caddr_t, memid_t *);
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate int	as_add_callback(struct as *, void (*)(), void *, uint_t,
3077c478bd9Sstevel@tonic-gate 			caddr_t, size_t, int);
3087c478bd9Sstevel@tonic-gate uint_t	as_delete_callback(struct as *, void *);
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate #endif
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate #endif	/* _VM_AS_H */
317