- Timestamp:
- Oct 13, 2016 2:00:33 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvHostBase-darwin.cpp
r64246 r64251 154 154 } 155 155 156 157 DECLHIDDEN(int) drvHostBaseReadOs(PDRVHOSTBASE pThis, uint64_t off, void *pvBuf, size_t cbRead) 158 { 159 int rc = VINF_SUCCESS; 160 161 if ( pThis->ppScsiTaskDI 162 && pThis->cbBlock) 163 { 164 /* 165 * Issue a READ(12) request. 166 */ 167 do 168 { 169 const uint32_t LBA = off / pThis->cbBlock; 170 AssertReturn(!(off % pThis->cbBlock), VERR_INVALID_PARAMETER); 171 uint32_t cbRead32 = cbRead > SCSI_MAX_BUFFER_SIZE 172 ? SCSI_MAX_BUFFER_SIZE 173 : (uint32_t)cbRead; 174 const uint32_t cBlocks = cbRead32 / pThis->cbBlock; 175 AssertReturn(!(cbRead % pThis->cbBlock), VERR_INVALID_PARAMETER); 176 uint8_t abCmd[16] = 177 { 178 SCSI_READ_12, 0, 179 RT_BYTE4(LBA), RT_BYTE3(LBA), RT_BYTE2(LBA), RT_BYTE1(LBA), 180 RT_BYTE4(cBlocks), RT_BYTE3(cBlocks), RT_BYTE2(cBlocks), RT_BYTE1(cBlocks), 181 0, 0, 0, 0, 0 182 }; 183 rc = drvHostBaseScsiCmdOs(pThis, abCmd, 12, PDMMEDIATXDIR_FROM_DEVICE, pvBuf, &cbRead32, NULL, 0, 0); 184 185 off += cbRead32; 186 cbRead -= cbRead32; 187 pvBuf = (uint8_t *)pvBuf + cbRead32; 188 } while ((cbRead > 0) && RT_SUCCESS(rc)); 189 } 190 else 191 rc = VERR_MEDIA_NOT_PRESENT; 192 193 return rc; 194 } 195 196 197 DECLHIDDEN(int) drvHostBaseWriteOs(PDRVHOSTBASE pThis, uint64_t off, const void *pvBuf, size_t cbWrite) 198 { 199 RT_NOREF4(pThis, off, pvBuf, cbWrite); 200 return VERR_WRITE_PROTECT; 201 } 202 203 204 DECLHIDDEN(int) drvHostBaseFlushOs(PDRVHOSTBASE pThis) 205 { 206 RT_NOREF1(pThis); 207 return VINF_SUCCESS; 208 } 209 -
trunk/src/VBox/Devices/Storage/DrvHostBase-freebsd.cpp
r64246 r64251 155 155 } 156 156 157 158 DECLHIDDEN(int) drvHostBaseReadOs(PDRVHOSTBASE pThis, uint64_t off, void *pvBuf, size_t cbRead) 159 { 160 int rc = VINF_SUCCESS; 161 162 if (pThis->cbBlock) 163 { 164 /* 165 * Issue a READ(12) request. 166 */ 167 do 168 { 169 const uint32_t LBA = off / pThis->cbBlock; 170 AssertReturn(!(off % pThis->cbBlock), VERR_INVALID_PARAMETER); 171 uint32_t cbRead32 = cbRead > SCSI_MAX_BUFFER_SIZE 172 ? SCSI_MAX_BUFFER_SIZE 173 : (uint32_t)cbRead; 174 const uint32_t cBlocks = cbRead32 / pThis->cbBlock; 175 AssertReturn(!(cbRead % pThis->cbBlock), VERR_INVALID_PARAMETER); 176 uint8_t abCmd[16] = 177 { 178 SCSI_READ_12, 0, 179 RT_BYTE4(LBA), RT_BYTE3(LBA), RT_BYTE2(LBA), RT_BYTE1(LBA), 180 RT_BYTE4(cBlocks), RT_BYTE3(cBlocks), RT_BYTE2(cBlocks), RT_BYTE1(cBlocks), 181 0, 0, 0, 0, 0 182 }; 183 rc = drvHostBaseScsiCmdOs(pThis, abCmd, 12, PDMMEDIATXDIR_FROM_DEVICE, pvBuf, &cbRead32, NULL, 0, 0); 184 185 off += cbRead32; 186 cbRead -= cbRead32; 187 pvBuf = (uint8_t *)pvBuf + cbRead32; 188 } while ((cbRead > 0) && RT_SUCCESS(rc)); 189 } 190 else 191 rc = VERR_MEDIA_NOT_PRESENT; 192 193 return rc; 194 } 195 196 197 DECLHIDDEN(int) drvHostBaseWriteOs(PDRVHOSTBASE pThis, uint64_t off, const void *pvBuf, size_t cbWrite) 198 { 199 RT_NOREF4(pThis, off, pvBuf, cbWrite); 200 return VERR_WRITE_PROTECT; 201 } 202 203 204 DECLHIDDEN(int) drvHostBaseFlushOs(PDRVHOSTBASE pThis) 205 { 206 RT_NOREF1(pThis); 207 return VINF_SUCCESS; 208 } 209 -
trunk/src/VBox/Devices/Storage/DrvHostBase-linux.cpp
r64246 r64251 163 163 } 164 164 165 166 DECLHIDDEN(int) drvHostBaseReadOs(PDRVHOSTBASE pThis, uint64_t off, void *pvBuf, size_t cbRead) 167 { 168 return RTFileReadAt(pThis->hFileDevice, off, pvBuf, cbRead, NULL); 169 } 170 171 172 DECLHIDDEN(int) drvHostBaseWriteOs(PDRVHOSTBASE pThis, uint64_t off, const void *pvBuf, size_t cbWrite) 173 { 174 return RTFileWriteAt(pThis->hFileDevice, off, pvBuf, cbWrite, NULL); 175 } 176 177 178 DECLHIDDEN(int) drvHostBaseFlushOs(PDRVHOSTBASE pThis) 179 { 180 return RTFileFlush(pThis->hFileDevice); 181 } 182 -
trunk/src/VBox/Devices/Storage/DrvHostBase-solaris.cpp
r64246 r64251 183 183 } 184 184 185 186 DECLHIDDEN(int) drvHostBaseReadOs(PDRVHOSTBASE pThis, uint64_t off, void *pvBuf, size_t cbRead) 187 { 188 return RTFileReadAt(pThis->hFileDevice, off, pvBuf, cbRead, NULL); 189 } 190 191 192 DECLHIDDEN(int) drvHostBaseWriteOs(PDRVHOSTBASE pThis, uint64_t off, const void *pvBuf, size_t cbWrite) 193 { 194 return RTFileWriteAt(pThis->hFileDevice, off, pvBuf, cbWrite, NULL); 195 } 196 197 198 DECLHIDDEN(int) drvHostBaseFlushOs(PDRVHOSTBASE pThis) 199 { 200 return RTFileFlush(pThis->hFileDevice); 201 } 202 -
trunk/src/VBox/Devices/Storage/DrvHostBase-win.cpp
r64248 r64251 221 221 } 222 222 223 224 DECLHIDDEN(int) drvHostBaseReadOs(PDRVHOSTBASE pThis, uint64_t off, void *pvBuf, size_t cbRead) 225 { 226 return RTFileReadAt(pThis->hFileDevice, off, pvBuf, cbRead, NULL); 227 } 228 229 230 DECLHIDDEN(int) drvHostBaseWriteOs(PDRVHOSTBASE pThis, uint64_t off, const void *pvBuf, size_t cbWrite) 231 { 232 return RTFileWriteAt(pThis->hFileDevice, off, pvBuf, cbWrite, NULL); 233 } 234 235 236 DECLHIDDEN(int) drvHostBaseFlushOs(PDRVHOSTBASE pThis) 237 { 238 return RTFileFlush(pThis->hFileDevice); 239 } 240 -
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r64246 r64251 145 145 */ 146 146 int rc; 147 #ifdef RT_OS_DARWIN148 if ( pThis->fMediaPresent149 && pThis->ppScsiTaskDI150 && pThis->cbBlock)151 #elif defined(RT_OS_FREEBSD)152 if ( pThis->fMediaPresent153 && pThis->cbBlock)154 #else155 147 if (pThis->fMediaPresent) 156 #endif 157 { 158 #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) 159 /* 160 * Issue a READ(12) request. 161 */ 162 do 163 { 164 const uint32_t LBA = off / pThis->cbBlock; 165 AssertReturn(!(off % pThis->cbBlock), VERR_INVALID_PARAMETER); 166 uint32_t cbRead32 = cbRead > SCSI_MAX_BUFFER_SIZE 167 ? SCSI_MAX_BUFFER_SIZE 168 : (uint32_t)cbRead; 169 const uint32_t cBlocks = cbRead32 / pThis->cbBlock; 170 AssertReturn(!(cbRead % pThis->cbBlock), VERR_INVALID_PARAMETER); 171 uint8_t abCmd[16] = 172 { 173 SCSI_READ_12, 0, 174 RT_BYTE4(LBA), RT_BYTE3(LBA), RT_BYTE2(LBA), RT_BYTE1(LBA), 175 RT_BYTE4(cBlocks), RT_BYTE3(cBlocks), RT_BYTE2(cBlocks), RT_BYTE1(cBlocks), 176 0, 0, 0, 0, 0 177 }; 178 rc = drvHostBaseScsiCmdOs(pThis, abCmd, 12, PDMMEDIATXDIR_FROM_DEVICE, pvBuf, &cbRead32, NULL, 0, 0); 179 180 off += cbRead32; 181 cbRead -= cbRead32; 182 pvBuf = (uint8_t *)pvBuf + cbRead32; 183 } while ((cbRead > 0) && RT_SUCCESS(rc)); 184 185 #else 148 { 186 149 /* 187 150 * Seek and read. 188 151 */ 189 rc = RTFileReadAt(pThis->hFileDevice, off, pvBuf, cbRead, NULL);152 rc = drvHostBaseReadOs(pThis, off, pvBuf, cbRead); 190 153 if (RT_SUCCESS(rc)) 191 154 { 192 Log2(("%s-%d: drvHostBaseRead : off=%#llx cbRead=%#x\n"155 Log2(("%s-%d: drvHostBaseReadOs: off=%#llx cbRead=%#x\n" 193 156 "%16.*Rhxd\n", 194 157 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, off, cbRead, cbRead, pvBuf)); 195 158 } 196 159 else 197 Log(("%s-%d: drvHostBaseRead : RTFileReadAt(%RTfile,%#llx, %p, %#x) -> %Rrc ('%s')\n",198 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->hFileDevice,160 Log(("%s-%d: drvHostBaseReadOs: drvHostBaseReadOs(%#llx, %p, %#x) -> %Rrc ('%s')\n", 161 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, 199 162 off, pvBuf, cbRead, rc, pThis->pszDevice)); 200 #endif201 163 } 202 164 else … … 229 191 if (pThis->fMediaPresent) 230 192 { 231 #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)232 /** @todo write support... */233 rc = VERR_WRITE_PROTECT;234 235 #else236 193 /* 237 194 * Seek and write. 238 195 */ 239 rc = RTFileWriteAt(pThis->hFileDevice, off, pvBuf, cbWrite, NULL);196 rc = drvHostBaseWriteOs(pThis, off, pvBuf, cbWrite); 240 197 if (RT_FAILURE(rc)) 241 Log(("%s-%d: drvHostBaseWrite: RTFileWriteAt(%RTfile,%#llx, %p, %#x) -> %Rrc ('%s')\n",242 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->hFileDevice,198 Log(("%s-%d: drvHostBaseWrite: drvHostBaseWriteOs(%#llx, %p, %#x) -> %Rrc ('%s')\n", 199 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, 243 200 off, pvBuf, cbWrite, rc, pThis->pszDevice)); 244 #endif245 201 } 246 202 else … … 266 222 267 223 if (pThis->fMediaPresent) 268 { 269 #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) 270 rc = VINF_SUCCESS; 271 /** @todo scsi device buffer flush... */ 272 #else 273 rc = RTFileFlush(pThis->hFileDevice); 274 #endif 275 } 224 rc = drvHostBaseFlushOs(pThis); 276 225 else 277 226 rc = VERR_MEDIA_NOT_PRESENT; -
trunk/src/VBox/Devices/Storage/DrvHostBase.h
r64246 r64251 192 192 DECLHIDDEN(int) drvHostBaseScsiCmdOs(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMMEDIATXDIR enmTxDir, 193 193 void *pvBuf, uint32_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies); 194 195 194 DECLHIDDEN(int) drvHostBaseGetMediaSizeOs(PDRVHOSTBASE pThis, uint64_t *pcb); 195 DECLHIDDEN(int) drvHostBaseReadOs(PDRVHOSTBASE pThis, uint64_t off, void *pvBuf, size_t cbRead); 196 DECLHIDDEN(int) drvHostBaseWriteOs(PDRVHOSTBASE pThis, uint64_t off, const void *pvBuf, size_t cbWrite); 197 DECLHIDDEN(int) drvHostBaseFlushOs(PDRVHOSTBASE pThis); 196 198 197 199 /** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
Note:
See TracChangeset
for help on using the changeset viewer.