Changeset 13667 in vbox
- Timestamp:
- Oct 29, 2008 6:27:15 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 38617
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VM.cpp
r13413 r13667 20 20 */ 21 21 22 /** @page pg_vm VM API 23 * 24 * This is the encapsulating bit. It provides the APIs that Main and VBoxBFE 25 * use to create a VMM instance for running a guest in. It also provides 26 * facilities for queuing request for execution in EMT (serialization purposes 27 * mostly) and for reporting error back to the VMM user (Main/VBoxBFE). 28 * 29 * 30 * @section sec_vm_design Design Critique / Things To Do 31 * 32 * In hindsight this component is a big design mistake, all this stuff really 33 * belongs in the VMM component. It just seemed like a kind of ok idea at a 34 * time when the VMM bit was a bit vague. 'VM' also happend to be the name of 35 * the per-VM instance structure (see vm.h), so it kind of made sense. However 36 * as it turned out, VMM(.cpp) is almost empty all it provides in ring-3 is some 37 * minor functionally and some "routing" services. 38 * 39 * Fixing this is just a matter of some more or less straight forward 40 * refactoring, the question is just when someone will get to it. 41 * 42 */ 22 43 23 44 /******************************************************************************* … … 103 124 * Internal Functions * 104 125 *******************************************************************************/ 105 static int vmR3CreateUVM(PUVM *ppUVM);106 static int vmR3CreateU(PUVM pUVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM);107 static int vmR3InitRing3(PVM pVM, PUVM pUVM);108 static int vmR3InitRing0(PVM pVM);109 static int vmR3InitGC(PVM pVM);110 static int vmR3InitDoCompleted(PVM pVM, VMINITCOMPLETED enmWhat);126 static int vmR3CreateUVM(PUVM *ppUVM); 127 static int vmR3CreateU(PUVM pUVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM); 128 static int vmR3InitRing3(PVM pVM, PUVM pUVM); 129 static int vmR3InitRing0(PVM pVM); 130 static int vmR3InitGC(PVM pVM); 131 static int vmR3InitDoCompleted(PVM pVM, VMINITCOMPLETED enmWhat); 111 132 static DECLCALLBACK(int) vmR3PowerOn(PVM pVM); 112 133 static DECLCALLBACK(int) vmR3Suspend(PVM pVM); … … 115 136 static DECLCALLBACK(int) vmR3Load(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser); 116 137 static DECLCALLBACK(int) vmR3PowerOff(PVM pVM); 117 static void vmR3DestroyUVM(PUVM pUVM);118 static void vmR3AtDtor(PVM pVM);119 static int vmR3AtResetU(PUVM pUVM);138 static void vmR3DestroyUVM(PUVM pUVM); 139 static void vmR3AtDtor(PVM pVM); 140 static int vmR3AtResetU(PUVM pUVM); 120 141 static DECLCALLBACK(int) vmR3Reset(PVM pVM); 121 142 static DECLCALLBACK(int) vmR3AtStateRegisterU(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser); … … 444 465 pVM->NativeThreadEMT = pVM->aCpus[0].hNativeThreadR3 = pUVM->vm.s.NativeThreadEMT; 445 466 446 pVM->vm.s.offVM = RT_OFFSETOF(VM, vm.s);447 448 467 /* 449 468 * Init the configuration. … … 542 561 return rc; 543 562 } 544 545 563 546 564 … … 828 846 829 847 830 831 848 /** 832 849 * Power on the virtual machine. -
trunk/src/VBox/VMM/VMEmt.cpp
r13059 r13667 43 43 #include <iprt/thread.h> 44 44 #include <iprt/time.h> 45 46 47 45 48 46 … … 852 850 853 851 854 855 852 /** 856 853 * Default VMR3Wait() worker. -
trunk/src/VBox/VMM/VMInternal.h
r12989 r13667 59 59 { 60 60 /** Pointer to the next one in the list. */ 61 PVMATRESET pNext;61 PVMATRESET pNext; 62 62 /** Callback type. */ 63 VMATRESETTYPE enmType;63 VMATRESETTYPE enmType; 64 64 /** User argument for the callback. */ 65 void *pvUser;65 void *pvUser; 66 66 /** Description. */ 67 const char *pszDesc;67 const char *pszDesc; 68 68 /** Type specific data. */ 69 69 union … … 73 73 { 74 74 /** Callback. */ 75 PFNVMATRESET pfnCallback;75 PFNVMATRESET pfnCallback; 76 76 /** Device instance. */ 77 PPDMDEVINS pDevIns;77 PPDMDEVINS pDevIns; 78 78 } Dev; 79 79 … … 82 82 { 83 83 /** Callback. */ 84 PFNVMATRESETINT pfnCallback;84 PFNVMATRESETINT pfnCallback; 85 85 } Internal; 86 86 … … 89 89 { 90 90 /** Callback. */ 91 PFNVMATRESETEXT pfnCallback;91 PFNVMATRESETEXT pfnCallback; 92 92 } External; 93 93 } u; … … 101 101 { 102 102 /** Pointer to the next one. */ 103 struct VMATSTATE *pNext;103 struct VMATSTATE *pNext; 104 104 /** Pointer to the callback. */ 105 PFNVMATSTATE pfnAtState;105 PFNVMATSTATE pfnAtState; 106 106 /** The user argument. */ 107 void *pvUser;107 void *pvUser; 108 108 } VMATSTATE; 109 109 /** Pointer to a VM state change callback. */ … … 117 117 { 118 118 /** Pointer to the next one. */ 119 struct VMATERROR *pNext;119 struct VMATERROR *pNext; 120 120 /** Pointer to the callback. */ 121 PFNVMATERROR pfnAtError;121 PFNVMATERROR pfnAtError; 122 122 /** The user argument. */ 123 void *pvUser;123 void *pvUser; 124 124 } VMATERROR; 125 125 /** Pointer to a VM error callback. */ … … 134 134 { 135 135 /** The size of the chunk. */ 136 uint32_t cbAllocated;136 uint32_t cbAllocated; 137 137 /** The current offset into the chunk. 138 138 * We start by putting the filename and function immediatly 139 139 * after the end of the buffer. */ 140 uint32_t off;140 uint32_t off; 141 141 /** Offset from the start of this structure to the file name. */ 142 uint32_t offFile;142 uint32_t offFile; 143 143 /** The line number. */ 144 uint32_t iLine;144 uint32_t iLine; 145 145 /** Offset from the start of this structure to the function name. */ 146 uint32_t offFunction;146 uint32_t offFunction; 147 147 /** Offset from the start of this structure to the formatted message text. */ 148 uint32_t offMessage;148 uint32_t offMessage; 149 149 /** The VBox status code. */ 150 int32_t rc;150 int32_t rc; 151 151 } VMERROR, *PVMERROR; 152 152 … … 158 158 { 159 159 /** Pointer to the next one. */ 160 struct VMATRUNTIMEERROR *pNext;160 struct VMATRUNTIMEERROR *pNext; 161 161 /** Pointer to the callback. */ 162 PFNVMATRUNTIMEERROR pfnAtRuntimeError;162 PFNVMATRUNTIMEERROR pfnAtRuntimeError; 163 163 /** The user argument. */ 164 void *pvUser;164 void *pvUser; 165 165 } VMATRUNTIMEERROR; 166 166 /** Pointer to a VM error callback. */ … … 175 175 { 176 176 /** The size of the chunk. */ 177 uint32_t cbAllocated;177 uint32_t cbAllocated; 178 178 /** The current offset into the chunk. 179 179 * We start by putting the error ID immediatly 180 180 * after the end of the buffer. */ 181 uint32_t off;181 uint32_t off; 182 182 /** Offset from the start of this structure to the error ID. */ 183 uint32_t offErrorID;183 uint32_t offErrorID; 184 184 /** Offset from the start of this structure to the formatted message text. */ 185 uint32_t offMessage;185 uint32_t offMessage; 186 186 /** Whether the error is fatal or not */ 187 bool fFatal;187 bool fFatal; 188 188 } VMRUNTIMEERROR, *PVMRUNTIMEERROR; 189 189 … … 211 211 212 212 /** 213 * Converts a VMM pointer into a VM pointer. 214 * @returns Pointer to the VM structure the VMM is part of. 215 * @param pVMM Pointer to VMM instance data. 216 */ 217 #define VMINT2VM(pVMM) ( (PVM)((char*)pVMM - pVMM->offVM) ) 218 219 220 /** 221 * VM Internal Data (part of VM) 213 * VM Internal Data (part of the VM structure). 214 * 215 * @todo Move this and all related things to VMM. The VM component was, to some 216 * extent at least, a bad ad hoc design which should all have been put in 217 * VMM. @see pg_vm. 222 218 */ 223 219 typedef struct VMINT 224 220 { 225 /** Offset to the VM structure.226 * See VMINT2VM(). */227 RTINT offVM;228 221 /** VM Error Message. */ 229 222 R3PTRTYPE(PVMERROR) pErrorR3; 230 223 /** VM Runtime Error Message. */ 231 224 R3PTRTYPE(PVMRUNTIMEERROR) pRuntimeErrorR3; 232 /** Set by VMR3SuspendNoSave; cleared by VMR3Resume; signals the VM is in an inconsistent state and saving is not allowed. */ 225 /** Set by VMR3SuspendNoSave; cleared by VMR3Resume; signals the VM is in an 226 * inconsistent state and saving is not allowed. */ 233 227 bool fPreventSaveState; 234 } VMINT, *PVMINT; 228 } VMINT; 229 /** Pointer to the VM Internal Data (part of the VM structure). */ 230 typedef VMINT *PVMINT; 235 231 236 232 … … 417 413 418 414 419 DECLCALLBACK(int) vmR3EmulationThread(RTTHREAD ThreadSelf, void *pvArg);420 int vmR3SetHaltMethodU(PUVM pUVM, VMHALTMETHOD enmHaltMethod);421 DECLCALLBACK(int) vmR3Destroy(PVM pVM);422 DECLCALLBACK(void) vmR3SetErrorUV(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list *args);423 void vmSetErrorCopy(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args);424 DECLCALLBACK(void) vmR3SetRuntimeErrorV(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list *args);425 void vmSetRuntimeErrorCopy(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list args);426 void vmR3DestroyFinalBitFromEMT(PUVM pUVM);427 void vmR3SetState(PVM pVM, VMSTATE enmStateNew);415 DECLCALLBACK(int) vmR3EmulationThread(RTTHREAD ThreadSelf, void *pvArg); 416 int vmR3SetHaltMethodU(PUVM pUVM, VMHALTMETHOD enmHaltMethod); 417 DECLCALLBACK(int) vmR3Destroy(PVM pVM); 418 DECLCALLBACK(void) vmR3SetErrorUV(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list *args); 419 void vmSetErrorCopy(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args); 420 DECLCALLBACK(void) vmR3SetRuntimeErrorV(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list *args); 421 void vmSetRuntimeErrorCopy(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list args); 422 void vmR3DestroyFinalBitFromEMT(PUVM pUVM); 423 void vmR3SetState(PVM pVM, VMSTATE enmStateNew); 428 424 429 425 -
trunk/src/VBox/VMM/VMMAll/VMAll.cpp
r12989 r13667 226 226 */ 227 227 VMMDECL(int) VMSetRuntimeError(PVM pVM, bool fFatal, const char *pszErrorID, 228 const char *pszFormat, ...)228 const char *pszFormat, ...) 229 229 { 230 230 va_list args; … … 379 379 } 380 380 } 381
Note:
See TracChangeset
for help on using the changeset viewer.