Lines Matching refs:pLsiReq
1842 * @param pLsiReq LSI request state.
1846 static void lsilogicSgBufWalker(PPDMDEVINS pDevIns, PLSILOGICREQ pLsiReq, size_t cbCopy,
1850 RTGCPHYS GCPhysSgEntryNext = pLsiReq->GCPhysSgStart;
1851 RTGCPHYS GCPhysSegmentStart = pLsiReq->GCPhysSgStart;
1852 uint32_t cChainOffsetNext = pLsiReq->cChainOffset;
1853 uint8_t *pbBuf = (uint8_t *)pLsiReq->SegIoBuf.pvSeg;
1947 * @param pLsiReq Request data.
1950 DECLINLINE(void) lsilogicCopyFromSgBuf(PPDMDEVINS pDevIns, PLSILOGICREQ pLsiReq, size_t cbCopy)
1952 lsilogicSgBufWalker(pDevIns, pLsiReq, cbCopy, lsilogicCopyFromGuest);
1960 * @param pLsiReq Request data.
1963 DECLINLINE(void) lsilogicCopyToSgBuf(PPDMDEVINS pDevIns, PLSILOGICREQ pLsiReq, size_t cbCopy)
1965 lsilogicSgBufWalker(pDevIns, pLsiReq, cbCopy, lsilogicCopyToGuest);
1972 * @param pLsiReq The request to allocate memory for.
1975 static void *lsilogicReqMemAlloc(PLSILOGICREQ pLsiReq, size_t cb)
1977 if (pLsiReq->cbAlloc > cb)
1978 pLsiReq->cAllocTooMuch++;
1979 else if (pLsiReq->cbAlloc < cb)
1981 if (pLsiReq->cbAlloc)
1982 RTMemPageFree(pLsiReq->pvAlloc, pLsiReq->cbAlloc);
1984 pLsiReq->cbAlloc = RT_ALIGN_Z(cb, _4K);
1985 pLsiReq->pvAlloc = RTMemPageAlloc(pLsiReq->cbAlloc);
1986 pLsiReq->cAllocTooMuch = 0;
1987 if (RT_UNLIKELY(!pLsiReq->pvAlloc))
1988 pLsiReq->cbAlloc = 0;
1991 return pLsiReq->pvAlloc;
1998 * @param pLsiReq The request.
2000 static void lsilogicReqMemFree(PLSILOGICREQ pLsiReq)
2002 if (pLsiReq->cAllocTooMuch >= LSILOGIC_MAX_ALLOC_TOO_MUCH)
2004 RTMemPageFree(pLsiReq->pvAlloc, pLsiReq->cbAlloc);
2005 pLsiReq->cbAlloc = 0;
2006 pLsiReq->cAllocTooMuch = 0;
2015 * @param pLsiReq The request state.
2018 static int lsilogicIoBufAllocate(PPDMDEVINS pDevIns, PLSILOGICREQ pLsiReq,
2021 uint8_t uTxDir = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_GET(pLsiReq->GuestRequest.SCSIIO.u32Control);
2028 pLsiReq->SegIoBuf.pvSeg = lsilogicReqMemAlloc(pLsiReq, cbTransfer);
2029 if (!pLsiReq->SegIoBuf.pvSeg)
2032 pLsiReq->SegIoBuf.cbSeg = cbTransfer;
2035 lsilogicCopyFromSgBuf(pDevIns, pLsiReq, cbTransfer);
2045 * @param pLsiReq The request state.
2049 static void lsilogicIoBufFree(PPDMDEVINS pDevIns, PLSILOGICREQ pLsiReq,
2052 uint8_t uTxDir = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_GET(pLsiReq->GuestRequest.SCSIIO.u32Control);
2062 lsilogicCopyToSgBuf(pDevIns, pLsiReq, pLsiReq->SegIoBuf.cbSeg);
2064 lsilogicReqMemFree(pLsiReq);
2065 pLsiReq->SegIoBuf.pvSeg = NULL;
2066 pLsiReq->SegIoBuf.cbSeg = 0;
2154 * @param pLsiReq Pointer to the task state data.
2156 static int lsilogicR3ProcessSCSIIORequest(PLSILOGICSCSI pThis, PLSILOGICREQ pLsiReq)
2161 lsilogicR3DumpSCSIIORequest(&pLsiReq->GuestRequest.SCSIIO);
2164 pLsiReq->fBIOS = false;
2165 pLsiReq->GCPhysSgStart = pLsiReq->GCPhysMessageFrameAddr + sizeof(MptSCSIIORequest);
2166 pLsiReq->cChainOffset = pLsiReq->GuestRequest.SCSIIO.u8ChainOffset;
2167 if (pLsiReq->cChainOffset)
2168 pLsiReq->cChainOffset = pLsiReq->cChainOffset * sizeof(uint32_t) - sizeof(MptSCSIIORequest);
2170 if (RT_LIKELY( (pLsiReq->GuestRequest.SCSIIO.u8TargetID < pThis->cDeviceStates)
2171 && (pLsiReq->GuestRequest.SCSIIO.u8Bus == 0)))
2174 pTargetDevice = &pThis->paDeviceStates[pLsiReq->GuestRequest.SCSIIO.u8TargetID];
2179 if (pLsiReq->GuestRequest.SCSIIO.u32DataLength)
2182 rc = lsilogicIoBufAllocate(pThis->CTX_SUFF(pDevIns), pLsiReq,
2183 pLsiReq->GuestRequest.SCSIIO.u32DataLength);
2188 pLsiReq->pTargetDevice = pTargetDevice;
2189 pLsiReq->PDMScsiRequest.uLogicalUnit = pLsiReq->GuestRequest.SCSIIO.au8LUN[1];
2191 uint8_t uDataDirection = MPT_SCSIIO_REQUEST_CONTROL_TXDIR_GET(pLsiReq->GuestRequest.SCSIIO.u32Control);
2194 pLsiReq->PDMScsiRequest.uDataDirection = PDMSCSIREQUESTTXDIR_NONE;
2196 pLsiReq->PDMScsiRequest.uDataDirection = PDMSCSIREQUESTTXDIR_TO_DEVICE;
2198 pLsiReq->PDMScsiRequest.uDataDirection = PDMSCSIREQUESTTXDIR_FROM_DEVICE;
2200 pLsiReq->PDMScsiRequest.cbCDB = pLsiReq->GuestRequest.SCSIIO.u8CDBLength;
2201 pLsiReq->PDMScsiRequest.pbCDB = pLsiReq->GuestRequest.SCSIIO.au8CDB;
2202 pLsiReq->PDMScsiRequest.cbScatterGather = pLsiReq->GuestRequest.SCSIIO.u32DataLength;
2203 if (pLsiReq->PDMScsiRequest.cbScatterGather)
2205 pLsiReq->PDMScsiRequest.cScatterGatherEntries = 1;
2206 pLsiReq->PDMScsiRequest.paScatterGatherHead = &pLsiReq->SegIoBuf;
2210 pLsiReq->PDMScsiRequest.cScatterGatherEntries = 0;
2211 pLsiReq->PDMScsiRequest.paScatterGatherHead = NULL;
2213 pLsiReq->PDMScsiRequest.cbSenseBuffer = sizeof(pLsiReq->abSenseBuffer);
2214 memset(pLsiReq->abSenseBuffer, 0, pLsiReq->PDMScsiRequest.cbSenseBuffer);
2215 pLsiReq->PDMScsiRequest.pbSenseBuffer = pLsiReq->abSenseBuffer;
2216 pLsiReq->PDMScsiRequest.pvUser = pLsiReq;
2219 rc = pTargetDevice->pDrvSCSIConnector->pfnSCSIRequestSend(pTargetDevice->pDrvSCSIConnector, &pLsiReq->PDMScsiRequest);
2226 pLsiReq->IOCReply.SCSIIOError.u16IOCStatus = MPT_SCSI_IO_ERROR_IOCSTATUS_DEVICE_NOT_THERE;
2232 if (pLsiReq->GuestRequest.SCSIIO.u8Bus != 0)
2233 pLsiReq->IOCReply.SCSIIOError.u16IOCStatus = MPT_SCSI_IO_ERROR_IOCSTATUS_INVALID_BUS;
2235 pLsiReq->IOCReply.SCSIIOError.u16IOCStatus = MPT_SCSI_IO_ERROR_IOCSTATUS_INVALID_TARGETID;
2243 pLsiReq->GuestRequest.SCSIIO.u8TargetID, pLsiReq->GuestRequest.SCSIIO.u8Bus));
2246 pThis->CTX_SUFF(pDevIns)->iInstance, pLsiReq->GuestRequest.SCSIIO.au8CDB[0]));
2247 for (unsigned i = 1; i < pLsiReq->GuestRequest.SCSIIO.u8CDBLength; i++)
2248 LogRel((", %#x", pLsiReq->GuestRequest.SCSIIO.au8CDB[i]));
2253 pLsiReq->IOCReply.SCSIIOError.u8TargetID = pLsiReq->GuestRequest.SCSIIO.u8TargetID;
2254 pLsiReq->IOCReply.SCSIIOError.u8Bus = pLsiReq->GuestRequest.SCSIIO.u8Bus;
2255 pLsiReq->IOCReply.SCSIIOError.u8MessageLength = sizeof(MptSCSIIOErrorReply) / 4;
2256 pLsiReq->IOCReply.SCSIIOError.u8Function = pLsiReq->GuestRequest.SCSIIO.u8Function;
2257 pLsiReq->IOCReply.SCSIIOError.u8CDBLength = pLsiReq->GuestRequest.SCSIIO.u8CDBLength;
2258 pLsiReq->IOCReply.SCSIIOError.u8SenseBufferLength = pLsiReq->GuestRequest.SCSIIO.u8SenseBufferLength;
2259 pLsiReq->IOCReply.SCSIIOError.u32MessageContext = pLsiReq->GuestRequest.SCSIIO.u32MessageContext;
2260 pLsiReq->IOCReply.SCSIIOError.u8SCSIStatus = SCSI_STATUS_OK;
2261 pLsiReq->IOCReply.SCSIIOError.u8SCSIState = MPT_SCSI_IO_ERROR_SCSI_STATE_TERMINATED;
2262 pLsiReq->IOCReply.SCSIIOError.u32IOCLogInfo = 0;
2263 pLsiReq->IOCReply.SCSIIOError.u32TransferCount = 0;
2264 pLsiReq->IOCReply.SCSIIOError.u32SenseCount = 0;
2265 pLsiReq->IOCReply.SCSIIOError.u32ResponseInfo = 0;
2267 lsilogicFinishAddressReply(pThis, &pLsiReq->IOCReply, false);
2268 RTMemCacheFree(pThis->hTaskCache, pLsiReq);
2280 PLSILOGICREQ pLsiReq = (PLSILOGICREQ)pSCSIRequest->pvUser;
2281 PLSILOGICDEVICE pLsiLogicDevice = pLsiReq->pTargetDevice;
2288 if (!pLsiReq->fBIOS && pLsiReq->PDMScsiRequest.cbScatterGather)
2289 lsilogicIoBufFree(pThis->CTX_SUFF(pDevIns), pLsiReq, false /* fCopyToGuest */);
2294 pLsiReq->pRedoNext = ASMAtomicReadPtrT(&pThis->pTasksRedoHead, PLSILOGICREQ);
2295 } while (!ASMAtomicCmpXchgPtr(&pThis->pTasksRedoHead, pLsiReq, pLsiReq->pRedoNext));
2303 if (RT_UNLIKELY(pLsiReq->fBIOS))
2312 GCPhysAddrSenseBuffer = pLsiReq->GuestRequest.SCSIIO.u32SenseBufferLowAddress;
2316 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysAddrSenseBuffer, pLsiReq->abSenseBuffer,
2317 RT_UNLIKELY( pLsiReq->GuestRequest.SCSIIO.u8SenseBufferLength
2318 < pLsiReq->PDMScsiRequest.cbSenseBuffer)
2319 ? pLsiReq->GuestRequest.SCSIIO.u8SenseBufferLength
2320 : pLsiReq->PDMScsiRequest.cbSenseBuffer);
2322 if (pLsiReq->PDMScsiRequest.cbScatterGather)
2323 lsilogicIoBufFree(pThis->CTX_SUFF(pDevIns), pLsiReq, true /* fCopyToGuest */);
2327 lsilogicR3FinishContextReply(pThis, pLsiReq->GuestRequest.SCSIIO.u32MessageContext);
2331 memset(&pLsiReq->IOCReply, 0, sizeof(MptReplyUnion));
2332 pLsiReq->IOCReply.SCSIIOError.u8TargetID = pLsiReq->GuestRequest.SCSIIO.u8TargetID;
2333 pLsiReq->IOCReply.SCSIIOError.u8Bus = pLsiReq->GuestRequest.SCSIIO.u8Bus;
2334 pLsiReq->IOCReply.SCSIIOError.u8MessageLength = 8;
2335 pLsiReq->IOCReply.SCSIIOError.u8Function = pLsiReq->GuestRequest.SCSIIO.u8Function;
2336 pLsiReq->IOCReply.SCSIIOError.u8CDBLength = pLsiReq->GuestRequest.SCSIIO.u8CDBLength;
2337 pLsiReq->IOCReply.SCSIIOError.u8SenseBufferLength = pLsiReq->GuestRequest.SCSIIO.u8SenseBufferLength;
2338 pLsiReq->IOCReply.SCSIIOError.u8MessageFlags = pLsiReq->GuestRequest.SCSIIO.u8MessageFlags;
2339 pLsiReq->IOCReply.SCSIIOError.u32MessageContext = pLsiReq->GuestRequest.SCSIIO.u32MessageContext;
2340 pLsiReq->IOCReply.SCSIIOError.u8SCSIStatus = rcCompletion;
2341 pLsiReq->IOCReply.SCSIIOError.u8SCSIState = MPT_SCSI_IO_ERROR_SCSI_STATE_AUTOSENSE_VALID;
2342 pLsiReq->IOCReply.SCSIIOError.u16IOCStatus = 0;
2343 pLsiReq->IOCReply.SCSIIOError.u32IOCLogInfo = 0;
2344 pLsiReq->IOCReply.SCSIIOError.u32TransferCount = 0;
2345 pLsiReq->IOCReply.SCSIIOError.u32SenseCount = sizeof(pLsiReq->abSenseBuffer);
2346 pLsiReq->IOCReply.SCSIIOError.u32ResponseInfo = 0;
2348 lsilogicFinishAddressReply(pThis, &pLsiReq->IOCReply, false);
2352 RTMemCacheFree(pThis->hTaskCache, pLsiReq);
3777 PLSILOGICREQ pLsiReq;
3780 rc = RTMemCacheAllocEx(pThis->hTaskCache, (void **)&pLsiReq);
3783 pLsiReq->fBIOS = true;
3785 rc = vboxscsiSetupRequest(&pThis->VBoxSCSI, &pLsiReq->PDMScsiRequest, &uTargetDevice);
3788 pLsiReq->PDMScsiRequest.pvUser = pLsiReq;
3792 pLsiReq->pTargetDevice = &pThis->paDeviceStates[uTargetDevice];
3794 if (pLsiReq->pTargetDevice->pDrvBase)
3796 ASMAtomicIncU32(&pLsiReq->pTargetDevice->cOutstandingRequests);
3798 rc = pLsiReq->pTargetDevice->pDrvSCSIConnector->pfnSCSIRequestSend(pLsiReq->pTargetDevice->pDrvSCSIConnector,
3799 &pLsiReq->PDMScsiRequest);
3806 AssertMsg(pLsiReq->PDMScsiRequest.pbCDB[0] == SCSI_INQUIRY,
3817 rc = vboxscsiRequestFinished(&pThis->VBoxSCSI, &pLsiReq->PDMScsiRequest, SCSI_STATUS_OK);
3820 RTMemCacheFree(pThis->hTaskCache, pLsiReq);
4195 PLSILOGICREQ pLsiReq;
4198 rc = RTMemCacheAllocEx(pThis->hTaskCache, (void **)&pLsiReq);
4201 pLsiReq->GCPhysMessageFrameAddr = GCPhysMessageFrameAddr;
4204 PDMDevHlpPhysRead(pDevIns, GCPhysMessageFrameAddr, &pLsiReq->GuestRequest, sizeof(MptMessageHdr));
4209 switch (pLsiReq->GuestRequest.Header.u8Function)
4246 AssertMsgFailed(("Unknown function issued %u\n", pLsiReq->GuestRequest.Header.u8Function));
4253 PDMDevHlpPhysRead(pDevIns, GCPhysMessageFrameAddr, &pLsiReq->GuestRequest, cbRequest);
4256 if (pLsiReq->GuestRequest.Header.u8Function == MPT_MESSAGE_HDR_FUNCTION_SCSI_IO_REQUEST)
4258 rc = lsilogicR3ProcessSCSIIORequest(pThis, pLsiReq);
4264 rc = lsilogicR3ProcessMessageRequest(pThis, &pLsiReq->GuestRequest.Header, &Reply);
4266 RTMemCacheFree(pThis->hTaskCache, pLsiReq);
5009 PLSILOGICREQ pLsiReq = pThis->pTasksRedoHead;
5013 while (pLsiReq)
5017 if (!pLsiReq->fBIOS)
5021 pLsiReq->GCPhysMessageFrameAddr & UINT32_C(0xffffffff));
5030 AssertMsg(!pLsiReq->pRedoNext, ("Only one BIOS task can be active!\n"));
5031 vboxscsiSetRequestRedo(&pThis->VBoxSCSI, &pLsiReq->PDMScsiRequest);
5034 pFree = pLsiReq;
5035 pLsiReq = pLsiReq->pRedoNext;