VirtualBox

Ignore:
Timestamp:
May 1, 2009 4:11:18 PM (16 years ago)
Author:
vboxsync
Message:

DBGF,VMM: SMP refactoring of the DBGF disassembler code. Changed VMMGetCpu and VMMGetCpuId to return NULL and NIL if the caller isn't an EMT. Renamed VMMGetCpuEx to VMMGetCpuById.

File:
1 edited

Legend:

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

    r19228 r19293  
    4848
    4949/**
    50  * Gets the current virtual CPU ID.
     50 * Gets the ID virtual of the virtual CPU assoicated with the calling thread.
    5151 *
    52  * @returns The CPU ID.
     52 * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT.
     53 *
    5354 * @param   pVM         Pointer to the shared VM handle.
    54  * @thread  EMT
    5555 */
    5656VMMDECL(VMCPUID) VMMGetCpuId(PVM pVM)
    5757{
    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);
    6360
    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. */
    6563    VM_ASSERT_EMT(pVM);
    66 
    67     /* Shortcut for one CPU */
    6864    if (pVM->cCPUs == 1)
    6965        return 0;
     66    return HWACCMR0GetVMCPUId(pVM);
    7067
    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) */
    7869    return 0;
     70#endif
    7971}
    8072
     73
    8174/**
    82  * Returns the VMCPU of the current EMT thread.
     75 * Returns the VMCPU of the calling EMT.
    8376 *
    84  * @returns The VMCPU pointer.
     77 * @returns The VMCPU pointer. NULL if not an EMT.
     78 *
    8579 * @param   pVM         The VM to operate on.
    8680 */
     
    8882{
    8983#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. */
    9592    VM_ASSERT_EMT(pVM);
    96 
    97     /* Shortcut for one CPU */
    9893    if (pVM->cCPUs == 1)
    9994        return &pVM->aCpus[0];
     95    return HWACCMR0GetVMCPU(pVM);
    10096
    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];
    10599#endif /* IN_RING0 */
     100}
    106101
    107     AssertFailed();
    108     return &pVM->aCpus[0];
    109 }
    110102
    111103/**
     
    121113}
    122114
     115
    123116/**
    124117 * Returns the VMCPU of the specified virtual CPU.
    125118 *
    126  * @returns The VMCPU pointer.
     119 * @returns The VMCPU pointer. NULL if idCpu is invalid.
     120 *
    127121 * @param   pVM         The VM to operate on.
     122 * @param   idCpu       The ID of the virtual CPU.
    128123 */
    129 VMMDECL(PVMCPU) VMMGetCpuEx(PVM pVM, RTCPUID idCpu)
     124VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, RTCPUID idCpu)
    130125{
    131126    AssertReturn(idCpu < pVM->cCPUs, NULL);
    132127    return &pVM->aCpus[idCpu];
    133128}
     129
    134130
    135131/**
     
    146142}
    147143
     144
    148145/**
    149146 * Queries the current switcher
     
    156153    return pVM->vmm.s.enmSwitcher;
    157154}
     155
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