VirtualBox

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

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

VMMGetStackRC change

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