xref: /titanic_51/usr/src/uts/common/sys/hold_page.h (revision 843e19887f64dde75055cf8842fc4db2171eff45)
1ae115bc7Smrj /*
2ae115bc7Smrj  * CDDL HEADER START
3ae115bc7Smrj  *
4ae115bc7Smrj  * The contents of this file are subject to the terms of the
5ae115bc7Smrj  * Common Development and Distribution License (the "License").
6ae115bc7Smrj  * You may not use this file except in compliance with the License.
7ae115bc7Smrj  *
8ae115bc7Smrj  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9ae115bc7Smrj  * or http://www.opensolaris.org/os/licensing.
10ae115bc7Smrj  * See the License for the specific language governing permissions
11ae115bc7Smrj  * and limitations under the License.
12ae115bc7Smrj  *
13ae115bc7Smrj  * When distributing Covered Code, include this CDDL HEADER in each
14ae115bc7Smrj  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15ae115bc7Smrj  * If applicable, add the following below this CDDL HEADER, with the
16ae115bc7Smrj  * fields enclosed by brackets "[]" replaced with your own identifying
17ae115bc7Smrj  * information: Portions Copyright [yyyy] [name of copyright owner]
18ae115bc7Smrj  *
19ae115bc7Smrj  * CDDL HEADER END
20ae115bc7Smrj  */
21ae115bc7Smrj /*
22ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23ae115bc7Smrj  * Use is subject to license terms.
24ae115bc7Smrj  */
25ae115bc7Smrj 
26ae115bc7Smrj #ifndef _SYS_HOLD_PAGE_H
27ae115bc7Smrj #define	_SYS_HOLD_PAGE_H
28ae115bc7Smrj 
29ae115bc7Smrj #pragma ident	"%Z%%M%	%I%	%E% SMI"
30ae115bc7Smrj 
31ae115bc7Smrj #ifdef __cplusplus
32ae115bc7Smrj extern "C" {
33ae115bc7Smrj #endif
34ae115bc7Smrj 
35ae115bc7Smrj #include <sys/types.h>
36ae115bc7Smrj #include <vm/page.h>
37ae115bc7Smrj 
38ae115bc7Smrj /*
39ae115bc7Smrj  * swrand generates entropy by mapping different pages in the system.  This
40ae115bc7Smrj  * can create problems for some hypervisors, as certain pages may be removed
41ae115bc7Smrj  * from the system at any time.  The following interfaces allow swrand to
42ae115bc7Smrj  * check the validity and make sure a page is not given away while it is mapped.
43ae115bc7Smrj  *
44ae115bc7Smrj  * int plat_hold_page(pfn_t pfn, int lock, page_t **pp_ret)
45ae115bc7Smrj  *
46ae115bc7Smrj  *	If lock is PLAT_HOLD_NO_LOCK, simply check if the page pfn is valid
47ae115bc7Smrj  *	in the system.  If the page is valid, PLAT_HOLD_OK will be returned.
48ae115bc7Smrj  *	pp_ret is ignored if lock is PLAT_HOLD_NO_LOCK.
49ae115bc7Smrj  *
50ae115bc7Smrj  *	If lock is PLAT_HOLD_LOCK, in addition to the above, attempt to lock
51ae115bc7Smrj  *	the page exclusively.  Again, if the lock is successful, the page
52*843e1988Sjohnlev  *	pointer will be put in pp_ret, and PLAT_HOLD_OK will be returned.
53*843e1988Sjohnlev  *	pp_ret must be passed to a later call to plat_release_page.  If the
54*843e1988Sjohnlev  *	page wasn't found, or the lock couldn't be grabbed, the return value
55*843e1988Sjohnlev  *	will be PLAT_HOLD_FAIL.
56ae115bc7Smrj  *
57ae115bc7Smrj  * void plat_release_page(page_t *pp)
58ae115bc7Smrj  *
59ae115bc7Smrj  *	Unlock the page pp.  Should only be called after a previous,
60*843e1988Sjohnlev  *	successful call to plat_hold_page(pfn, PLAT_HOLD_LOCK, &pp);
61ae115bc7Smrj  */
62ae115bc7Smrj 
63ae115bc7Smrj #define	PLAT_HOLD_NO_LOCK	0
64ae115bc7Smrj #define	PLAT_HOLD_LOCK		1
65ae115bc7Smrj 
66ae115bc7Smrj #define	PLAT_HOLD_OK		0
67ae115bc7Smrj #define	PLAT_HOLD_FAIL		1
68ae115bc7Smrj 
69ae115bc7Smrj extern int plat_hold_page(pfn_t, int, page_t **);
70ae115bc7Smrj extern void plat_release_page(page_t *);
71ae115bc7Smrj 
72ae115bc7Smrj #ifdef __cplusplus
73ae115bc7Smrj }
74ae115bc7Smrj #endif
75ae115bc7Smrj 
76ae115bc7Smrj #endif	/* _SYS_HOLD_PAGE_H */
77