- Timestamp:
- Jul 25, 2019 8:10:25 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r79929 r79973 55 55 typedef struct VIRTIOSCSITARGET 56 56 { 57 58 59 /** Pointer to the owning virtioScsi device instance. - R3 pointer */ 57 /** Pointer to PCI device that owns this target instance. - R3 /pointer */ 60 58 R3PTRTYPE(struct VIRTIOSCSI *) pVirtioScsiR3; 61 /** Pointer to the owning virtioScsi deviceinstance. - R0 pointer */59 /** Pointer to PCI device that owns this target instance. - R0 pointer */ 62 60 R3PTRTYPE(struct VIRTIOSCSI *) pVirtioScsiR0; 63 /** Pointer to the owning virtioScsi deviceinstance. - RC pointer */61 /** Pointer to PCI device that owns this target instance. - RC pointer */ 64 62 R3PTRTYPE(struct VIRTIOSCSI *) pVirtioScsiRC; 65 63 … … 108 106 typedef struct VIRTIOSCSI 109 107 { 108 /* virtioState must be first member */ 109 VIRTIOSTATE virtioState; 110 111 /* SCSI target instances data */ 112 VIRTIOSCSITARGET aTargetInstances[VIRTIOSCSI_MAX_TARGETS]; 110 113 111 114 PPDMDEVINSR3 pDevInsR3; /**< Device instance - R3. */ 112 115 PPDMDEVINSR0 pDevInsR0; /**< Device instance - R0. */ 113 116 PPDMDEVINSRC pDevInsRC; /**< Device instance - RC. */ 114 115 /* virtioState must be first member */116 VIRTIOSTATE virtioState;117 118 /* SCSI target instances data */119 VIRTIOSCSITARGET aTargetInstances[VIRTIOSCSI_MAX_TARGETS];120 121 /** Base address of the I/O ports. */122 RTIOPORT IOPortBase;123 117 124 118 /** Base address of the memory mapping. */ … … 766 760 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pTarget->IMediaPort); 767 761 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAEXPORT, &pTarget->IMediaExPort); 762 763 /* This call back is necessary to get Status / LED support */ 764 return virtioQueryInterface(pInterface, pszIID); 765 768 766 return NULL; 769 767 } … … 867 865 pVirtioPciParams->uInterruptPin = 0x01; 868 866 869 870 PVIRTIOSTATE pVirtioScsi = &(pThis->virtioState); 871 rc = virtioConstruct(pDevIns, pVirtioScsi, iInstance, pVirtioPciParams, 867 PVIRTIOSTATE pVirtio = &(pThis->virtioState); 868 pDevIns->IBase.pfnQueryInterface = virtioScsiR3DeviceQueryInterface; 869 870 rc = virtioConstruct(pDevIns, pVirtio, iInstance, pVirtioPciParams, 872 871 VIRTIO_SCSI_NAME_FMT, VIRTIO_SCSI_N_QUEUES, VIRTIO_SCSI_REGION_PCI_CAP, 873 virtioScsiR3DevCapRead, virtioScsiR3DevCapWrite, sizeof(VIRTIODEVC FG));872 virtioScsiR3DevCapRead, virtioScsiR3DevCapWrite, sizeof(VIRTIODEVCAP)); 874 873 if (RT_FAILURE(rc)) 875 874 return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi: failed to initialize VirtIO")); 876 875 877 rc = PDMDevHlpPCIIORegionRegister(pDevIns, VIRTIO_SCSI_REGION_ PORT_IO, 32,876 rc = PDMDevHlpPCIIORegionRegister(pDevIns, VIRTIO_SCSI_REGION_MEM_IO, 32, 878 877 PCI_ADDRESS_SPACE_MEM, virtioScsiR3Map); 879 878 if (RT_FAILURE(rc)) … … 904 903 PVIRTIOSCSITARGET pTarget = &pThis->aTargetInstances[iLUN]; 905 904 906 if (RTStrAPrintf(&pTarget->pszLunName, "V SCSI%u", iLUN) < 0)905 if (RTStrAPrintf(&pTarget->pszLunName, "VIRTIOSCSI%u", iLUN) < 0) 907 906 AssertLogRelFailedReturn(VERR_NO_MEMORY); 908 907 … … 919 918 pTarget->IMediaExPort.pfnIoReqQueryBuf = NULL; 920 919 pTarget->IMediaExPort.pfnIoReqQueryDiscardRanges = NULL; 921 pDevIns->IBase.pfnQueryInterface = virtioScsiR3DeviceQueryInterface;922 920 923 921 LogFunc(("Attaching LUN: %s\n", pTarget->pszLunName)); … … 986 984 "virtio-scsi", 987 985 /* szRCMod */ 988 " ",986 "VBoxDDRC.rc", 989 987 /* szR0Mod */ 990 " ",988 "VBoxDDR0.r0", 991 989 /* pszDescription */ 992 "Virtio SCSI.\n",990 "Virtio Host SCSI.\n", 993 991 /* fFlags */ 994 992 #ifdef VIRTIOSCSI_GC_SUPPORT -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r79941 r79973 22 22 #define LOG_GROUP LOG_GROUP_DEV_VIRTIO 23 23 24 #include <VBox/log.h> 24 25 #include <iprt/param.h> 26 #include <iprt/assert.h> 25 27 #include <iprt/uuid.h> 26 28 #include <VBox/vmm/pdmdev.h> … … 717 719 uint16_t cbDevSpecificCap) 718 720 { 719 720 721 RT_NOREF(nQueues); 721 722 … … 730 731 pVirtio->pfnVirtioDevCapRead = devCapReadCallback; 731 732 pVirtio->pfnVirtioDevCapWrite = devCapWriteCallback; 732 733 int rc = VINF_SUCCESS;734 rc = PDMDevHlpPCIIORegionRegister(pDevIns, uVirtioRegion, 32, PCI_ADDRESS_SPACE_MEM, virtioR3Map);735 if (RT_FAILURE(rc))736 return PDMDEV_SET_ERROR(pDevIns, rc,737 N_("virtio: cannot register PCI Capabilities address space")); /* can we put params in this error? */738 739 733 740 734 /* Set PCI config registers (assume 32-bit mode) */ … … 750 744 PCIDevSetInterruptPin (&pVirtio->dev, pPciParams->uInterruptPin); 751 745 746 int rc = VINF_SUCCESS; 747 /* Register PCI device */ 748 rc = PDMDevHlpPCIRegister(pDevIns, &pVirtio->dev); 749 if (RT_FAILURE(rc)) 750 return PDMDEV_SET_ERROR(pDevIns, rc, 751 N_("virtio: cannot register PCI Device")); /* can we put params in this error? */ 752 753 pVirtio->IBase = pDevIns->IBase; 754 755 rc = PDMDevHlpPCIIORegionRegister(pDevIns, uVirtioRegion, 32, PCI_ADDRESS_SPACE_MEM, virtioR3Map); 756 if (RT_FAILURE(rc)) 757 return PDMDEV_SET_ERROR(pDevIns, rc, 758 N_("virtio: cannot register PCI Capabilities address space")); /* can we put params in this error? */ 759 752 760 /** Build PCI vendor-specific capabilities list for exchanging 753 761 * VirtIO device capabilities with driver */ … … 758 766 #endif 759 767 uint8_t uCfgCapOffset = 0x40; 760 PVIRTIOPCICAP pCommonCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 761 pCommonCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 762 pCommonCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP); 763 pCommonCfg->uCfgType = VIRTIO_PCI_CAP_COMMON_CFG; 764 pCommonCfg->uBar = uVirtioRegion; 765 pCommonCfg->uOffset = 0; 766 pCommonCfg->uLength = sizeof(VIRTIOPCICAP); 767 768 PVIRTIOPCICAP pNotifyCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 769 pNotifyCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 770 pNotifyCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP); 771 pNotifyCfg->uCfgType = VIRTIO_PCI_CAP_NOTIFY_CFG; 772 pNotifyCfg->uBar = uVirtioRegion; 773 pNotifyCfg->uOffset = pVirtio->pCommonCfg->uOffset + sizeof(VIRTIOCOMMONCFG); 774 pNotifyCfg->uLength = sizeof(VIRTIOPCICAP); 775 776 PVIRTIOPCICAP pISRConfig = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 777 pISRConfig->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 778 pISRConfig->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP); 779 pISRConfig->uCfgType = VIRTIO_PCI_CAP_ISR_CFG; 780 pISRConfig->uBar = uVirtioRegion; 781 pISRConfig->uOffset = pVirtio->pNotifyCfg->uOffset + sizeof(VIRTIONOTIFYCFG); 782 pISRConfig->uLength = sizeof(VIRTIOPCICAP); 783 784 PVIRTIOPCICAP pPCIConfig = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 785 pPCIConfig->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 786 pPCIConfig->uCapNext = (uint8_t)(fMsiSupport || cbDevSpecificCap ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)): 0); 787 pPCIConfig->uCfgType = VIRTIO_PCI_CAP_PCI_CFG; 788 pPCIConfig->uBar = uVirtioRegion; 789 pPCIConfig->uOffset = pVirtio->pISRConfig->uOffset + sizeof(VIRTIOISRCFG); 790 pPCIConfig->uLength = sizeof(VIRTIOPCICAP); 791 792 pVirtio->pCommonCfg = pCommonCfg; 793 pVirtio->pNotifyCfg = pNotifyCfg; 794 pVirtio->pISRConfig = pISRConfig; 795 pVirtio->pPCIConfig = pPCIConfig; 768 /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_common_cfg (VIRTIOCOMMONCFG)*/ 769 PVIRTIOPCICAP pCfg = pVirtio->pCommonCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 770 pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 771 pCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP); 772 pCfg->uCfgType = VIRTIO_PCI_CAP_COMMON_CFG; 773 pCfg->uBar = uVirtioRegion; 774 pCfg->uOffset = 0; 775 pCfg->uLength = sizeof(VIRTIOPCICAP); 776 777 /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_notify_cap (VIRTIONOTIFYCAP)*/ 778 pCfg = pVirtio->pNotifyCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 779 pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 780 pCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP); 781 pCfg->uCfgType = VIRTIO_PCI_CAP_NOTIFY_CFG; 782 pCfg->uBar = uVirtioRegion; 783 pCfg->uOffset = pVirtio->pCommonCfg->uOffset + sizeof(VIRTIOCOMMONCFG); 784 pCfg->uLength = sizeof(VIRTIOPCICAP); 785 786 /* Capability will be mapped via VirtIO 1.0: uint8_t (VIRTIOISRCAP) */ 787 pCfg = pVirtio->pISRCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 788 pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 789 pCfg->uCapNext = uCfgCapOffset += sizeof(VIRTIOPCICAP); 790 pCfg->uCfgType = VIRTIO_PCI_CAP_ISR_CFG; 791 pCfg->uBar = uVirtioRegion; 792 pCfg->uOffset = pVirtio->pNotifyCap->uOffset + sizeof(VIRTIONOTIFYCAP); 793 pCfg->uLength = sizeof(VIRTIOPCICAP); 794 795 /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_cfg_cap (VIRTIOPCICAP) */ 796 pCfg = pVirtio->pPCICfgCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 797 pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 798 pCfg->uCapNext = (uint8_t)(fMsiSupport || cbDevSpecificCap ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)): 0); 799 pCfg->uCfgType = VIRTIO_PCI_CAP_PCI_CFG; 800 pCfg->uBar = uVirtioRegion; 801 pCfg->uOffset = pVirtio->pISRCap->uOffset + sizeof(VIRTIOISRCAP); 802 pCfg->uLength = sizeof(VIRTIOPCICAP); 796 803 797 804 if (cbDevSpecificCap) 798 805 { 799 PVIRTIOPCICAP pDeviceCfg = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset];800 p DeviceCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR;801 p DeviceCfg->uCapNext = (uint8_t)(fMsiSupport ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)) : 0);802 p DeviceCfg->uCfgType = VIRTIO_PCI_CAP_DEVICE_CFG;803 p DeviceCfg->uBar = uVirtioRegion;804 p DeviceCfg->uOffset = pVirtio->pPCIConfig->uOffset + sizeof(VIRTIOCAPCFG);805 p DeviceCfg->uLength =sizeof(VIRTIOPCICAP);806 p Virtio->pDeviceCfg = pDeviceCfg;806 /* Capability will be mapped via VirtIO 1.0: struct virtio_pci_dev_cap (VIRTIODEVCAP)*/ 807 pCfg = pVirtio->pDeviceCap = (PVIRTIOPCICAP)&pVirtio->dev.abConfig[uCfgCapOffset]; 808 pCfg->uCapVndr = VIRTIO_PCI_CAP_ID_VENDOR; 809 pCfg->uCapNext = (uint8_t)(fMsiSupport ? (uCfgCapOffset += sizeof(VIRTIOPCICAP)) : 0); 810 pCfg->uCfgType = VIRTIO_PCI_CAP_DEVICE_CFG; 811 pCfg->uBar = uVirtioRegion; 812 pCfg->uOffset = pVirtio->pPCICfgCap->uOffset + sizeof(VIRTIOPCICAP); 813 pCfg->uLength = sizeof(VIRTIOPCICAP); 807 814 } 808 815 … … 810 817 PCIDevSetCapabilityList (&pVirtio->dev, 0x40); 811 818 PCIDevSetStatus (&pVirtio->dev, VBOX_PCI_STATUS_CAP_LIST); 812 813 /* Register PCI device */814 rc = PDMDevHlpPCIRegister(pDevIns, &pVirtio->dev);815 if (RT_FAILURE(rc))816 return rc;817 819 818 820 if (fMsiSupport) … … 834 836 835 837 /* Status driver */ 836 PPDMIBASE pBase; 837 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pVirtio->IBase, &pBase, "Status Port"); 838 PPDMIBASE pUpstreamBase; 839 840 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pVirtio->IBase, &pUpstreamBase, "Status Port"); 838 841 if (RT_FAILURE(rc)) 839 842 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the status LUN")); 840 pVirtio->pLedsConnector = PDMIBASE_QUERY_INTERFACE( pBase, PDMILEDCONNECTORS);843 pVirtio->pLedsConnector = PDMIBASE_QUERY_INTERFACE(&pVirtio->IBase, PDMILEDCONNECTORS); 841 844 842 845 return rc; -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h
r79928 r79973 1 1 /* $Id$ */ 2 2 /** @file 3 * Virtio_1_0 .h - Virtio Declarations3 * Virtio_1_0p .h - Virtio Declarations 4 4 */ 5 5 … … 175 175 struct virtio_pci_cap cap; 176 176 uint32_t uNotifyOffMultiplier; /* notify_off_multiplier */ 177 } VIRTIONOTIFYC FG, *PVIRTIONOTIFYCFG;178 179 typedef uint 32_t VIRTIOISRCFG, *PVIRTIOISRCFG;177 } VIRTIONOTIFYCAP, *PVIRTIONOTIFYCAP; 178 179 typedef uint8_t VIRTIOISRCAP, *PVIRTIOISRCAP; 180 180 181 181 /* Device-specific configuration (if any) ... T.B.D. (if and when neeed), provide an … … 185 185 typedef struct virtio_pci_dev_cfg 186 186 { 187 } VIRTIODEVC FG, *PVIRTIODEVCFG;187 } VIRTIODEVCAP, *PVIRTIODEVCAP; 188 188 189 189 typedef struct virtio_pci_cfg_cap { 190 190 struct virtio_pci_cap cap; 191 191 uint8_t pci_cfg_data[4]; /* Data for BAR access. */ 192 } VIRTIO CAPCFG, *PVIRTIOCAPCFG;192 } VIRTIOPCICFGCAP, *PVIRTIOPCICFGCAP; 193 193 194 194 typedef struct virtq_desc /* VirtIO 1.0 specification formal name of this struct */ … … 319 319 320 320 VIRTIOCOMMONCFG pGcPhysVirtioCommonCfg; 321 VIRTIONOTIFYC FG pGcPhysVirtioNotifyCfg;322 VIRTIOISRC FG pGcPhysVirtioIsrCfg;323 VIRTIO CAPCFG pGcPhysVirtioCapCfg;324 VIRTIO DEVCFG pGcPhysVirtioDevCfg;321 VIRTIONOTIFYCAP pGcPhysVirtioNotifyCap; 322 VIRTIOISRCAP pGcPhysVirtioIsrCap; 323 VIRTIODEVCAP pGcPhysVirtioDevCap; 324 VIRTIOPCICFGCAP pGcPhysVirtioPciCap; 325 325 326 326 /** Callbacks when guest driver reads or writes VirtIO device-specific capabilities(s) */ … … 353 353 354 354 PVIRTIOPCICAP pCommonCfg; 355 PVIRTIOPCICAP pNotifyC fg;356 PVIRTIOPCICAP pISRC onfig;357 PVIRTIOPCICAP pPCIC onfig;358 PVIRTIOPCICAP pDeviceC fg;355 PVIRTIOPCICAP pNotifyCap; 356 PVIRTIOPCICAP pISRCap; 357 PVIRTIOPCICAP pPCICfgCap; 358 PVIRTIOPCICAP pDeviceCap; 359 359 } VIRTIOSTATE, *PVIRTIOSTATE; 360 360
Note:
See TracChangeset
for help on using the changeset viewer.