Changeset 19293 in vbox for trunk/src/VBox/VMM/VMMAll/VMMAll.cpp
- Timestamp:
- May 1, 2009 4:11:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/VMMAll.cpp
r19228 r19293 48 48 49 49 /** 50 * Gets the current virtual CPU ID.50 * Gets the ID virtual of the virtual CPU assoicated with the calling thread. 51 51 * 52 * @returns The CPU ID. 52 * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT. 53 * 53 54 * @param pVM Pointer to the shared VM handle. 54 * @thread EMT55 55 */ 56 56 VMMDECL(VMCPUID) VMMGetCpuId(PVM pVM) 57 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 58 #if defined(IN_RING3) 59 return VMR3GetVMCPUId(pVM); 63 60 64 /* Only emulation thread(s) allowed to ask for CPU id */ 61 #elif defined(IN_RING0) 62 /* ASSUME that only EMTs calls this function in R0. */ 65 63 VM_ASSERT_EMT(pVM); 66 67 /* Shortcut for one CPU */68 64 if (pVM->cCPUs == 1) 69 65 return 0; 66 return HWACCMR0GetVMCPUId(pVM); 70 67 71 #if defined(IN_RING3) 72 return VMR3GetVMCPUId(pVM); 73 #elif defined(IN_RING0) 74 return HWACCMR0GetVMCPUId(pVM); 75 #endif /* IN_RING0 */ 76 77 AssertFailed(); 68 #else /* RC: Always EMT(0) */ 78 69 return 0; 70 #endif 79 71 } 80 72 73 81 74 /** 82 * Returns the VMCPU of the c urrent EMT thread.75 * Returns the VMCPU of the calling EMT. 83 76 * 84 * @returns The VMCPU pointer. 77 * @returns The VMCPU pointer. NULL if not an EMT. 78 * 85 79 * @param pVM The VM to operate on. 86 80 */ … … 88 82 { 89 83 #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 */ 84 VMCPUID idCpu = VMR3GetVMCPUId(pVM); 85 if (idCpu == NIL_VMCPUID) 86 return NULL; 87 Assert(idCpu < pVM->cCPUs); 88 return &pVM->aCpus[VMR3GetVMCPUId(pVM)]; 89 90 #elif defined(IN_RING0) 91 /* ASSUME that only EMTs calls this function in R0. */ 95 92 VM_ASSERT_EMT(pVM); 96 97 /* Shortcut for one CPU */98 93 if (pVM->cCPUs == 1) 99 94 return &pVM->aCpus[0]; 95 return HWACCMR0GetVMCPU(pVM); 100 96 101 #ifdef IN_RING3 102 return &pVM->aCpus[VMR3GetVMCPUId(pVM)]; 103 #elif defined(IN_RING0) 104 return HWACCMR0GetVMCPU(pVM); 97 #else /* RC: Always EMT(0) */ 98 return &pVM->aCpus[0]; 105 99 #endif /* IN_RING0 */ 100 } 106 101 107 AssertFailed();108 return &pVM->aCpus[0];109 }110 102 111 103 /** … … 121 113 } 122 114 115 123 116 /** 124 117 * Returns the VMCPU of the specified virtual CPU. 125 118 * 126 * @returns The VMCPU pointer. 119 * @returns The VMCPU pointer. NULL if idCpu is invalid. 120 * 127 121 * @param pVM The VM to operate on. 122 * @param idCpu The ID of the virtual CPU. 128 123 */ 129 VMMDECL(PVMCPU) VMMGetCpu Ex(PVM pVM, RTCPUID idCpu)124 VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, RTCPUID idCpu) 130 125 { 131 126 AssertReturn(idCpu < pVM->cCPUs, NULL); 132 127 return &pVM->aCpus[idCpu]; 133 128 } 129 134 130 135 131 /** … … 146 142 } 147 143 144 148 145 /** 149 146 * Queries the current switcher … … 156 153 return pVM->vmm.s.enmSwitcher; 157 154 } 155
Note:
See TracChangeset
for help on using the changeset viewer.