VirtualBox

Changeset 13667 in vbox


Ignore:
Timestamp:
Oct 29, 2008 6:27:15 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
38617
Message:

#1865: VM.

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VM.cpp

    r13413 r13667  
    2020 */
    2121
     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 */
    2243
    2344/*******************************************************************************
     
    103124*   Internal Functions                                                         *
    104125*******************************************************************************/
    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);
     126static int               vmR3CreateUVM(PUVM *ppUVM);
     127static int               vmR3CreateU(PUVM pUVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM);
     128static int               vmR3InitRing3(PVM pVM, PUVM pUVM);
     129static int               vmR3InitRing0(PVM pVM);
     130static int               vmR3InitGC(PVM pVM);
     131static int               vmR3InitDoCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
    111132static DECLCALLBACK(int) vmR3PowerOn(PVM pVM);
    112133static DECLCALLBACK(int) vmR3Suspend(PVM pVM);
     
    115136static DECLCALLBACK(int) vmR3Load(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
    116137static DECLCALLBACK(int) vmR3PowerOff(PVM pVM);
    117 static void vmR3DestroyUVM(PUVM pUVM);
    118 static void vmR3AtDtor(PVM pVM);
    119 static int  vmR3AtResetU(PUVM pUVM);
     138static void              vmR3DestroyUVM(PUVM pUVM);
     139static void              vmR3AtDtor(PVM pVM);
     140static int               vmR3AtResetU(PUVM pUVM);
    120141static DECLCALLBACK(int) vmR3Reset(PVM pVM);
    121142static DECLCALLBACK(int) vmR3AtStateRegisterU(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);
     
    444465        pVM->NativeThreadEMT = pVM->aCpus[0].hNativeThreadR3 = pUVM->vm.s.NativeThreadEMT;
    445466
    446         pVM->vm.s.offVM = RT_OFFSETOF(VM, vm.s);
    447 
    448467        /*
    449468         * Init the configuration.
     
    542561    return rc;
    543562}
    544 
    545563
    546564
     
    828846
    829847
    830 
    831848/**
    832849 * Power on the virtual machine.
  • trunk/src/VBox/VMM/VMEmt.cpp

    r13059 r13667  
    4343#include <iprt/thread.h>
    4444#include <iprt/time.h>
    45 
    46 
    4745
    4846
     
    852850
    853851
    854 
    855852/**
    856853 * Default VMR3Wait() worker.
  • trunk/src/VBox/VMM/VMInternal.h

    r12989 r13667  
    5959{
    6060    /** Pointer to the next one in the list. */
    61     PVMATRESET      pNext;
     61    PVMATRESET                      pNext;
    6262    /** Callback type. */
    63     VMATRESETTYPE   enmType;
     63    VMATRESETTYPE                   enmType;
    6464    /** User argument for the callback. */
    65     void           *pvUser;
     65    void                           *pvUser;
    6666    /** Description. */
    67     const char     *pszDesc;
     67    const char                     *pszDesc;
    6868    /** Type specific data. */
    6969    union
     
    7373        {
    7474            /** Callback. */
    75             PFNVMATRESET    pfnCallback;
     75            PFNVMATRESET            pfnCallback;
    7676            /** Device instance. */
    77             PPDMDEVINS      pDevIns;
     77            PPDMDEVINS              pDevIns;
    7878        } Dev;
    7979
     
    8282        {
    8383            /** Callback. */
    84             PFNVMATRESETINT pfnCallback;
     84            PFNVMATRESETINT         pfnCallback;
    8585        } Internal;
    8686
     
    8989        {
    9090            /** Callback. */
    91             PFNVMATRESETEXT pfnCallback;
     91            PFNVMATRESETEXT         pfnCallback;
    9292        } External;
    9393    } u;
     
    101101{
    102102    /** Pointer to the next one. */
    103     struct VMATSTATE   *pNext;
     103    struct VMATSTATE               *pNext;
    104104    /** Pointer to the callback. */
    105     PFNVMATSTATE        pfnAtState;
     105    PFNVMATSTATE                    pfnAtState;
    106106    /** The user argument. */
    107     void               *pvUser;
     107    void                           *pvUser;
    108108} VMATSTATE;
    109109/** Pointer to a VM state change callback. */
     
    117117{
    118118    /** Pointer to the next one. */
    119     struct VMATERROR   *pNext;
     119    struct VMATERROR               *pNext;
    120120    /** Pointer to the callback. */
    121     PFNVMATERROR        pfnAtError;
     121    PFNVMATERROR                    pfnAtError;
    122122    /** The user argument. */
    123     void               *pvUser;
     123    void                           *pvUser;
    124124} VMATERROR;
    125125/** Pointer to a VM error callback. */
     
    134134{
    135135    /** The size of the chunk. */
    136     uint32_t                cbAllocated;
     136    uint32_t                        cbAllocated;
    137137    /** The current offset into the chunk.
    138138     * We start by putting the filename and function immediatly
    139139     * after the end of the buffer. */
    140     uint32_t                off;
     140    uint32_t                        off;
    141141    /** Offset from the start of this structure to the file name. */
    142     uint32_t                offFile;
     142    uint32_t                        offFile;
    143143    /** The line number. */
    144     uint32_t                iLine;
     144    uint32_t                        iLine;
    145145    /** Offset from the start of this structure to the function name. */
    146     uint32_t                offFunction;
     146    uint32_t                        offFunction;
    147147    /** Offset from the start of this structure to the formatted message text. */
    148     uint32_t                offMessage;
     148    uint32_t                        offMessage;
    149149    /** The VBox status code. */
    150     int32_t                 rc;
     150    int32_t                         rc;
    151151} VMERROR, *PVMERROR;
    152152
     
    158158{
    159159    /** Pointer to the next one. */
    160     struct VMATRUNTIMEERROR *pNext;
     160    struct VMATRUNTIMEERROR         *pNext;
    161161    /** Pointer to the callback. */
    162     PFNVMATRUNTIMEERROR      pfnAtRuntimeError;
     162    PFNVMATRUNTIMEERROR              pfnAtRuntimeError;
    163163    /** The user argument. */
    164     void                    *pvUser;
     164    void                            *pvUser;
    165165} VMATRUNTIMEERROR;
    166166/** Pointer to a VM error callback. */
     
    175175{
    176176    /** The size of the chunk. */
    177     uint32_t                cbAllocated;
     177    uint32_t                        cbAllocated;
    178178    /** The current offset into the chunk.
    179179     * We start by putting the error ID immediatly
    180180     * after the end of the buffer. */
    181     uint32_t                off;
     181    uint32_t                        off;
    182182    /** Offset from the start of this structure to the error ID. */
    183     uint32_t                offErrorID;
     183    uint32_t                        offErrorID;
    184184    /** Offset from the start of this structure to the formatted message text. */
    185     uint32_t                offMessage;
     185    uint32_t                        offMessage;
    186186    /** Whether the error is fatal or not */
    187     bool                    fFatal;
     187    bool                            fFatal;
    188188} VMRUNTIMEERROR, *PVMRUNTIMEERROR;
    189189
     
    211211
    212212/**
    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.
    222218 */
    223219typedef struct VMINT
    224220{
    225     /** Offset to the VM structure.
    226      * See VMINT2VM(). */
    227     RTINT                           offVM;
    228221    /** VM Error Message. */
    229222    R3PTRTYPE(PVMERROR)             pErrorR3;
    230223    /** VM Runtime Error Message. */
    231224    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. */
    233227    bool                            fPreventSaveState;
    234 } VMINT, *PVMINT;
     228} VMINT;
     229/** Pointer to the VM Internal Data (part of the VM structure). */
     230typedef VMINT *PVMINT;
    235231
    236232
     
    417413
    418414
    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);
     415DECLCALLBACK(int)   vmR3EmulationThread(RTTHREAD ThreadSelf, void *pvArg);
     416int                 vmR3SetHaltMethodU(PUVM pUVM, VMHALTMETHOD enmHaltMethod);
     417DECLCALLBACK(int)   vmR3Destroy(PVM pVM);
     418DECLCALLBACK(void)  vmR3SetErrorUV(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list *args);
     419void                vmSetErrorCopy(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args);
     420DECLCALLBACK(void)  vmR3SetRuntimeErrorV(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list *args);
     421void                vmSetRuntimeErrorCopy(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list args);
     422void                vmR3DestroyFinalBitFromEMT(PUVM pUVM);
     423void                vmR3SetState(PVM pVM, VMSTATE enmStateNew);
    428424
    429425
  • trunk/src/VBox/VMM/VMMAll/VMAll.cpp

    r12989 r13667  
    226226 */
    227227VMMDECL(int) VMSetRuntimeError(PVM pVM, bool fFatal, const char *pszErrorID,
    228                               const char *pszFormat, ...)
     228                               const char *pszFormat, ...)
    229229{
    230230    va_list args;
     
    379379    }
    380380}
     381
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette