Changeset 77828 in vbox for trunk/src/VBox/Devices/Samples
- Timestamp:
- Mar 21, 2019 3:01:15 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129510
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Samples/DevPlayground.cpp
r76553 r77828 200 200 * Validate and read the configuration. 201 201 */ 202 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Whatever1|Whatever2", ""); 202 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Whatever1|NumFunctions|BigBAR0MB|BigBAR0GB|BigBAR2MB|BigBAR2GB", ""); 203 204 uint8_t uNumFunctions; 205 rc = CFGMR3QueryU8Def(pCfg, "NumFunctions", &uNumFunctions, RT_ELEMENTS(pThis->aPciFuns)); 206 if (RT_FAILURE(rc)) 207 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query integer value \"NumFunctions\"")); 208 if ((uNumFunctions < 1) || (uNumFunctions > RT_ELEMENTS(pThis->aPciFuns))) 209 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Invalid \"NumFunctions\" value (must be between 1 and 8)")); 210 211 RTGCPHYS cbFirstBAR; 212 uint16_t uBigBAR0GB; 213 rc = CFGMR3QueryU16Def(pCfg, "BigBAR0GB", &uBigBAR0GB, 0); /* Default to nothing. */ 214 if (RT_FAILURE(rc)) 215 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query integer value \"BigBAR0GB\"")); 216 if (uBigBAR0GB > 512) 217 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Invalid \"BigBAR0GB\" value (must be 512 or less)")); 218 219 if (uBigBAR0GB) 220 cbFirstBAR = uBigBAR0GB * _1G64; 221 else 222 { 223 uint16_t uBigBAR0MB; 224 rc = CFGMR3QueryU16Def(pCfg, "BigBAR0MB", &uBigBAR0MB, 8); /* 8 MB default. */ 225 if (RT_FAILURE(rc)) 226 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query integer value \"BigBAR0MB\"")); 227 if (uBigBAR0MB < 1 || uBigBAR0MB > 4095) 228 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Invalid \"BigBAR0MB\" value (must be between 1 and 4095)")); 229 cbFirstBAR = uBigBAR0MB * _1M; 230 } 231 232 RTGCPHYS cbSecondBAR; 233 uint16_t uBigBAR2GB; 234 rc = CFGMR3QueryU16Def(pCfg, "BigBAR2GB", &uBigBAR2GB, 0); /* Default to nothing. */ 235 if (RT_FAILURE(rc)) 236 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query integer value \"BigBAR2GB\"")); 237 if (uBigBAR2GB > 512) 238 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Invalid \"BigBAR2GB\" value (must be 512 or less)")); 239 240 if (uBigBAR2GB) 241 cbSecondBAR = uBigBAR2GB * _1G64; 242 else 243 { 244 uint16_t uBigBAR2MB; 245 rc = CFGMR3QueryU16Def(pCfg, "BigBAR2MB", &uBigBAR2MB, 16); /* 16 MB default. */ 246 if (RT_FAILURE(rc)) 247 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query integer value \"BigBAR2MB\"")); 248 if (uBigBAR2MB < 1 || uBigBAR2MB > 4095) 249 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Invalid \"BigBAR2MB\" value (must be between 1 and 4095)")); 250 cbSecondBAR = uBigBAR2MB * _1M; 251 } 252 203 253 204 254 /* … … 206 256 */ 207 257 uint32_t iPciDevNo = PDMPCIDEVREG_DEV_NO_FIRST_UNUSED; 208 for (uint32_t iPciFun = 0; iPciFun < RT_ELEMENTS(pThis->aPciFuns); iPciFun++)258 for (uint32_t iPciFun = 0; iPciFun < uNumFunctions; iPciFun++) 209 259 { 210 260 PVBOXPLAYGROUNDDEVICEFUNCTION pFun = &pThis->aPciFuns[iPciFun]; … … 220 270 221 271 rc = PDMDevHlpPCIRegisterEx(pDevIns, &pFun->PciDev, iPciFun, 0 /*fFlags*/, iPciDevNo, iPciFun, 222 272 pThis->aPciFuns[iPciFun].szName); 223 273 AssertLogRelRCReturn(rc, rc); 224 274 225 275 /* First region. */ 226 RTGCPHYS const cbFirst = iPciFun == 0 ? 8*_1M: iPciFun * _4K;276 RTGCPHYS const cbFirst = iPciFun == 0 ? cbFirstBAR : iPciFun * _4K; 227 277 rc = PDMDevHlpPCIIORegionRegisterEx(pDevIns, &pFun->PciDev, 0, cbFirst, 228 278 (PCIADDRESSSPACE)( PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_BAR64 … … 241 291 242 292 /* Second region. */ 243 RTGCPHYS const cbSecond = iPciFun == 0 ? 32*_1M: iPciFun * _32K;293 RTGCPHYS const cbSecond = iPciFun == 0 ? cbSecondBAR : iPciFun * _32K; 244 294 rc = PDMDevHlpPCIIORegionRegisterEx(pDevIns, &pFun->PciDev, 2, cbSecond, 245 295 (PCIADDRESSSPACE)( PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_BAR64
Note:
See TracChangeset
for help on using the changeset viewer.