gmm.h revision cbf380b7d4a6c4cfa9457976e7eb4dbcfd273423
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/** @file
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * GMM - The Global Memory Manager.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/*
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Copyright (C) 2007 InnoTek Systemberatung GmbH
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * available from http://www.virtualbox.org. This file is free software;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * General Public License as published by the Free Software Foundation,
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifndef ___VBox_gmm_h
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define ___VBox_gmm_h
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/types.h>
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#include <VBox/gvmm.h>
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/** @defgroup grp_gmm GMM - The Global Memory Manager
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * @{
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/** @def IN_GMM_R0
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Used to indicate whether we're inside the same link module as the ring 0
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * part of the Global Memory Manager or not.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/** @def GMMR0DECL
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Ring 0 GMM export or import declaration.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param type The return type of the function declaration.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifdef IN_GMM_R0
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync# define GMMR0DECL(type) DECLEXPORT(type) VBOXCALL
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync#else
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync# define GMMR0DECL(type) DECLIMPORT(type) VBOXCALL
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#endif
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/** The chunk shift. (2^20 = 1 MB) */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#define GMM_CHUNK_SHIFT 20
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/** The allocation chunk size. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define GMM_CHUNK_SIZE (1U << GMM_CHUNK_SHIFT)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/** The shift factor for converting a page id into a chunk id. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define GMM_CHUNKID_SHIFT (GMM_CHUNK_SHIFT - PAGE_SHIFT)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/** The NIL Chunk ID value. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define NIL_GMM_CHUNKID 0
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/** The NIL Page ID value. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#define NIL_GMM_PAGEID 0
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/**
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Over-commitment policy.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsynctypedef enum GMMOCPOLICY
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync{
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /** The usual invalid 0 value. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync GMMOCPOLICY_INVALID = 0,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /** No over-commitment, fully backed.
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * The GMM guarantees that it will be able to allocate all of the
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * guest RAM for a VM with OC policy. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync GMMOCPOLICY_NO_OC,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /** to-be-determined. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync GMMOCPOLICY_TBD,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /** The end of the valid policy range. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync GMMOCPOLICY_END,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The usual 32-bit hack. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync GMMOCPOLICY_32BIT_HACK = 0x7fffffff
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync} GMMOCPOLICY;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/**
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * VM / Memory priority.
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsynctypedef enum GMMPRIORITY
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The usual invalid 0 value. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync GMMPRIORITY_INVALID = 0,
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /** High - avoid interrupting it if at all possible */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync GMMPRIORITY_HIGH,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** Normal - pause, save it or kill it. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync GMMPRIORITY_NORMAL,
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync /** Low - save or kill it. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync GMMPRIORITY_LOW,
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync /** The end of the valid priority range. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync GMMPRIORITY_END = 0,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The custom 32-bit type blowup. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync GMMPRIORITY_32BIT_HACK = 0x7fffffff
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync} GMMPRIORITY;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync/** @} */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync