VirtualBox

Ignore:
Timestamp:
Oct 8, 2015 10:13:54 AM (9 years ago)
Author:
vboxsync
Message:

VBoxGuest: Vbgd -> VGDrv, cleanups - will probably not build cleanly everywhere. :)

File:
1 edited

Legend:

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

    r58053 r58113  
    3232*********************************************************************************************************************************/
    3333RT_C_DECLS_BEGIN
    34 static NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict);
    35 static NTSTATUS vbgdNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
    36 static VOID     vbgdNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList);
     34static NTSTATUS vgdrvNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict);
     35static NTSTATUS vgdrvNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
     36static VOID     vgdrvNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList);
    3737RT_C_DECLS_END
    3838
    3939#ifdef ALLOC_PRAGMA
    40 # pragma alloc_text(PAGE, vbgdNtPnP)
    41 # pragma alloc_text(PAGE, vbgdNtPower)
    42 # pragma alloc_text(PAGE, vbgdNtSendIrpSynchronously)
    43 # pragma alloc_text(PAGE, vbgdNtShowDeviceResources)
     40# pragma alloc_text(PAGE, vgdrvNtPnP)
     41# pragma alloc_text(PAGE, vgdrvNtPower)
     42# pragma alloc_text(PAGE, vgdrvNtSendIrpSynchronously)
     43# pragma alloc_text(PAGE, vgdrvNtShowDeviceResources)
    4444#endif
    4545
     
    4848 * Irp completion routine for PnP Irps we send.
    4949 *
     50 * @returns NT status code.
    5051 * @param   pDevObj   Device object.
    5152 * @param   pIrp      Request packet.
    5253 * @param   pEvent    Semaphore.
    53  * @return   NT status code
    54  */
    55 static NTSTATUS vbgdNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent)
     54 */
     55static NTSTATUS vgdrvNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent)
    5656{
    5757    KeSetEvent(pEvent, 0, FALSE);
     
    6363 * Helper to send a PnP IRP and wait until it's done.
    6464 *
     65 * @returns NT status code.
    6566 * @param    pDevObj    Device object.
    6667 * @param    pIrp       Request packet.
    6768 * @param    fStrict    When set, returns an error if the IRP gives an error.
    68  * @return   NT status code
    69  */
    70 static NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict)
     69 */
     70static NTSTATUS vgdrvNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict)
    7171{
    7272    KEVENT Event;
     
    7575
    7676    IoCopyCurrentIrpStackLocationToNext(pIrp);
    77     IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vbgdNtPnpIrpComplete,
    78                            &Event, TRUE, TRUE, TRUE);
     77    IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vgdrvNtPnpIrpComplete, &Event, TRUE, TRUE, TRUE);
    7978
    8079    NTSTATUS rc = IoCallDriver(pDevObj, pIrp);
     
    8685    }
    8786
    88     if (!fStrict
     87    if (   !fStrict
    8988        && (rc == STATUS_NOT_SUPPORTED || rc == STATUS_INVALID_DEVICE_REQUEST))
    9089    {
     
    9291    }
    9392
    94     Log(("VBoxGuest::vbgdNtSendIrpSynchronously: Returning 0x%x\n", rc));
     93    Log(("vgdrvNtSendIrpSynchronously: Returning 0x%x\n", rc));
    9594    return rc;
    9695}
     
    103102 * @param  pIrp       Request packet.
    104103 */
    105 NTSTATUS vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     104NTSTATUS vgdrvNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    106105{
    107106    PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
     
    136135        "IRP_MN_SURPRISE_REMOVAL",
    137136    };
    138     Log(("VBoxGuest::vbgdNtGuestPnp: MinorFunction: %s\n",
     137    Log(("vgdrvNtPnP: MinorFunction: %s\n",
    139138         pStack->MinorFunction < RT_ELEMENTS(s_apszFnctName) ? s_apszFnctName[pStack->MinorFunction] : "Unknown"));
    140139#endif
     
    145144        case IRP_MN_START_DEVICE:
    146145        {
    147             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE\n"));
     146            Log(("vgdrvNtPnP: START_DEVICE\n"));
    148147
    149148            /* This must be handled first by the lower driver. */
    150             rc = vbgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
     149            rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
    151150
    152151            if (   NT_SUCCESS(rc)
    153152                && NT_SUCCESS(pIrp->IoStatus.Status))
    154153            {
    155                 Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n",
     154                Log(("vgdrvNtPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n",
    156155                     pStack->Parameters.StartDevice.AllocatedResources));
    157156
    158                 if (!pStack->Parameters.StartDevice.AllocatedResources)
     157                if (pStack->Parameters.StartDevice.AllocatedResources)
     158                    rc = vgdrvNtInit(pDevObj, pIrp);
     159                else
    159160                {
    160                     Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n",
     161                    Log(("vgdrvNtPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n",
    161162                         pDevExt, pDevExt ? pDevExt->pNextLowerDriver : NULL));
    162163                    rc = STATUS_UNSUCCESSFUL;
    163164                }
    164                 else
    165                 {
    166                     rc = vbgdNtInit(pDevObj, pIrp);
    167                 }
    168165            }
    169166
    170167            if (NT_ERROR(rc))
    171168            {
    172                 Log(("VBoxGuest::vbgdNtGuestPnp: START_DEVICE: Error: rc = 0x%x\n", rc));
     169                Log(("vgdrvNtPnP: START_DEVICE: Error: rc = 0x%x\n", rc));
    173170
    174171                /* Need to unmap memory in case of errors ... */
    175                 vbgdNtUnmapVMMDevMemory(pDevExt);
     172/** @todo r=bird: vgdrvNtInit maps it and is responsible for cleaning up its own friggin mess...
     173 * Fix it instead of kind of working around things there!! */
     174                vgdrvNtUnmapVMMDevMemory(pDevExt);
    176175            }
    177176            break;
     
    180179        case IRP_MN_CANCEL_REMOVE_DEVICE:
    181180        {
    182             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_REMOVE_DEVICE\n"));
     181            Log(("vgdrvNtPnP: CANCEL_REMOVE_DEVICE\n"));
    183182
    184183            /* This must be handled first by the lower driver. */
    185             rc = vbgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
    186 
    187             if (NT_SUCCESS(rc) && pDevExt->devState == PENDINGREMOVE)
     184            rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
     185
     186            if (NT_SUCCESS(rc) && pDevExt->enmDevState == VGDRVNTDEVSTATE_PENDINGREMOVE)
    188187            {
    189188                /* Return to the state prior to receiving the IRP_MN_QUERY_REMOVE_DEVICE request. */
    190                 pDevExt->devState = pDevExt->prevDevState;
     189                pDevExt->enmDevState = pDevExt->enmPrevDevState;
    191190            }
    192191
     
    197196        case IRP_MN_SURPRISE_REMOVAL:
    198197        {
    199             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: IRP_MN_SURPRISE_REMOVAL\n"));
    200 
    201             VBOXGUEST_UPDATE_DEVSTATE(pDevExt, SURPRISEREMOVED);
     198            Log(("vgdrvNtPnP: IRP_MN_SURPRISE_REMOVAL\n"));
     199
     200            VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_SURPRISEREMOVED);
    202201
    203202            /* Do nothing here actually. Cleanup is done in IRP_MN_REMOVE_DEVICE.
     
    219218        case IRP_MN_QUERY_REMOVE_DEVICE:
    220219        {
    221             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_REMOVE_DEVICE\n"));
     220            Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE\n"));
    222221
    223222#ifdef VBOX_REBOOT_ON_UNINSTALL
    224             Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n"));
     223            Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n"));
    225224            rc = STATUS_UNSUCCESSFUL;
    226225#endif
     
    228227            if (NT_SUCCESS(rc))
    229228            {
    230                 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, PENDINGREMOVE);
     229                VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_PENDINGREMOVE);
    231230
    232231                /* This IRP passed down to lower driver. */
     
    236235
    237236                rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    238                 Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     237                Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    239238
    240239                /* we must not do anything the IRP after doing IoSkip & CallDriver
     
    250249        case IRP_MN_REMOVE_DEVICE:
    251250        {
    252             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: REMOVE_DEVICE\n"));
    253 
    254             VBOXGUEST_UPDATE_DEVSTATE(pDevExt, REMOVED);
     251            Log(("vgdrvNtPnP: REMOVE_DEVICE\n"));
     252
     253            VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_REMOVED);
    255254
    256255            /* Free hardware resources. */
    257256            /** @todo this should actually free I/O ports, interrupts, etc.
    258              * Update/bird: vbgdNtCleanup actually does that... So, what's there to do?  */
    259             rc = vbgdNtCleanup(pDevObj);
    260             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: vbgdNtCleanup rc = 0x%08X\n", rc));
     257             * Update/bird: vgdrvNtCleanup actually does that... So, what's there to do?  */
     258            rc = vgdrvNtCleanup(pDevObj);
     259            Log(("vgdrvNtPnP: REMOVE_DEVICE: vgdrvNtCleanup rc = 0x%08X\n", rc));
    261260
    262261            /*
     
    270269
    271270            rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    272             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     271            Log(("vgdrvNtPnP: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    273272
    274273            IoDetachDevice(pDevExt->pNextLowerDriver);
    275274
    276             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Removing device ...\n"));
     275            Log(("vgdrvNtPnP: REMOVE_DEVICE: Removing device ...\n"));
    277276
    278277            /* Destroy device extension and clean up everything else. */
     
    284283            IoDeleteSymbolicLink(&win32Name);
    285284
    286             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Deleting device ...\n"));
     285            Log(("vgdrvNtPnP: REMOVE_DEVICE: Deleting device ...\n"));
    287286
    288287            /* Last action: Delete our device! pDevObj is *not* failed
     
    290289            IoDeleteDevice(pDevObj);
    291290
    292             Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Device removed!\n"));
     291            Log(("vgdrvNtPnP: REMOVE_DEVICE: Device removed!\n"));
    293292
    294293            /* Propagating rc from IoCallDriver. */
     
    298297        case IRP_MN_CANCEL_STOP_DEVICE:
    299298        {
    300             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_STOP_DEVICE\n"));
     299            Log(("vgdrvNtPnP: CANCEL_STOP_DEVICE\n"));
    301300
    302301            /* This must be handled first by the lower driver. */
    303             rc = vbgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
    304 
    305             if (NT_SUCCESS(rc) && pDevExt->devState == PENDINGSTOP)
     302            rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);
     303
     304            if (NT_SUCCESS(rc) && pDevExt->enmDevState == VGDRVNTDEVSTATE_PENDINGSTOP)
    306305            {
    307306                /* Return to the state prior to receiving the IRP_MN_QUERY_STOP_DEVICE request. */
    308                 pDevExt->devState = pDevExt->prevDevState;
     307                pDevExt->enmDevState = pDevExt->enmPrevDevState;
    309308            }
    310309
     
    315314        case IRP_MN_QUERY_STOP_DEVICE:
    316315        {
    317             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_STOP_DEVICE\n"));
     316            Log(("vgdrvNtPnP: QUERY_STOP_DEVICE\n"));
    318317
    319318#ifdef VBOX_REBOOT_ON_UNINSTALL
    320             Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n"));
     319            Log(("vgdrvNtPnP: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n"));
    321320            pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
    322321#endif
     
    324323            if (NT_SUCCESS(rc))
    325324            {
    326                 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, PENDINGSTOP);
     325                VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_PENDINGSTOP);
    327326
    328327                /* This IRP passed down to lower driver. */
     
    332331
    333332                rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    334                 Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     333                Log(("vgdrvNtPnP: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    335334
    336335                /* we must not do anything with the IRP after doing IoSkip & CallDriver
     
    346345        case IRP_MN_STOP_DEVICE:
    347346        {
    348             Log(("VBoxGuest::vbgdNtVBoxGuestPnP: STOP_DEVICE\n"));
    349 
    350             VBOXGUEST_UPDATE_DEVSTATE(pDevExt, STOPPED);
     347            Log(("vgdrvNtPnP: STOP_DEVICE\n"));
     348
     349            VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_STOPPED);
    351350
    352351            /* Free hardware resources. */
    353352            /** @todo this should actually free I/O ports, interrupts, etc.
    354              * Update/bird: vbgdNtCleanup actually does that... So, what's there to do?  */
    355             rc = vbgdNtCleanup(pDevObj);
    356             Log(("VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc));
     353             * Update/bird: vgdrvNtCleanup actually does that... So, what's there to do?  */
     354            rc = vgdrvNtCleanup(pDevObj);
     355            Log(("vgdrvNtPnP: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc));
    357356
    358357            /* Pass to the lower driver. */
     
    362361
    363362            rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
    364             Log(("VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
     363            Log(("vgdrvNtPnP: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
    365364
    366365            return rc;
     
    378377    IoCompleteRequest(pIrp, IO_NO_INCREMENT);
    379378
    380     Log(("VBoxGuest::vbgdNtGuestPnp: Returning with rc = 0x%x\n", rc));
     379    Log(("vgdrvNtPnP: Returning with rc = 0x%x\n", rc));
    381380    return rc;
    382381}
     
    391390 * @param pContext  Context value passed to IoSetCompletionRoutine in VBoxGuestPower.
    392391 */
    393 static NTSTATUS vbgdNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext)
     392static NTSTATUS vgdrvNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext)
    394393{
    395394#ifdef VBOX_STRICT
     
    407406            {
    408407                case IRP_MN_SET_POWER:
    409 
    410408                    switch (pIrpSp->Parameters.Power.Type)
    411409                    {
     
    435433 * @param     pIrp      IRP
    436434 */
    437 NTSTATUS vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     435NTSTATUS vgdrvNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    438436{
    439437    PIO_STACK_LOCATION  pStack   = IoGetCurrentIrpStackLocation(pIrp);
     
    443441    POWER_ACTION        enmPowerAction = pStack->Parameters.Power.ShutdownType;
    444442
    445     Log(("VBoxGuest::vbgdNtGuestPower\n"));
     443    Log(("vgdrvNtPower:\n"));
    446444
    447445    switch (pStack->MinorFunction)
     
    449447        case IRP_MN_SET_POWER:
    450448        {
    451             Log(("VBoxGuest::vbgdNtGuestPower: IRP_MN_SET_POWER, type= %d\n", enmPowerType));
     449            Log(("vgdrvNtPower: IRP_MN_SET_POWER, type= %d\n", enmPowerType));
    452450            switch (enmPowerType)
    453451            {
    454452                case SystemPowerState:
    455453                {
    456                     Log(("VBoxGuest::vbgdNtGuestPower: SystemPowerState, action = %d, state = %d/%d\n",
     454                    Log(("vgdrvNtPower: SystemPowerState, action = %d, state = %d/%d\n",
    457455                         enmPowerAction, PowerState.SystemState, PowerState.DeviceState));
    458456
     
    467465                                    && pDevExt->LastSystemPowerAction == PowerActionHibernate)
    468466                                {
    469                                     Log(("VBoxGuest::vbgdNtGuestPower: Returning from hibernation!\n"));
     467                                    Log(("vgdrvNtPower: Returning from hibernation!\n"));
    470468                                    int rc = VGDrvCommonReinitDevExtAfterHibernation(&pDevExt->Core,
    471                                                                                      vbgdNtVersionToOSType(g_enmVbgdNtVer));
     469                                                                                     vgdrvNtVersionToOSType(g_enmVGDrvNtVer));
    472470                                    if (RT_FAILURE(rc))
    473                                         Log(("VBoxGuest::vbgdNtGuestPower: Cannot re-init VMMDev chain, rc = %d!\n", rc));
     471                                        Log(("vgdrvNtPower: Cannot re-init VMMDev chain, rc = %d!\n", rc));
    474472                                }
    475473                            }
     
    478476                        case PowerActionShutdownReset:
    479477                        {
    480                             Log(("VBoxGuest::vbgdNtGuestPower: Power action reset!\n"));
     478                            Log(("vgdrvNtPower: Power action reset!\n"));
    481479
    482480                            /* Tell the VMM that we no longer support mouse pointer integration. */
     
    493491                                if (RT_FAILURE(vrc))
    494492                                {
    495                                     Log(("VBoxGuest::PowerStateRequest: error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
     493                                    Log(("vgdrvNtPower: error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
    496494                                }
    497495
     
    507505                        case PowerActionShutdownOff:
    508506                        {
    509                             Log(("VBoxGuest::vbgdNtGuestPower: Power action shutdown!\n"));
     507                            Log(("vgdrvNtPower: Power action shutdown!\n"));
    510508                            if (PowerState.SystemState >= PowerSystemShutdown)
    511509                            {
    512                                 Log(("VBoxGuest::vbgdNtGuestPower: Telling the VMMDev to close the VM ...\n"));
     510                                Log(("vgdrvNtPower: Telling the VMMDev to close the VM ...\n"));
    513511
    514512                                VMMDevPowerStateRequest *pReq = pDevExt->pPowerStateRequest;
     
    522520                                }
    523521                                if (RT_FAILURE(vrc))
    524                                     Log(("VBoxGuest::PowerStateRequest: Error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
     522                                    Log(("vgdrvNtPower: Error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));
    525523
    526524                                /* No need to do cleanup here; at this point we should've been
     
    532530                        case PowerActionHibernate:
    533531
    534                             Log(("VBoxGuest::vbgdNtGuestPower: Power action hibernate!\n"));
     532                            Log(("vgdrvNtPower: Power action hibernate!\n"));
    535533                            break;
    536534                    }
     
    566564    IoCopyCurrentIrpStackLocationToNext(pIrp);
    567565    IoSetCompletionRoutine(pIrp,
    568                            vbgdNtPowerComplete,
     566                           vgdrvNtPowerComplete,
    569567                           (PVOID)pDevExt,
    570568                           TRUE,
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