VirtualBox

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

Last change on this file since 22890 was 22890, checked in by vboxsync, 15 years ago

VM::cCPUs -> VM::cCpus so it matches all the other cCpus and aCpus members.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1/* $Id: VMMAll.cpp 22890 2009-09-09 23:11:31Z 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/vmm.h>
31#include <VBox/param.h>
32#include <VBox/hwaccm.h>
33#include <iprt/buildconfig.h>
34
35
36/**
37 * Gets the bottom of the hypervisor stack - RC Ptr.
38 *
39 * (The returned address is not actually writable, only after it's decremented
40 * by a push/ret/whatever does it become writable.)
41 *
42 * @returns bottom of the stack.
43 * @param pVM The VM handle.
44 */
45VMMDECL(RTRCPTR) VMMGetStackRC(PVM pVM)
46{
47 PVMCPU pVCpu = VMMGetCpu(pVM);
48 Assert(pVCpu);
49
50 return (RTRCPTR)pVCpu->vmm.s.pbEMTStackBottomRC;
51}
52
53
54/**
55 * Gets the ID virtual of the virtual CPU assoicated with the calling thread.
56 *
57 * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT.
58 *
59 * @param pVM Pointer to the shared VM handle.
60 */
61VMMDECL(VMCPUID) VMMGetCpuId(PVM pVM)
62{
63#if defined(IN_RING3)
64 return VMR3GetVMCPUId(pVM);
65
66#elif defined(IN_RING0)
67 if (pVM->cCpus == 1)
68 return 0;
69 return HWACCMR0GetVMCPUId(pVM);
70
71#else /* RC: Always EMT(0) */
72 return 0;
73#endif
74}
75
76
77/**
78 * Returns the VMCPU of the calling EMT.
79 *
80 * @returns The VMCPU pointer. NULL if not an EMT.
81 *
82 * @param pVM The VM to operate on.
83 */
84VMMDECL(PVMCPU) VMMGetCpu(PVM pVM)
85{
86#ifdef IN_RING3
87 VMCPUID idCpu = VMR3GetVMCPUId(pVM);
88 if (idCpu == NIL_VMCPUID)
89 return NULL;
90 Assert(idCpu < pVM->cCpus);
91 return &pVM->aCpus[VMR3GetVMCPUId(pVM)];
92
93#elif defined(IN_RING0)
94 if (pVM->cCpus == 1)
95 return &pVM->aCpus[0];
96 return HWACCMR0GetVMCPU(pVM);
97
98#else /* RC: Always EMT(0) */
99 return &pVM->aCpus[0];
100#endif /* IN_RING0 */
101}
102
103
104/**
105 * Returns the VMCPU of the first EMT thread.
106 *
107 * @returns The VMCPU pointer.
108 * @param pVM The VM to operate on.
109 */
110VMMDECL(PVMCPU) VMMGetCpu0(PVM pVM)
111{
112 Assert(pVM->cCpus == 1);
113 return &pVM->aCpus[0];
114}
115
116
117/**
118 * Returns the VMCPU of the specified virtual CPU.
119 *
120 * @returns The VMCPU pointer. NULL if idCpu is invalid.
121 *
122 * @param pVM The VM to operate on.
123 * @param idCpu The ID of the virtual CPU.
124 */
125VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, RTCPUID idCpu)
126{
127 AssertReturn(idCpu < pVM->cCpus, NULL);
128 return &pVM->aCpus[idCpu];
129}
130
131
132/**
133 * Gets the VBOX_SVN_REV.
134 *
135 * This is just to avoid having to compile a bunch of big files
136 * and requires less Makefile mess.
137 *
138 * @returns VBOX_SVN_REV.
139 */
140VMMDECL(uint32_t) VMMGetSvnRev(void)
141{
142 return RTBldCfgRevision();
143}
144
145
146/**
147 * Queries the current switcher
148 *
149 * @returns active switcher
150 * @param pVM VM handle.
151 */
152VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM)
153{
154 return pVM->vmm.s.enmSwitcher;
155}
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