VirtualBox

Changeset 6796 in vbox for trunk/src/VBox/VMM/VMInternal.h


Ignore:
Timestamp:
Feb 4, 2008 6:19:58 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27892
Message:

Fixed init problems wrt. VM ownership by implementing the UVM structure (U = user mode) and moving problematic ring-3 stuff over there (emt+reqs, r3heap, stam, loader[VMMR0.r0]). Big change, but it works fine here... :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMInternal.h

    r6398 r6796  
    192192    /** The usual invalid value. */
    193193    VMHALTMETHOD_INVALID = 0,
     194    /** Use the method used during bootstrapping. */
     195    VMHALTMETHOD_BOOTSTRAP,
    194196    /** Use the default method. */
    195197    VMHALTMETHOD_DEFAULT,
     
    223225     * See VMINT2VM(). */
    224226    RTINT                           offVM;
    225 
    226     /** List of registered reset callbacks. */
    227     R3PTRTYPE(PVMATRESET)           pAtReset;
    228     /** List of registered reset callbacks. */
    229     R3PTRTYPE(PVMATRESET *)         ppAtResetNext;
    230 
    231     /** List of registered state change callbacks. */
    232     R3PTRTYPE(PVMATSTATE)           pAtState;
    233     /** List of registered state change callbacks. */
    234     R3PTRTYPE(PVMATSTATE *)         ppAtStateNext;
    235 
    236     /** List of registered error callbacks. */
    237     R3PTRTYPE(PVMATERROR)           pAtError;
    238     /** List of registered error callbacks. */
    239     R3PTRTYPE(PVMATERROR *)         ppAtErrorNext;
    240 
    241     /** List of registered error callbacks. */
    242     R3PTRTYPE(PVMATRUNTIMEERROR)    pAtRuntimeError;
    243     /** List of registered error callbacks. */
    244     R3PTRTYPE(PVMATRUNTIMEERROR *)  ppAtRuntimeErrorNext;
    245 
     227    /** VM Error Message. */
     228    R3PTRTYPE(PVMERROR)             pErrorR3;
     229    /** VM Runtime Error Message. */
     230    R3PTRTYPE(PVMRUNTIMEERROR)      pRuntimeErrorR3;
     231    /** Set by VMR3SuspendNoSave; cleared by VMR3Resume; signals the VM is in an inconsistent state and saving is not allowed. */
     232    bool                            fPreventSaveState;
     233} VMINT, *PVMINT;
     234
     235
     236/**
     237 * VM internal data kept in the UVM.
     238 */
     239typedef struct VMINTUSERPERVM
     240{
    246241    /** Head of the request queue. Atomic. */
    247     volatile R3PTRTYPE(PVMREQ)      pReqs;
     242    volatile PVMREQ                 pReqs;
    248243    /** The last index used during alloc/free. */
    249244    volatile uint32_t               iReqFree;
    250     /** Array of pointers to lists of free request packets. Atomic. */
    251     volatile R3PTRTYPE(PVMREQ)      apReqFree[9];
    252245    /** Number of free request packets. */
    253246    volatile uint32_t               cReqFree;
    254 
     247    /** Array of pointers to lists of free request packets. Atomic. */
     248    volatile PVMREQ                 apReqFree[9];
     249
     250#ifdef VBOX_WITH_STATISTICS
     251    /** Number of VMR3ReqAlloc returning a new packet. */
     252    STAMCOUNTER                     StatReqAllocNew;
     253    /** Number of VMR3ReqAlloc causing races. */
     254    STAMCOUNTER                     StatReqAllocRaces;
     255    /** Number of VMR3ReqAlloc returning a recycled packet. */
     256    STAMCOUNTER                     StatReqAllocRecycled;
     257    /** Number of VMR3ReqFree calls. */
     258    STAMCOUNTER                     StatReqFree;
     259    /** Number of times the request was actually freed. */
     260    STAMCOUNTER                     StatReqFreeOverflow;
     261#endif
     262
     263    /** Pointer to the support library session.
     264     * Mainly for creation and destruction.. */
     265    PSUPDRVSESSION                  pSession;
     266
     267    /** The handle to the EMT thread. */
     268    RTTHREAD                        ThreadEMT;
     269    /** The native of the EMT thread. */
     270    RTNATIVETHREAD                  NativeThreadEMT;
     271    /** Wait event semaphore. */
     272    RTSEMEVENT                      EventSemWait;
    255273    /** Wait/Idle indicator. */
    256     volatile uint32_t               fWait;
    257     /** Wait event semaphore. */
    258     R3PTRTYPE(RTSEMEVENT)           EventSemWait;
    259 
    260     /** VM Error Message. */
    261     R3PTRTYPE(PVMERROR)             pErrorR3;
    262 
    263     /** VM Runtime Error Message. */
    264     R3PTRTYPE(PVMRUNTIMEERROR)      pRuntimeErrorR3;
    265 
    266     /** Pointer to the DBGC instance data. */
    267     R3PTRTYPE(void *)               pvDBGC;
    268 
     274    bool volatile                   fWait;
     275    /** Force EMT to terminate. */
     276    bool volatile                   fTerminateEMT;
    269277    /** If set the EMT does the final VM cleanup when it exits.
    270278     * If clear the VMR3Destroy() caller does so. */
    271279    bool                            fEMTDoesTheCleanup;
    272 
    273     /** Set by VMR3SuspendNoSave; cleared by VMR3Resume; signals the VM is in an inconsistent state and saving is not allowed. */
    274     bool                            fPreventSaveState;
    275 
    276     /** vmR3EmulationThread longjmp buffer
    277      * @todo r=bird: requires union with padding. See EMInternal.h. */
    278     jmp_buf                         emtJumpEnv;
    279280
    280281    /** @name Generic Halt data
     
    374375    }                               Halt;
    375376
    376     /** @} */
    377 
    378     /** Number of VMR3ReqAlloc returning a new packet. */
    379     STAMCOUNTER                     StatReqAllocNew;
    380     /** Number of VMR3ReqAlloc causing races. */
    381     STAMCOUNTER                     StatReqAllocRaces;
    382     /** Number of VMR3ReqAlloc returning a recycled packet. */
    383     STAMCOUNTER                     StatReqAllocRecycled;
    384     /** Number of VMR3ReqFree calls. */
    385     STAMCOUNTER                     StatReqFree;
    386     /** Number of times the request was actually freed. */
    387     STAMCOUNTER                     StatReqFreeOverflow;
    388 
    389     /** Profiling the halted state; yielding vs blocking. */
     377    /** Profiling the halted state; yielding vs blocking.
     378     * @{ */
    390379    STAMPROFILE                     StatHaltYield;
    391380    STAMPROFILE                     StatHaltBlock;
    392381    STAMPROFILE                     StatHaltTimers;
    393382    STAMPROFILE                     StatHaltPoll;
    394 } VMINT, *PVMINT;
    395 
    396 
    397 /**
    398  * Emulation thread arguments.
    399  */
    400 typedef struct VMEMULATIONTHREADARGS
    401 {
    402     /** Pointer to the VM structure. */
    403     PVM     pVM;
    404 } VMEMULATIONTHREADARGS;
    405 /** Pointer to the emulation thread arguments. */
    406 typedef VMEMULATIONTHREADARGS *PVMEMULATIONTHREADARGS;
     383    /** @} */
     384
     385
     386    /** List of registered reset callbacks. */
     387    PVMATRESET                      pAtReset;
     388    /** List of registered reset callbacks. */
     389    PVMATRESET                     *ppAtResetNext;
     390
     391    /** List of registered state change callbacks. */
     392    PVMATSTATE                      pAtState;
     393    /** List of registered state change callbacks. */
     394    PVMATSTATE                     *ppAtStateNext;
     395
     396    /** List of registered error callbacks. */
     397    PVMATERROR                      pAtError;
     398    /** List of registered error callbacks. */
     399    PVMATERROR                     *ppAtErrorNext;
     400
     401    /** List of registered error callbacks. */
     402    PVMATRUNTIMEERROR               pAtRuntimeError;
     403    /** List of registered error callbacks. */
     404    PVMATRUNTIMEERROR              *ppAtRuntimeErrorNext;
     405
     406    /** Pointer to the DBGC instance data. */
     407    void                           *pvDBGC;
     408
     409
     410    /** vmR3EmulationThread longjmp buffer. Must be last in the structure. */
     411    jmp_buf                         emtJumpEnv;
     412} VMINTUSERPERVM;
     413
     414/** Pointer to the VM internal data kept in the UVM. */
     415typedef VMINTUSERPERVM *PVMINTUSERPERVM;
     416
    407417
    408418DECLCALLBACK(int) vmR3EmulationThread(RTTHREAD ThreadSelf, void *pvArg);
    409 int vmR3SetHaltMethod(PVM pVM, VMHALTMETHOD enmHaltMethod);
     419int vmR3SetHaltMethodU(PUVM pUVM, VMHALTMETHOD enmHaltMethod);
    410420DECLCALLBACK(int) vmR3Destroy(PVM pVM);
    411 DECLCALLBACK(void) vmR3SetErrorV(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list *args);
     421DECLCALLBACK(void) vmR3SetErrorUV(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list *args);
    412422void vmSetErrorCopy(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args);
    413423DECLCALLBACK(void) vmR3SetRuntimeErrorV(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list *args);
    414424void vmSetRuntimeErrorCopy(PVM pVM, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list args);
    415 void vmR3DestroyFinalBit(PVM pVM);
     425void vmR3DestroyFinalBitFromEMT(PUVM pUVM);
    416426void vmR3SetState(PVM pVM, VMSTATE enmStateNew);
    417427
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