1 | /* $Id: VMMAll.cpp 13898 2008-11-06 09:44:29Z 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 | */
|
---|
44 | RTRCPTR 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 | */
|
---|
58 | VMCPUID VMMGetCpuId(PVM pVM)
|
---|
59 | {
|
---|
60 | /* Only emulation thread(s) allowed to ask for CPU id */
|
---|
61 | VM_ASSERT_EMT(pVM);
|
---|
62 |
|
---|
63 | #if defined(IN_RC)
|
---|
64 | /* There is only one CPU if we're in GC. */
|
---|
65 | return 0;
|
---|
66 |
|
---|
67 | #elif defined(IN_RING3)
|
---|
68 | return VMR3GetVMCPUId(pVM);
|
---|
69 |
|
---|
70 | #else /* IN_RING0 */
|
---|
71 | return HWACCMGetVMCPUId(pVM);
|
---|
72 | #endif /* IN_RING0 */
|
---|
73 | }
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Returns the VMCPU of the current EMT thread.
|
---|
77 | *
|
---|
78 | * @returns The VMCPU pointer.
|
---|
79 | * @param pVM The VM to operate on.
|
---|
80 | */
|
---|
81 | PVMCPU VMMGetCpu(PVM pVM)
|
---|
82 | {
|
---|
83 | /* Only emulation thread(s) allowed to ask for CPU id */
|
---|
84 | VM_ASSERT_EMT(pVM);
|
---|
85 |
|
---|
86 | #if defined(IN_RC)
|
---|
87 | /* There is only one CPU if we're in GC. */
|
---|
88 | return &pVM->aCpus[0];
|
---|
89 |
|
---|
90 | #elif defined(IN_RING3)
|
---|
91 | return &pVM->aCpus[VMR3GetVMCPUId(pVM)];
|
---|
92 |
|
---|
93 | #else /* IN_RING0 */
|
---|
94 | return &pVM->aCpus[HWACCMGetVMCPUId(pVM)];
|
---|
95 | #endif /* IN_RING0 */
|
---|
96 | }
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Gets the VBOX_SVN_REV.
|
---|
100 | *
|
---|
101 | * This is just to avoid having to compile a bunch of big files
|
---|
102 | * and requires less Makefile mess.
|
---|
103 | *
|
---|
104 | * @returns VBOX_SVN_REV.
|
---|
105 | */
|
---|
106 | VMMDECL(uint32_t) VMMGetSvnRev(void)
|
---|
107 | {
|
---|
108 | return VBOX_SVN_REV;
|
---|
109 | }
|
---|
110 |
|
---|