gvmm.h revision ec1eca74badc326cb04c0d139286e5a2ce99da63
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/* $Id$ */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** @file
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * GVMM - The Global VM Manager.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/*
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Copyright (C) 2007 InnoTek Systemberatung GmbH
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * available from http://www.virtualbox.org. This file is free software;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * General Public License as published by the Free Software Foundation,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#ifndef ___VBox_gvmm_h
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#define ___VBox_gvmm_h
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <VBox/cdefs.h>
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <VBox/types.h>
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <VBox/sup.h>
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync__BEGIN_DECLS
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync/** @defgroup grp_GVMM GVMM - The Global VM Manager.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** @def IN_GVMM_R0
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Used to indicate whether we're inside the same link module as the ring 0
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * part of the Global VM Manager or not.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** @def GVMMR0DECL
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Ring 0 VM export or import declaration.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @param type The return type of the function declaration.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#ifdef IN_GVMM_R0
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# define GVMMR0DECL(type) DECLEXPORT(type) VBOXCALL
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#else
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# define GVMMR0DECL(type) DECLIMPORT(type) VBOXCALL
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#endif
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** @def NIL_GVM_HANDLE
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * The nil GVM VM handle value (VM::hSelf).
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#define NIL_GVM_HANDLE 0
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * The scheduler statistics
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef struct GVMMSTATSSCHED
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of calls to GVMMR0SchedHalt. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cHaltCalls;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of times we did go to sleep in GVMMR0SchedHalt. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cHaltBlocking;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of times we timed out in GVMMR0SchedHalt. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cHaltTimeouts;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of times we didn't go to sleep in GVMMR0SchedHalt. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cHaltNotBlocking;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of wake ups done during GVMMR0SchedHalt. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cHaltWakeUps;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of calls to GVMMR0WakeUp. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cWakeUpCalls;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of times the EMT thread wasn't actually halted when GVMMR0WakeUp was called. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cWakeUpNotHalted;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of wake ups done during GVMMR0WakeUp (not counting the explicit one). */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cWakeUpWakeUps;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of calls to GVMMR0SchedPoll. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cPollCalls;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of times the EMT has halted in a GVMMR0SchedPoll call. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cPollHalts;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of wake ups done during GVMMR0SchedPoll. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t cPollWakeUps;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint64_t u64Alignment; /**< padding */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync} GVMMSTATSSCHED;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** Pointer to the GVMM scheduler statistics. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef GVMMSTATSSCHED *PGVMMSTATSSCHED;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * The GMM statistics.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef struct GVMMSTATS
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The VM statistics if a VM was specified. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync GVMMSTATSSCHED SchedVM;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The sum statistics of all VMs accessible to the caller. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync GVMMSTATSSCHED SchedSum;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The number of VMs accessible to the caller. */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync uint32_t cVMs;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync /** Alignment padding. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t u32Padding;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync} GVMMSTATS;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync/** Pointer to the GVMM statistics. */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsynctypedef GVMMSTATS *PGVMMSTATS;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** Const pointer to the GVMM statistics. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef const GVMMSTATS *PCGVMMSTATS;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0Init(void);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(void) GVMMR0Term(void);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0CreateVM(PSUPDRVSESSION pSession, PVM *ppVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0DisassociateEMTFromVM(PVM pVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0InitVM(PVM pVM);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsyncGVMMR0DECL(int) GVMMR0AssociateEMTWithVM(PVM pVM);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsyncGVMMR0DECL(int) GVMMR0DestroyVM(PVM pVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(PGVM) GVMMR0ByHandle(uint32_t hGVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(PGVM) GVMMR0ByVM(PVM pVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0ByVMAndEMT(PVM pVM, PGVM *ppGVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(PVM) GVMMR0GetVMByHandle(uint32_t hGVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(PVM) GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsyncGVMMR0DECL(int) GVMMR0SchedHalt(PVM pVM, uint64_t u64ExpireGipTime);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsyncGVMMR0DECL(int) GVMMR0SchedWakeUp(PVM pVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0SchedPoll(PVM pVM, bool fYield);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsyncGVMMR0DECL(int) GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Request packet for calling GVMMR0CreateVM.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsynctypedef struct GVMMCREATEVMREQ
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The request header. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync SUPVMMR0REQHDR Hdr;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The support driver session. (IN) */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PSUPDRVSESSION pSession;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the ring-3 mapping of the shared VM structure on return. (OUT) */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PVMR3 pVMR3;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the ring-0 mapping of the shared VM structure on return. (OUT) */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PVMR0 pVMR0;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync} GVMMCREATEVMREQ;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync/** Pointer to a GVMMR0CreateVM request packet. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef GVMMCREATEVMREQ *PGVMMCREATEVMREQ;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0CreateVMReq(PGVMMCREATEVMREQ pReq);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync * Request buffer for GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @see GVMMR0QueryStatistics.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsynctypedef struct GVMMQUERYSTATISTICSSREQ
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The header. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync SUPVMMR0REQHDR Hdr;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The support driver session. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PSUPDRVSESSION pSession;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The statistics. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync GVMMSTATS Stats;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync} GVMMQUERYSTATISTICSSREQ;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef GVMMQUERYSTATISTICSSREQ *PGVMMQUERYSTATISTICSSREQ;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0QueryStatisticsReq(PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Request buffer for GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @see GVMMR0ResetStatistics.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef struct GVMMRESETSTATISTICSSREQ
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The header. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync SUPVMMR0REQHDR Hdr;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The support driver session. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PSUPDRVSESSION pSession;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** The statistics to reset.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Any non-zero entry will be reset (if permitted). */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync GVMMSTATS Stats;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync} GVMMRESETSTATISTICSSREQ;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** Pointer to a GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS request buffer. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsynctypedef GVMMRESETSTATISTICSSREQ *PGVMMRESETSTATISTICSSREQ;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncGVMMR0DECL(int) GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync/** @} */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync__END_DECLS
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#endif
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync