GMMR0Internal.h revision 4d4f336b656d46f8d301603114bb99ce635aafc0
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/* $Id$ */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/** @file
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * GMM - The Global Memory Manager, Internal Header.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2007 Oracle Corporation
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync *
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * available from http://www.virtualbox.org. This file is free software;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#ifndef ___GMMR0Internal_h
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#define ___GMMR0Internal_h
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync#include <VBox/vmm/gmm.h>
5e31c5b77713d7c61de5f65f1c3d057dddaa27f3vboxsync#include <iprt/avl.h>
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
b2def6ea46868a11f7fd2857874e46c51932223avboxsync/**
b2def6ea46868a11f7fd2857874e46c51932223avboxsync * Shared module registration info (per VM)
b2def6ea46868a11f7fd2857874e46c51932223avboxsync */
b2def6ea46868a11f7fd2857874e46c51932223avboxsynctypedef struct GMMSHAREDMODULEPERVM
b2def6ea46868a11f7fd2857874e46c51932223avboxsync{
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Tree node. */
b2def6ea46868a11f7fd2857874e46c51932223avboxsync AVLGCPTRNODECORE Core;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Pointer to global shared module info. */
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync PGMMSHAREDMODULE pGlobalModule;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Set if another VM registered a different shared module at the same base address. */
1084dfee3c44a35cbe9aef69158474a913a3e0d9vboxsync bool fCollision;
e4d7b580d72e968d3753363ab36e196a968c1947vboxsync /** Alignment. */
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync bool bAlignment[3];
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync /** Number of included region descriptors */
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync uint32_t cRegions;
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync /** Shared region descriptor(s). */
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync GMMSHAREDREGIONDESC aRegions[1];
b2def6ea46868a11f7fd2857874e46c51932223avboxsync} GMMSHAREDMODULEPERVM;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync/** Pointer to a GMMSHAREDMODULEPERVM. */
b2def6ea46868a11f7fd2857874e46c51932223avboxsynctypedef GMMSHAREDMODULEPERVM *PGMMSHAREDMODULEPERVM;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync/** Pointer to a GMM allocation chunk. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsynctypedef struct GMMCHUNK *PGMMCHUNK;
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync/** The GMMCHUNK::cFree shift count employed by gmmR0SelectFreeSetList. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync#define GMM_CHUNK_FREE_SET_SHIFT 4
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync/** Index of the list containing completely unused chunks.
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync * The code ASSUMES this is the last list. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync#define GMM_CHUNK_FREE_SET_UNUSED_LIST (GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT)
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync/**
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync * A set of free chunks.
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsynctypedef struct GMMCHUNKFREESET
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync{
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync /** The number of free pages in the set. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync uint64_t cFreePages;
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync /** The generation ID for the set. This is incremented whenever
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync * something is linked or unlinked from this set. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync uint64_t idGeneration;
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync /** Chunks ordered by increasing number of free pages.
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync * In the final list the chunks are completely unused. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync PGMMCHUNK apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST + 1];
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync} GMMCHUNKFREESET;
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/**
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * The per-VM GMM data.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsynctypedef struct GMMPERVM
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync{
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync /** Free set for use in bound mode. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync GMMCHUNKFREESET Private;
4d4f336b656d46f8d301603114bb99ce635aafc0vboxsync /** The VM statistics. */
4d4f336b656d46f8d301603114bb99ce635aafc0vboxsync GMMVMSTATS Stats;
b2def6ea46868a11f7fd2857874e46c51932223avboxsync /** Shared module tree (per-vm). */
b2def6ea46868a11f7fd2857874e46c51932223avboxsync PAVLGCPTRNODECORE pSharedModuleTree;
4d4f336b656d46f8d301603114bb99ce635aafc0vboxsync /** Hints at the last chunk we allocated some memory from. */
4d4f336b656d46f8d301603114bb99ce635aafc0vboxsync uint32_t idLastChunkHint;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync} GMMPERVM;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/** Pointer to the per-VM GMM data. */
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsynctypedef GMMPERVM *PGMMPERVM;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync#endif
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync