Changeset 59357 in vbox
- Timestamp:
- Jan 15, 2016 11:14:12 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105044
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r59351 r59357 314 314 /** LUN # to which this driver has been assigned. */ 315 315 uint8_t uLUN; 316 uint8_t Padding[5]; 316 /** Whether this driver is in an attached state or not. */ 317 bool fAttached; 318 uint8_t Padding[4]; 317 319 /** Pointer to attached driver base interface. */ 318 320 R3PTRTYPE(PPDMIBASE) pDrvBase; … … 2175 2177 2176 2178 /** 2177 * Attach command .2179 * Attach command, internal version. 2178 2180 * 2179 2181 * This is called to let the device attach to a driver for a specified LUN 2180 2182 * during runtime. This is not called during VM construction, the device 2181 * constructor ha veto attach to all the available drivers.2183 * constructor has to attach to all the available drivers. 2182 2184 * 2183 2185 * @returns VBox status code. 2184 2186 * @param pDevIns The device instance. 2187 * @param pDrv Driver to (re-)use for (re-)attaching to. 2188 * If NULL is specified, a new driver will be created and appended 2189 * to the driver list. 2185 2190 * @param uLUN The logical unit which is being detached. 2186 2191 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 2187 2192 */ 2188 static DECLCALLBACK(int) ichac97Attach (PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)2193 static DECLCALLBACK(int) ichac97AttachInternal(PPDMDEVINS pDevIns, PAC97DRIVER pDrv, unsigned uLUN, uint32_t fFlags) 2189 2194 { 2190 2195 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); … … 2204 2209 if (RT_SUCCESS(rc)) 2205 2210 { 2206 PAC97DRIVER pDrv = (PAC97DRIVER)RTMemAllocZ(sizeof(AC97DRIVER)); 2211 if (pDrv == NULL) 2212 pDrv = (PAC97DRIVER)RTMemAllocZ(sizeof(AC97DRIVER)); 2207 2213 if (pDrv) 2208 2214 { … … 2222 2228 LogFunc(("LUN#%RU8: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags)); 2223 2229 2224 /* Attach to driver list. */ 2225 RTListAppend(&pThis->lstDrv, &pDrv->Node); 2230 /* Attach to driver list if not attached yet. */ 2231 if (!pDrv->fAttached) 2232 { 2233 RTListAppend(&pThis->lstDrv, &pDrv->Node); 2234 pDrv->fAttached = true; 2235 } 2226 2236 } 2227 2237 else … … 2245 2255 LogFunc(("iLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); 2246 2256 return rc; 2257 } 2258 2259 2260 /** 2261 * Attach command. 2262 * 2263 * This is called to let the device attach to a driver for a specified LUN 2264 * during runtime. This is not called during VM construction, the device 2265 * constructor has to attach to all the available drivers. 2266 * 2267 * @returns VBox status code. 2268 * @param pDevIns The device instance. 2269 * @param uLUN The logical unit which is being detached. 2270 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 2271 */ 2272 static DECLCALLBACK(int) ichac97Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 2273 { 2274 return ichac97AttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags); 2247 2275 } 2248 2276 … … 2289 2317 2290 2318 if (RT_SUCCESS(rc)) 2291 rc = ichac97Attach (pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */);2319 rc = ichac97AttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */); 2292 2320 2293 2321 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc)); … … 2423 2451 { 2424 2452 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); 2425 rc = ichac97Attach (pDevIns, uLUN, 0 /* fFlags */);2453 rc = ichac97AttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */); 2426 2454 if (RT_FAILURE(rc)) 2427 2455 { … … 2511 2539 else if (cFailed) 2512 2540 { 2513 if (!pDrv->pConnector->pfnIsValidIn (p Drv->pConnector, pDrv->LineIn.pStrmIn))2541 if (!pDrv->pConnector->pfnIsValidIn (pCon, pDrv->LineIn.pStrmIn)) 2514 2542 LogRel(("AC97: WARNING: Unable to open PCM line input for LUN #%RU32!\n", pDrv->uLUN)); 2515 if (!pDrv->pConnector->pfnIsValidIn (p Drv->pConnector, pDrv->MicIn.pStrmIn))2543 if (!pDrv->pConnector->pfnIsValidIn (pCon, pDrv->MicIn.pStrmIn)) 2516 2544 LogRel(("AC97: WARNING: Unable to open PCM microphone input for LUN #%RU32!\n", pDrv->uLUN)); 2517 if (!pDrv->pConnector->pfnIsValidOut(p Drv->pConnector, pDrv->Out.pStrmOut))2545 if (!pDrv->pConnector->pfnIsValidOut(pCon, pDrv->Out.pStrmOut)) 2518 2546 LogRel(("AC97: WARNING: Unable to open PCM output for LUN #%RU32!\n", pDrv->uLUN)); 2519 2547 … … 2573 2601 /* Only register primary driver. 2574 2602 * The device emulation does the output multiplexing then. */ 2575 if ( pDrv->Flags != PDMAUDIODRVFLAG_PRIMARY)2603 if (!(pDrv->Flags & PDMAUDIODRVFLAG_PRIMARY)) 2576 2604 continue; 2577 2605 -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r59348 r59357 658 658 /** LUN to which this driver has been assigned. */ 659 659 uint8_t uLUN; 660 /** Whether this driver is in an attached state or not. */ 661 bool fAttached; 660 662 /** Pointer to attached driver base interface. */ 661 663 R3PTRTYPE(PPDMIBASE) pDrvBase; … … 4306 4308 } 4307 4309 4310 4308 4311 /** 4309 * Attach command .4312 * Attach command, internal version. 4310 4313 * 4311 4314 * This is called to let the device attach to a driver for a specified LUN 4312 4315 * during runtime. This is not called during VM construction, the device 4313 * constructor ha veto attach to all the available drivers.4316 * constructor has to attach to all the available drivers. 4314 4317 * 4315 4318 * @returns VBox status code. 4316 4319 * @param pDevIns The device instance. 4320 * @param pDrv Driver to (re-)use for (re-)attaching to. 4321 * If NULL is specified, a new driver will be created and appended 4322 * to the driver list. 4317 4323 * @param uLUN The logical unit which is being detached. 4318 4324 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 4319 4325 */ 4320 static DECLCALLBACK(int) hdaAttach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)4326 static int hdaAttachInternal(PPDMDEVINS pDevIns, PHDADRIVER pDrv, unsigned uLUN, uint32_t fFlags) 4321 4327 { 4322 4328 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4336 4342 if (RT_SUCCESS(rc)) 4337 4343 { 4338 PHDADRIVER pDrv = (PHDADRIVER)RTMemAllocZ(sizeof(HDADRIVER)); 4344 if (pDrv == NULL) 4345 pDrv = (PHDADRIVER)RTMemAllocZ(sizeof(HDADRIVER)); 4339 4346 if (pDrv) 4340 4347 { … … 4354 4361 LogFunc(("LUN#%u: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags)); 4355 4362 4356 /* Attach to driver list. */ 4357 RTListAppend(&pThis->lstDrv, &pDrv->Node); 4363 /* Attach to driver list if not attached yet. */ 4364 if (!pDrv->fAttached) 4365 { 4366 RTListAppend(&pThis->lstDrv, &pDrv->Node); 4367 pDrv->fAttached = true; 4368 } 4358 4369 } 4359 4370 else … … 4377 4388 LogFunc(("uLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); 4378 4389 return rc; 4390 } 4391 4392 /** 4393 * Attach command. 4394 * 4395 * This is called to let the device attach to a driver for a specified LUN 4396 * during runtime. This is not called during VM construction, the device 4397 * constructor has to attach to all the available drivers. 4398 * 4399 * @returns VBox status code. 4400 * @param pDevIns The device instance. 4401 * @param uLUN The logical unit which is being detached. 4402 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 4403 */ 4404 static DECLCALLBACK(int) hdaAttach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 4405 { 4406 return hdaAttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags); 4379 4407 } 4380 4408 … … 4421 4449 4422 4450 if (RT_SUCCESS(rc)) 4423 rc = hdaAttach (pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */);4451 rc = hdaAttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */); 4424 4452 4425 4453 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc)); … … 4585 4613 { 4586 4614 LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN)); 4587 rc = hdaAttach (pDevIns, uLUN, 0 /* fFlags */);4615 rc = hdaAttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */); 4588 4616 if (RT_FAILURE(rc)) 4589 4617 { -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r59351 r59357 97 97 /** LUN # to which this driver has been assigned. */ 98 98 uint8_t uLUN; 99 uint8_t Padding[5]; 99 /** Whether this driver is in an attached state or not. */ 100 bool fAttached; 101 uint8_t Padding[4]; 100 102 /** Pointer to attached driver base interface. */ 101 103 R3PTRTYPE(PPDMIBASE) pDrvBase; … … 192 194 193 195 /** 194 * Attach command .196 * Attach command, internal version. 195 197 * 196 198 * This is called to let the device attach to a driver for a specified LUN 197 199 * during runtime. This is not called during VM construction, the device 198 * constructor ha veto attach to all the available drivers.200 * constructor has to attach to all the available drivers. 199 201 * 200 202 * @returns VBox status code. 201 203 * @param pDevIns The device instance. 204 * @param pDrv Driver to (re-)use for (re-)attaching to. 205 * If NULL is specified, a new driver will be created and appended 206 * to the driver list. 202 207 * @param uLUN The logical unit which is being detached. 203 208 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 204 209 */ 205 static DECLCALLBACK(int) sb16Attach (PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)210 static DECLCALLBACK(int) sb16AttachInternal(PPDMDEVINS pDevIns, PSB16DRIVER pDrv, unsigned uLUN, uint32_t fFlags) 206 211 { 207 212 PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE); … … 221 226 if (RT_SUCCESS(rc)) 222 227 { 223 PSB16DRIVER pDrv = (PSB16DRIVER)RTMemAllocZ(sizeof(SB16DRIVER)); 228 if (pDrv == NULL) 229 pDrv = (PSB16DRIVER)RTMemAllocZ(sizeof(SB16DRIVER)); 224 230 if (pDrv) 225 231 { … … 239 245 LogFunc(("LUN#%RU8: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags)); 240 246 241 /* Attach to driver list. */ 242 RTListAppend(&pThis->lstDrv, &pDrv->Node); 247 /* Attach to driver list if not attached yet. */ 248 if (!pDrv->fAttached) 249 { 250 RTListAppend(&pThis->lstDrv, &pDrv->Node); 251 pDrv->fAttached = true; 252 } 243 253 } 244 254 else … … 262 272 LogFunc(("iLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); 263 273 return rc; 274 } 275 276 /** 277 * Attach command. 278 * 279 * This is called to let the device attach to a driver for a specified LUN 280 * during runtime. This is not called during VM construction, the device 281 * constructor has to attach to all the available drivers. 282 * 283 * @returns VBox status code. 284 * @param pDevIns The device instance. 285 * @param uLUN The logical unit which is being detached. 286 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 287 */ 288 static DECLCALLBACK(int) sb16Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 289 { 290 return sb16AttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags); 264 291 } 265 292 … … 306 333 307 334 if (RT_SUCCESS(rc)) 308 rc = sb16Attach (pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */);335 rc = sb16AttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */); 309 336 310 337 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc)); … … 2241 2268 { 2242 2269 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); 2243 rc = sb16Attach (pDevIns, uLUN, 0 /* fFlags */);2270 rc = sb16AttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */); 2244 2271 if (RT_FAILURE(rc)) 2245 2272 { -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r59348 r59357 1849 1849 GEN_CHECK_OFF(AC97DRIVER, Flags); 1850 1850 GEN_CHECK_OFF(AC97DRIVER, uLUN); 1851 GEN_CHECK_OFF(AC97DRIVER, fAttached); 1851 1852 GEN_CHECK_OFF(AC97DRIVER, pConnector); 1852 1853 GEN_CHECK_OFF(AC97DRIVER, LineIn); … … 1867 1868 GEN_CHECK_OFF(HDADRIVER, Flags); 1868 1869 GEN_CHECK_OFF(HDADRIVER, uLUN); 1870 GEN_CHECK_OFF(HDADRIVER, fAttached); 1869 1871 GEN_CHECK_OFF(HDADRIVER, pConnector); 1870 1872 GEN_CHECK_OFF(HDADRIVER, LineIn);
Note:
See TracChangeset
for help on using the changeset viewer.