VirtualBox

Changeset 32457 in vbox


Ignore:
Timestamp:
Sep 13, 2010 3:51:34 PM (14 years ago)
Author:
vboxsync
Message:

VBoxGuest/win: Delayed wake-up handling in DPC handler (requires RTSPINLOCK_NT_HACK_NOIRQ to be set, see r65824), additional documentation and cleanup.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-pnp.cpp

    r32322 r32457  
    445445                            }
    446446
    447                             /* Cleanup. */
    448                             vboxguestwinCleanup(pDevObj);
     447                            /* Don't do any cleanup here; there might be still coming in some IOCtls after we got this
     448                             * power action and would assert/crash when we already cleaned up all the stuff! */
    449449                            break;
    450450                        }
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp

    r32443 r32457  
    6262RT_C_DECLS_BEGIN
    6363#ifdef DEBUG
    64  static VOID    vboxguestwinDoTests(VOID);
     64 static void    vboxguestwinDoTests(void);
    6565#endif
    6666RT_C_DECLS_END
     
    278278 * @param pResourceList  list of device resources.
    279279 */
    280 static VOID vboxguestwinShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList)
     280static void vboxguestwinShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList)
    281281{
    282282#ifdef LOG_ENABLED
     
    561561NTSTATUS vboxguestwinCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    562562{
    563     Log(("VBoxGuest::vboxguestwinGuestCreate\n"));
    564 
    565563    /** @todo AssertPtrReturn(pIrp); */
    566564    PIO_STACK_LOCATION pStack   = IoGetCurrentIrpStackLocation(pIrp);
     
    584582        if (pFileObj)
    585583        {
     584            Log(("VBoxGuest::vboxguestwinGuestCreate: File object type = %d\n",
     585                 pFileObj->Type));
     586
    586587            int vrc;
    587588            PVBOXGUESTSESSION pSession;
     
    838839
    839840/**
    840  * DPC handler
    841  *
    842  * @param   dpc         DPC descriptor.
     841 * DPC handler.
     842 *
     843 * @param   pDPC        DPC descriptor.
    843844 * @param   pDevObj     Device object.
    844  * @param   irp         Interrupt request packet.
    845  * @param   context     Context specific pointer.
    846  */
    847 VOID vboxguestwinDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj,
     845 * @param   pIrp        Interrupt request packet.
     846 * @param   pContext    Context specific pointer.
     847 */
     848void vboxguestwinDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj,
    848849                            PIRP pIrp, PVOID pContext)
    849850{
    850     /* Unblock handlers waiting for arrived events.
    851      *
    852      * Events are very low things, there is one event flag (1 or more bit)
    853      * for each event. Each event is processed by exactly one handler.
    854      *
    855      * Assume that we trust additions and that other drivers will
    856      * handle its respective events without trying to fetch all events.
    857      *
    858      * Anyway design assures that wrong event processing will affect only guest.
    859      *
    860      * Event handler calls VMMDev IOCTL for waiting an event.
    861      * It supplies event mask. IOCTL blocks on EventNotification.
    862      * Here we just signal an the EventNotification to all waiting
    863      * threads, the IOCTL handler analyzes events and either
    864      * return to caller or blocks again.
    865      *
    866      * If we do not have too many events this is a simple and good
    867      * approach. Other way is to have as many Event objects as the callers
    868      * and wake up only callers waiting for the specific event.
    869      *
    870      * Now with the 'wake up all' appoach we probably do not need the DPC
    871      * handler and can signal event directly from ISR.
    872      *
    873      */
    874 
    875851    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
    876 
    877852    Log(("VBoxGuest::vboxguestwinGuestDpcHandler: pDevExt=0x%p\n", pDevExt));
    878853
    879 #ifdef VBOX_WITH_HGCM
    880     if (pDevExt)
    881         KePulseEvent(&pDevExt->win.s.hgcm.s.keventNotification, 0, FALSE);
    882 #endif
     854    /* Process the wake-up list we were asked by the scheduling a DPC
     855     *  in vboxguestwinIsrHandler(). */
     856    VBoxGuestWaitDoWakeUps(pDevExt);
    883857}
    884858
     
    887861 * ISR handler.
    888862 *
    889  * @return  BOOLEAN        Indicates whether the IRQ came from us (TRUE) or not (FALSE).
    890  * @param   interrupt      Interrupt that was triggered.
    891  * @param   serviceContext Context specific pointer.
    892  */
    893 BOOLEAN vboxguestwinIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext)
    894 {
    895     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)serviceContext;
     863 * @return  BOOLEAN         Indicates whether the IRQ came from us (TRUE) or not (FALSE).
     864 * @param   pInterrupt      Interrupt that was triggered.
     865 * @param   pServiceContext Context specific pointer.
     866 */
     867BOOLEAN vboxguestwinIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)
     868{
     869    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pServiceContext;
    896870    BOOLEAN fIRQTaken = FALSE;
    897871
     
    899873             pDevExt, pDevExt ? pDevExt->pVMMDevMemory : NULL));*/
    900874
    901     if (VBoxGuestCommonISR(pDevExt))
    902     {
    903         /*Log(("VBoxGuest::vboxguestwinGuestIsrHandler: IRQ was taken! pDeviceObject = 0x%p, pCurrentIrp = 0x%p\n",
    904                 pDevExt->win.s.pDeviceObject, pDevExt->win.s.pCurrentIrp));*/
    905 
     875    /* Enter the common ISR routine and do the actual work. */
     876    fIRQTaken = VBoxGuestCommonISR(pDevExt);
     877
     878    /* If we need to wake up some events we do that in a DPC to make
     879     * sure we're called at the right IRQL. */
     880    if (fIRQTaken && !RTListIsEmpty(&pDevExt->WakeUpList))
    906881        IoRequestDpc(pDevExt->win.s.pDeviceObject, pDevExt->win.s.pCurrentIrp, NULL);
    907         fIRQTaken = TRUE;
    908     }
    909 
     882
     883    /*if (fIRQTaken)
     884        Log(("VBoxGuest::vboxguestwinGuestIsrHandler: IRQ was taken! pDeviceObject = 0x%p, pCurrentIrp = 0x%p\n",
     885             pDevExt->win.s.pDeviceObject, pDevExt->win.s.pCurrentIrp));*/
    910886    return fIRQTaken;
    911887}
     
    10571033
    10581034
     1035/**
     1036 * Maps the I/O space from VMMDev to virtual kernel adress space.
     1037 *
     1038 * @return NTSTATUS
     1039 *
     1040 * @param pDevExt           The device extension.
     1041 * @param physicalAdr       Physical address to map.
     1042 * @param ulLength          Length (in bytes) to map.
     1043 * @param ppvMMIOBase       Pointer of mapped I/O base.
     1044 * @param pcbMMIO           Length of mapped I/O base.
     1045 */
    10591046NTSTATUS vboxguestwinMapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt, PHYSICAL_ADDRESS physicalAdr, ULONG ulLength,
    10601047                                     void **ppvMMIOBase, uint32_t *pcbMMIO)
     
    11021089
    11031090
     1091/**
     1092 * Unmaps the VMMDev I/O range from kernel space.
     1093 *
     1094 * @param   pDevExt     The device extension.
     1095 */
    11041096void vboxguestwinUnmapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt)
    11051097{
     
    11511143 *  bits.
    11521144 */
    1153 static uint32_t guestAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)
     1145static uint32_t vboxugestwinAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)
    11541146{
    11551147    AssertPtrReturn(pu32Bits, 0);
     
    11721164}
    11731165
    1174 static VOID vboxguestwinTestAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits,
     1166
     1167static void vboxguestwinTestAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits,
    11751168                                                      uint32_t u32Exp)
    11761169{
    11771170    ULONG u32Bits2 = u32Bits;
    1178     uint32_t u32Result = guestAtomicBitsTestAndClear(&u32Bits2, u32Mask);
     1171    uint32_t u32Result = vboxugestwinAtomicBitsTestAndClear(&u32Bits2, u32Mask);
    11791172    if (   u32Result != u32Exp
    11801173        || (u32Bits2 & u32Mask)
     
    11871180}
    11881181
    1189 static VOID vboxguestwinDoTests(VOID)
     1182
     1183static void vboxguestwinDoTests()
    11901184{
    11911185    vboxguestwinTestAtomicTestAndClearBitsU32(0x00, 0x23, 0);
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