Lines Matching refs:pVScsiDevice
36 * @param pVScsiDevice The SCSI device instance.
39 DECLINLINE(bool) vscsiDeviceLunIsPresent(PVSCSIDEVICEINT pVScsiDevice, uint32_t iLun)
41 return ( iLun < pVScsiDevice->cLunsMax
42 && pVScsiDevice->papVScsiLun[iLun] != NULL);
49 * @param pVScsiDevice The virtual SCSI device instance.
53 static bool vscsiDeviceReqProcess(PVSCSIDEVICEINT pVScsiDevice, PVSCSIREQINT pVScsiReq,
62 if (!vscsiDeviceLunIsPresent(pVScsiDevice, pVScsiReq->iLun))
72 *prcReq = vscsiReqSenseOkSet(&pVScsiDevice->VScsiSense, pVScsiReq);
86 *prcReq = vscsiReqSenseErrorSet(&pVScsiDevice->VScsiSense, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET, 0x00);
96 *prcReq = vscsiReqSenseErrorSet(&pVScsiDevice->VScsiSense, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET, 0x00);
98 *prcReq = vscsiReqSenseOkSet(&pVScsiDevice->VScsiSense, pVScsiReq);
104 if ( vscsiDeviceLunIsPresent(pVScsiDevice, pVScsiReq->iLun)
105 && pVScsiDevice->papVScsiLun[pVScsiReq->iLun]->fReady)
106 *prcReq = vscsiReqSenseOkSet(&pVScsiDevice->VScsiSense, pVScsiReq);
115 *prcReq = vscsiReqSenseErrorSet(&pVScsiDevice->VScsiSense, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET, 0x00);
117 *prcReq = vscsiReqSenseCmd(&pVScsiDevice->VScsiSense, pVScsiReq);
128 void vscsiDeviceReqComplete(PVSCSIDEVICEINT pVScsiDevice, PVSCSIREQINT pVScsiReq,
131 pVScsiDevice->pfnVScsiReqCompleted(pVScsiDevice, pVScsiDevice->pvVScsiDeviceUser,
135 RTMemCacheFree(pVScsiDevice->hCacheReq, pVScsiReq);
144 PVSCSIDEVICEINT pVScsiDevice = NULL;
149 pVScsiDevice = (PVSCSIDEVICEINT)RTMemAllocZ(sizeof(VSCSIDEVICEINT));
150 if (!pVScsiDevice)
153 pVScsiDevice->pfnVScsiReqCompleted = pfnVScsiReqCompleted;
154 pVScsiDevice->pvVScsiDeviceUser = pvVScsiDeviceUser;
155 pVScsiDevice->cLunsAttached = 0;
156 pVScsiDevice->cLunsMax = 0;
157 pVScsiDevice->papVScsiLun = NULL;
158 vscsiSenseInit(&pVScsiDevice->VScsiSense);
160 rc = RTMemCacheCreate(&pVScsiDevice->hCacheReq, sizeof(VSCSIREQINT), 0, UINT32_MAX,
164 *phVScsiDevice = pVScsiDevice;
165 LogFlow(("%s: hVScsiDevice=%#p -> VINF_SUCCESS\n", __FUNCTION__, pVScsiDevice));
169 RTMemFree(pVScsiDevice);
179 PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
181 if (pVScsiDevice->cLunsAttached > 0)
184 if (pVScsiDevice->papVScsiLun)
185 RTMemFree(pVScsiDevice->papVScsiLun);
187 RTMemCacheDestroy(pVScsiDevice->hCacheReq);
188 RTMemFree(pVScsiDevice);
196 PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
201 AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
204 AssertReturn(!pVScsiLun->pVScsiDevice, VERR_VSCSI_LUN_ATTACHED_TO_DEVICE);
206 if (iLun >= pVScsiDevice->cLunsMax)
208 PPVSCSILUNINT papLunOld = pVScsiDevice->papVScsiLun;
210 pVScsiDevice->papVScsiLun = (PPVSCSILUNINT)RTMemAllocZ((iLun + 1) * sizeof(PVSCSILUNINT));
211 if (pVScsiDevice->papVScsiLun)
213 for (uint32_t i = 0; i < pVScsiDevice->cLunsMax; i++)
214 pVScsiDevice->papVScsiLun[i] = papLunOld[i];
219 pVScsiDevice->cLunsMax = iLun + 1;
227 pVScsiLun->pVScsiDevice = pVScsiDevice;
228 pVScsiDevice->papVScsiLun[iLun] = pVScsiLun;
229 pVScsiDevice->cLunsAttached++;
239 PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
242 AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
245 AssertReturn(iLun < pVScsiDevice->cLunsMax, VERR_VSCSI_LUN_NOT_ATTACHED);
246 AssertPtrReturn(pVScsiDevice->papVScsiLun[iLun], VERR_VSCSI_LUN_NOT_ATTACHED);
248 PVSCSILUNINT pVScsiLun = pVScsiDevice->papVScsiLun[iLun];
250 pVScsiLun->pVScsiDevice = NULL;
252 pVScsiDevice->papVScsiLun[iLun] = NULL;
253 pVScsiDevice->cLunsAttached--;
262 PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
265 AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
268 AssertReturn(iLun < pVScsiDevice->cLunsMax, VERR_VSCSI_LUN_NOT_ATTACHED);
269 AssertPtrReturn(pVScsiDevice->papVScsiLun[iLun], VERR_VSCSI_LUN_NOT_ATTACHED);
271 *phVScsiLun = pVScsiDevice->papVScsiLun[iLun];
279 PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
284 AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
289 bool fProcessed = vscsiDeviceReqProcess(pVScsiDevice, pVScsiReq, &rcReq);
293 if (vscsiDeviceLunIsPresent(pVScsiDevice, pVScsiReq->iLun))
295 PVSCSILUNINT pVScsiLun = pVScsiDevice->papVScsiLun[pVScsiReq->iLun];
301 vscsiReqSenseErrorSet(&pVScsiDevice->VScsiSense, pVScsiReq,
306 vscsiDeviceReqComplete(pVScsiDevice, pVScsiReq,
311 vscsiDeviceReqComplete(pVScsiDevice, pVScsiReq,
324 PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
328 AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
333 pVScsiReq = (PVSCSIREQINT)RTMemCacheAlloc(pVScsiDevice->hCacheReq);