Changeset 5722 in vbox
- Timestamp:
- Nov 13, 2007 4:13:43 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmapi.h
r5031 r5722 376 376 377 377 /** 378 * Detaches a driver from an existing device instance.378 * Detaches a driver chain from an existing device instance. 379 379 * 380 380 * This is used to change drivers and suchlike at runtime. -
trunk/include/VBox/pdmusb.h
r5713 r5722 79 79 80 80 /** 81 * Destruct an USB device instance. 82 * 83 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 84 * resources can be freed correctly. 85 * 86 * This method will be called regardless of the pfnConstruc result to avoid 87 * complicated failure paths. 88 * 89 * @param pUsbIns The USB device instance data. 90 * @remarks Optional. 91 */ 92 DECLR3CALLBACKMEMBER(void, pfnDestruct,(PPDMUSBINS pUsbIns)); 93 94 95 /** 81 96 * Init complete notification. 82 97 * … … 87 102 * @param pUsbIns The USB device instance data. 88 103 * @remarks Optional. 89 */ 90 DECLR3CALLBACKMEMBER(int, pfnInitComplete,(PPDMUSBINS pUsbIns)); 91 92 /** 93 * Destruct an USB device instance. 94 * 95 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 96 * resources can be freed correctly. 97 * 98 * This method will be called regardless of the pfnConstruc result to avoid 99 * complicated failure paths. 100 * 101 * @param pUsbIns The USB device instance data. 102 * @remarks Optional. 103 */ 104 DECLR3CALLBACKMEMBER(void, pfnDestruct,(PPDMUSBINS pUsbIns)); 105 106 /** 107 * Power On notification. 108 * 109 * @returns VBox status. 110 * @param pUsbIns The USB device instance data. 111 * @remarks Optional. 112 */ 113 DECLR3CALLBACKMEMBER(void, pfnPowerOn,(PPDMUSBINS pUsbIns)); 114 115 /** 116 * Reset notification. 117 * 118 * @returns VBox status. 119 * @param pUsbIns The USB device instance data. 120 * @remarks Optional. 121 */ 122 DECLR3CALLBACKMEMBER(void, pfnReset,(PPDMUSBINS pUsbIns)); 123 124 /** 125 * Suspend notification. 126 * 127 * @returns VBox status. 128 * @param pUsbIns The USB device instance data. 129 * @remarks Optional. 130 */ 131 DECLR3CALLBACKMEMBER(void, pfnSuspend,(PPDMUSBINS pUsbIns)); 132 133 /** 134 * Resume notification. 135 * 136 * @returns VBox status. 137 * @param pUsbIns The USB device instance data. 138 * @remarks Optional. 139 */ 140 DECLR3CALLBACKMEMBER(void, pfnResume,(PPDMUSBINS pUsbIns)); 141 142 /** 143 * Power Off notification. 144 * 145 * @param pUsbIns The USB device instance data. 146 */ 147 DECLR3CALLBACKMEMBER(void, pfnPowerOff,(PPDMUSBINS pUsbIns)); 148 149 /** 150 * Attach command. 104 * @remarks Not called when hotplugged. 105 */ 106 DECLR3CALLBACKMEMBER(int, pfnVMInitComplete,(PPDMUSBINS pUsbIns)); 107 108 /** 109 * VM Power On notification. 110 * 111 * @returns VBox status. 112 * @param pUsbIns The USB device instance data. 113 * @remarks Optional. 114 */ 115 DECLR3CALLBACKMEMBER(void, pfnVMPowerOn,(PPDMUSBINS pUsbIns)); 116 117 /** 118 * VM Reset notification. 119 * 120 * @returns VBox status. 121 * @param pUsbIns The USB device instance data. 122 * @remarks Optional. 123 */ 124 DECLR3CALLBACKMEMBER(void, pfnVMReset,(PPDMUSBINS pUsbIns)); 125 126 /** 127 * VM Suspend notification. 128 * 129 * @returns VBox status. 130 * @param pUsbIns The USB device instance data. 131 * @remarks Optional. 132 */ 133 DECLR3CALLBACKMEMBER(void, pfnVMSuspend,(PPDMUSBINS pUsbIns)); 134 135 /** 136 * VM Resume notification. 137 * 138 * @returns VBox status. 139 * @param pUsbIns The USB device instance data. 140 * @remarks Optional. 141 */ 142 DECLR3CALLBACKMEMBER(void, pfnVMResume,(PPDMUSBINS pUsbIns)); 143 144 /** 145 * VM Power Off notification. 146 * 147 * @param pUsbIns The USB device instance data. 148 */ 149 DECLR3CALLBACKMEMBER(void, pfnVMPowerOff,(PPDMUSBINS pUsbIns)); 150 151 /** 152 * Called after the constructor when attaching a device at run time. 153 * 154 * This can be used to do tasks normally assigned to pfnInitComplete and/or pfnVMPowerOn. 155 * 156 * @returns VBox status. 157 * @param pUsbIns The USB device instance data. 158 * @remarks Optional. 159 */ 160 DECLR3CALLBACKMEMBER(void, pfnHotPlugged,(PPDMUSBINS pUsbIns)); 161 162 /** 163 * Called before the destructor when a device is unplugged at run time. 164 * 165 * This can be used to do tasks normally assigned to pfnVMSuspend and/or pfnVMPowerOff. 166 * 167 * @returns VBox status. 168 * @param pUsbIns The USB device instance data. 169 * @remarks Optional. 170 */ 171 DECLR3CALLBACKMEMBER(void, pfnHotUnplugged,(PPDMUSBINS pUsbIns)); 172 /** 173 * Driver Attach command. 151 174 * 152 175 * This is called to let the USB device attach to a driver for a specified LUN … … 159 182 * @remarks Optional. 160 183 */ 161 DECLR3CALLBACKMEMBER(int, pfn Attach,(PPDMUSBINS pUsbIns, unsigned iLUN));162 163 /** 164 * D etach notification.184 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMUSBINS pUsbIns, unsigned iLUN)); 185 186 /** 187 * Driver Detach notification. 165 188 * 166 189 * This is called when a driver is detaching itself from a LUN of the device. … … 171 194 * @remarks Optional. 172 195 */ 173 DECLR3CALLBACKMEMBER(void, pfnD etach,(PPDMUSBINS pUsbIns, unsigned iLUN));196 DECLR3CALLBACKMEMBER(void, pfnDriverDetach,(PPDMUSBINS pUsbIns, unsigned iLUN)); 174 197 175 198 /** -
trunk/include/VBox/vusb.h
r5605 r5722 347 347 VUSB_DEVICE_STATE_SUSPENDED, 348 348 /** The device is being reset. Don't mess with it. 349 * Next states: VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_ RESET_DESTROY349 * Next states: VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_DESTROYED 350 350 */ 351 351 VUSB_DEVICE_STATE_RESET, 352 /** The device is being reset and should be destroyed. Don't mess with it.353 * Prev state: VUSB_DEVICE_STATE_RESET354 * Next state: VUSB_DEVICE_STATE_DESTROY355 */356 VUSB_DEVICE_STATE_RESET_DESTROY,357 /** The device is being destroyed.358 * Prev state: Any but VUSB_DEVICE_STATE_RESET359 * Next state: VUSB_DEVICE_STATE_DESTROYED360 */361 VUSB_DEVICE_STATE_DESTROY,362 352 /** The device has been destroy. */ 363 353 VUSB_DEVICE_STATE_DESTROYED, -
trunk/src/VBox/VMM/PDM.cpp
r5720 r5722 320 320 for (; pLun; pLun = pLun->pNext) 321 321 { 322 /* Find the bottom driver. */ 323 /** @todo Add pBottom to PDMLUN, this might not be the only place we will have to work it from the bottom up. */ 324 PPDMDRVINS pDrvIns = pLun->pTop; 325 while (pDrvIns && pDrvIns->Internal.s.pDown) 326 pDrvIns = pDrvIns->Internal.s.pDown; 327 328 /* And destroy them one at a time from the bottom up. */ 322 /* 323 * Destroy them one at a time from the bottom up. 324 * (The serial device/drivers depends on this - bad.) 325 */ 326 PPDMDRVINS pDrvIns = pLun->pBottom; 327 pLun->pBottom = pLun->pTop = NULL; 329 328 while (pDrvIns) 330 329 { … … 336 335 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pLun->iLun, pszDevice, iInstance)); 337 336 pDrvIns->pDrvReg->pfnDestruct(pDrvIns); 338 339 337 } 340 338 … … 660 658 } 661 659 660 #ifdef VBOX_WITH_USB 661 for (PPDMUSBINS pUsbIns = pVM->pdm.s.pUsbInstances; pUsbIns; pUsbIns = pUsbIns->Internal.s.pNext) 662 { 663 for (PPDMLUN pLun = pUsbIns->Internal.s.pLuns; pLun; pLun = pLun->pNext) 664 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 665 if (pDrvIns->pDrvReg->pfnPowerOn) 666 { 667 LogFlow(("PDMR3PowerOn: Notifying - driver '%s'/%d on LUN#%d of usb device '%s'/%d\n", 668 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pLun->iLun, pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 669 pDrvIns->pDrvReg->pfnPowerOn(pDrvIns); 670 } 671 672 if (pUsbIns->pUsbReg->pfnVMPowerOn) 673 { 674 LogFlow(("PDMR3PowerOn: Notifying - device '%s'/%d\n", 675 pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 676 pUsbIns->pUsbReg->pfnVMPowerOn(pUsbIns); 677 } 678 } 679 #endif 680 662 681 /* 663 682 * Resume all threads. … … 712 731 } 713 732 733 #ifdef VBOX_WITH_USB 734 for (PPDMUSBINS pUsbIns = pVM->pdm.s.pUsbInstances; pUsbIns; pUsbIns = pUsbIns->Internal.s.pNext) 735 { 736 for (PPDMLUN pLun = pUsbIns->Internal.s.pLuns; pLun; pLun = pLun->pNext) 737 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 738 if (pDrvIns->pDrvReg->pfnReset) 739 { 740 LogFlow(("PDMR3Reset: Notifying - driver '%s'/%d on LUN#%d of usb device '%s'/%d\n", 741 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pLun->iLun, pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 742 pDrvIns->pDrvReg->pfnReset(pDrvIns); 743 } 744 745 if (pUsbIns->pUsbReg->pfnVMReset) 746 { 747 LogFlow(("PDMR3Reset: Notifying - device '%s'/%d\n", 748 pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 749 pUsbIns->pUsbReg->pfnVMReset(pUsbIns); 750 } 751 } 752 #endif 753 714 754 LogFlow(("PDMR3Reset: returns void\n")); 715 755 } … … 733 773 { 734 774 for (PPDMLUN pLun = pDevIns->Internal.s.pLunsHC; pLun; pLun = pLun->pNext) 735 /** @todo Inverse the order here? */736 775 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 737 776 if (pDrvIns->pDrvReg->pfnSuspend) … … 750 789 } 751 790 791 #ifdef VBOX_WITH_USB 792 for (PPDMUSBINS pUsbIns = pVM->pdm.s.pUsbInstances; pUsbIns; pUsbIns = pUsbIns->Internal.s.pNext) 793 { 794 for (PPDMLUN pLun = pUsbIns->Internal.s.pLuns; pLun; pLun = pLun->pNext) 795 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 796 if (pDrvIns->pDrvReg->pfnSuspend) 797 { 798 LogFlow(("PDMR3Suspend: Notifying - driver '%s'/%d on LUN#%d of usb device '%s'/%d\n", 799 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pLun->iLun, pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 800 pDrvIns->pDrvReg->pfnSuspend(pDrvIns); 801 } 802 803 if (pUsbIns->pUsbReg->pfnVMSuspend) 804 { 805 LogFlow(("PDMR3Suspend: Notifying - device '%s'/%d\n", 806 pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 807 pUsbIns->pUsbReg->pfnVMSuspend(pUsbIns); 808 } 809 } 810 #endif 811 752 812 /* 753 813 * Suspend all threads. … … 776 836 { 777 837 for (PPDMLUN pLun = pDevIns->Internal.s.pLunsHC; pLun; pLun = pLun->pNext) 778 /** @todo Inverse the order here? */779 838 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 780 839 if (pDrvIns->pDrvReg->pfnResume) … … 793 852 } 794 853 854 #ifdef VBOX_WITH_USB 855 for (PPDMUSBINS pUsbIns = pVM->pdm.s.pUsbInstances; pUsbIns; pUsbIns = pUsbIns->Internal.s.pNext) 856 { 857 for (PPDMLUN pLun = pUsbIns->Internal.s.pLuns; pLun; pLun = pLun->pNext) 858 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 859 if (pDrvIns->pDrvReg->pfnResume) 860 { 861 LogFlow(("PDMR3Resume: Notifying - driver '%s'/%d on LUN#%d of usb device '%s'/%d\n", 862 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pLun->iLun, pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 863 pDrvIns->pDrvReg->pfnResume(pDrvIns); 864 } 865 866 if (pUsbIns->pUsbReg->pfnVMResume) 867 { 868 LogFlow(("PDMR3Resume: Notifying - device '%s'/%d\n", 869 pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 870 pUsbIns->pUsbReg->pfnVMResume(pUsbIns); 871 } 872 } 873 #endif 874 795 875 /* 796 876 * Resume all threads. … … 819 899 { 820 900 for (PPDMLUN pLun = pDevIns->Internal.s.pLunsHC; pLun; pLun = pLun->pNext) 821 /** @todo Inverse the order here? */822 901 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 823 902 if (pDrvIns->pDrvReg->pfnPowerOff) … … 835 914 } 836 915 } 916 917 #ifdef VBOX_WITH_USB 918 for (PPDMUSBINS pUsbIns = pVM->pdm.s.pUsbInstances; pUsbIns; pUsbIns = pUsbIns->Internal.s.pNext) 919 { 920 for (PPDMLUN pLun = pUsbIns->Internal.s.pLuns; pLun; pLun = pLun->pNext) 921 for (PPDMDRVINS pDrvIns = pLun->pTop; pDrvIns; pDrvIns = pDrvIns->Internal.s.pDown) 922 if (pDrvIns->pDrvReg->pfnPowerOff) 923 { 924 LogFlow(("PDMR3PowerOff: Notifying - driver '%s'/%d on LUN#%d of usb device '%s'/%d\n", 925 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pLun->iLun, pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 926 pDrvIns->pDrvReg->pfnPowerOff(pDrvIns); 927 } 928 929 if (pUsbIns->pUsbReg->pfnVMPowerOff) 930 { 931 LogFlow(("PDMR3PowerOff: Notifying - device '%s'/%d\n", 932 pUsbIns->pUsbReg->szDeviceName, pUsbIns->iInstance)); 933 pUsbIns->pUsbReg->pfnVMPowerOff(pUsbIns); 934 } 935 } 936 #endif 837 937 838 938 /* -
trunk/src/VBox/VMM/PDMDevice.cpp
r5525 r5722 955 955 #ifdef VBOX_WITH_USB 956 956 /* ditto for USB Devices. */ 957 rc = pdmR3Usb InitComplete(pVM);957 rc = pdmR3UsbVMInitComplete(pVM); 958 958 if (RT_FAILURE(rc)) 959 959 return rc; … … 1965 1965 pLun->pNext = pLunPrev ? pLunPrev->pNext : NULL; 1966 1966 pLun->pTop = NULL; 1967 pLun->pBottom = NULL; 1967 1968 pLun->pDevIns = pDevIns; 1968 1969 pLun->pszDesc = pszDesc; … … 2042 2043 * Link with LUN and call the constructor. 2043 2044 */ 2045 pLun->pTop = pLun->pBottom = pNew; 2044 2046 rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle); 2045 2047 if (VBOX_SUCCESS(rc)) 2046 2048 { 2047 pLun->pTop = pNew;2048 2049 MMR3HeapFree(pszName); 2049 2050 *ppBaseInterface = &pNew->IBase; … … 2059 2060 * Free the driver. 2060 2061 */ 2061 pLun->pTop = NULL;2062 pLun->pTop = pLun->pBottom = NULL; 2062 2063 ASMMemFill32(pNew, cb, 0xdeadd0d0); 2063 2064 MMR3HeapFree(pNew); … … 4318 4319 4319 4320 /** 4320 * Detaches a driver from an existing device instance.4321 * Detaches a driver chain from an existing device instance. 4321 4322 * 4322 4323 * This is used to change drivers and suchlike at runtime. -
trunk/src/VBox/VMM/PDMDriver.cpp
r5530 r5722 437 437 /* 438 438 * Check that we actually can detach this instance. 439 * The requirement is that the driver/device above ha vea detach method.439 * The requirement is that the driver/device above has a detach method. 440 440 */ 441 441 if (pDrvIns->Internal.s.pUp … … 448 448 449 449 /* 450 * Detach the bottom most driver until we've detached pDrvIns. 450 * Join paths with pdmR3DrvDestroyChain. 451 */ 452 pdmR3DrvDestroyChain(pDrvIns); 453 return VINF_SUCCESS; 454 } 455 456 457 /** 458 * Destroys a driver chain starting with the specified driver. 459 * 460 * This is used when unplugging a device at run time. 461 * 462 * @param pDrvIns Pointer to the driver instance to start with. 463 */ 464 void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns) 465 { 466 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM); 467 468 /* 469 * Detach the bottommost driver until we've detached pDrvIns. 451 470 */ 452 471 pDrvIns->Internal.s.fDetaching = true; … … 464 483 */ 465 484 pCur->Internal.s.fDetaching = true; 485 486 PPDMLUN pLun = pCur->Internal.s.pLun; 487 Assert(pLun->pBottom == pCur); 488 pLun->pBottom = pCur->Internal.s.pUp; 489 466 490 if (pCur->Internal.s.pUp) 467 491 { … … 479 503 { 480 504 /* device parent */ 481 PPDMLUN pLun = pCur->Internal.s.pLun;505 Assert(pLun->pTop == pCur); 482 506 pLun->pTop = NULL; 483 507 if (pLun->pDevIns->pDevReg->pfnDetach) … … 512 536 513 537 } while (pCur != pDrvIns); 514 515 return VINF_SUCCESS;516 538 } 517 539 … … 531 553 if (!pDrvIns->Internal.s.pDown) 532 554 { 555 Assert(pDrvIns->Internal.s.pLun->pBottom == pDrvIns); 556 533 557 /* 534 558 * Get the attached driver configuration. 535 559 */ 536 PCFGMNODE 560 PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver"); 537 561 if (pNode) 538 562 { … … 545 569 */ 546 570 PVM pVM = pDrvIns->Internal.s.pVM; 547 PPDMDRV 571 PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName); 548 572 if (pDrv) 549 573 { … … 585 609 */ 586 610 pDrvIns->Internal.s.pDown = pNew; 611 pDrvIns->Internal.s.pLun->pBottom = pNew; 612 587 613 Log(("PDM: Constructing driver '%s' instance %d...\n", pNew->pDrvReg->szDriverName, pNew->iInstance)); 588 614 rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle); … … 597 623 * Unlink and free the data. 598 624 */ 625 Assert(pDrvIns->Internal.s.pLun->pBottom == pNew); 626 pDrvIns->Internal.s.pLun->pBottom = pDrvIns; 599 627 pDrvIns->Internal.s.pDown = NULL; 600 628 ASMMemFill32(pNew, cb, 0xdeadd0d0); -
trunk/src/VBox/VMM/PDMInternal.h
r5525 r5722 281 281 /** Pointer to the top driver in the driver chain. */ 282 282 PPDMDRVINS pTop; 283 /** Pointer to the bottom driver in the driver chain. */ 284 PPDMDRVINS pBottom; 283 285 /** Pointer to the device instance which the LUN belongs to. 284 286 * Either this is set or pUsbIns is set. Both is never set at the same time. */ … … 879 881 int pdmR3UsbLoadModules(PVM pVM); 880 882 int pdmR3UsbInstantiateDevices(PVM pVM); 881 int pdmR3UsbInitComplete(PVM pVM);882 883 PPDMUSB pdmR3UsbLookup(PVM pVM, const char *pszName); 883 884 int pdmR3UsbFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun); 884 885 int pdmR3UsbRegisterHub(PVM pVM, PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp); 886 int pdmR3UsbVMInitComplete(PVM pVM); 885 887 886 888 int pdmR3DrvInit(PVM pVM); 887 889 int pdmR3DrvDetach(PPDMDRVINS pDrvIns); 890 void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns); 888 891 PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName); 889 892
Note:
See TracChangeset
for help on using the changeset viewer.