Changeset 29758 in vbox
- Timestamp:
- May 24, 2010 8:38:48 AM (14 years ago)
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 3 edited
-
ATAController.cpp (modified) (10 diffs)
-
ATAController.h (modified) (2 diffs)
-
DevAHCI.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/ATAController.cpp
r28800 r29758 4965 4965 } 4966 4966 4967 #if 04968 4967 /** 4969 4968 * Detach notification. … … 4972 4971 * 4973 4972 * @param pDevIns The device instance. 4974 * @param iLUN The logical unit which is being detached. 4973 * @param fMaster True if the master is detached 4974 * false for the slave 4975 4975 */ 4976 static DECLCALLBACK(void) ataDetach(PPDMDEVINS pDevIns, unsigned iLUN) 4977 { 4978 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4979 PAHCIATACONTROLLER pCtl; 4976 void ataControllerDetach(PAHCIATACONTROLLER pCtl, bool fMaster) 4977 { 4980 4978 AHCIATADevState *pIf; 4981 unsigned iController;4982 unsigned iInterface;4983 4979 4984 4980 /* 4985 4981 * Locate the controller and stuff. 4986 4982 */ 4987 iController = iLUN / RT_ELEMENTS(pThis->aCts[0].aIfs); 4988 AssertReleaseMsg(iController < RT_ELEMENTS(pThis->aCts), ("iController=%d iLUN=%d\n", iController, iLUN)); 4989 pCtl = &pThis->aCts[iController]; 4990 4991 iInterface = iLUN % RT_ELEMENTS(pThis->aCts[0].aIfs); 4992 pIf = &pCtl->aIfs[iInterface]; 4983 pIf = &pCtl->aIfs[fMaster ? 0 : 1]; 4993 4984 4994 4985 /* … … 4999 4990 pIf->pDrvBlockBios = NULL; 5000 4991 pIf->pDrvMount = NULL; 5001 5002 /* 5003 * Just in case there was a medium inserted. Only required when attached to a physical drive 5004 * in passthrough mode as in virtual ATAPI mode we've got an unmount notification. 5005 */ 5006 if (pIf->fATAPIPassthrough) 5007 ataMediumRemoved(pIf); 5008 5009 } 5010 #endif 4992 } 5011 4993 5012 4994 /** … … 5139 5121 } 5140 5122 5141 #if 05142 5123 /** 5143 5124 * Attach command. … … 5149 5130 * @param iLUN The logical unit which is being detached. 5150 5131 */ 5151 static DECLCALLBACK(int) ataAttach(PPDMDEVINS pDevIns, unsigned iLUN) 5152 { 5153 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5154 PAHCIATACONTROLLER pCtl; 5132 int ataControllerAttach(PAHCIATACONTROLLER pCtl, PPDMIBASE pDrvBase, bool fMaster) 5133 { 5155 5134 AHCIATADevState *pIf; 5156 5135 int rc; 5157 unsigned iController;5158 unsigned iInterface;5159 5136 5160 5137 /* 5161 5138 * Locate the controller and stuff. 5162 5139 */ 5163 iController = iLUN / RT_ELEMENTS(pThis->aCts[0].aIfs); 5164 AssertReleaseMsg(iController < RT_ELEMENTS(pThis->aCts), ("iController=%d iLUN=%d\n", iController, iLUN)); 5165 pCtl = &pThis->aCts[iController]; 5166 5167 iInterface = iLUN % RT_ELEMENTS(pThis->aCts[0].aIfs); 5168 pIf = &pCtl->aIfs[iInterface]; 5140 pIf = &pCtl->aIfs[fMaster ? 0 : 1]; 5169 5141 5170 5142 /* the usual paranoia */ … … 5172 5144 AssertRelease(!pIf->pDrvBlock); 5173 5145 Assert(ATADEVSTATE_2_CONTROLLER(pIf) == pCtl); 5174 Assert(pIf->iLUN == iLUN);5175 5146 5176 5147 /* … … 5178 5149 * required as well as optional. 5179 5150 */ 5180 rc = PDMDevHlpDriverAttach(pDevIns, pIf->iLUN, &pIf->IBase, &pIf->pDrvBase, NULL); 5181 if (RT_SUCCESS(rc)) 5182 { 5183 rc = ataConfigLun(pDevIns, pIf); 5184 /* 5185 * In case there is a new medium inserted. In virtual ATAPI mode we get an mount 5186 * notification. 5187 */ 5188 if (pIf->fATAPIPassthrough) 5189 ataMediumInserted(pIf); 5151 5152 pIf->pDrvBase = pDrvBase; 5153 if (pDrvBase) 5154 { 5155 rc = ataConfigLun(pCtl->pDevInsR3, pIf); 5190 5156 } 5191 5157 else … … 5199 5165 return rc; 5200 5166 } 5201 #endif5202 5167 5203 5168 … … 5466 5431 } 5467 5432 5468 DECLCALLBACK(int) ataControllerInit(PPDMDEVINS pDevIns, PAHCIATACONTROLLER pCtl, PPDMIBASE pDrvBaseMaster, PPDMIBASE pDrvBaseSlave, 5433 DECLCALLBACK(int) ataControllerInit(PPDMDEVINS pDevIns, PAHCIATACONTROLLER pCtl, 5434 unsigned iLUNMaster, PPDMIBASE pDrvBaseMaster, 5435 unsigned iLUNSlave, PPDMIBASE pDrvBaseSlave, 5469 5436 uint32_t *pcbSSMState, const char *szName, PPDMLED pLed, 5470 5437 PSTAMCOUNTER pStatBytesRead, PSTAMCOUNTER pStatBytesWritten) … … 5484 5451 for (uint32_t j = 0; j < RT_ELEMENTS(pCtl->aIfs); j++) 5485 5452 { 5486 pCtl->aIfs[j].iLUN = j ;5453 pCtl->aIfs[j].iLUN = j == 0 ? iLUNMaster : iLUNSlave; 5487 5454 pCtl->aIfs[j].pDevInsR3 = pDevIns; 5488 5455 pCtl->aIfs[j].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); -
trunk/src/VBox/Devices/Storage/ATAController.h
r28800 r29758 420 420 * @param szName Name of the controller (Used to initialize the critical section). 421 421 */ 422 int ataControllerInit(PPDMDEVINS pDevIns, PAHCIATACONTROLLER pCtl, PPDMIBASE pDrvBaseMaster, PPDMIBASE pDrvBaseSlave, 422 int ataControllerInit(PPDMDEVINS pDevIns, PAHCIATACONTROLLER pCtl, 423 unsigned iLUNMaster, PPDMIBASE pDrvBaseMaster, 424 unsigned iLUNSlave, PPDMIBASE pDrvBaseSlave, 423 425 uint32_t *pcbSSMState, const char *szName, PPDMLED pLed, PSTAMCOUNTER pStatBytesRead, PSTAMCOUNTER pStatBytesWritten); 424 426 … … 483 485 int ataControllerLoadExec(PAHCIATACONTROLLER pCtl, PSSMHANDLE pSSM); 484 486 487 /** 488 * Attach command. 489 * 490 * This is called when we change block driver for the DVD drive. 491 * 492 * @returns VBox status code. 493 * @param pDevIns The device instance. 494 * @param iLUN The logical unit which is being detached. 495 */ 496 int ataControllerAttach(PAHCIATACONTROLLER pCtl, PPDMIBASE pDrvBase, bool fMaster); 497 498 /** 499 * Detach notification. 500 * 501 * The DVD drive has been unplugged. 502 * 503 * @param pDevIns The device instance. 504 * @param fMaster True if the master is detached 505 * false for the slave 506 */ 507 void ataControllerDetach(PAHCIATACONTROLLER pCtl, bool fMaster); 508 485 509 #endif /* IN_RING3 */ 486 510 -
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r29672 r29758 6545 6545 } 6546 6546 6547 /* Check if the changed port uses IDE emulation. */ 6548 bool fMaster = false; 6549 PAHCIATACONTROLLER pCtl = NULL; 6550 6551 for (unsigned i = 0; i < RT_ELEMENTS(pAhci->aCts); i++) 6552 for (unsigned j = 0; j < RT_ELEMENTS(pAhci->aCts[0].aIfs); j++) 6553 { 6554 PAHCIATACONTROLLER pTmp = &pAhci->aCts[i]; 6555 if (pTmp->aIfs[j].iLUN == iLUN) 6556 { 6557 pCtl = pTmp; 6558 fMaster = j == 0 ? true : false; 6559 } 6560 } 6561 6562 if (pCtl) 6563 ataControllerDetach(pCtl, fMaster); 6564 6547 6565 /* 6548 6566 * Zero some important members. … … 6597 6615 else 6598 6616 { 6599 char szName[24]; 6600 RTStrPrintf(szName, sizeof(szName), "Port%d", iLUN); 6601 6602 if (pAhciPort->pDrvBlockAsync) 6603 { 6604 pAhciPort->fAsyncInterface = true; 6605 } 6606 else 6607 { 6608 pAhciPort->fAsyncInterface = false; 6609 6610 /* Create event semaphore. */ 6611 rc = RTSemEventCreate(&pAhciPort->AsyncIORequestSem); 6612 if (RT_FAILURE(rc)) 6617 /* Check if the changed port uses IDE emulation. */ 6618 bool fMaster = false; 6619 PAHCIATACONTROLLER pCtl = NULL; 6620 6621 for (unsigned i = 0; i < RT_ELEMENTS(pAhci->aCts); i++) 6622 for (unsigned j = 0; j < RT_ELEMENTS(pAhci->aCts[0].aIfs); j++) 6613 6623 { 6614 Log(("%s: Failed to create event semaphore for %s.\n", __FUNCTION__, szName)); 6615 return rc; 6624 PAHCIATACONTROLLER pTmp = &pAhci->aCts[i]; 6625 if (pTmp->aIfs[j].iLUN == iLUN) 6626 { 6627 pCtl = pTmp; 6628 fMaster = j == 0 ? true : false; 6629 } 6616 6630 } 6617 6631 6618 /* Create the async IO thread. */ 6619 rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPort->pAsyncIOThread, pAhciPort, ahciAsyncIOLoop, ahciAsyncIOLoopWakeUp, 0, 6620 RTTHREADTYPE_IO, szName); 6621 if (RT_FAILURE(rc)) 6632 /* Attach to the controller if available */ 6633 if (pCtl) 6634 rc = ataControllerAttach(pCtl, pAhciPort->pDrvBase, fMaster); 6635 6636 if (RT_SUCCESS(rc)) 6637 { 6638 if (pAhciPort->pDrvBlockAsync) 6622 6639 { 6623 AssertMsgFailed(("%s: Async IO Thread creation for %s failed rc=%d\n", __FUNCTION__, szName, rc)); 6624 return rc; 6640 pAhciPort->fAsyncInterface = true; 6641 } 6642 else 6643 { 6644 char szName[24]; 6645 RTStrPrintf(szName, sizeof(szName), "Port%d", iLUN); 6646 6647 pAhciPort->fAsyncInterface = false; 6648 6649 /* Create event semaphore. */ 6650 rc = RTSemEventCreate(&pAhciPort->AsyncIORequestSem); 6651 if (RT_FAILURE(rc)) 6652 { 6653 Log(("%s: Failed to create event semaphore for %s.\n", __FUNCTION__, szName)); 6654 return rc; 6655 } 6656 6657 /* Create the async IO thread. */ 6658 rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPort->pAsyncIOThread, pAhciPort, ahciAsyncIOLoop, ahciAsyncIOLoopWakeUp, 0, 6659 RTTHREADTYPE_IO, szName); 6660 if (RT_FAILURE(rc)) 6661 { 6662 AssertMsgFailed(("%s: Async IO Thread creation for %s failed rc=%d\n", __FUNCTION__, szName, rc)); 6663 return rc; 6664 } 6625 6665 } 6626 6666 } … … 7138 7178 char szName[24]; 7139 7179 RTStrPrintf(szName, sizeof(szName), "EmulatedATA%d", i); 7140 rc = ataControllerInit(pDevIns, pCtl, pThis->ahciPort[iPortMaster].pDrvBase, pThis->ahciPort[iPortSlave].pDrvBase, 7141 &cbSSMState, szName, &pThis->ahciPort[iPortMaster].Led, &pThis->ahciPort[iPortMaster].StatBytesRead, 7180 rc = ataControllerInit(pDevIns, pCtl, 7181 iPortMaster, pThis->ahciPort[iPortMaster].pDrvBase, 7182 iPortSlave, pThis->ahciPort[iPortSlave].pDrvBase, 7183 &cbSSMState, szName, &pThis->ahciPort[iPortMaster].Led, 7184 &pThis->ahciPort[iPortMaster].StatBytesRead, 7142 7185 &pThis->ahciPort[iPortMaster].StatBytesWritten); 7143 7186 if (RT_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.

