VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/VMMAll.cpp@ 17659

Last change on this file since 17659 was 17246, checked in by vboxsync, 16 years ago

Allow mixing of VT-x and software virtualization. (untested so far)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1/* $Id: VMMAll.cpp 17246 2009-03-02 12:31:50Z vboxsync $ */
2/** @file
3 * VMM All Contexts.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_VMM
27#include <VBox/vmm.h>
28#include "VMMInternal.h"
29#include <VBox/vm.h>
30#include <VBox/param.h>
31#include <VBox/hwaccm.h>
32
33
34/**
35 * Gets the bottom of the hypervisor stack - RC Ptr.
36 *
37 * (The returned address is not actually writable, only after it's decremented
38 * by a push/ret/whatever does it become writable.)
39 *
40 * @returns bottom of the stack.
41 * @param pVM The VM handle.
42 */
43RTRCPTR VMMGetStackRC(PVM pVM)
44{
45 return (RTRCPTR)pVM->vmm.s.pbEMTStackBottomRC;
46}
47
48
49/**
50 * Gets the current virtual CPU ID.
51 *
52 * @returns The CPU ID.
53 * @param pVM Pointer to the shared VM handle.
54 * @thread EMT
55 */
56VMCPUID VMMGetCpuId(PVM pVM)
57{
58#ifdef IN_RING3
59 /* Only emulation thread(s) allowed to ask for CPU id */
60 if (!VM_IS_EMT(pVM))
61 return 0;
62#endif
63
64 /* Only emulation thread(s) allowed to ask for CPU id */
65 VM_ASSERT_EMT(pVM);
66
67#if defined(IN_RC)
68 /* There is only one CPU if we're in GC. */
69 return 0;
70
71#elif defined(IN_RING3)
72 return VMR3GetVMCPUId(pVM);
73
74#else /* IN_RING0 */
75 return HWACCMGetVMCPUId(pVM);
76#endif /* IN_RING0 */
77}
78
79/**
80 * Returns the VMCPU of the current EMT thread.
81 *
82 * @returns The VMCPU pointer.
83 * @param pVM The VM to operate on.
84 */
85PVMCPU VMMGetCpu(PVM pVM)
86{
87#ifdef IN_RING3
88 /* Only emulation thread(s) allowed to ask for CPU id */
89 if (!VM_IS_EMT(pVM))
90 return &pVM->aCpus[0];
91#endif
92 /* Only emulation thread(s) allowed to ask for CPU id */
93 VM_ASSERT_EMT(pVM);
94
95#if defined(IN_RC)
96 /* There is only one CPU if we're in GC. */
97 return &pVM->aCpus[0];
98
99#elif defined(IN_RING3)
100 return &pVM->aCpus[VMR3GetVMCPUId(pVM)];
101
102#else /* IN_RING0 */
103 return &pVM->aCpus[HWACCMGetVMCPUId(pVM)];
104#endif /* IN_RING0 */
105}
106
107/**
108 * Returns the VMCPU of the specified virtual CPU.
109 *
110 * @returns The VMCPU pointer.
111 * @param pVM The VM to operate on.
112 */
113VMMDECL(PVMCPU) VMMGetCpuEx(PVM pVM, RTCPUID idCpu)
114{
115 AssertReturn(idCpu < pVM->cCPUs, NULL);
116 return &pVM->aCpus[idCpu];
117}
118
119/**
120 * Gets the VBOX_SVN_REV.
121 *
122 * This is just to avoid having to compile a bunch of big files
123 * and requires less Makefile mess.
124 *
125 * @returns VBOX_SVN_REV.
126 */
127VMMDECL(uint32_t) VMMGetSvnRev(void)
128{
129 return VBOX_SVN_REV;
130}
131
132/**
133 * Queries the current switcher
134 *
135 * @returns active switcher
136 * @param pVM VM handle.
137 */
138VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM)
139{
140 return pVM->vmm.s.enmSwitcher;
141}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette