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 #pragma ident   "%Z%%M% %I%     %E% SMI"
  30 
  31 #include <sys/balloon.h>
  32 #include <sys/types.h>
  33 #include <vm/page.h>
  34 #include <sys/xen_mmu.h>  /* to get typedef of mfn_t */
  35 
  36 #ifdef __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 /*
  41  * This file contains interfaces for both the balloon kernel thread
  42  * and the balloon driver.  The balloon device is installed under /dev/xen,
  43  * and can be used with the ioctl values in balloon.h to get the balloon
  44  * memory status.
  45  */
  46 
  47 /* balloon thread declarations */
  48 void balloon_init(pgcnt_t);
  49 size_t balloon_values(int);
  50 void balloon_drv_added(int64_t);
  51 void balloon_drv_subtracted(int64_t);
  52 long balloon_alloc_pages(uint_t, mfn_t *);
  53 long balloon_free_pages(uint_t, mfn_t *, caddr_t, pfn_t *);
  54 long balloon_replace_pages(uint_t, page_t **, uint_t, uint_t, mfn_t *);
  55 
  56 /* balloon driver information */
  57 #define BALLOON_MINOR           0
  58 
  59 /*
  60  * Critical stats for the balloon thread.  All values are in pages.
  61  */
  62 typedef struct {
  63         pgcnt_t bln_current_pages;      /* current reservation */
  64         pgcnt_t bln_new_target;         /* target value for reservation */
  65         pgcnt_t bln_max_pages;  /* first pfn for which we don't have a page_t */
  66         pgcnt_t bln_low;        /* lowest value of reservation since boot */
  67         pgcnt_t bln_high;       /* highest value of reservation since boot */
  68         spgcnt_t bln_hv_pages;  /* number of total pages given to hypervisor */
  69         spgcnt_t bln_hard_limit;        /* domain's max-mem limit */
  70 } bln_stats_t;
  71 
  72 #ifdef __cplusplus
  73 }
  74 #endif
  75 
  76 #endif /* _SYS_BALLOON_IMPL_H */