VirtualBox

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

Last change on this file since 14446 was 13974, checked in by vboxsync, 16 years ago

Non-EMT threads get CPU 0 by default.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1/* $Id: VMMAll.cpp 13974 2008-11-07 16:28:05Z 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#ifndef IN_RING0
35/**
36 * Gets the bottom of the hypervisor stack - RC Ptr.
37 *
38 * (The returned address is not actually writable, only after it's decremented
39 * by a push/ret/whatever does it become writable.)
40 *
41 * @returns bottom of the stack.
42 * @param pVM The VM handle.
43 */
44RTRCPTR VMMGetStackRC(PVM pVM)
45{
46 return (RTRCPTR)pVM->vmm.s.pbEMTStackBottomRC;
47}
48#endif /* !IN_RING0 */
49
50
51/**
52 * Gets the current virtual CPU ID.
53 *
54 * @returns The CPU ID.
55 * @param pVM Pointer to the shared VM handle.
56 * @thread EMT
57 */
58VMCPUID VMMGetCpuId(PVM pVM)
59{
60#ifdef IN_RING3
61 /* Only emulation thread(s) allowed to ask for CPU id */
62 if (!VM_IS_EMT(pVM))
63 return 0;
64#endif
65
66 /* Only emulation thread(s) allowed to ask for CPU id */
67 VM_ASSERT_EMT(pVM);
68
69#if defined(IN_RC)
70 /* There is only one CPU if we're in GC. */
71 return 0;
72
73#elif defined(IN_RING3)
74 return VMR3GetVMCPUId(pVM);
75
76#else /* IN_RING0 */
77 return HWACCMGetVMCPUId(pVM);
78#endif /* IN_RING0 */
79}
80
81/**
82 * Returns the VMCPU of the current EMT thread.
83 *
84 * @returns The VMCPU pointer.
85 * @param pVM The VM to operate on.
86 */
87PVMCPU VMMGetCpu(PVM pVM)
88{
89#ifdef IN_RING3
90 /* Only emulation thread(s) allowed to ask for CPU id */
91 if (!VM_IS_EMT(pVM))
92 return &pVM->aCpus[0];
93#endif
94 /* Only emulation thread(s) allowed to ask for CPU id */
95 VM_ASSERT_EMT(pVM);
96
97#if defined(IN_RC)
98 /* There is only one CPU if we're in GC. */
99 return &pVM->aCpus[0];
100
101#elif defined(IN_RING3)
102 return &pVM->aCpus[VMR3GetVMCPUId(pVM)];
103
104#else /* IN_RING0 */
105 return &pVM->aCpus[HWACCMGetVMCPUId(pVM)];
106#endif /* IN_RING0 */
107}
108
109/**
110 * Returns the VMCPU of the specified virtual CPU.
111 *
112 * @returns The VMCPU pointer.
113 * @param pVM The VM to operate on.
114 */
115VMMDECL(PVMCPU) VMMGetCpuEx(PVM pVM, RTCPUID idCpu)
116{
117 AssertReturn(idCpu < pVM->cCPUs, NULL);
118 return &pVM->aCpus[idCpu];
119}
120
121/**
122 * Gets the VBOX_SVN_REV.
123 *
124 * This is just to avoid having to compile a bunch of big files
125 * and requires less Makefile mess.
126 *
127 * @returns VBOX_SVN_REV.
128 */
129VMMDECL(uint32_t) VMMGetSvnRev(void)
130{
131 return VBOX_SVN_REV;
132}
133
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