VirtualBox

Changeset 19435 in vbox for trunk/include/VBox


Ignore:
Timestamp:
May 6, 2009 2:01:15 PM (16 years ago)
Author:
vboxsync
Message:

VMM: VMCPU::enmState.

Location:
trunk/include/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vm.h

    r19434 r19435  
    4545
    4646/**
    47  * The state of a virtual CPU.
    48  *
    49  * The VM running states are a sub-states of the VMSTATE_RUNNING state. While
    50  * VMCPUSTATE_NOT_RUNNING is a place holder for the other VM states.
     47 * The state of a Virtual CPU.
     48 *
     49 * The basic state indicated here is whether the CPU has been started or not. In
     50 * addition, there are sub-states when started for assisting scheduling (GVMM
     51 * mostly).
     52 *
     53 * The transision out of the STOPPED state is done by a vmR3PowerOn.
     54 * The transision back to the STOPPED state is done by vmR3PowerOff.
     55 *
     56 * (Alternatively we could let vmR3PowerOn start CPU 0 only and let the SPIP
     57 * handling switch on the other CPUs. Then vmR3Reset would stop all but CPU 0.)
    5158 */
    5259typedef enum VMCPUSTATE
     
    5562    VMCPUSTATE_INVALID = 0,
    5663
    57     /** Running guest code (VM running). */
    58     VMCPUSTATE_RUN_EXEC,
    59     /** Running guest code in the recompiler (VM running). */
    60     VMCPUSTATE_RUN_EXEC_REM,
    61     /** Halted (VM running). */
    62     VMCPUSTATE_RUN_HALTED,
    63     /** All the other bits we do while running a VM (VM running). */
    64     VMCPUSTATE_RUN_MISC,
    65     /** VM not running, we're servicing requests or whatever. */
    66     VMCPUSTATE_NOT_RUNNING,
     64    /** Virtual CPU has not yet been started.  */
     65    VMCPUSTATE_STOPPED,
     66
     67    /** CPU started. */
     68    VMCPUSTATE_STARTED,
     69    /** Executing guest code and can be poked. */
     70    VMCPUSTATE_STARTED_EXEC,
     71    /** Executing guest code in the recompiler. */
     72    VMCPUSTATE_STARTED_EXEC_REM,
     73    /** Halted. */
     74    VMCPUSTATE_STARTED_HALTED,
     75
    6776    /** The end of valid virtual CPU states. */
    6877    VMCPUSTATE_END,
     
    182191} VMCPU;
    183192
    184 /** Pointer to a VMCPU. */
    185 #ifndef ___VBox_types_h
    186 typedef struct VMCPU *PVMCPU;
    187 #endif
     193
     194/** @name Operations on VMCPU::enmState
     195 * @{ */
     196/** Gets the VMCPU state. */
     197#define VMCPU_GET_STATE(pVCpu)              ( (pVCpu)->enmState )
     198/** Sets the VMCPU state. */
     199#define VMCPU_SET_STATE(pVCpu, enmNewState) \
     200    ASMAtomicWriteU32((uint32_t volatile *)&(pVCpu)->enmState, (enmNewState))
     201/** Checks the VMCPU state. */
     202#define VMCPU_ASSERT_STATE(pVCpu, enmExpectedState) \
     203    do { \
     204        VMCPUSTATE enmState = VMCPU_GET_STATE(pVCpu); \
     205        AssertMsg(enmState == (enmExpectedState), \
     206                  ("enmState=%d  enmExpectedState=%d idCpu=%u\n", \
     207                  enmState, enmExpectedState, (pVCpu)->idCpu)); \
     208    } while (0)
     209/** Tests if the state means that the CPU is started. */
     210#define VMCPUSTATE_IS_STARTED(enmState)     ( (enmState) > VMCPUSTATE_STOPPED )
     211/** Tests if the state means that the CPU is stopped. */
     212#define VMCPUSTATE_IS_STOPPED(enmState)     ( (enmState) == VMCPUSTATE_STOPPED )
     213/** @} */
     214
    188215
    189216/** The name of the Guest Context VMM Core module. */
     
    450477# define VMCPU_IS_EMT(pVCpu)                true
    451478#else
    452 # define VMCPU_IS_EMT(pVCpu)                (pVCpu && (pVCpu == VMMGetCpu(pVCpu->CTX_SUFF(pVM))))
     479# define VMCPU_IS_EMT(pVCpu)                ((pVCpu) && ((pVCpu) == VMMGetCpu((pVCpu)->CTX_SUFF(pVM))))
    453480#endif
    454481
     
    523550#define VM_ASSERT_STATE(pVM, _enmState) \
    524551        AssertMsg((pVM)->enmVMState == (_enmState), \
    525                   ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)))
     552                  ("state %s, expected %s\n", VMGetStateName((pVM)->enmVMState), VMGetStateName(_enmState)))
    526553
    527554/** @def VM_ASSERT_STATE_RETURN
     
    530557#define VM_ASSERT_STATE_RETURN(pVM, _enmState, rc) \
    531558        AssertMsgReturn((pVM)->enmVMState == (_enmState), \
    532                         ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)), \
     559                        ("state %s, expected %s\n", VMGetStateName((pVM)->enmVMState), VMGetStateName(_enmState)), \
    533560                        (rc))
    534561
     
    900927} VM;
    901928
    902 /** Pointer to a VM. */
    903 #ifndef ___VBox_types_h
    904 typedef struct VM *PVM;
    905 #endif
    906 
    907929
    908930#ifdef IN_RC
  • trunk/include/VBox/vmapi.h

    r19402 r19435  
    376376VMMR3DECL(void) VMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
    377377VMMR3DECL(PVM)  VMR3EnumVMs(PVM pVMPrev);
    378 VMMR3DECL(int)  VMR3WaitForResume(PVM pVM);
    379378
    380379/**
Note: See TracChangeset for help on using the changeset viewer.

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