Changeset 81031 in vbox for trunk/src/VBox/Devices/Samples
- Timestamp:
- Sep 26, 2019 7:26:33 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133634
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Samples/DevPlayground.cpp
r80704 r81031 51 51 typedef struct VBOXPLAYGROUNDDEVICEFUNCTION 52 52 { 53 /** The PCI devices. */54 PDMPCIDEV PciDev;55 53 /** The function number. */ 56 54 uint8_t iFun; … … 203 201 204 202 uint8_t uNumFunctions; 203 AssertCompile(RT_ELEMENTS(pThis->aPciFuns) <= RT_ELEMENTS(pDevIns->apPciDevs)); 205 204 rc = CFGMR3QueryU8Def(pCfg, "NumFunctions", &uNumFunctions, RT_ELEMENTS(pThis->aPciFuns)); 206 205 if (RT_FAILURE(rc)) … … 258 257 for (uint32_t iPciFun = 0; iPciFun < uNumFunctions; iPciFun++) 259 258 { 260 PVBOXPLAYGROUNDDEVICEFUNCTION pFun = &pThis->aPciFuns[iPciFun]; 261 RTStrPrintf(pFun->szName, sizeof(pThis->aPciFuns[iPciFun].PciDev), "playground%u", iPciFun); 259 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[iPciFun]; 260 PVBOXPLAYGROUNDDEVICEFUNCTION pFun = &pThis->aPciFuns[iPciFun]; 261 RTStrPrintf(pFun->szName, sizeof(pFun->szName), "playground%u", iPciFun); 262 262 pFun->iFun = iPciFun; 263 263 264 PCIDevSetVendorId( &pFun->PciDev, 0x80ee); 265 PCIDevSetDeviceId( &pFun->PciDev, 0xde4e); 266 PCIDevSetClassBase(&pFun->PciDev, 0x07); /* communications device */ 267 PCIDevSetClassSub( &pFun->PciDev, 0x80); /* other communications device */ 268 if (iPciFun == 0) /* only for the primary function */ 269 PCIDevSetHeaderType(&pFun->PciDev, 0x80); /* normal, multifunction device */ 270 271 rc = PDMDevHlpPCIRegisterEx(pDevIns, &pFun->PciDev, iPciFun, 0 /*fFlags*/, iPciDevNo, iPciFun, 272 pThis->aPciFuns[iPciFun].szName); 264 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 265 266 PDMPciDevSetVendorId(pPciDev, 0x80ee); 267 PDMPciDevSetDeviceId(pPciDev, 0xde4e); 268 PDMPciDevSetClassBase(pPciDev, 0x07); /* communications device */ 269 PDMPciDevSetClassSub(pPciDev, 0x80); /* other communications device */ 270 if (iPciFun == 0) /* only for the primary function */ 271 PDMPciDevSetHeaderType(pPciDev, 0x80); /* normal, multifunction device */ 272 273 rc = PDMDevHlpPCIRegisterEx(pDevIns, pPciDev, 0 /*fFlags*/, iPciDevNo, iPciFun, pThis->aPciFuns[iPciFun].szName); 273 274 AssertLogRelRCReturn(rc, rc); 274 275 275 276 /* First region. */ 276 277 RTGCPHYS const cbFirst = iPciFun == 0 ? cbFirstBAR : iPciFun * _4K; 277 rc = PDMDevHlpPCIIORegionRegisterEx(pDevIns, &pFun->PciDev, 0, cbFirst,278 rc = PDMDevHlpPCIIORegionRegisterEx(pDevIns, pPciDev, 0, cbFirst, 278 279 (PCIADDRESSSPACE)( PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_BAR64 279 280 | (iPciFun == 0 ? PCI_ADDRESS_SPACE_MEM_PREFETCH : 0)), … … 283 284 RTStrAPrintf(&pszRegionName, "PG-F%d-BAR0", iPciFun); 284 285 Assert(pszRegionName); 285 rc = PDMDevHlpMMIOExPreRegister(pDevIns, &pFun->PciDev, 0, cbFirst,286 rc = PDMDevHlpMMIOExPreRegister(pDevIns, pPciDev, 0, cbFirst, 286 287 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, pszRegionName, 287 288 NULL /*pvUser*/, devPlaygroundMMIOWrite, devPlaygroundMMIORead, NULL /*pfnFill*/, … … 292 293 /* Second region. */ 293 294 RTGCPHYS const cbSecond = iPciFun == 0 ? cbSecondBAR : iPciFun * _32K; 294 rc = PDMDevHlpPCIIORegionRegisterEx(pDevIns, &pFun->PciDev, 2, cbSecond,295 rc = PDMDevHlpPCIIORegionRegisterEx(pDevIns, pPciDev, 2, cbSecond, 295 296 (PCIADDRESSSPACE)( PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_BAR64 296 297 | (iPciFun == 0 ? PCI_ADDRESS_SPACE_MEM_PREFETCH : 0)), … … 300 301 RTStrAPrintf(&pszRegionName, "PG-F%d-BAR2", iPciFun); 301 302 Assert(pszRegionName); 302 rc = PDMDevHlpMMIOExPreRegister(pDevIns, &pFun->PciDev, 2, cbSecond,303 rc = PDMDevHlpMMIOExPreRegister(pDevIns, pPciDev, 2, cbSecond, 303 304 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, pszRegionName, 304 305 NULL /*pvUser*/, devPlaygroundMMIOWrite, devPlaygroundMMIORead, NULL /*pfnFill*/, … … 351 352 /* .cbInstanceCC = */ 0, 352 353 /* .cbInstanceRC = */ 0, 353 /* .cMaxPciDevices = */ 1,354 /* .cMaxPciDevices = */ 8, 354 355 /* .cMaxMsixVectors = */ 0, 355 356 /* .pszDescription = */ "VBox Playground Device.",
Note:
See TracChangeset
for help on using the changeset viewer.