VirtualBox

Changeset 53795 in vbox


Ignore:
Timestamp:
Jan 14, 2015 9:36:47 AM (10 years ago)
Author:
vboxsync
Message:

Added an official way of implementing a HLT/MWAIT like port on a device (for use with VMSVGA).

Location:
trunk
Files:
3 edited

Legend:

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

    r53630 r53795  
    695695#else
    696696# define VMCPU_ASSERT_EMT_RETURN(pVCpu, rc) \
    697     AssertMsg(VMCPU_IS_EMT(pVCpu), \
    698               ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd idCpu=%#x\n", \
    699                RTThreadNativeSelf(), (pVCpu)->hNativeThread, (pVCpu)->idCpu), \
    700               (rc))
     697    AssertMsgReturn(VMCPU_IS_EMT(pVCpu), \
     698                    ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd idCpu=%#x\n", \
     699                     RTThreadNativeSelf(), (pVCpu)->hNativeThread, (pVCpu)->idCpu), \
     700                    (rc))
    701701#endif
    702702
  • trunk/include/VBox/vmm/vmapi.h

    r52419 r53795  
    472472VMMR3_INT_DECL(void)        VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
    473473VMMR3_INT_DECL(void)        VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
     474VMMR3DECL(int)              VMR3NotifyCpuDeviceReady(PVM pVM, VMCPUID idCpu);
    474475VMMR3_INT_DECL(int)         VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
    475476VMMR3_INT_DECL(int)         VMR3WaitU(PUVMCPU pUVMCpu);
     477VMMR3DECL(int)              VMR3WaitForDeviceReady(PVM pVM, VMCPUID idCpu);
    476478VMMR3_INT_DECL(int)         VMR3AsyncPdmNotificationWaitU(PUVMCPU pUVCpu);
    477479VMMR3_INT_DECL(void)        VMR3AsyncPdmNotificationWakeupU(PUVM pUVM);
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r51052 r53795  
    10231023 * sure EMT wakes up and promptly service an FF request.
    10241024 *
    1025  * @param   pUVM            Pointer to the user mode VM structure.
     1025 * @param   pUVCpu          Pointer to the user mode per CPU VM structure.
    10261026 * @param   fFlags          Notification flags, VMNOTIFYFF_FLAGS_*.
    10271027 * @internal
     
    10461046 * @param   fIgnoreInterrupts   If set the VM_FF_INTERRUPT flags is ignored.
    10471047 * @thread  The emulation thread.
     1048 * @remarks Made visible for implementing vmsvga sync register.
    10481049 * @internal
    10491050 */
     
    12961297}
    12971298
     1299
     1300/**
     1301 * Special interface for implementing a HLT-like port on a device.
     1302 *
     1303 * This can be called directly from device code, provide the device is trusted
     1304 * to access the VMM directly.  Since we may not have an accurate register set
     1305 * and the caller certainly shouldn't (device code does not access CPU
     1306 * registers), this function will return when interrupts are pending regardless
     1307 * of the actual EFLAGS.IF state.
     1308 *
     1309 * @returns VBox error status (never informational statuses).
     1310 * @param   pVM                 The VM handle.
     1311 * @param   idCpu               The id of the calling EMT.
     1312 */
     1313VMMR3DECL(int) VMR3WaitForDeviceReady(PVM pVM, VMCPUID idCpu)
     1314{
     1315    /*
     1316     * Validate caller and resolve the CPU ID.
     1317     */
     1318    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     1319    AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID);
     1320    PVMCPU pVCpu = &pVM->aCpus[idCpu];
     1321    VMCPU_ASSERT_EMT_RETURN(pVCpu, VERR_VM_THREAD_NOT_EMT);
     1322
     1323    /*
     1324     * Tag along with the HLT mechanics for now.
     1325     */
     1326    int rc = VMR3WaitHalted(pVM, pVCpu, false /*fIgnoreInterrupts*/);
     1327    if (RT_SUCCESS(rc))
     1328        return VINF_SUCCESS;
     1329    return rc;
     1330}
     1331
     1332
     1333/**
     1334 * Wakes up a CPU that has called VMR3WaitForDeviceReady.
     1335 *
     1336 * @returns VBox error status (never informational statuses).
     1337 * @param   pVM                 The VM handle.
     1338 * @param   idCpu               The id of the calling EMT.
     1339 */
     1340VMMR3DECL(int) VMR3NotifyCpuDeviceReady(PVM pVM, VMCPUID idCpu)
     1341{
     1342    /*
     1343     * Validate caller and resolve the CPU ID.
     1344     */
     1345    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     1346    AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID);
     1347    PVMCPU pVCpu = &pVM->aCpus[idCpu];
     1348
     1349    /*
     1350     * Pretend it was an FF that got set since we've got logic for that already.
     1351     */
     1352    VMR3NotifyCpuFFU(pVCpu->pUVCpu, VMNOTIFYFF_FLAGS_DONE_REM);
     1353    return VINF_SUCCESS;
     1354}
     1355
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