VirtualBox

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

Last change on this file since 18976 was 18927, checked in by vboxsync, 16 years ago

Big step to separate VMM data structures for guest SMP. (pgm, em)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1/* $Id: VMMAll.cpp 18927 2009-04-16 11:41:38Z 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 */
43VMMDECL(RTRCPTR) 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 */
56VMMDECL(VMCPUID) 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 */
85VMMDECL(PVMCPU) 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 first EMT thread.
109 *
110 * @returns The VMCPU pointer.
111 * @param pVM The VM to operate on.
112 */
113VMMDECL(PVMCPU) VMMGetCpu0(PVM pVM)
114{
115 Assert(pVM->cCPUs == 1);
116 return &pVM->aCpus[0];
117}
118
119/**
120 * Returns the VMCPU of the specified virtual CPU.
121 *
122 * @returns The VMCPU pointer.
123 * @param pVM The VM to operate on.
124 */
125VMMDECL(PVMCPU) VMMGetCpuEx(PVM pVM, RTCPUID idCpu)
126{
127 AssertReturn(idCpu < pVM->cCPUs, NULL);
128 return &pVM->aCpus[idCpu];
129}
130
131/**
132 * Gets the VBOX_SVN_REV.
133 *
134 * This is just to avoid having to compile a bunch of big files
135 * and requires less Makefile mess.
136 *
137 * @returns VBOX_SVN_REV.
138 */
139VMMDECL(uint32_t) VMMGetSvnRev(void)
140{
141 return VBOX_SVN_REV;
142}
143
144/**
145 * Queries the current switcher
146 *
147 * @returns active switcher
148 * @param pVM VM handle.
149 */
150VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM)
151{
152 return pVM->vmm.s.enmSwitcher;
153}
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