xref: /illumos-gate/usr/src/uts/i86xpv/sys/balloon_impl.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_BALLOON_IMPL_H
27 #define	_SYS_BALLOON_IMPL_H
28 
29 #include <sys/balloon.h>
30 #include <sys/types.h>
31 #include <vm/page.h>
32 #include <sys/xen_mmu.h>	/* to get typedef of mfn_t */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * This file contains interfaces for both the balloon kernel thread
40  * and the balloon driver.  The balloon device is installed under /dev/xen,
41  * and can be used with the ioctl values in balloon.h to get the balloon
42  * memory status.
43  */
44 
45 /* balloon thread declarations */
46 void balloon_init(pgcnt_t);
47 size_t balloon_values(int);
48 void balloon_drv_added(int64_t);
49 void balloon_drv_subtracted(int64_t);
50 long balloon_alloc_pages(uint_t, mfn_t *);
51 long balloon_free_pages(uint_t, mfn_t *, caddr_t, pfn_t *);
52 long balloon_replace_pages(uint_t, page_t **, uint_t, uint_t, mfn_t *);
53 
54 /* balloon driver information */
55 #define	BALLOON_MINOR		0
56 
57 /*
58  * Critical stats for the balloon thread.  All values are in pages.
59  */
60 typedef struct {
61 	pgcnt_t bln_current_pages;	/* current reservation */
62 	pgcnt_t bln_new_target;		/* target value for reservation */
63 	pgcnt_t bln_max_pages;	/* first pfn for which we don't have a page_t */
64 	pgcnt_t bln_low;	/* lowest value of reservation since boot */
65 	pgcnt_t bln_high;	/* highest value of reservation since boot */
66 	spgcnt_t bln_hv_pages;	/* number of total pages given to hypervisor */
67 	spgcnt_t bln_hard_limit;	/* domain's max-mem limit */
68 } bln_stats_t;
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* _SYS_BALLOON_IMPL_H */
75