- Timestamp:
- Jan 4, 2016 2:13:22 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmifs.h
r58154 r59248 1018 1018 1019 1019 1020 /** Pointer to a block port interface. */ 1021 typedef struct PDMIBLOCKPORT *PPDMIBLOCKPORT; 1022 /** 1023 * Block notify interface (down). 1024 * Pair with PDMIBLOCK. 1025 */ 1026 typedef struct PDMIBLOCKPORT 1027 { 1028 /** 1029 * Returns the storage controller name, instance and LUN of the attached medium. 1030 * 1031 * @returns VBox status. 1020 /** Pointer to a mount interface. */ 1021 typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY; 1022 /** 1023 * Block interface (up). 1024 * Pair with PDMIMOUNT. 1025 */ 1026 typedef struct PDMIMOUNTNOTIFY 1027 { 1028 /** 1029 * Called when a media is mounted. 1030 * 1031 * @param pInterface Pointer to the interface structure containing the called function pointer. 1032 * @thread The emulation thread. 1033 */ 1034 DECLR3CALLBACKMEMBER(void, pfnMountNotify,(PPDMIMOUNTNOTIFY pInterface)); 1035 1036 /** 1037 * Called when a media is unmounted 1038 * @param pInterface Pointer to the interface structure containing the called function pointer. 1039 * @thread The emulation thread. 1040 */ 1041 DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface)); 1042 } PDMIMOUNTNOTIFY; 1043 /** PDMIMOUNTNOTIFY interface ID. */ 1044 #define PDMIMOUNTNOTIFY_IID "fa143ac9-9fc6-498e-997f-945380a558f9" 1045 1046 1047 /** Pointer to mount interface. */ 1048 typedef struct PDMIMOUNT *PPDMIMOUNT; 1049 /** 1050 * Mount interface (down). 1051 * Pair with PDMIMOUNTNOTIFY. 1052 */ 1053 typedef struct PDMIMOUNT 1054 { 1055 /** 1056 * Unmount the media. 1057 * 1058 * The driver will validate and pass it on. On the rebounce it will decide whether or not to detach it self. 1059 * 1060 * @returns VBox status code. 1061 * @param pInterface Pointer to the interface structure containing the called function pointer. 1062 * @thread The emulation thread. 1063 * @param fForce Force the unmount, even for locked media. 1064 * @param fEject Eject the medium. Only relevant for host drives. 1065 * @thread The emulation thread. 1066 */ 1067 DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce, bool fEject)); 1068 1069 /** 1070 * Checks if a media is mounted. 1071 * 1072 * @returns true if mounted. 1073 * @returns false if not mounted. 1074 * @param pInterface Pointer to the interface structure containing the called function pointer. 1075 * @thread Any thread. 1076 */ 1077 DECLR3CALLBACKMEMBER(bool, pfnIsMounted,(PPDMIMOUNT pInterface)); 1078 1079 /** 1080 * Locks the media, preventing any unmounting of it. 1081 * 1082 * @returns VBox status code. 1083 * @param pInterface Pointer to the interface structure containing the called function pointer. 1084 * @thread The emulation thread. 1085 */ 1086 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMIMOUNT pInterface)); 1087 1088 /** 1089 * Unlocks the media, canceling previous calls to pfnLock(). 1090 * 1091 * @returns VBox status code. 1092 * @param pInterface Pointer to the interface structure containing the called function pointer. 1093 * @thread The emulation thread. 1094 */ 1095 DECLR3CALLBACKMEMBER(int, pfnUnlock,(PPDMIMOUNT pInterface)); 1096 1097 /** 1098 * Checks if a media is locked. 1099 * 1100 * @returns true if locked. 1101 * @returns false if not locked. 1102 * @param pInterface Pointer to the interface structure containing the called function pointer. 1103 * @thread Any thread. 1104 */ 1105 DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface)); 1106 } PDMIMOUNT; 1107 /** PDMIMOUNT interface ID. */ 1108 #define PDMIMOUNT_IID "34fc7a4c-623a-4806-a6bf-5be1be33c99f" 1109 1110 /** Pointer to a secret key interface. */ 1111 typedef struct PDMISECKEY *PPDMISECKEY; 1112 1113 /** 1114 * Secret key interface to retrieve secret keys. 1115 */ 1116 typedef struct PDMISECKEY 1117 { 1118 /** 1119 * Retains a key identified by the ID. The caller will only hold a reference 1120 * to the key and must not modify the key buffer in any way. 1121 * 1122 * @returns VBox status code. 1032 1123 * @param pInterface Pointer to this interface. 1033 * @param ppcszController Where to store the name of the storage controller. 1034 * @param piInstance Where to store the instance number of the controller. 1035 * @param piLUN Where to store the LUN of the attached device. 1036 */ 1037 DECLR3CALLBACKMEMBER(int, pfnQueryDeviceLocation, (PPDMIBLOCKPORT pInterface, const char **ppcszController, 1038 uint32_t *piInstance, uint32_t *piLUN)); 1039 1040 } PDMIBLOCKPORT; 1041 /** PDMIBLOCKPORT interface ID. */ 1042 #define PDMIBLOCKPORT_IID "bbbed4cf-0862-4ffd-b60c-f7a65ef8e8ff" 1124 * @param pszId The alias/id for the key to retrieve. 1125 * @param ppbKey Where to store the pointer to the key buffer on success. 1126 * @param pcbKey Where to store the size of the key in bytes on success. 1127 */ 1128 DECLR3CALLBACKMEMBER(int, pfnKeyRetain, (PPDMISECKEY pInterface, const char *pszId, 1129 const uint8_t **pbKey, size_t *pcbKey)); 1130 1131 /** 1132 * Releases one reference of the key identified by the given identifier. 1133 * The caller must not access the key buffer after calling this operation. 1134 * 1135 * @returns VBox status code. 1136 * @param pInterface Pointer to this interface. 1137 * @param pszId The alias/id for the key to release. 1138 * 1139 * @note: It is advised to release the key whenever it is not used anymore so the entity 1140 * storing the key can do anything to make retrieving the key from memory more 1141 * difficult like scrambling the memory buffer for instance. 1142 */ 1143 DECLR3CALLBACKMEMBER(int, pfnKeyRelease, (PPDMISECKEY pInterface, const char *pszId)); 1144 1145 /** 1146 * Retains a password identified by the ID. The caller will only hold a reference 1147 * to the password and must not modify the buffer in any way. 1148 * 1149 * @returns VBox status code. 1150 * @param pInterface Pointer to this interface. 1151 * @param pszId The alias/id for the password to retrieve. 1152 * @param ppszPassword Where to store the pointer to the password on success. 1153 */ 1154 DECLR3CALLBACKMEMBER(int, pfnPasswordRetain, (PPDMISECKEY pInterface, const char *pszId, 1155 const char **ppszPassword)); 1156 1157 /** 1158 * Releases one reference of the password identified by the given identifier. 1159 * The caller must not access the password after calling this operation. 1160 * 1161 * @returns VBox status code. 1162 * @param pInterface Pointer to this interface. 1163 * @param pszId The alias/id for the password to release. 1164 * 1165 * @note: It is advised to release the password whenever it is not used anymore so the entity 1166 * storing the password can do anything to make retrieving the password from memory more 1167 * difficult like scrambling the memory buffer for instance. 1168 */ 1169 DECLR3CALLBACKMEMBER(int, pfnPasswordRelease, (PPDMISECKEY pInterface, const char *pszId)); 1170 } PDMISECKEY; 1171 /** PDMISECKEY interface ID. */ 1172 #define PDMISECKEY_IID "3d698355-d995-453d-960f-31566a891df2" 1173 1174 /** Pointer to a secret key helper interface. */ 1175 typedef struct PDMISECKEYHLP *PPDMISECKEYHLP; 1176 1177 /** 1178 * Secret key helper interface for non critical functionality. 1179 */ 1180 typedef struct PDMISECKEYHLP 1181 { 1182 /** 1183 * Notifies the interface provider that a key couldn't be retrieved from the key store. 1184 * 1185 * @returns VBox status code. 1186 * @param pInterface Pointer to this interface. 1187 */ 1188 DECLR3CALLBACKMEMBER(int, pfnKeyMissingNotify, (PPDMISECKEYHLP pInterface)); 1189 1190 } PDMISECKEYHLP; 1191 /** PDMISECKEY interface ID. */ 1192 #define PDMISECKEYHLP_IID "7be96168-4156-40ac-86d2-3073bf8b318e" 1043 1193 1044 1194 … … 1056 1206 1057 1207 /** 1058 * Block drivetype.1059 */ 1060 typedef enum PDM BLOCKTYPE1208 * Media type. 1209 */ 1210 typedef enum PDMMEDIATYPE 1061 1211 { 1062 1212 /** Error (for the query function). */ 1063 PDM BLOCKTYPE_ERROR = 1,1213 PDMMEDIATYPE_ERROR = 1, 1064 1214 /** 360KB 5 1/4" floppy drive. */ 1065 PDM BLOCKTYPE_FLOPPY_360,1215 PDMMEDIATYPE_FLOPPY_360, 1066 1216 /** 720KB 3 1/2" floppy drive. */ 1067 PDM BLOCKTYPE_FLOPPY_720,1217 PDMMEDIATYPE_FLOPPY_720, 1068 1218 /** 1.2MB 5 1/4" floppy drive. */ 1069 PDM BLOCKTYPE_FLOPPY_1_20,1219 PDMMEDIATYPE_FLOPPY_1_20, 1070 1220 /** 1.44MB 3 1/2" floppy drive. */ 1071 PDM BLOCKTYPE_FLOPPY_1_44,1221 PDMMEDIATYPE_FLOPPY_1_44, 1072 1222 /** 2.88MB 3 1/2" floppy drive. */ 1073 PDM BLOCKTYPE_FLOPPY_2_88,1223 PDMMEDIATYPE_FLOPPY_2_88, 1074 1224 /** Fake drive that can take up to 15.6 MB images. 1075 1225 * C=255, H=2, S=63. */ 1076 PDM BLOCKTYPE_FLOPPY_FAKE_15_6,1226 PDMMEDIATYPE_FLOPPY_FAKE_15_6, 1077 1227 /** Fake drive that can take up to 63.5 MB images. 1078 1228 * C=255, H=2, S=255. */ 1079 PDM BLOCKTYPE_FLOPPY_FAKE_63_5,1229 PDMMEDIATYPE_FLOPPY_FAKE_63_5, 1080 1230 /** CDROM drive. */ 1081 PDM BLOCKTYPE_CDROM,1231 PDMMEDIATYPE_CDROM, 1082 1232 /** DVD drive. */ 1083 PDM BLOCKTYPE_DVD,1233 PDMMEDIATYPE_DVD, 1084 1234 /** Hard disk drive. */ 1085 PDM BLOCKTYPE_HARD_DISK1086 } PDM BLOCKTYPE;1235 PDMMEDIATYPE_HARD_DISK 1236 } PDMMEDIATYPE; 1087 1237 1088 1238 /** Check if the given block type is a floppy. */ 1089 #define PDMBLOCKTYPE_IS_FLOPPY(a_enmType) ( (a_enmType) >= PDMBLOCKTYPE_FLOPPY_360 && (a_enmType) <= PDMBLOCKTYPE_FLOPPY_2_88 ) 1090 1091 /** 1092 * Block raw command data transfer direction. 1093 */ 1094 typedef enum PDMBLOCKTXDIR 1095 { 1096 PDMBLOCKTXDIR_NONE = 0, 1097 PDMBLOCKTXDIR_FROM_DEVICE, 1098 PDMBLOCKTXDIR_TO_DEVICE 1099 } PDMBLOCKTXDIR; 1100 1101 1102 /** Pointer to a block interface. */ 1103 typedef struct PDMIBLOCK *PPDMIBLOCK; 1104 /** 1105 * Block interface (up). 1106 * Pair with PDMIBLOCKPORT. 1107 */ 1108 typedef struct PDMIBLOCK 1109 { 1110 /** 1111 * Read bits. 1112 * 1113 * @returns VBox status code. 1114 * @param pInterface Pointer to the interface structure containing the called function pointer. 1115 * @param off Offset to start reading from. The offset must be aligned to a sector boundary. 1116 * @param pvBuf Where to store the read bits. 1117 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary. 1118 * @thread Any thread. 1119 */ 1120 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead)); 1121 1122 /** 1123 * Read bits - version for DevPcBios. 1124 * 1125 * @returns VBox status code. 1126 * @param pInterface Pointer to the interface structure containing the called function pointer. 1127 * @param off Offset to start reading from. The offset must be aligned to a sector boundary. 1128 * @param pvBuf Where to store the read bits. 1129 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary. 1130 * @thread Any thread. 1131 * 1132 * @note: Special version of pfnRead which doesn't try to suspend the VM when the DEKs for encrypted disks 1133 * are missing but just returns an error. 1134 */ 1135 DECLR3CALLBACKMEMBER(int, pfnReadPcBios,(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead)); 1136 1137 /** 1138 * Write bits. 1139 * 1140 * @returns VBox status code. 1141 * @param pInterface Pointer to the interface structure containing the called function pointer. 1142 * @param off Offset to start writing at. The offset must be aligned to a sector boundary. 1143 * @param pvBuf Where to store the write bits. 1144 * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary. 1145 * @thread Any thread. 1146 */ 1147 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite)); 1148 1149 /** 1150 * Make sure that the bits written are actually on the storage medium. 1151 * 1152 * @returns VBox status code. 1153 * @param pInterface Pointer to the interface structure containing the called function pointer. 1154 * @thread Any thread. 1155 */ 1156 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIBLOCK pInterface)); 1157 1158 /** 1159 * Send a raw command to the underlying device (CDROM). 1160 * This method is optional (i.e. the function pointer may be NULL). 1161 * 1162 * @returns VBox status code. 1163 * @param pInterface Pointer to the interface structure containing the called function pointer. 1164 * @param pbCmd Offset to start reading from. 1165 * @param enmTxDir Direction of transfer. 1166 * @param pvBuf Pointer tp the transfer buffer. 1167 * @param cbBuf Size of the transfer buffer. 1168 * @param pbSenseKey Status of the command (when return value is VERR_DEV_IO_ERROR). 1169 * @param cTimeoutMillies Command timeout in milliseconds. 1170 * @thread Any thread. 1171 */ 1172 DECLR3CALLBACKMEMBER(int, pfnSendCmd,(PPDMIBLOCK pInterface, const uint8_t *pbCmd, PDMBLOCKTXDIR enmTxDir, void *pvBuf, uint32_t *pcbBuf, uint8_t *pabSense, size_t cbSense, uint32_t cTimeoutMillies)); 1173 1174 /** 1175 * Merge medium contents during a live snapshot deletion. 1176 * 1177 * @returns VBox status code. 1178 * @param pInterface Pointer to the interface structure containing the called function pointer. 1179 * @param pfnProgress Function pointer for progress notification. 1180 * @param pvUser Opaque user data for progress notification. 1181 * @thread Any thread. 1182 */ 1183 DECLR3CALLBACKMEMBER(int, pfnMerge,(PPDMIBLOCK pInterface, PFNSIMPLEPROGRESS pfnProgress, void *pvUser)); 1184 1185 /** 1186 * Check if the media is readonly or not. 1187 * 1188 * @returns true if readonly. 1189 * @returns false if read/write. 1190 * @param pInterface Pointer to the interface structure containing the called function pointer. 1191 * @thread Any thread. 1192 */ 1193 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIBLOCK pInterface)); 1194 1195 /** 1196 * Gets the media size in bytes. 1197 * 1198 * @returns Media size in bytes. 1199 * @param pInterface Pointer to the interface structure containing the called function pointer. 1200 * @thread Any thread. 1201 */ 1202 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIBLOCK pInterface)); 1203 1204 /** 1205 * Gets the media sector size in bytes. 1206 * 1207 * @returns Media sector size in bytes. 1208 * @param pInterface Pointer to the interface structure containing the called function pointer. 1209 * @thread Any thread. 1210 */ 1211 DECLR3CALLBACKMEMBER(uint32_t, pfnGetSectorSize,(PPDMIBLOCK pInterface)); 1212 1213 /** 1214 * Gets the block drive type. 1215 * 1216 * @returns block drive type. 1217 * @param pInterface Pointer to the interface structure containing the called function pointer. 1218 * @thread Any thread. 1219 */ 1220 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCK pInterface)); 1221 1222 /** 1223 * Gets the UUID of the block drive. 1224 * Don't return the media UUID if it's removable. 1225 * 1226 * @returns VBox status code. 1227 * @param pInterface Pointer to the interface structure containing the called function pointer. 1228 * @param pUuid Where to store the UUID on success. 1229 * @thread Any thread. 1230 */ 1231 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIBLOCK pInterface, PRTUUID pUuid)); 1232 1233 /** 1234 * Discards the given range. 1235 * 1236 * @returns VBox status code. 1237 * @param pInterface Pointer to the interface structure containing the called function pointer. 1238 * @param paRanges Array of ranges to discard. 1239 * @param cRanges Number of entries in the array. 1240 * @thread Any thread. 1241 */ 1242 DECLR3CALLBACKMEMBER(int, pfnDiscard,(PPDMIBLOCK pInterface, PCRTRANGE paRanges, unsigned cRanges)); 1243 1244 /** 1245 * Allocate buffer memory which is suitable for I/O and might have special proerties for secure 1246 * environments (non-pageable memory for sensitive data which should not end up on the disk). 1247 * 1248 * @returns VBox status code. 1249 * @param pInterface Pointer to the interface structure containing the called function pointer. 1250 * @param cb Amount of memory to allocate. 1251 * @param ppvNew Where to store the pointer to the buffer on success. 1252 */ 1253 DECLR3CALLBACKMEMBER(int, pfnIoBufAlloc, (PPDMIBLOCK pInterface, size_t cb, void **ppvNew)); 1254 1255 /** 1256 * Free memory allocated with PDMIBLOCK::pfnIoBufAlloc(). 1257 * 1258 * @returns VBox status code. 1259 * @param pInterface Pointer to the interface structure containing the called function pointer. 1260 * @param pv Pointer to the memory to free. 1261 * @param cb Amount of bytes given in PDMIBLOCK::pfnIoBufAlloc(). 1262 */ 1263 DECLR3CALLBACKMEMBER(int, pfnIoBufFree, (PPDMIBLOCK pInterface, void *pv, size_t cb)); 1264 1265 } PDMIBLOCK; 1266 /** PDMIBLOCK interface ID. */ 1267 #define PDMIBLOCK_IID "4e804e8e-3c01-4f20-98d9-a30ece8ec9f5" 1268 1269 1270 /** Pointer to a mount interface. */ 1271 typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY; 1272 /** 1273 * Block interface (up). 1274 * Pair with PDMIMOUNT. 1275 */ 1276 typedef struct PDMIMOUNTNOTIFY 1277 { 1278 /** 1279 * Called when a media is mounted. 1280 * 1281 * @param pInterface Pointer to the interface structure containing the called function pointer. 1282 * @thread The emulation thread. 1283 */ 1284 DECLR3CALLBACKMEMBER(void, pfnMountNotify,(PPDMIMOUNTNOTIFY pInterface)); 1285 1286 /** 1287 * Called when a media is unmounted 1288 * @param pInterface Pointer to the interface structure containing the called function pointer. 1289 * @thread The emulation thread. 1290 */ 1291 DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface)); 1292 } PDMIMOUNTNOTIFY; 1293 /** PDMIMOUNTNOTIFY interface ID. */ 1294 #define PDMIMOUNTNOTIFY_IID "fa143ac9-9fc6-498e-997f-945380a558f9" 1295 1296 1297 /** Pointer to mount interface. */ 1298 typedef struct PDMIMOUNT *PPDMIMOUNT; 1299 /** 1300 * Mount interface (down). 1301 * Pair with PDMIMOUNTNOTIFY. 1302 */ 1303 typedef struct PDMIMOUNT 1304 { 1305 /** 1306 * Mount a media. 1307 * 1308 * This will not unmount any currently mounted media! 1309 * 1310 * @returns VBox status code. 1311 * @param pInterface Pointer to the interface structure containing the called function pointer. 1312 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have 1313 * constructed a configuration which can be attached to the bottom driver. 1314 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL. 1315 * @thread The emulation thread. 1316 */ 1317 DECLR3CALLBACKMEMBER(int, pfnMount,(PPDMIMOUNT pInterface, const char *pszFilename, const char *pszCoreDriver)); 1318 1319 /** 1320 * Unmount the media. 1321 * 1322 * The driver will validate and pass it on. On the rebounce it will decide whether or not to detach it self. 1323 * 1324 * @returns VBox status code. 1325 * @param pInterface Pointer to the interface structure containing the called function pointer. 1326 * @thread The emulation thread. 1327 * @param fForce Force the unmount, even for locked media. 1328 * @param fEject Eject the medium. Only relevant for host drives. 1329 * @thread The emulation thread. 1330 */ 1331 DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce, bool fEject)); 1332 1333 /** 1334 * Checks if a media is mounted. 1335 * 1336 * @returns true if mounted. 1337 * @returns false if not mounted. 1338 * @param pInterface Pointer to the interface structure containing the called function pointer. 1339 * @thread Any thread. 1340 */ 1341 DECLR3CALLBACKMEMBER(bool, pfnIsMounted,(PPDMIMOUNT pInterface)); 1342 1343 /** 1344 * Locks the media, preventing any unmounting of it. 1345 * 1346 * @returns VBox status code. 1347 * @param pInterface Pointer to the interface structure containing the called function pointer. 1348 * @thread The emulation thread. 1349 */ 1350 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMIMOUNT pInterface)); 1351 1352 /** 1353 * Unlocks the media, canceling previous calls to pfnLock(). 1354 * 1355 * @returns VBox status code. 1356 * @param pInterface Pointer to the interface structure containing the called function pointer. 1357 * @thread The emulation thread. 1358 */ 1359 DECLR3CALLBACKMEMBER(int, pfnUnlock,(PPDMIMOUNT pInterface)); 1360 1361 /** 1362 * Checks if a media is locked. 1363 * 1364 * @returns true if locked. 1365 * @returns false if not locked. 1366 * @param pInterface Pointer to the interface structure containing the called function pointer. 1367 * @thread Any thread. 1368 */ 1369 DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface)); 1370 } PDMIMOUNT; 1371 /** PDMIMOUNT interface ID. */ 1372 #define PDMIMOUNT_IID "34fc7a4c-623a-4806-a6bf-5be1be33c99f" 1373 1374 /** Pointer to a secret key interface. */ 1375 typedef struct PDMISECKEY *PPDMISECKEY; 1376 1377 /** 1378 * Secret key interface to retrieve secret keys. 1379 */ 1380 typedef struct PDMISECKEY 1381 { 1382 /** 1383 * Retains a key identified by the ID. The caller will only hold a reference 1384 * to the key and must not modify the key buffer in any way. 1385 * 1386 * @returns VBox status code. 1387 * @param pInterface Pointer to this interface. 1388 * @param pszId The alias/id for the key to retrieve. 1389 * @param ppbKey Where to store the pointer to the key buffer on success. 1390 * @param pcbKey Where to store the size of the key in bytes on success. 1391 */ 1392 DECLR3CALLBACKMEMBER(int, pfnKeyRetain, (PPDMISECKEY pInterface, const char *pszId, 1393 const uint8_t **pbKey, size_t *pcbKey)); 1394 1395 /** 1396 * Releases one reference of the key identified by the given identifier. 1397 * The caller must not access the key buffer after calling this operation. 1398 * 1399 * @returns VBox status code. 1400 * @param pInterface Pointer to this interface. 1401 * @param pszId The alias/id for the key to release. 1402 * 1403 * @note: It is advised to release the key whenever it is not used anymore so the entity 1404 * storing the key can do anything to make retrieving the key from memory more 1405 * difficult like scrambling the memory buffer for instance. 1406 */ 1407 DECLR3CALLBACKMEMBER(int, pfnKeyRelease, (PPDMISECKEY pInterface, const char *pszId)); 1408 1409 /** 1410 * Retains a password identified by the ID. The caller will only hold a reference 1411 * to the password and must not modify the buffer in any way. 1412 * 1413 * @returns VBox status code. 1414 * @param pInterface Pointer to this interface. 1415 * @param pszId The alias/id for the password to retrieve. 1416 * @param ppszPassword Where to store the pointer to the password on success. 1417 */ 1418 DECLR3CALLBACKMEMBER(int, pfnPasswordRetain, (PPDMISECKEY pInterface, const char *pszId, 1419 const char **ppszPassword)); 1420 1421 /** 1422 * Releases one reference of the password identified by the given identifier. 1423 * The caller must not access the password after calling this operation. 1424 * 1425 * @returns VBox status code. 1426 * @param pInterface Pointer to this interface. 1427 * @param pszId The alias/id for the password to release. 1428 * 1429 * @note: It is advised to release the password whenever it is not used anymore so the entity 1430 * storing the password can do anything to make retrieving the password from memory more 1431 * difficult like scrambling the memory buffer for instance. 1432 */ 1433 DECLR3CALLBACKMEMBER(int, pfnPasswordRelease, (PPDMISECKEY pInterface, const char *pszId)); 1434 } PDMISECKEY; 1435 /** PDMISECKEY interface ID. */ 1436 #define PDMISECKEY_IID "3d698355-d995-453d-960f-31566a891df2" 1437 1438 /** Pointer to a secret key helper interface. */ 1439 typedef struct PDMISECKEYHLP *PPDMISECKEYHLP; 1440 1441 /** 1442 * Secret key helper interface for non critical functionality. 1443 */ 1444 typedef struct PDMISECKEYHLP 1445 { 1446 /** 1447 * Notifies the interface provider that a key couldn't be retrieved from the key store. 1448 * 1449 * @returns VBox status code. 1450 * @param pInterface Pointer to this interface. 1451 */ 1452 DECLR3CALLBACKMEMBER(int, pfnKeyMissingNotify, (PPDMISECKEYHLP pInterface)); 1453 1454 } PDMISECKEYHLP; 1455 /** PDMISECKEY interface ID. */ 1456 #define PDMISECKEYHLP_IID "7be96168-4156-40ac-86d2-3073bf8b318e" 1239 #define PDMMEDIATYPE_IS_FLOPPY(a_enmType) ( (a_enmType) >= PDMMEDIATYPE_FLOPPY_360 && (a_enmType) <= PDMMEDIATYPE_FLOPPY_2_88 ) 1240 1241 /** 1242 * Raw command data transfer direction. 1243 */ 1244 typedef enum PDMMEDIATXDIR 1245 { 1246 PDMMEDIATXDIR_NONE = 0, 1247 PDMMEDIATXDIR_FROM_DEVICE, 1248 PDMMEDIATXDIR_TO_DEVICE 1249 } PDMMEDIATXDIR; 1457 1250 1458 1251 /** … … 1501 1294 /** 1502 1295 * Media interface (up). 1503 * Makes up the foundation for PDMIBLOCK and PDMIBLOCKBIOS.1504 1296 * Pairs with PDMIMEDIAPORT. 1505 1297 */ … … 1553 1345 */ 1554 1346 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIMEDIA pInterface)); 1347 1348 /** 1349 * Send a raw command to the underlying device (CDROM). 1350 * This method is optional (i.e. the function pointer may be NULL). 1351 * 1352 * @returns VBox status code. 1353 * @param pInterface Pointer to the interface structure containing the called function pointer. 1354 * @param pbCmd Offset to start reading from. 1355 * @param enmTxDir Direction of transfer. 1356 * @param pvBuf Pointer tp the transfer buffer. 1357 * @param cbBuf Size of the transfer buffer. 1358 * @param pbSenseKey Status of the command (when return value is VERR_DEV_IO_ERROR). 1359 * @param cTimeoutMillies Command timeout in milliseconds. 1360 * @thread Any thread. 1361 */ 1362 DECLR3CALLBACKMEMBER(int, pfnSendCmd,(PPDMIMEDIA pInterface, const uint8_t *pbCmd, PDMMEDIATXDIR enmTxDir, void *pvBuf, uint32_t *pcbBuf, uint8_t *pabSense, size_t cbSense, uint32_t cTimeoutMillies)); 1555 1363 1556 1364 /** … … 1664 1472 1665 1473 /** 1474 * Checks if the device should be visible to the BIOS or not. 1475 * 1476 * @returns true if the device is visible to the BIOS. 1477 * @returns false if the device is not visible to the BIOS. 1478 * @param pInterface Pointer to the interface structure containing the called function pointer. 1479 * @thread Any thread. 1480 */ 1481 DECLR3CALLBACKMEMBER(bool, pfnBiosIsVisible,(PPDMIMEDIA pInterface)); 1482 1483 /** 1484 * Gets the media type. 1485 * 1486 * @returns media type. 1487 * @param pInterface Pointer to the interface structure containing the called function pointer. 1488 * @thread Any thread. 1489 */ 1490 DECLR3CALLBACKMEMBER(PDMMEDIATYPE, pfnGetType,(PPDMIMEDIA pInterface)); 1491 1492 /** 1666 1493 * Gets the UUID of the media drive. 1667 1494 * … … 1707 1534 } PDMIMEDIA; 1708 1535 /** PDMIMEDIA interface ID. */ 1709 #define PDMIMEDIA_IID "d8997ad8-4dda-4352-aa99-99bf87d54102" 1710 1711 1712 /** Pointer to a block BIOS interface. */ 1713 typedef struct PDMIBLOCKBIOS *PPDMIBLOCKBIOS; 1714 /** 1715 * Media BIOS interface (Up / External). 1716 * The interface the getting and setting properties which the BIOS/CMOS care about. 1717 */ 1718 typedef struct PDMIBLOCKBIOS 1719 { 1720 /** 1721 * Get stored media geometry (physical CHS, PCHS) - BIOS property. 1722 * This is an optional feature of a media. 1723 * 1724 * @returns VBox status code. 1725 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry. 1726 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnSetPCHSGeometry() yet. 1727 * @param pInterface Pointer to the interface structure containing the called function pointer. 1728 * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors). 1729 * @remark This has no influence on the read/write operations. 1730 * @thread Any thread. 1731 */ 1732 DECLR3CALLBACKMEMBER(int, pfnGetPCHSGeometry,(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry)); 1733 1734 /** 1735 * Store the media geometry (physical CHS, PCHS) - BIOS property. 1736 * This is an optional feature of a media. 1737 * 1738 * @returns VBox status code. 1739 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry. 1740 * @param pInterface Pointer to the interface structure containing the called function pointer. 1741 * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors). 1742 * @remark This has no influence on the read/write operations. 1743 * @thread The emulation thread. 1744 */ 1745 DECLR3CALLBACKMEMBER(int, pfnSetPCHSGeometry,(PPDMIBLOCKBIOS pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry)); 1746 1747 /** 1748 * Get stored media geometry (logical CHS, LCHS) - BIOS property. 1749 * This is an optional feature of a media. 1750 * 1751 * @returns VBox status code. 1752 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry. 1753 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnSetLCHSGeometry() yet. 1754 * @param pInterface Pointer to the interface structure containing the called function pointer. 1755 * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors). 1756 * @remark This has no influence on the read/write operations. 1757 * @thread Any thread. 1758 */ 1759 DECLR3CALLBACKMEMBER(int, pfnGetLCHSGeometry,(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry)); 1760 1761 /** 1762 * Store the media geometry (logical CHS, LCHS) - BIOS property. 1763 * This is an optional feature of a media. 1764 * 1765 * @returns VBox status code. 1766 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry. 1767 * @param pInterface Pointer to the interface structure containing the called function pointer. 1768 * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors). 1769 * @remark This has no influence on the read/write operations. 1770 * @thread The emulation thread. 1771 */ 1772 DECLR3CALLBACKMEMBER(int, pfnSetLCHSGeometry,(PPDMIBLOCKBIOS pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry)); 1773 1774 /** 1775 * Checks if the device should be visible to the BIOS or not. 1776 * 1777 * @returns true if the device is visible to the BIOS. 1778 * @returns false if the device is not visible to the BIOS. 1779 * @param pInterface Pointer to the interface structure containing the called function pointer. 1780 * @thread Any thread. 1781 */ 1782 DECLR3CALLBACKMEMBER(bool, pfnIsVisible,(PPDMIBLOCKBIOS pInterface)); 1783 1784 /** 1785 * Gets the block drive type. 1786 * 1787 * @returns block drive type. 1788 * @param pInterface Pointer to the interface structure containing the called function pointer. 1789 * @thread Any thread. 1790 */ 1791 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCKBIOS pInterface)); 1792 1793 } PDMIBLOCKBIOS; 1794 /** PDMIBLOCKBIOS interface ID. */ 1795 #define PDMIBLOCKBIOS_IID "477c3eee-a48d-48a9-82fd-2a54de16b2e9" 1796 1797 1798 /** Pointer to a static block core driver interface. */ 1799 typedef struct PDMIMEDIASTATIC *PPDMIMEDIASTATIC; 1800 /** 1801 * Static block core driver interface. 1802 */ 1803 typedef struct PDMIMEDIASTATIC 1804 { 1805 /** 1806 * Check if the specified file is a format which the core driver can handle. 1807 * 1808 * @returns true / false accordingly. 1809 * @param pInterface Pointer to the interface structure containing the called function pointer. 1810 * @param pszFilename Name of the file to probe. 1811 */ 1812 DECLR3CALLBACKMEMBER(bool, pfnCanHandle,(PPDMIMEDIASTATIC pInterface, const char *pszFilename)); 1813 } PDMIMEDIASTATIC; 1814 1815 1816 1817 1818 1819 /** Pointer to an asynchronous block notify interface. */ 1820 typedef struct PDMIBLOCKASYNCPORT *PPDMIBLOCKASYNCPORT; 1821 /** 1822 * Asynchronous block notify interface (up). 1823 * Pair with PDMIBLOCKASYNC. 1824 */ 1825 typedef struct PDMIBLOCKASYNCPORT 1826 { 1827 /** 1828 * Notify completion of an asynchronous transfer. 1829 * 1830 * @returns VBox status code. 1831 * @param pInterface Pointer to the interface structure containing the called function pointer. 1832 * @param pvUser The user argument given in pfnStartWrite/Read. 1833 * @param rcReq IPRT Status code of the completed request. 1834 * @thread Any thread. 1835 */ 1836 DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIBLOCKASYNCPORT pInterface, void *pvUser, int rcReq)); 1837 } PDMIBLOCKASYNCPORT; 1838 /** PDMIBLOCKASYNCPORT interface ID. */ 1839 #define PDMIBLOCKASYNCPORT_IID "e3bdc0cb-9d99-41dd-8eec-0dc8cf5b2a92" 1840 1841 1842 1843 /** Pointer to an asynchronous block interface. */ 1844 typedef struct PDMIBLOCKASYNC *PPDMIBLOCKASYNC; 1845 /** 1846 * Asynchronous block interface (down). 1847 * Pair with PDMIBLOCKASYNCPORT. 1848 */ 1849 typedef struct PDMIBLOCKASYNC 1850 { 1851 /** 1852 * Start reading task. 1853 * 1854 * @returns VBox status code. 1855 * @param pInterface Pointer to the interface structure containing the called function pointer. 1856 * @param off Offset to start reading from.c 1857 * @param paSegs Pointer to the S/G segment array. 1858 * @param cSegs Number of entries in the array. 1859 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary. 1860 * @param pvUser User argument which is returned in completion callback. 1861 * @thread Any thread. 1862 */ 1863 DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIBLOCKASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbRead, void *pvUser)); 1864 1865 /** 1866 * Write bits. 1867 * 1868 * @returns VBox status code. 1869 * @param pInterface Pointer to the interface structure containing the called function pointer. 1870 * @param off Offset to start writing at. The offset must be aligned to a sector boundary. 1871 * @param paSegs Pointer to the S/G segment array. 1872 * @param cSegs Number of entries in the array. 1873 * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary. 1874 * @param pvUser User argument which is returned in completion callback. 1875 * @thread Any thread. 1876 */ 1877 DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIBLOCKASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbWrite, void *pvUser)); 1878 1879 /** 1880 * Flush everything to disk. 1881 * 1882 * @returns VBox status code. 1883 * @param pInterface Pointer to the interface structure containing the called function pointer. 1884 * @param pvUser User argument which is returned in completion callback. 1885 * @thread Any thread. 1886 */ 1887 DECLR3CALLBACKMEMBER(int, pfnStartFlush,(PPDMIBLOCKASYNC pInterface, void *pvUser)); 1888 1889 /** 1890 * Discards the given range. 1891 * 1892 * @returns VBox status code. 1893 * @param pInterface Pointer to the interface structure containing the called function pointer. 1894 * @param paRanges Array of ranges to discard. 1895 * @param cRanges Number of entries in the array. 1896 * @param pvUser User argument which is returned in completion callback. 1897 * @thread Any thread. 1898 */ 1899 DECLR3CALLBACKMEMBER(int, pfnStartDiscard,(PPDMIBLOCKASYNC pInterface, PCRTRANGE paRanges, unsigned cRanges, void *pvUser)); 1900 1901 } PDMIBLOCKASYNC; 1902 /** PDMIBLOCKASYNC interface ID. */ 1903 #define PDMIBLOCKASYNC_IID "a921dd96-1748-4ecd-941e-d5f3cd4c8fe4" 1536 #define PDMIMEDIA_IID "352f2fa2-52c0-4e51-ba3c-9f59b7043218" 1904 1537 1905 1538 -
trunk/src/VBox/Devices/Makefile.kmk
r59063 r59248 173 173 Serial/DrvTCP.cpp \ 174 174 Serial/DrvRawFile.cpp \ 175 Storage/DrvBlock.cpp \176 Storage/DrvMediaISO.cpp \177 Storage/DrvRawImage.cpp \178 175 Storage/Debug.cpp \ 179 176 Storage/DrvVD.cpp \ -
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r59227 r59248 291 291 * @param pLCHSGeometry Where to return the disk geometry on success 292 292 */ 293 static int biosGuessDiskLCHS(PPDMI BLOCK pBlock, PPDMMEDIAGEOMETRY pLCHSGeometry)293 static int biosGuessDiskLCHS(PPDMIMEDIA pMedia, PPDMMEDIAGEOMETRY pLCHSGeometry) 294 294 { 295 295 uint8_t aMBR[512], *p; … … 297 297 uint32_t iEndHead, iEndSector, cLCHSCylinders, cLCHSHeads, cLCHSSectors; 298 298 299 if (!p Block)299 if (!pMedia) 300 300 return VERR_INVALID_PARAMETER; 301 rc = p Block->pfnReadPcBios(pBlock, 0, aMBR, sizeof(aMBR));301 rc = pMedia->pfnReadPcBios(pMedia, 0, aMBR, sizeof(aMBR)); 302 302 if (RT_FAILURE(rc)) 303 303 return rc; … … 316 316 cLCHSHeads = iEndHead + 1; 317 317 cLCHSSectors = iEndSector; 318 cLCHSCylinders = RT_MIN(1024, p Block->pfnGetSize(pBlock) / (512 * cLCHSHeads * cLCHSSectors));318 cLCHSCylinders = RT_MIN(1024, pMedia->pfnGetSize(pMedia) / (512 * cLCHSHeads * cLCHSSectors)); 319 319 if (cLCHSCylinders >= 1) 320 320 { … … 397 397 * @param pLCHSGeometry Where to store the geometry settings. 398 398 */ 399 static int setLogicalDiskGeometry(PPDMIBASE pBase, PPDMI BLOCKBIOSpHardDisk, PPDMMEDIAGEOMETRY pLCHSGeometry)399 static int setLogicalDiskGeometry(PPDMIBASE pBase, PPDMIMEDIA pHardDisk, PPDMMEDIAGEOMETRY pLCHSGeometry) 400 400 { 401 401 PDMMEDIAGEOMETRY LCHSGeometry; 402 402 int rc = VINF_SUCCESS; 403 403 404 rc = pHardDisk->pfn GetLCHSGeometry(pHardDisk, &LCHSGeometry);404 rc = pHardDisk->pfnBiosGetLCHSGeometry(pHardDisk, &LCHSGeometry); 405 405 if ( rc == VERR_PDM_GEOMETRY_NOT_SET 406 406 || LCHSGeometry.cCylinders == 0 … … 410 410 || LCHSGeometry.cSectors > 63) 411 411 { 412 PPDMIBLOCK pBlock;413 pBlock = PDMIBASE_QUERY_INTERFACE(pBase, PDMIBLOCK);414 412 /* No LCHS geometry, autodetect and set. */ 415 rc = biosGuessDiskLCHS(p Block, &LCHSGeometry);413 rc = biosGuessDiskLCHS(pHardDisk, &LCHSGeometry); 416 414 if (RT_FAILURE(rc)) 417 415 { 418 416 /* Try if PCHS geometry works, otherwise fall back. */ 419 rc = pHardDisk->pfn GetPCHSGeometry(pHardDisk, &LCHSGeometry);417 rc = pHardDisk->pfnBiosGetPCHSGeometry(pHardDisk, &LCHSGeometry); 420 418 } 421 419 if ( RT_FAILURE(rc) … … 427 425 || LCHSGeometry.cSectors > 63) 428 426 { 429 uint64_t cSectors = p Block->pfnGetSize(pBlock) / 512;427 uint64_t cSectors = pHardDisk->pfnGetSize(pHardDisk) / 512; 430 428 if (cSectors / 16 / 63 <= 1024) 431 429 { … … 456 454 457 455 } 458 rc = pHardDisk->pfn SetLCHSGeometry(pHardDisk, &LCHSGeometry);456 rc = pHardDisk->pfnBiosSetLCHSGeometry(pHardDisk, &LCHSGeometry); 459 457 if (rc == VERR_VD_IMAGE_READ_ONLY) 460 458 { … … 483 481 * @param pLCHSGeometry Where to store the geometry settings. 484 482 */ 485 static int getLogicalDiskGeometry(PPDMI BLOCKBIOSpHardDisk, PPDMMEDIAGEOMETRY pLCHSGeometry)483 static int getLogicalDiskGeometry(PPDMIMEDIA pHardDisk, PPDMMEDIAGEOMETRY pLCHSGeometry) 486 484 { 487 485 PDMMEDIAGEOMETRY LCHSGeometry; 488 486 int rc = VINF_SUCCESS; 489 487 490 rc = pHardDisk->pfn GetLCHSGeometry(pHardDisk, &LCHSGeometry);488 rc = pHardDisk->pfnBiosGetLCHSGeometry(pHardDisk, &LCHSGeometry); 491 489 if ( rc == VERR_PDM_GEOMETRY_NOT_SET 492 490 || LCHSGeometry.cCylinders == 0 … … 549 547 unsigned i; 550 548 PUVM pUVM = PDMDevHlpGetUVM(pDevIns); AssertRelease(pUVM); 551 PPDMI BLOCKBIOSapHDs[4] = {0};549 PPDMIMEDIA apHDs[4] = {0}; 552 550 LogFlow(("pcbiosInitComplete:\n")); 553 551 … … 642 640 if (RT_SUCCESS(rc)) 643 641 { 644 PPDMI BLOCKBIOS pFD = PDMIBASE_QUERY_INTERFACE(pBase, PDMIBLOCKBIOS);642 PPDMIMEDIA pFD = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIA); 645 643 if (pFD) 646 644 { … … 649 647 switch (pFD->pfnGetType(pFD)) 650 648 { 651 case PDM BLOCKTYPE_FLOPPY_360: u32 |= 1 << cShift; break;652 case PDM BLOCKTYPE_FLOPPY_1_20: u32 |= 2 << cShift; break;653 case PDM BLOCKTYPE_FLOPPY_720: u32 |= 3 << cShift; break;654 case PDM BLOCKTYPE_FLOPPY_1_44: u32 |= 4 << cShift; break;655 case PDM BLOCKTYPE_FLOPPY_2_88: u32 |= 5 << cShift; break;656 case PDM BLOCKTYPE_FLOPPY_FAKE_15_6: u32 |= 14 << cShift; break;657 case PDM BLOCKTYPE_FLOPPY_FAKE_63_5: u32 |= 15 << cShift; break;649 case PDMMEDIATYPE_FLOPPY_360: u32 |= 1 << cShift; break; 650 case PDMMEDIATYPE_FLOPPY_1_20: u32 |= 2 << cShift; break; 651 case PDMMEDIATYPE_FLOPPY_720: u32 |= 3 << cShift; break; 652 case PDMMEDIATYPE_FLOPPY_1_44: u32 |= 4 << cShift; break; 653 case PDMMEDIATYPE_FLOPPY_2_88: u32 |= 5 << cShift; break; 654 case PDMMEDIATYPE_FLOPPY_FAKE_15_6: u32 |= 14 << cShift; break; 655 case PDMMEDIATYPE_FLOPPY_FAKE_63_5: u32 |= 15 << cShift; break; 658 656 default: AssertFailed(); break; 659 657 } … … 683 681 int rc = PDMR3QueryLun(pUVM, pThis->pszHDDevice, 0, i, &pBase); 684 682 if (RT_SUCCESS(rc)) 685 apHDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMI BLOCKBIOS);683 apHDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIA); 686 684 if ( apHDs[i] 687 && ( apHDs[i]->pfnGetType(apHDs[i]) != PDM BLOCKTYPE_HARD_DISK688 || !apHDs[i]->pfn IsVisible(apHDs[i])))685 && ( apHDs[i]->pfnGetType(apHDs[i]) != PDMMEDIATYPE_HARD_DISK 686 || !apHDs[i]->pfnBiosIsVisible(apHDs[i]))) 689 687 apHDs[i] = NULL; 690 688 if (apHDs[i]) … … 744 742 int rc = PDMR3QueryLun(pUVM, pThis->pszSataDevice, 0, pThis->iSataHDLUN[i], &pBase); 745 743 if (RT_SUCCESS(rc)) 746 apHDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMI BLOCKBIOS);744 apHDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIA); 747 745 if ( apHDs[i] 748 && ( apHDs[i]->pfnGetType(apHDs[i]) != PDM BLOCKTYPE_HARD_DISK749 || !apHDs[i]->pfn IsVisible(apHDs[i])))746 && ( apHDs[i]->pfnGetType(apHDs[i]) != PDMMEDIATYPE_HARD_DISK 747 || !apHDs[i]->pfnBiosIsVisible(apHDs[i]))) 750 748 apHDs[i] = NULL; 751 749 if (apHDs[i]) … … 798 796 int rc = PDMR3QueryLun(pUVM, pThis->pszScsiDevice, 0, pThis->iScsiHDLUN[i], &pBase); 799 797 if (RT_SUCCESS(rc)) 800 apHDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMI BLOCKBIOS);798 apHDs[i] = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIA); 801 799 if ( apHDs[i] 802 && ( apHDs[i]->pfnGetType(apHDs[i]) != PDM BLOCKTYPE_HARD_DISK803 || !apHDs[i]->pfn IsVisible(apHDs[i])))800 && ( apHDs[i]->pfnGetType(apHDs[i]) != PDMMEDIATYPE_HARD_DISK 801 || !apHDs[i]->pfnBiosIsVisible(apHDs[i]))) 804 802 apHDs[i] = NULL; 805 803 if (apHDs[i]) -
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r58170 r59248 375 375 /** 376 376 * @implements PDMIBASE 377 * @implements PDMI BLOCKPORT378 * @implements PDMI BLOCKASYNCPORT377 * @implements PDMIMEDIAPORT 378 * @implements PDMIMEDIAASYNCPORT 379 379 * @implements PDMIMOUNTNOTIFY 380 380 */ … … 505 505 R3PTRTYPE(PPDMIBASE) pDrvBase; 506 506 /** Pointer to the attached driver's block interface. */ 507 R3PTRTYPE(PPDMI BLOCK) pDrvBlock;507 R3PTRTYPE(PPDMIMEDIA) pDrvMedia; 508 508 /** Pointer to the attached driver's async block interface. */ 509 R3PTRTYPE(PPDMIBLOCKASYNC) pDrvBlockAsync; 510 /** Pointer to the attached driver's block bios interface. */ 511 R3PTRTYPE(PPDMIBLOCKBIOS) pDrvBlockBios; 509 R3PTRTYPE(PPDMIMEDIAASYNC) pDrvMediaAsync; 512 510 /** Pointer to the attached driver's mount interface. */ 513 511 R3PTRTYPE(PPDMIMOUNT) pDrvMount; … … 515 513 PDMIBASE IBase; 516 514 /** The block port interface. */ 517 PDMI BLOCKPORT IPort;515 PDMIMEDIAPORT IPort; 518 516 /** The optional block async port interface. */ 519 PDMI BLOCKASYNCPORT IPortAsync;517 PDMIMEDIAASYNCPORT IPortAsync; 520 518 /** The mount notify interface. */ 521 519 PDMIMOUNTNOTIFY IMountNotify; … … 971 969 #define PDMIMOUNTNOTIFY_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IMountNotify)) ) 972 970 #define PDMIBASE_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IBase)) ) 973 #define PDMI BLOCKPORT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IPort)) )971 #define PDMIMEDIAPORT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IPort)) ) 974 972 #define PDMIBASE_2_PAHCI(pInterface) ( (PAHCI)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCI, IBase)) ) 975 973 #define PDMILEDPORTS_2_PAHCI(pInterface) ( (PAHCI)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCI, ILeds)) ) … … 2670 2668 PAHCIPort pAhciPort = PDMIBASE_2_PAHCIPORT(pInterface); 2671 2669 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pAhciPort->IBase); 2672 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKPORT, &pAhciPort->IPort);2673 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKASYNCPORT, &pAhciPort->IPortAsync);2670 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pAhciPort->IPort); 2671 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNCPORT, &pAhciPort->IPortAsync); 2674 2672 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pAhciPort->IMountNotify); 2675 2673 return NULL; … … 2677 2675 2678 2676 /** 2679 * @interface_method_impl{PDMI BLOCKPORT,pfnQueryDeviceLocation}2680 */ 2681 static DECLCALLBACK(int) ahciR3PortQueryDeviceLocation(PPDMI BLOCKPORT pInterface, const char **ppcszController,2677 * @interface_method_impl{PDMIMEDIAPORT,pfnQueryDeviceLocation} 2678 */ 2679 static DECLCALLBACK(int) ahciR3PortQueryDeviceLocation(PPDMIMEDIAPORT pInterface, const char **ppcszController, 2682 2680 uint32_t *piInstance, uint32_t *piLUN) 2683 2681 { 2684 PAHCIPort pAhciPort = PDMI BLOCKPORT_2_PAHCIPORT(pInterface);2682 PAHCIPort pAhciPort = PDMIMEDIAPORT_2_PAHCIPORT(pInterface); 2685 2683 PPDMDEVINS pDevIns = pAhciPort->CTX_SUFF(pDevIns); 2686 2684 … … 3099 3097 p[67] = RT_H2LE_U16(120); /* minimum PIO cycle time without flow control */ 3100 3098 p[68] = RT_H2LE_U16(120); /* minimum PIO cycle time with IORDY flow control */ 3101 if ( pAhciPort->pDrv Block->pfnDiscard3099 if ( pAhciPort->pDrvMedia->pfnDiscard 3102 3100 || ( pAhciPort->fAsyncInterface 3103 && pAhciPort->pDrv BlockAsync->pfnStartDiscard)3101 && pAhciPort->pDrvMediaAsync->pfnStartDiscard) 3104 3102 || pAhciPort->cbSector != 512 3105 3103 || pAhciPort->fNonRotational) … … 3142 3140 p[217] = RT_H2LE_U16(1); /* Non-rotational medium */ 3143 3141 3144 if ( pAhciPort->pDrv Block->pfnDiscard3142 if ( pAhciPort->pDrvMedia->pfnDiscard 3145 3143 || ( pAhciPort->fAsyncInterface 3146 && pAhciPort->pDrv BlockAsync->pfnStartDiscard)) /** @todo: Set bit 14 in word 69 too? (Deterministic read after TRIM). */3144 && pAhciPort->pDrvMediaAsync->pfnStartDiscard)) /** @todo: Set bit 14 in word 69 too? (Deterministic read after TRIM). */ 3147 3145 p[169] = RT_H2LE_U16(1); /* DATA SET MANAGEMENT command supported. */ 3148 3146 … … 4041 4039 break; 4042 4040 } 4043 rc = pAhciPort->pDrv Block->pfnSendCmd(pAhciPort->pDrvBlock,4041 rc = pAhciPort->pDrvMedia->pfnSendCmd(pAhciPort->pDrvMedia, 4044 4042 aATAPICmd, 4045 4043 pAhciReq->enmTxDir == AHCITXDIR_READ 4046 ? PDM BLOCKTXDIR_FROM_DEVICE4047 : PDM BLOCKTXDIR_TO_DEVICE,4044 ? PDMMEDIATXDIR_FROM_DEVICE 4045 : PDMMEDIATXDIR_TO_DEVICE, 4048 4046 pbBuf, 4049 4047 &cbCurrTX, … … 4059 4057 else 4060 4058 { 4061 PDM BLOCKTXDIR enmBlockTxDir = PDMBLOCKTXDIR_NONE;4059 PDMMEDIATXDIR enmBlockTxDir = PDMMEDIATXDIR_NONE; 4062 4060 4063 4061 if (pAhciReq->enmTxDir == AHCITXDIR_READ) 4064 enmBlockTxDir = PDM BLOCKTXDIR_FROM_DEVICE;4062 enmBlockTxDir = PDMMEDIATXDIR_FROM_DEVICE; 4065 4063 else if (pAhciReq->enmTxDir == AHCITXDIR_WRITE) 4066 enmBlockTxDir = PDM BLOCKTXDIR_TO_DEVICE;4064 enmBlockTxDir = PDMMEDIATXDIR_TO_DEVICE; 4067 4065 else if (pAhciReq->enmTxDir == AHCITXDIR_NONE) 4068 enmBlockTxDir = PDM BLOCKTXDIR_NONE;4066 enmBlockTxDir = PDMMEDIATXDIR_NONE; 4069 4067 else 4070 4068 AssertMsgFailed(("Invalid transfer direction %d\n", pAhciReq->enmTxDir)); 4071 4069 4072 rc = pAhciPort->pDrv Block->pfnSendCmd(pAhciPort->pDrvBlock,4070 rc = pAhciPort->pDrvMedia->pfnSendCmd(pAhciPort->pDrvMedia, 4073 4071 pAhciReq->aATAPICmd, 4074 4072 enmBlockTxDir, … … 5476 5474 { 5477 5475 if (pAhciReq->cbAlloc) 5478 pAhciPort->pDrv Block->pfnIoBufFree(pAhciPort->pDrvBlock, pAhciReq->pvAlloc, pAhciReq->cbAlloc);5476 pAhciPort->pDrvMedia->pfnIoBufFree(pAhciPort->pDrvMedia, pAhciReq->pvAlloc, pAhciReq->cbAlloc); 5479 5477 5480 5478 pAhciReq->pvAlloc = NULL; 5481 5479 pAhciReq->cbAlloc = RT_ALIGN_Z(cb, _4K); 5482 int rc = pAhciPort->pDrv Block->pfnIoBufAlloc(pAhciPort->pDrvBlock, pAhciReq->cbAlloc, &pAhciReq->pvAlloc);5480 int rc = pAhciPort->pDrvMedia->pfnIoBufAlloc(pAhciPort->pDrvMedia, pAhciReq->cbAlloc, &pAhciReq->pvAlloc); 5483 5481 if (RT_FAILURE(rc)) 5484 5482 pAhciReq->pvAlloc = NULL; … … 5507 5505 if (pAhciReq->cbAlloc) 5508 5506 { 5509 pAhciPort->pDrv Block->pfnIoBufFree(pAhciPort->pDrvBlock, pAhciReq->pvAlloc, pAhciReq->cbAlloc);5507 pAhciPort->pDrvMedia->pfnIoBufFree(pAhciPort->pDrvMedia, pAhciReq->pvAlloc, pAhciReq->cbAlloc); 5510 5508 pAhciReq->cbAlloc = 0; 5511 5509 pAhciReq->cAllocTooMuch = 0; … … 5760 5758 } 5761 5759 5762 /* -=-=-=-=- I BlockAsyncPort -=-=-=-=- */5763 5764 /** Makes a PAHCIPort out of a PPDMI BLOCKASYNCPORT. */5765 #define PDMI BLOCKASYNCPORT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)pInterface - RT_OFFSETOF(AHCIPort, IPortAsync)) )5760 /* -=-=-=-=- IMediaAsyncPort -=-=-=-=- */ 5761 5762 /** Makes a PAHCIPort out of a PPDMIMEDIAASYNCPORT. */ 5763 #define PDMIMEDIAASYNCPORT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)pInterface - RT_OFFSETOF(AHCIPort, IPortAsync)) ) 5766 5764 5767 5765 static void ahciWarningDiskFull(PPDMDEVINS pDevIns) … … 6242 6240 * @param rcReq IPRT Status code of the completed request. 6243 6241 */ 6244 static DECLCALLBACK(int) ahciR3TransferCompleteNotify(PPDMI BLOCKASYNCPORT pInterface, void *pvUser, int rcReq)6245 { 6246 PAHCIPort pAhciPort = PDMI BLOCKASYNCPORT_2_PAHCIPORT(pInterface);6242 static DECLCALLBACK(int) ahciR3TransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rcReq) 6243 { 6244 PAHCIPort pAhciPort = PDMIMEDIAASYNCPORT_2_PAHCIPORT(pInterface); 6247 6245 PAHCIREQ pAhciReq = (PAHCIREQ)pvUser; 6248 6246 … … 6275 6273 case ATA_IDENTIFY_DEVICE: 6276 6274 { 6277 if (pAhciPort->pDrv Block&& !pAhciPort->fATAPI)6275 if (pAhciPort->pDrvMedia && !pAhciPort->fATAPI) 6278 6276 { 6279 6277 uint16_t u16Temp[256]; … … 6526 6524 { 6527 6525 if ( ( !pAhciPort->fAsyncInterface 6528 && pAhciPort->pDrv Block->pfnDiscard)6526 && pAhciPort->pDrvMedia->pfnDiscard) 6529 6527 || ( pAhciPort->fAsyncInterface 6530 && pAhciPort->pDrv BlockAsync->pfnStartDiscard))6528 && pAhciPort->pDrvMediaAsync->pfnStartDiscard)) 6531 6529 { 6532 6530 /* Check that the trim bit is set and all other bits are 0. */ … … 6672 6670 if (enmTxDir == AHCITXDIR_FLUSH) 6673 6671 { 6674 rc = pAhciPort->pDrv BlockAsync->pfnStartFlush(pAhciPort->pDrvBlockAsync,6672 rc = pAhciPort->pDrvMediaAsync->pfnStartFlush(pAhciPort->pDrvMediaAsync, 6675 6673 pAhciReq); 6676 6674 } … … 6681 6679 { 6682 6680 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 6683 rc = pAhciPort->pDrv BlockAsync->pfnStartDiscard(pAhciPort->pDrvBlockAsync, pAhciReq->u.Trim.paRanges,6681 rc = pAhciPort->pDrvMediaAsync->pfnStartDiscard(pAhciPort->pDrvMediaAsync, pAhciReq->u.Trim.paRanges, 6684 6682 pAhciReq->u.Trim.cRanges, pAhciReq); 6685 6683 } … … 6688 6686 { 6689 6687 pAhciPort->Led.Asserted.s.fReading = pAhciPort->Led.Actual.s.fReading = 1; 6690 rc = pAhciPort->pDrv BlockAsync->pfnStartRead(pAhciPort->pDrvBlockAsync, pAhciReq->uOffset,6688 rc = pAhciPort->pDrvMediaAsync->pfnStartRead(pAhciPort->pDrvMediaAsync, pAhciReq->uOffset, 6691 6689 &pAhciReq->u.Io.DataSeg, 1, 6692 6690 pAhciReq->cbTransfer, … … 6696 6694 { 6697 6695 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 6698 rc = pAhciPort->pDrv BlockAsync->pfnStartWrite(pAhciPort->pDrvBlockAsync, pAhciReq->uOffset,6696 rc = pAhciPort->pDrvMediaAsync->pfnStartWrite(pAhciPort->pDrvMediaAsync, pAhciReq->uOffset, 6699 6697 &pAhciReq->u.Io.DataSeg, 1, 6700 6698 pAhciReq->cbTransfer, … … 6709 6707 { 6710 6708 if (enmTxDir == AHCITXDIR_FLUSH) 6711 rc = pAhciPort->pDrv Block->pfnFlush(pAhciPort->pDrvBlock);6709 rc = pAhciPort->pDrvMedia->pfnFlush(pAhciPort->pDrvMedia); 6712 6710 else if (enmTxDir == AHCITXDIR_TRIM) 6713 6711 { … … 6716 6714 { 6717 6715 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 6718 rc = pAhciPort->pDrv Block->pfnDiscard(pAhciPort->pDrvBlock, pAhciReq->u.Trim.paRanges,6716 rc = pAhciPort->pDrvMedia->pfnDiscard(pAhciPort->pDrvMedia, pAhciReq->u.Trim.paRanges, 6719 6717 pAhciReq->u.Trim.cRanges); 6720 6718 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 0; … … 6724 6722 { 6725 6723 pAhciPort->Led.Asserted.s.fReading = pAhciPort->Led.Actual.s.fReading = 1; 6726 rc = pAhciPort->pDrv Block->pfnRead(pAhciPort->pDrvBlock, pAhciReq->uOffset,6724 rc = pAhciPort->pDrvMedia->pfnRead(pAhciPort->pDrvMedia, pAhciReq->uOffset, 6727 6725 pAhciReq->u.Io.DataSeg.pvSeg, 6728 6726 pAhciReq->cbTransfer); … … 6732 6730 { 6733 6731 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 6734 rc = pAhciPort->pDrv Block->pfnWrite(pAhciPort->pDrvBlock, pAhciReq->uOffset,6732 rc = pAhciPort->pDrvMedia->pfnWrite(pAhciPort->pDrvMedia, pAhciReq->uOffset, 6735 6733 pAhciReq->u.Io.DataSeg.pvSeg, 6736 6734 pAhciReq->cbTransfer); … … 7601 7599 7602 7600 /* Ignore the call if we're called while being attached. */ 7603 if (!pAhciPort->pDrv Block)7601 if (!pAhciPort->pDrvMedia) 7604 7602 return; 7605 7603 7606 7604 if (pAhciPort->fATAPI) 7607 7605 { 7608 pAhciPort->cTotalSectors = pAhciPort->pDrv Block->pfnGetSize(pAhciPort->pDrvBlock) / 2048;7606 pAhciPort->cTotalSectors = pAhciPort->pDrvMedia->pfnGetSize(pAhciPort->pDrvMedia) / 2048; 7609 7607 7610 7608 LogRel(("AHCI: LUN#%d: CD/DVD, total number of sectors %Ld, passthrough unchanged\n", pAhciPort->iLUN, pAhciPort->cTotalSectors)); … … 7662 7660 { 7663 7661 int rc = VINF_SUCCESS; 7664 PDM BLOCKTYPE enmType;7662 PDMMEDIATYPE enmType; 7665 7663 7666 7664 /* 7667 7665 * Query the block and blockbios interfaces. 7668 7666 */ 7669 pAhciPort->pDrv Block = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIBLOCK);7670 if (!pAhciPort->pDrv Block)7667 pAhciPort->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIMEDIA); 7668 if (!pAhciPort->pDrvMedia) 7671 7669 { 7672 7670 AssertMsgFailed(("Configuration error: LUN#%d hasn't a block interface!\n", pAhciPort->iLUN)); 7673 7671 return VERR_PDM_MISSING_INTERFACE; 7674 7672 } 7675 pAhciPort->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIBLOCKBIOS);7676 if (!pAhciPort->pDrvBlockBios)7677 {7678 AssertMsgFailed(("Configuration error: LUN#%d hasn't a block BIOS interface!\n", pAhciPort->iLUN));7679 return VERR_PDM_MISSING_INTERFACE;7680 }7681 7673 7682 7674 pAhciPort->pDrvMount = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIMOUNT); 7683 7675 7684 7676 /* Try to get the optional async block interface. */ 7685 pAhciPort->pDrv BlockAsync = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIBLOCKASYNC);7677 pAhciPort->pDrvMediaAsync = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIMEDIAASYNC); 7686 7678 7687 7679 /* 7688 7680 * Validate type. 7689 7681 */ 7690 enmType = pAhciPort->pDrv Block->pfnGetType(pAhciPort->pDrvBlock);7691 7692 if ( enmType != PDM BLOCKTYPE_HARD_DISK7693 && enmType != PDM BLOCKTYPE_CDROM7694 && enmType != PDM BLOCKTYPE_DVD)7682 enmType = pAhciPort->pDrvMedia->pfnGetType(pAhciPort->pDrvMedia); 7683 7684 if ( enmType != PDMMEDIATYPE_HARD_DISK 7685 && enmType != PDMMEDIATYPE_CDROM 7686 && enmType != PDMMEDIATYPE_DVD) 7695 7687 { 7696 7688 AssertMsgFailed(("Configuration error: LUN#%d isn't a disk or cd/dvd. enmType=%d\n", pAhciPort->iLUN, enmType)); … … 7698 7690 } 7699 7691 7700 if ( (enmType == PDM BLOCKTYPE_CDROM || enmType == PDMBLOCKTYPE_DVD)7692 if ( (enmType == PDMMEDIATYPE_CDROM || enmType == PDMMEDIATYPE_DVD) 7701 7693 && !pAhciPort->pDrvMount) 7702 7694 { … … 7704 7696 return VERR_INTERNAL_ERROR; 7705 7697 } 7706 pAhciPort->fATAPI = (enmType == PDM BLOCKTYPE_CDROM || enmType == PDMBLOCKTYPE_DVD);7707 pAhciPort->fATAPIPassthrough = pAhciPort->fATAPI ? (pAhciPort->pDrv Block->pfnSendCmd != NULL) : false;7698 pAhciPort->fATAPI = (enmType == PDMMEDIATYPE_CDROM || enmType == PDMMEDIATYPE_DVD); 7699 pAhciPort->fATAPIPassthrough = pAhciPort->fATAPI ? (pAhciPort->pDrvMedia->pfnSendCmd != NULL) : false; 7708 7700 7709 7701 rc = RTCritSectInit(&pAhciPort->CritSectReqsFree); … … 7721 7713 if (pAhciPort->fATAPI) 7722 7714 { 7723 pAhciPort->cTotalSectors = pAhciPort->pDrv Block->pfnGetSize(pAhciPort->pDrvBlock) / 2048;7715 pAhciPort->cTotalSectors = pAhciPort->pDrvMedia->pfnGetSize(pAhciPort->pDrvMedia) / 2048; 7724 7716 pAhciPort->PCHSGeometry.cCylinders = 0; 7725 7717 pAhciPort->PCHSGeometry.cHeads = 0; … … 7730 7722 else 7731 7723 { 7732 pAhciPort->cbSector = pAhciPort->pDrvBlock->pfnGetSectorSize(pAhciPort->pDrvBlock); 7733 pAhciPort->cTotalSectors = pAhciPort->pDrvBlock->pfnGetSize(pAhciPort->pDrvBlock) / pAhciPort->cbSector; 7734 rc = pAhciPort->pDrvBlockBios->pfnGetPCHSGeometry(pAhciPort->pDrvBlockBios, 7735 &pAhciPort->PCHSGeometry); 7724 pAhciPort->cbSector = pAhciPort->pDrvMedia->pfnGetSectorSize(pAhciPort->pDrvMedia); 7725 pAhciPort->cTotalSectors = pAhciPort->pDrvMedia->pfnGetSize(pAhciPort->pDrvMedia) / pAhciPort->cbSector; 7726 rc = pAhciPort->pDrvMedia->pfnBiosGetPCHSGeometry(pAhciPort->pDrvMedia, &pAhciPort->PCHSGeometry); 7736 7727 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 7737 7728 { … … 7756 7747 pAhciPort->PCHSGeometry.cSectors = 63; 7757 7748 /* Set the disk geometry information. Ignore errors. */ 7758 pAhciPort->pDrvBlockBios->pfnSetPCHSGeometry(pAhciPort->pDrvBlockBios, 7759 &pAhciPort->PCHSGeometry); 7749 pAhciPort->pDrvMedia->pfnBiosSetPCHSGeometry(pAhciPort->pDrvMedia, &pAhciPort->PCHSGeometry); 7760 7750 rc = VINF_SUCCESS; 7761 7751 } … … 7764 7754 pAhciPort->PCHSGeometry.cHeads, pAhciPort->PCHSGeometry.cSectors, 7765 7755 pAhciPort->cTotalSectors)); 7766 if (pAhciPort->pDrv Block->pfnDiscard)7756 if (pAhciPort->pDrvMedia->pfnDiscard) 7767 7757 LogRel(("AHCI: LUN#%d: Enabled TRIM support\n", pAhciPort->iLUN)); 7768 7758 } … … 7879 7869 RTUUID Uuid; 7880 7870 7881 if (pAhciPort->pDrv Block)7882 rc = pAhciPort->pDrv Block->pfnGetUuid(pAhciPort->pDrvBlock, &Uuid);7871 if (pAhciPort->pDrvMedia) 7872 rc = pAhciPort->pDrvMedia->pfnGetUuid(pAhciPort->pDrvMedia, &Uuid); 7883 7873 else 7884 7874 RTUuidClear(&Uuid); … … 8056 8046 */ 8057 8047 pAhciPort->pDrvBase = NULL; 8058 pAhciPort->pDrvBlock = NULL; 8059 pAhciPort->pDrvBlockAsync = NULL; 8060 pAhciPort->pDrvBlockBios = NULL; 8048 pAhciPort->pDrvMedia = NULL; 8049 pAhciPort->pDrvMediaAsync = NULL; 8061 8050 } 8062 8051 … … 8083 8072 AssertMsg(iLUN < pThis->cPortsImpl, ("iLUN=%u", iLUN)); 8084 8073 AssertRelease(!pAhciPort->pDrvBase); 8085 AssertRelease(!pAhciPort->pDrv Block);8086 AssertRelease(!pAhciPort->pDrv BlockAsync);8074 AssertRelease(!pAhciPort->pDrvMedia); 8075 AssertRelease(!pAhciPort->pDrvMediaAsync); 8087 8076 Assert(pAhciPort->iLUN == iLUN); 8088 8077 … … 8113 8102 { 8114 8103 pAhciPort->pDrvBase = NULL; 8115 pAhciPort->pDrv Block= NULL;8104 pAhciPort->pDrvMedia = NULL; 8116 8105 } 8117 8106 else … … 8120 8109 RTStrPrintf(szName, sizeof(szName), "Port%d", iLUN); 8121 8110 8122 if ( pAhciPort->pDrv BlockAsync8111 if ( pAhciPort->pDrvMediaAsync 8123 8112 && !pAhciPort->fATAPI) 8124 8113 pAhciPort->fAsyncInterface = true; … … 8618 8607 * Otherwise we use a event semaphore and a async I/O thread which processes them. 8619 8608 */ 8620 if (pAhciPort->pDrv BlockAsync && pThis->fUseAsyncInterfaceIfAvailable)8609 if (pAhciPort->pDrvMediaAsync && pThis->fUseAsyncInterfaceIfAvailable) 8621 8610 { 8622 8611 LogRel(("AHCI: LUN#%d: using async I/O\n", pAhciPort->iLUN)); -
trunk/src/VBox/Devices/Storage/DevATA.cpp
r58170 r59248 277 277 R3PTRTYPE(PPDMIBASE) pDrvBase; 278 278 /** Pointer to the attached driver's block interface. */ 279 R3PTRTYPE(PPDMIBLOCK) pDrvBlock; 280 /** Pointer to the attached driver's block bios interface. */ 281 R3PTRTYPE(PPDMIBLOCKBIOS) pDrvBlockBios; 279 R3PTRTYPE(PPDMIMEDIA) pDrvMedia; 282 280 /** Pointer to the attached driver's mount interface. 283 281 * This is NULL if the driver isn't a removable unit. */ … … 286 284 PDMIBASE IBase; 287 285 /** The block port interface. */ 288 PDMI BLOCKPORT IPort;286 PDMIMEDIAPORT IPort; 289 287 /** The mount notify interface. */ 290 288 PDMIMOUNTNOTIFY IMountNotify; … … 510 508 #define PDMIBASE_2_PCIATASTATE(pInterface) ( (PCIATAState *)((uintptr_t)(pInterface) - RT_OFFSETOF(PCIATAState, IBase)) ) 511 509 #define PDMILEDPORTS_2_PCIATASTATE(pInterface) ( (PCIATAState *)((uintptr_t)(pInterface) - RT_OFFSETOF(PCIATAState, ILeds)) ) 512 #define PDMI BLOCKPORT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IPort)) )510 #define PDMIMEDIAPORT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IPort)) ) 513 511 #define PDMIMOUNT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IMount)) ) 514 512 #define PDMIMOUNTNOTIFY_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IMountNotify)) ) … … 521 519 #define CONTROLLER_2_DEVINS(pController) ( (pController)->CTX_SUFF(pDevIns) ) 522 520 #define PDMIBASE_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IBase)) ) 523 #define PDMI BLOCKPORT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IPort)) )521 #define PDMIMEDIAPORT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IPort)) ) 524 522 525 523 #ifndef VBOX_DEVICE_STRUCT_TESTCASE … … 1210 1208 s->iIOBufferCur = 0; 1211 1209 s->iIOBufferEnd = 0; 1212 s->uTxDir = PDM BLOCKTXDIR_NONE;1210 s->uTxDir = PDMMEDIATXDIR_NONE; 1213 1211 s->iBeginTransfer = ATAFN_BT_NULL; 1214 1212 s->iSourceSink = ATAFN_SS_NULL; … … 1232 1230 uint16_t *p; 1233 1231 1234 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);1232 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 1235 1233 Assert(s->cbElementaryTransfer == 512); 1236 1234 … … 1286 1284 p[67] = RT_H2LE_U16(120); /* minimum PIO cycle time without flow control */ 1287 1285 p[68] = RT_H2LE_U16(120); /* minimum PIO cycle time with IORDY flow control */ 1288 if ( s->pDrv Block->pfnDiscard1286 if ( s->pDrvMedia->pfnDiscard 1289 1287 || s->cbSector != 512 1290 1288 || s->fNonRotational) … … 1329 1327 } 1330 1328 1331 if (s->pDrv Block->pfnDiscard) /** @todo: Set bit 14 in word 69 too? (Deterministic read after TRIM). */1329 if (s->pDrvMedia->pfnDiscard) /** @todo: Set bit 14 in word 69 too? (Deterministic read after TRIM). */ 1332 1330 p[169] = RT_H2LE_U16(1); /* DATA SET MANAGEMENT command supported. */ 1333 1331 if (s->fNonRotational) … … 1346 1344 int rc; 1347 1345 1348 Assert(s->uTxDir == PDM BLOCKTXDIR_NONE);1346 Assert(s->uTxDir == PDMMEDIATXDIR_NONE); 1349 1347 Assert(!s->cbElementaryTransfer); 1350 1348 … … 1352 1350 1353 1351 STAM_PROFILE_START(&s->StatFlushes, f); 1354 rc = s->pDrv Block->pfnFlush(s->pDrvBlock);1352 rc = s->pDrvMedia->pfnFlush(s->pDrvMedia); 1355 1353 AssertRC(rc); 1356 1354 STAM_PROFILE_STOP(&s->StatFlushes, f); … … 1367 1365 uint16_t *p; 1368 1366 1369 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);1367 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 1370 1368 Assert(s->cbElementaryTransfer == 512); 1371 1369 … … 1436 1434 s->uATARegHCyl = 0xeb; 1437 1435 } 1438 else if (s->pDrv Block)1436 else if (s->pDrvMedia) 1439 1437 { 1440 1438 s->uATARegLCyl = 0; … … 1592 1590 STAM_PROFILE_ADV_START(&s->StatReads, r); 1593 1591 s->Led.Asserted.s.fReading = s->Led.Actual.s.fReading = 1; 1594 rc = s->pDrv Block->pfnRead(s->pDrvBlock, u64Sector * s->cbSector, pvBuf, cSectors * s->cbSector);1592 rc = s->pDrvMedia->pfnRead(s->pDrvMedia, u64Sector * s->cbSector, pvBuf, cSectors * s->cbSector); 1595 1593 s->Led.Actual.s.fReading = 0; 1596 1594 STAM_PROFILE_ADV_STOP(&s->StatReads, r); … … 1626 1624 STAM_PROFILE_ADV_START(&s->StatInstrVDWrites, vw); 1627 1625 # endif 1628 rc = s->pDrv Block->pfnWrite(s->pDrvBlock, u64Sector * s->cbSector, pvBuf, cSectors * s->cbSector);1626 rc = s->pDrvMedia->pfnWrite(s->pDrvMedia, u64Sector * s->cbSector, pvBuf, cSectors * s->cbSector); 1629 1627 # ifdef VBOX_INSTRUMENT_DMA_WRITES 1630 1628 if (s->fDMA) … … 1659 1657 else 1660 1658 s->cbElementaryTransfer = cSectors * s->cbSector; 1661 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE)1659 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE) 1662 1660 ataR3CmdOK(s, 0); 1663 1661 } … … 1745 1743 ataSetStatusValue(s, ATA_STAT_READY); 1746 1744 s->uATARegNSector = (s->uATARegNSector & ~7) 1747 | ((s->uTxDir != PDM BLOCKTXDIR_TO_DEVICE) ? ATAPI_INT_REASON_IO : 0)1745 | ((s->uTxDir != PDMMEDIATXDIR_TO_DEVICE) ? ATAPI_INT_REASON_IO : 0) 1748 1746 | (!s->cbTotalTransfer ? ATAPI_INT_REASON_CD : 0); 1749 1747 Log2(("%s: interrupt reason %#04x\n", __FUNCTION__, s->uATARegNSector)); … … 1770 1768 s->iIOBufferCur = 0; 1771 1769 s->iIOBufferEnd = 0; 1772 s->uTxDir = PDM BLOCKTXDIR_NONE;1770 s->uTxDir = PDMMEDIATXDIR_NONE; 1773 1771 s->iBeginTransfer = ATAFN_BT_NULL; 1774 1772 s->iSourceSink = ATAFN_SS_NULL; … … 1796 1794 s->cbAtapiPassthroughTransfer = s->cbTotalTransfer; 1797 1795 s->cbPIOTransferLimit = s->uATARegLCyl | (s->uATARegHCyl << 8); 1798 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE)1796 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE) 1799 1797 atapiR3CmdOK(s); 1800 1798 } … … 1808 1806 * and replies. */ 1809 1807 # if 0 1810 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE)1808 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE) 1811 1809 { 1812 1810 uint8_t cmd = s->aATAPICmd[0]; … … 1830 1828 aModeSenseCmd[8] = cbTransfer & 0xff; 1831 1829 aModeSenseCmd[9] = 0; /* control */ 1832 rc = s->pDrv Block->pfnSendCmd(s->pDrvBlock, aModeSenseCmd, PDMBLOCKTXDIR_FROM_DEVICE, aModeSenseResult, &cbTransfer, &uDummySense, 500);1830 rc = s->pDrvMedia->pfnSendCmd(s->pDrvMedia, aModeSenseCmd, PDMMEDIATXDIR_FROM_DEVICE, aModeSenseResult, &cbTransfer, &uDummySense, 500); 1833 1831 if (RT_FAILURE(rc)) 1834 1832 { … … 1871 1869 s->cbTotalTransfer *= s->cbATAPISector; 1872 1870 if (s->cbTotalTransfer == 0) 1873 s->uTxDir = PDM BLOCKTXDIR_NONE;1871 s->uTxDir = PDMMEDIATXDIR_NONE; 1874 1872 } 1875 1873 } … … 1884 1882 uint32_t cbTransfer, cSectors; 1885 1883 1886 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);1884 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 1887 1885 cbTransfer = RT_MIN(s->cbTotalTransfer, s->cbIOBuffer); 1888 1886 cSectors = cbTransfer / s->cbATAPISector; … … 1897 1895 { 1898 1896 case 2048: 1899 rc = s->pDrv Block->pfnRead(s->pDrvBlock, (uint64_t)s->iATAPILBA * s->cbATAPISector, s->CTX_SUFF(pbIOBuffer), s->cbATAPISector * cSectors);1897 rc = s->pDrvMedia->pfnRead(s->pDrvMedia, (uint64_t)s->iATAPILBA * s->cbATAPISector, s->CTX_SUFF(pbIOBuffer), s->cbATAPISector * cSectors); 1900 1898 break; 1901 1899 case 2352: … … 1915 1913 *pbBuf++ = 0x01; /* mode 1 data */ 1916 1914 /* data */ 1917 rc = s->pDrv Block->pfnRead(s->pDrvBlock, (uint64_t)i * 2048, pbBuf, 2048);1915 rc = s->pDrvMedia->pfnRead(s->pDrvMedia, (uint64_t)i * 2048, pbBuf, 2048); 1918 1916 if (RT_FAILURE(rc)) 1919 1917 break; … … 1986 1984 cbTransfer = RT_MIN(s->cbAtapiPassthroughTransfer, s->cbIOBuffer); 1987 1985 1988 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE)1986 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE) 1989 1987 Log3(("ATAPI PT data write (%d): %.*Rhxs\n", cbTransfer, cbTransfer, s->CTX_SUFF(pbIOBuffer))); 1990 1988 … … 1993 1991 if (cbTransfer >= 2048) 1994 1992 { 1995 if (s->uTxDir != PDM BLOCKTXDIR_TO_DEVICE)1993 if (s->uTxDir != PDMMEDIATXDIR_TO_DEVICE) 1996 1994 { 1997 1995 s->Led.Asserted.s.fReading = s->Led.Actual.s.fReading = 1; … … 2117 2115 break; 2118 2116 } 2119 rc = s->pDrv Block->pfnSendCmd(s->pDrvBlock, aATAPICmd, (PDMBLOCKTXDIR)s->uTxDir, pbBuf, &cbCurrTX, abATAPISense, sizeof(abATAPISense), 30000 /**< @todo timeout */);2117 rc = s->pDrvMedia->pfnSendCmd(s->pDrvMedia, aATAPICmd, (PDMMEDIATXDIR)s->uTxDir, pbBuf, &cbCurrTX, abATAPISense, sizeof(abATAPISense), 30000 /**< @todo timeout */); 2120 2118 if (rc != VINF_SUCCESS) 2121 2119 break; … … 2158 2156 } 2159 2157 else 2160 rc = s->pDrv Block->pfnSendCmd(s->pDrvBlock, s->aATAPICmd, (PDMBLOCKTXDIR)s->uTxDir, s->CTX_SUFF(pbIOBuffer), &cbTransfer, abATAPISense, sizeof(abATAPISense), 30000 /**< @todo timeout */);2158 rc = s->pDrvMedia->pfnSendCmd(s->pDrvMedia, s->aATAPICmd, (PDMMEDIATXDIR)s->uTxDir, s->CTX_SUFF(pbIOBuffer), &cbTransfer, abATAPISense, sizeof(abATAPISense), 30000 /**< @todo timeout */); 2161 2159 if (pProf) { STAM_PROFILE_ADV_STOP(pProf, b); } 2162 2160 … … 2168 2166 if (cbTransfer >= 2048) 2169 2167 { 2170 if (s->uTxDir != PDM BLOCKTXDIR_TO_DEVICE)2168 if (s->uTxDir != PDMMEDIATXDIR_TO_DEVICE) 2171 2169 { 2172 2170 s->Led.Actual.s.fReading = 0; … … 2208 2206 } 2209 2207 2210 if (s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE)2208 if (s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE) 2211 2209 { 2212 2210 Assert(cbTransfer <= s->cbAtapiPassthroughTransfer); … … 2433 2431 s->iATAPILBA = iATAPILBA; 2434 2432 s->cbATAPISector = cbSector; 2435 ataR3StartTransfer(s, cSectors * cbSector, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ, true);2433 ataR3StartTransfer(s, cSectors * cbSector, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ, true); 2436 2434 return false; 2437 2435 } … … 2442 2440 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2443 2441 2444 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2442 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2445 2443 Assert(s->cbElementaryTransfer <= 8); 2446 2444 ataH2BE_U32(pbBuf, s->cTotalSectors - 1); … … 2456 2454 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2457 2455 2458 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2456 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2459 2457 Assert(s->cbElementaryTransfer <= 34); 2460 2458 memset(pbBuf, '\0', 34); … … 2482 2480 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2483 2481 2484 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2482 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2485 2483 Assert(s->cbElementaryTransfer <= 36); 2486 2484 /* Accept address/number type of 1 only, and only track 1 exists. */ … … 2630 2628 uint16_t u16Sfn = ataBE2H_U16(&s->aATAPICmd[2]); 2631 2629 2632 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2630 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2633 2631 Assert(s->cbElementaryTransfer <= 80); 2634 2632 /* Accept valid request types only, and only starting feature 0. */ … … 2694 2692 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2695 2693 2696 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2694 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2697 2695 Assert(s->cbElementaryTransfer <= 8); 2698 2696 … … 2769 2767 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2770 2768 2771 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2769 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2772 2770 Assert(s->cbElementaryTransfer <= 36); 2773 2771 pbBuf[0] = 0x05; /* CD-ROM */ … … 2797 2795 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2798 2796 2799 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2797 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2800 2798 Assert(s->cbElementaryTransfer <= 16); 2801 2799 ataH2BE_U16(&pbBuf[0], 16 + 6); … … 2825 2823 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2826 2824 2827 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2825 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2828 2826 Assert(s->cbElementaryTransfer <= 40); 2829 2827 ataH2BE_U16(&pbBuf[0], 38); … … 2873 2871 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2874 2872 2875 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2873 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2876 2874 memset(pbBuf, '\0', s->cbElementaryTransfer); 2877 2875 memcpy(pbBuf, s->abATAPISense, RT_MIN(s->cbElementaryTransfer, sizeof(s->abATAPISense))); … … 2886 2884 uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer); 2887 2885 2888 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2886 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2889 2887 Assert(s->cbElementaryTransfer <= 8); 2890 2888 ataH2BE_U16(pbBuf, 0); … … 2907 2905 uint32_t cbSize; 2908 2906 2909 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2907 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2910 2908 fMSF = (s->aATAPICmd[1] >> 1) & 1; 2911 2909 iStartTrack = s->aATAPICmd[6]; … … 2968 2966 bool fMSF; 2969 2967 2970 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);2968 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 2971 2969 Assert(s->cbElementaryTransfer <= 12); 2972 2970 fMSF = (s->aATAPICmd[1] >> 1) & 1; … … 3001 2999 uint32_t cbSize; 3002 3000 3003 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);3001 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 3004 3002 fMSF = (s->aATAPICmd[1] >> 1) & 1; 3005 3003 iStartTrack = s->aATAPICmd[6]; … … 3107 3105 case SCSI_GET_EVENT_STATUS_NOTIFICATION: 3108 3106 cbMax = ataBE2H_U16(pbPacket + 7); 3109 ataR3StartTransfer(s, RT_MIN(cbMax, 8), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_GET_EVENT_STATUS_NOTIFICATION, true);3107 ataR3StartTransfer(s, RT_MIN(cbMax, 8), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_GET_EVENT_STATUS_NOTIFICATION, true); 3110 3108 break; 3111 3109 case SCSI_MODE_SENSE_10: … … 3121 3119 { 3122 3120 case SCSI_MODEPAGE_ERROR_RECOVERY: 3123 ataR3StartTransfer(s, RT_MIN(cbMax, 16), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_MODE_SENSE_ERROR_RECOVERY, true);3121 ataR3StartTransfer(s, RT_MIN(cbMax, 16), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_MODE_SENSE_ERROR_RECOVERY, true); 3124 3122 break; 3125 3123 case SCSI_MODEPAGE_CD_STATUS: 3126 ataR3StartTransfer(s, RT_MIN(cbMax, 40), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_MODE_SENSE_CD_STATUS, true);3124 ataR3StartTransfer(s, RT_MIN(cbMax, 40), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_MODE_SENSE_CD_STATUS, true); 3127 3125 break; 3128 3126 default: … … 3143 3141 case SCSI_REQUEST_SENSE: 3144 3142 cbMax = pbPacket[4]; 3145 ataR3StartTransfer(s, RT_MIN(cbMax, 18), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_REQUEST_SENSE, true);3143 ataR3StartTransfer(s, RT_MIN(cbMax, 18), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_REQUEST_SENSE, true); 3146 3144 break; 3147 3145 case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL: … … 3340 3338 { 3341 3339 cbMax = ataBE2H_U16(pbPacket + 8); 3342 ataR3StartTransfer(s, RT_MIN(cbMax, 8), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_MECHANISM_STATUS, true);3340 ataR3StartTransfer(s, RT_MIN(cbMax, 8), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_MECHANISM_STATUS, true); 3343 3341 break; 3344 3342 } … … 3366 3364 { 3367 3365 case 0: 3368 ataR3StartTransfer(s, cbMax, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TOC_NORMAL, true);3366 ataR3StartTransfer(s, cbMax, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TOC_NORMAL, true); 3369 3367 break; 3370 3368 case 1: 3371 ataR3StartTransfer(s, RT_MIN(cbMax, 12), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TOC_MULTI, true);3369 ataR3StartTransfer(s, RT_MIN(cbMax, 12), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TOC_MULTI, true); 3372 3370 break; 3373 3371 case 2: 3374 ataR3StartTransfer(s, cbMax, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TOC_RAW, true);3372 ataR3StartTransfer(s, cbMax, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TOC_RAW, true); 3375 3373 break; 3376 3374 default: … … 3393 3391 break; 3394 3392 } 3395 ataR3StartTransfer(s, 8, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_CAPACITY, true);3393 ataR3StartTransfer(s, 8, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_CAPACITY, true); 3396 3394 break; 3397 3395 case SCSI_READ_DISC_INFORMATION: … … 3408 3406 } 3409 3407 cbMax = ataBE2H_U16(pbPacket + 7); 3410 ataR3StartTransfer(s, RT_MIN(cbMax, 34), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_DISC_INFORMATION, true);3408 ataR3StartTransfer(s, RT_MIN(cbMax, 34), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_DISC_INFORMATION, true); 3411 3409 break; 3412 3410 case SCSI_READ_TRACK_INFORMATION: … … 3423 3421 } 3424 3422 cbMax = ataBE2H_U16(pbPacket + 7); 3425 ataR3StartTransfer(s, RT_MIN(cbMax, 36), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TRACK_INFORMATION, true);3423 ataR3StartTransfer(s, RT_MIN(cbMax, 36), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_TRACK_INFORMATION, true); 3426 3424 break; 3427 3425 case SCSI_GET_CONFIGURATION: 3428 3426 /* No media change stuff here, it can confuse Linux guests. */ 3429 3427 cbMax = ataBE2H_U16(pbPacket + 7); 3430 ataR3StartTransfer(s, RT_MIN(cbMax, 80), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_GET_CONFIGURATION, true);3428 ataR3StartTransfer(s, RT_MIN(cbMax, 80), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_GET_CONFIGURATION, true); 3431 3429 break; 3432 3430 case SCSI_INQUIRY: 3433 3431 cbMax = ataBE2H_U16(pbPacket + 3); 3434 ataR3StartTransfer(s, RT_MIN(cbMax, 36), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_INQUIRY, true);3432 ataR3StartTransfer(s, RT_MIN(cbMax, 36), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_INQUIRY, true); 3435 3433 break; 3436 3434 case SCSI_READ_DVD_STRUCTURE: 3437 3435 { 3438 3436 cbMax = ataBE2H_U16(pbPacket + 8); 3439 ataR3StartTransfer(s, RT_MIN(cbMax, 4), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_DVD_STRUCTURE, true);3437 ataR3StartTransfer(s, RT_MIN(cbMax, 4), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_READ_DVD_STRUCTURE, true); 3440 3438 break; 3441 3439 } … … 3456 3454 uint32_t cSectors, iATAPILBA; 3457 3455 uint32_t cbTransfer = 0; 3458 PDM BLOCKTXDIR uTxDir = PDMBLOCKTXDIR_NONE;3456 PDMMEDIATXDIR uTxDir = PDMMEDIATXDIR_NONE; 3459 3457 3460 3458 pbPacket = s->aATAPICmd; … … 3470 3468 cbTransfer = ataBE2H_U16(pbPacket + 7); 3471 3469 Log2(("ATAPI PT: lba %d\n", iATAPILBA)); 3472 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3470 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3473 3471 goto sendcmd; 3474 3472 case SCSI_FORMAT_UNIT: 3475 3473 cbTransfer = s->uATARegLCyl | (s->uATARegHCyl << 8); /* use ATAPI transfer length */ 3476 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3474 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3477 3475 goto sendcmd; 3478 3476 case SCSI_GET_CONFIGURATION: 3479 3477 cbTransfer = ataBE2H_U16(pbPacket + 7); 3480 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3478 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3481 3479 goto sendcmd; 3482 3480 case SCSI_GET_EVENT_STATUS_NOTIFICATION: … … 3484 3482 if (ASMAtomicReadU32(&s->MediaEventStatus) != ATA_EVENT_STATUS_UNCHANGED) 3485 3483 { 3486 ataR3StartTransfer(s, RT_MIN(cbTransfer, 8), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_GET_EVENT_STATUS_NOTIFICATION, true);3484 ataR3StartTransfer(s, RT_MIN(cbTransfer, 8), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_GET_EVENT_STATUS_NOTIFICATION, true); 3487 3485 break; 3488 3486 } 3489 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3487 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3490 3488 goto sendcmd; 3491 3489 case SCSI_GET_PERFORMANCE: 3492 3490 cbTransfer = s->uATARegLCyl | (s->uATARegHCyl << 8); /* use ATAPI transfer length */ 3493 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3491 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3494 3492 goto sendcmd; 3495 3493 case SCSI_INQUIRY: 3496 3494 cbTransfer = ataBE2H_U16(pbPacket + 3); 3497 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3495 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3498 3496 goto sendcmd; 3499 3497 case SCSI_LOAD_UNLOAD_MEDIUM: … … 3501 3499 case SCSI_MECHANISM_STATUS: 3502 3500 cbTransfer = ataBE2H_U16(pbPacket + 8); 3503 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3501 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3504 3502 goto sendcmd; 3505 3503 case SCSI_MODE_SELECT_10: 3506 3504 cbTransfer = ataBE2H_U16(pbPacket + 7); 3507 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3505 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3508 3506 goto sendcmd; 3509 3507 case SCSI_MODE_SENSE_10: 3510 3508 cbTransfer = ataBE2H_U16(pbPacket + 7); 3511 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3509 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3512 3510 goto sendcmd; 3513 3511 case SCSI_PAUSE_RESUME: … … 3528 3526 s->cbATAPISector = 2048; 3529 3527 cbTransfer = cSectors * s->cbATAPISector; 3530 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3528 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3531 3529 goto sendcmd; 3532 3530 case SCSI_READ_12: … … 3536 3534 s->cbATAPISector = 2048; 3537 3535 cbTransfer = cSectors * s->cbATAPISector; 3538 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3536 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3539 3537 goto sendcmd; 3540 3538 case SCSI_READ_BUFFER: 3541 3539 cbTransfer = ataBE2H_U24(pbPacket + 6); 3542 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3540 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3543 3541 goto sendcmd; 3544 3542 case SCSI_READ_BUFFER_CAPACITY: 3545 3543 cbTransfer = ataBE2H_U16(pbPacket + 7); 3546 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3544 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3547 3545 goto sendcmd; 3548 3546 case SCSI_READ_CAPACITY: 3549 3547 cbTransfer = 8; 3550 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3548 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3551 3549 goto sendcmd; 3552 3550 case SCSI_READ_CD: … … 3600 3598 cbTransfer = cSectors * s->cbATAPISector; 3601 3599 } 3602 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3600 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3603 3601 goto sendcmd; 3604 3602 } 3605 3603 case SCSI_READ_DISC_INFORMATION: 3606 3604 cbTransfer = ataBE2H_U16(pbPacket + 7); 3607 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3605 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3608 3606 goto sendcmd; 3609 3607 case SCSI_READ_DVD_STRUCTURE: 3610 3608 cbTransfer = ataBE2H_U16(pbPacket + 8); 3611 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3609 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3612 3610 goto sendcmd; 3613 3611 case SCSI_READ_FORMAT_CAPACITIES: 3614 3612 cbTransfer = ataBE2H_U16(pbPacket + 7); 3615 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3613 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3616 3614 goto sendcmd; 3617 3615 case SCSI_READ_SUBCHANNEL: 3618 3616 cbTransfer = ataBE2H_U16(pbPacket + 7); 3619 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3617 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3620 3618 goto sendcmd; 3621 3619 case SCSI_READ_TOC_PMA_ATIP: 3622 3620 cbTransfer = ataBE2H_U16(pbPacket + 7); 3623 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3621 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3624 3622 goto sendcmd; 3625 3623 case SCSI_READ_TRACK_INFORMATION: 3626 3624 cbTransfer = ataBE2H_U16(pbPacket + 7); 3627 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3625 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3628 3626 goto sendcmd; 3629 3627 case SCSI_REPAIR_TRACK: … … 3631 3629 case SCSI_REPORT_KEY: 3632 3630 cbTransfer = ataBE2H_U16(pbPacket + 8); 3633 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3631 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3634 3632 goto sendcmd; 3635 3633 case SCSI_REQUEST_SENSE: … … 3637 3635 if ((s->abATAPISense[2] & 0x0f) != SCSI_SENSE_NONE) 3638 3636 { 3639 ataR3StartTransfer(s, RT_MIN(cbTransfer, 18), PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_REQUEST_SENSE, true);3637 ataR3StartTransfer(s, RT_MIN(cbTransfer, 18), PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_ATAPI_CMD, ATAFN_SS_ATAPI_REQUEST_SENSE, true); 3640 3638 break; 3641 3639 } 3642 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3640 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3643 3641 goto sendcmd; 3644 3642 case SCSI_RESERVE_TRACK: … … 3650 3648 case SCSI_SEND_CUE_SHEET: 3651 3649 cbTransfer = ataBE2H_U24(pbPacket + 6); 3652 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3650 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3653 3651 goto sendcmd; 3654 3652 case SCSI_SEND_DVD_STRUCTURE: 3655 3653 cbTransfer = ataBE2H_U16(pbPacket + 8); 3656 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3654 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3657 3655 goto sendcmd; 3658 3656 case SCSI_SEND_EVENT: 3659 3657 cbTransfer = ataBE2H_U16(pbPacket + 8); 3660 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3658 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3661 3659 goto sendcmd; 3662 3660 case SCSI_SEND_KEY: 3663 3661 cbTransfer = ataBE2H_U16(pbPacket + 8); 3664 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3662 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3665 3663 goto sendcmd; 3666 3664 case SCSI_SEND_OPC_INFORMATION: 3667 3665 cbTransfer = ataBE2H_U16(pbPacket + 7); 3668 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3666 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3669 3667 goto sendcmd; 3670 3668 case SCSI_SET_CD_SPEED: … … 3674 3672 case SCSI_SET_STREAMING: 3675 3673 cbTransfer = ataBE2H_U16(pbPacket + 9); 3676 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3674 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3677 3675 goto sendcmd; 3678 3676 case SCSI_START_STOP_UNIT: … … 3696 3694 Log2(("ATAPI PT: lba %d sectors %d sector size %d\n", iATAPILBA, cSectors, s->cbATAPISector)); 3697 3695 cbTransfer = cSectors * s->cbATAPISector; 3698 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3696 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3699 3697 goto sendcmd; 3700 3698 case SCSI_WRITE_12: … … 3707 3705 Log2(("ATAPI PT: lba %d sectors %d sector size %d\n", iATAPILBA, cSectors, s->cbATAPISector)); 3708 3706 cbTransfer = cSectors * s->cbATAPISector; 3709 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3707 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3710 3708 goto sendcmd; 3711 3709 case SCSI_WRITE_BUFFER: … … 3723 3721 default: 3724 3722 cbTransfer = ataBE2H_U16(pbPacket + 6); 3725 uTxDir = PDM BLOCKTXDIR_TO_DEVICE;3723 uTxDir = PDMMEDIATXDIR_TO_DEVICE; 3726 3724 goto sendcmd; 3727 3725 } … … 3729 3727 case SCSI_REPORT_LUNS: /* Not part of MMC-3, but used by Windows. */ 3730 3728 cbTransfer = ataBE2H_U32(pbPacket + 6); 3731 uTxDir = PDM BLOCKTXDIR_FROM_DEVICE;3729 uTxDir = PDMMEDIATXDIR_FROM_DEVICE; 3732 3730 goto sendcmd; 3733 3731 case SCSI_REZERO_UNIT: … … 3751 3749 Log2(("ATAPI PT: max size %d\n", cbTransfer)); 3752 3750 if (cbTransfer == 0) 3753 uTxDir = PDM BLOCKTXDIR_NONE;3751 uTxDir = PDMMEDIATXDIR_NONE; 3754 3752 ataR3StartTransfer(s, cbTransfer, uTxDir, ATAFN_BT_ATAPI_PASSTHROUGH_CMD, ATAFN_SS_ATAPI_PASSTHROUGH, true); 3755 3753 } … … 3780 3778 s->fDMA = !!(s->uATARegFeature & 1); 3781 3779 memcpy(s->aATAPICmd, s->CTX_SUFF(pbIOBuffer), ATAPI_PACKET_SIZE); 3782 s->uTxDir = PDM BLOCKTXDIR_NONE;3780 s->uTxDir = PDMMEDIATXDIR_NONE; 3783 3781 s->cbTotalTransfer = 0; 3784 3782 s->cbElementaryTransfer = 0; … … 3834 3832 3835 3833 /* Ignore the call if we're called while being attached. */ 3836 if (!pIf->pDrv Block)3834 if (!pIf->pDrvMedia) 3837 3835 return; 3838 3836 3839 3837 if (pIf->fATAPI) 3840 pIf->cTotalSectors = pIf->pDrv Block->pfnGetSize(pIf->pDrvBlock) / 2048;3838 pIf->cTotalSectors = pIf->pDrvMedia->pfnGetSize(pIf->pDrvMedia) / 2048; 3841 3839 else 3842 pIf->cTotalSectors = pIf->pDrv Block->pfnGetSize(pIf->pDrvBlock) / pIf->cbSector;3840 pIf->cTotalSectors = pIf->pDrvMedia->pfnGetSize(pIf->pDrvMedia) / pIf->cbSector; 3843 3841 3844 3842 LogRel(("PIIX3 ATA: LUN#%d: CD/DVD, total number of sectors %Ld, passthrough unchanged\n", pIf->iLUN, pIf->cTotalSectors)); … … 3932 3930 3933 3931 s->Led.Asserted.s.fWriting = s->Led.Actual.s.fWriting = 1; 3934 rc = s->pDrv Block->pfnDiscard(s->pDrvBlock, &TrimRange, 1);3932 rc = s->pDrvMedia->pfnDiscard(s->pDrvMedia, &TrimRange, 1); 3935 3933 s->Led.Actual.s.fWriting = 0; 3936 3934 … … 4019 4017 { 4020 4018 case ATA_IDENTIFY_DEVICE: 4021 if (s->pDrv Block&& !s->fATAPI)4022 ataR3StartTransfer(s, 512, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_NULL, ATAFN_SS_IDENTIFY, false);4019 if (s->pDrvMedia && !s->fATAPI) 4020 ataR3StartTransfer(s, 512, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_NULL, ATAFN_SS_IDENTIFY, false); 4023 4021 else 4024 4022 { … … 4065 4063 case ATA_READ_SECTORS: 4066 4064 case ATA_READ_SECTORS_WITHOUT_RETRIES: 4067 if (!s->pDrv Block|| s->fATAPI)4065 if (!s->pDrvMedia || s->fATAPI) 4068 4066 goto abort_cmd; 4069 4067 s->cSectorsPerIRQ = 1; 4070 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_READ_SECTORS, false);4068 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_READ_SECTORS, false); 4071 4069 break; 4072 4070 case ATA_WRITE_SECTORS_EXT: … … 4074 4072 case ATA_WRITE_SECTORS: 4075 4073 case ATA_WRITE_SECTORS_WITHOUT_RETRIES: 4076 if (!s->pDrv Block|| s->fATAPI)4074 if (!s->pDrvMedia || s->fATAPI) 4077 4075 goto abort_cmd; 4078 4076 s->cSectorsPerIRQ = 1; 4079 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDM BLOCKTXDIR_TO_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_WRITE_SECTORS, false);4077 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDMMEDIATXDIR_TO_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_WRITE_SECTORS, false); 4080 4078 break; 4081 4079 case ATA_READ_MULTIPLE_EXT: 4082 4080 s->fLBA48 = true; 4083 4081 case ATA_READ_MULTIPLE: 4084 if (!s->pDrv Block|| !s->cMultSectors || s->fATAPI)4082 if (!s->pDrvMedia || !s->cMultSectors || s->fATAPI) 4085 4083 goto abort_cmd; 4086 4084 s->cSectorsPerIRQ = s->cMultSectors; 4087 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_READ_SECTORS, false);4085 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_READ_SECTORS, false); 4088 4086 break; 4089 4087 case ATA_WRITE_MULTIPLE_EXT: 4090 4088 s->fLBA48 = true; 4091 4089 case ATA_WRITE_MULTIPLE: 4092 if (!s->pDrv Block|| !s->cMultSectors || s->fATAPI)4090 if (!s->pDrvMedia || !s->cMultSectors || s->fATAPI) 4093 4091 goto abort_cmd; 4094 4092 s->cSectorsPerIRQ = s->cMultSectors; 4095 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDM BLOCKTXDIR_TO_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_WRITE_SECTORS, false);4093 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDMMEDIATXDIR_TO_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_WRITE_SECTORS, false); 4096 4094 break; 4097 4095 case ATA_READ_DMA_EXT: … … 4099 4097 case ATA_READ_DMA: 4100 4098 case ATA_READ_DMA_WITHOUT_RETRIES: 4101 if (!s->pDrv Block|| s->fATAPI)4099 if (!s->pDrvMedia || s->fATAPI) 4102 4100 goto abort_cmd; 4103 4101 s->cSectorsPerIRQ = ATA_MAX_MULT_SECTORS; 4104 4102 s->fDMA = true; 4105 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_READ_SECTORS, false);4103 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_READ_SECTORS, false); 4106 4104 break; 4107 4105 case ATA_WRITE_DMA_EXT: … … 4109 4107 case ATA_WRITE_DMA: 4110 4108 case ATA_WRITE_DMA_WITHOUT_RETRIES: 4111 if (!s->pDrv Block|| s->fATAPI)4109 if (!s->pDrvMedia || s->fATAPI) 4112 4110 goto abort_cmd; 4113 4111 s->cSectorsPerIRQ = ATA_MAX_MULT_SECTORS; 4114 4112 s->fDMA = true; 4115 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDM BLOCKTXDIR_TO_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_WRITE_SECTORS, false);4113 ataR3StartTransfer(s, ataR3GetNSectors(s) * s->cbSector, PDMMEDIATXDIR_TO_DEVICE, ATAFN_BT_READ_WRITE_SECTORS, ATAFN_SS_WRITE_SECTORS, false); 4116 4114 break; 4117 4115 case ATA_READ_NATIVE_MAX_ADDRESS_EXT: … … 4137 4135 case ATA_SET_FEATURES: 4138 4136 Log2(("%s: feature=%#x\n", __FUNCTION__, s->uATARegFeature)); 4139 if (!s->pDrv Block)4137 if (!s->pDrvMedia) 4140 4138 goto abort_cmd; 4141 4139 switch (s->uATARegFeature) … … 4170 4168 /* As per the ATA/ATAPI-6 specs, a write cache disable 4171 4169 * command MUST flush the write buffers to disc. */ 4172 ataR3StartTransfer(s, 0, PDM BLOCKTXDIR_NONE, ATAFN_BT_NULL, ATAFN_SS_FLUSH, false);4170 ataR3StartTransfer(s, 0, PDMMEDIATXDIR_NONE, ATAFN_BT_NULL, ATAFN_SS_FLUSH, false); 4173 4171 break; 4174 4172 case 0x03: { /* set transfer mode */ … … 4205 4203 case ATA_FLUSH_CACHE_EXT: 4206 4204 case ATA_FLUSH_CACHE: 4207 if (!s->pDrv Block|| s->fATAPI)4205 if (!s->pDrvMedia || s->fATAPI) 4208 4206 goto abort_cmd; 4209 ataR3StartTransfer(s, 0, PDM BLOCKTXDIR_NONE, ATAFN_BT_NULL, ATAFN_SS_FLUSH, false);4207 ataR3StartTransfer(s, 0, PDMMEDIATXDIR_NONE, ATAFN_BT_NULL, ATAFN_SS_FLUSH, false); 4210 4208 break; 4211 4209 case ATA_STANDBY_IMMEDIATE: … … 4224 4222 case ATA_IDENTIFY_PACKET_DEVICE: 4225 4223 if (s->fATAPI) 4226 ataR3StartTransfer(s, 512, PDM BLOCKTXDIR_FROM_DEVICE, ATAFN_BT_NULL, ATAFN_SS_ATAPI_IDENTIFY, false);4224 ataR3StartTransfer(s, 512, PDMMEDIATXDIR_FROM_DEVICE, ATAFN_BT_NULL, ATAFN_SS_ATAPI_IDENTIFY, false); 4227 4225 else 4228 4226 { … … 4232 4230 break; 4233 4231 case ATA_EXECUTE_DEVICE_DIAGNOSTIC: 4234 ataR3StartTransfer(s, 0, PDM BLOCKTXDIR_NONE, ATAFN_BT_NULL, ATAFN_SS_EXECUTE_DEVICE_DIAGNOSTIC, false);4232 ataR3StartTransfer(s, 0, PDMMEDIATXDIR_NONE, ATAFN_BT_NULL, ATAFN_SS_EXECUTE_DEVICE_DIAGNOSTIC, false); 4235 4233 break; 4236 4234 case ATA_DEVICE_RESET: … … 4246 4244 if (s->uATARegFeature & 0x02) 4247 4245 goto abort_cmd; 4248 ataR3StartTransfer(s, ATAPI_PACKET_SIZE, PDM BLOCKTXDIR_TO_DEVICE, ATAFN_BT_PACKET, ATAFN_SS_PACKET, false);4246 ataR3StartTransfer(s, ATAPI_PACKET_SIZE, PDMMEDIATXDIR_TO_DEVICE, ATAFN_BT_PACKET, ATAFN_SS_PACKET, false); 4249 4247 break; 4250 4248 case ATA_DATA_SET_MANAGEMENT: 4251 if (!s->pDrv Block || !s->pDrvBlock->pfnDiscard)4249 if (!s->pDrvMedia || !s->pDrvMedia->pfnDiscard) 4252 4250 goto abort_cmd; 4253 4251 if ( !(s->uATARegFeature & UINT8_C(0x01)) … … 4255 4253 goto abort_cmd; 4256 4254 s->fDMA = true; 4257 ataR3StartTransfer(s, (s->uATARegNSectorHOB << 8 | s->uATARegNSector) * s->cbSector, PDM BLOCKTXDIR_TO_DEVICE, ATAFN_BT_NULL, ATAFN_SS_TRIM, false);4255 ataR3StartTransfer(s, (s->uATARegNSectorHOB << 8 | s->uATARegNSector) * s->cbSector, PDMMEDIATXDIR_TO_DEVICE, ATAFN_BT_NULL, ATAFN_SS_TRIM, false); 4258 4256 break; 4259 4257 default: … … 4385 4383 case 7: /* command */ 4386 4384 /* ignore commands to non-existent device */ 4387 if (pCtl->iSelectedIf && !pCtl->aIfs[pCtl->iSelectedIf].pDrv Block)4385 if (pCtl->iSelectedIf && !pCtl->aIfs[pCtl->iSelectedIf].pDrvMedia) 4388 4386 break; 4389 4387 #ifndef IN_RING3 … … 4405 4403 4406 4404 /* Check if the guest is reading from a non-existent device. */ 4407 if (!s->pDrv Block)4405 if (!s->pDrvMedia) 4408 4406 { 4409 4407 if (pCtl->iSelectedIf) /* Device 1 selected, Device 0 responding for it. */ 4410 4408 { 4411 if (!pCtl->aIfs[0].pDrv Block) /** @todo this case should never get here! */4409 if (!pCtl->aIfs[0].pDrvMedia) /** @todo this case should never get here! */ 4412 4410 { 4413 4411 Log2(("%s: addr=%#x: no device on channel\n", __FUNCTION__, addr)); … … 4440 4438 * the feature register (write-only), so it seems that it's not 4441 4439 * necessary to support the usual HOB readback here. */ 4442 if (!s->pDrv Block)4440 if (!s->pDrvMedia) 4443 4441 val = 0; 4444 4442 else … … 4473 4471 * one drive attached to the controller. It is common between 4474 4472 * both drives anyway (completely identical content). */ 4475 if (!pCtl->aIfs[0].pDrv Block && !pCtl->aIfs[1].pDrvBlock)4473 if (!pCtl->aIfs[0].pDrvMedia && !pCtl->aIfs[1].pDrvMedia) 4476 4474 val = 0; 4477 4475 else … … 4484 4482 static unsigned cBusy = 0; 4485 4483 4486 if (!s->pDrv Block)4484 if (!s->pDrvMedia) 4487 4485 val = 0; 4488 4486 else … … 4569 4567 //@todo: The handler should not be even registered if there 4570 4568 // is no device on an IDE channel. 4571 if (!pCtl->aIfs[0].pDrv Block && !pCtl->aIfs[1].pDrvBlock)4569 if (!pCtl->aIfs[0].pDrvMedia && !pCtl->aIfs[1].pDrvMedia) 4572 4570 val = 0xff; 4573 else if (pCtl->iSelectedIf == 1 && !s->pDrv Block)4571 else if (pCtl->iSelectedIf == 1 && !s->pDrvMedia) 4574 4572 val = 0; /* Device 1 selected, Device 0 responding for it. */ 4575 4573 else … … 4701 4699 { 4702 4700 # ifdef IN_RING3 4703 LogRel(("PIIX3 ATA: LUN#%d: %s data in the middle of a PIO transfer - VERY SLOW\n", s->iLUN, s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE ? "loading" : "storing"));4701 LogRel(("PIIX3 ATA: LUN#%d: %s data in the middle of a PIO transfer - VERY SLOW\n", s->iLUN, s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE ? "loading" : "storing")); 4704 4702 /* Any guest OS that triggers this case has a pathetic ATA driver. 4705 4703 * In a real system it would block the CPU via IORDY, here we do it … … 4729 4727 ataHCPIOTransferLimitATAPI(s); 4730 4728 4731 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE && s->cbElementaryTransfer > s->cbTotalTransfer)4729 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE && s->cbElementaryTransfer > s->cbTotalTransfer) 4732 4730 s->cbElementaryTransfer = s->cbTotalTransfer; 4733 4731 4734 4732 Log2(("%s: %s tx_size=%d elem_tx_size=%d index=%d end=%d\n", 4735 __FUNCTION__, s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE ? "T2I" : "I2T",4733 __FUNCTION__, s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE ? "T2I" : "I2T", 4736 4734 s->cbTotalTransfer, s->cbElementaryTransfer, 4737 4735 s->iIOBufferCur, s->iIOBufferEnd)); … … 4740 4738 s->iIOBufferCur += s->cbElementaryTransfer; 4741 4739 4742 if (s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE && s->cbElementaryTransfer > s->cbTotalTransfer)4740 if (s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE && s->cbElementaryTransfer > s->cbTotalTransfer) 4743 4741 s->cbElementaryTransfer = s->cbTotalTransfer; 4744 4742 } … … 4758 4756 } 4759 4757 4760 if ( s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE4758 if ( s->uTxDir == PDMMEDIATXDIR_TO_DEVICE 4761 4759 || ( s->iSourceSink != ATAFN_SS_NULL 4762 4760 && s->iIOBufferCur >= s->iIOBufferEnd)) … … 4898 4896 if (s->iIOBufferPIODataStart < s->iIOBufferPIODataEnd) 4899 4897 { 4900 Assert(s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE);4898 Assert(s->uTxDir == PDMMEDIATXDIR_TO_DEVICE); 4901 4899 uint8_t *pbDst = s->CTX_SUFF(pbIOBuffer) + s->iIOBufferPIODataStart; 4902 4900 uint8_t const *pbSrc = (uint8_t const *)&u32; … … 4915 4913 if (s->iIOBufferPIODataStart + cb < s->iIOBufferPIODataEnd) 4916 4914 ataCopyPioData124(s, pbDst, pbSrc, cb); 4917 else if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE) /* paranoia */4915 else if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE) /* paranoia */ 4918 4916 { 4919 4917 ataCopyPioData124(s, pbDst, pbSrc, cb); … … 4970 4968 if (s->iIOBufferPIODataStart < s->iIOBufferPIODataEnd) 4971 4969 { 4972 Assert(s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE);4970 Assert(s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE); 4973 4971 uint8_t const *pbSrc = s->CTX_SUFF(pbIOBuffer) + s->iIOBufferPIODataStart; 4974 4972 uint8_t *pbDst = (uint8_t *)pu32; … … 5227 5225 uint32_t iIOBufferCur, iIOBufferEnd; 5228 5226 uint32_t dmalen; 5229 PDM BLOCKTXDIR uTxDir;5227 PDMMEDIATXDIR uTxDir; 5230 5228 bool fLastDesc = false; 5231 5229 … … 5235 5233 if (RT_LIKELY(!fRedo)) 5236 5234 Assert(s->cbTotalTransfer); 5237 uTxDir = (PDM BLOCKTXDIR)s->uTxDir;5235 uTxDir = (PDMMEDIATXDIR)s->uTxDir; 5238 5236 cbTotalTransfer = s->cbTotalTransfer; 5239 5237 cbElementaryTransfer = s->cbElementaryTransfer; … … 5247 5245 5248 5246 Log2(("%s: %s tx_size=%d elem_tx_size=%d index=%d end=%d\n", 5249 __FUNCTION__, uTxDir == PDM BLOCKTXDIR_FROM_DEVICE ? "T2I" : "I2T",5247 __FUNCTION__, uTxDir == PDMMEDIATXDIR_FROM_DEVICE ? "T2I" : "I2T", 5250 5248 cbTotalTransfer, cbElementaryTransfer, 5251 5249 iIOBufferCur, iIOBufferEnd)); … … 5285 5283 PCIATAState *pATAState = PDMINS_2_DATA(pDevIns, PCIATAState *); 5286 5284 AssertPtr(pATAState); 5287 if (uTxDir == PDM BLOCKTXDIR_FROM_DEVICE)5285 if (uTxDir == PDMMEDIATXDIR_FROM_DEVICE) 5288 5286 PDMDevHlpPCIPhysWrite(pDevIns, pBuffer, s->CTX_SUFF(pbIOBuffer) + iIOBufferCur, dmalen); 5289 5287 else … … 5296 5294 } 5297 5295 if ( iIOBufferCur == iIOBufferEnd 5298 && (uTxDir == PDM BLOCKTXDIR_TO_DEVICE || cbTotalTransfer))5296 && (uTxDir == PDMMEDIATXDIR_TO_DEVICE || cbTotalTransfer)) 5299 5297 { 5300 if (uTxDir == PDM BLOCKTXDIR_FROM_DEVICE && cbElementaryTransfer > cbTotalTransfer)5298 if (uTxDir == PDMMEDIATXDIR_FROM_DEVICE && cbElementaryTransfer > cbTotalTransfer) 5301 5299 cbElementaryTransfer = cbTotalTransfer; 5302 5300 … … 5331 5329 cbElementaryTransfer = s->cbElementaryTransfer; 5332 5330 5333 if (uTxDir == PDM BLOCKTXDIR_TO_DEVICE && cbElementaryTransfer > cbTotalTransfer)5331 if (uTxDir == PDMMEDIATXDIR_TO_DEVICE && cbElementaryTransfer > cbTotalTransfer) 5334 5332 cbElementaryTransfer = cbTotalTransfer; 5335 5333 iIOBufferCur = 0; … … 5550 5548 g_apfnBeginTransFuncs[s->iBeginTransfer](s); 5551 5549 s->iBeginTransfer = ATAFN_BT_NULL; 5552 if (s->uTxDir != PDM BLOCKTXDIR_FROM_DEVICE)5550 if (s->uTxDir != PDMMEDIATXDIR_FROM_DEVICE) 5553 5551 s->iIOBufferEnd = s->cbElementaryTransfer; 5554 5552 } … … 5560 5558 s->iIOBufferCur = 0; 5561 5559 5562 if (s->uTxDir != PDM BLOCKTXDIR_TO_DEVICE)5560 if (s->uTxDir != PDMMEDIATXDIR_TO_DEVICE) 5563 5561 { 5564 5562 if (s->iSourceSink != ATAFN_SS_NULL) … … 5607 5605 else 5608 5606 { 5609 Assert(s->uTxDir == PDM BLOCKTXDIR_NONE); /* Any transfer which has an initial transfer size of 0 must be marked as such. */5607 Assert(s->uTxDir == PDMMEDIATXDIR_NONE); /* Any transfer which has an initial transfer size of 0 must be marked as such. */ 5610 5608 /* Finish DMA transfer. */ 5611 5609 ataR3DMATransferStop(s); … … 5620 5618 ataHCPIOTransfer(pCtl); 5621 5619 Assert(!pCtl->fRedo); 5622 if (s->fATAPITransfer || s->uTxDir != PDM BLOCKTXDIR_TO_DEVICE)5620 if (s->fATAPITransfer || s->uTxDir != PDMMEDIATXDIR_TO_DEVICE) 5623 5621 ataHCSetIRQ(s); 5624 5622 5625 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE || s->iSourceSink != ATAFN_SS_NULL)5623 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE || s->iSourceSink != ATAFN_SS_NULL) 5626 5624 { 5627 5625 /* Write operations and not yet finished transfers … … 5644 5642 else 5645 5643 { 5646 Assert(s->uTxDir == PDM BLOCKTXDIR_NONE); /* Any transfer which has an initial transfer size of 0 must be marked as such. */5644 Assert(s->uTxDir == PDMMEDIATXDIR_NONE); /* Any transfer which has an initial transfer size of 0 must be marked as such. */ 5647 5645 /* Finish PIO transfer. */ 5648 5646 ataHCPIOTransfer(pCtl); … … 5661 5659 ATAFNSS iOriginalSourceSink = (ATAFNSS)s->iSourceSink; /* Used by the hack below, but gets reset by then. */ 5662 5660 5663 if (s->uTxDir == PDM BLOCKTXDIR_FROM_DEVICE)5661 if (s->uTxDir == PDMMEDIATXDIR_FROM_DEVICE) 5664 5662 AssertRelease(bm->u8Cmd & BM_CMD_WRITE); 5665 5663 else … … 5749 5747 ataHCSetIRQ(s); 5750 5748 5751 if (s->uTxDir == PDM BLOCKTXDIR_TO_DEVICE || s->iSourceSink != ATAFN_SS_NULL)5749 if (s->uTxDir == PDMMEDIATXDIR_TO_DEVICE || s->iSourceSink != ATAFN_SS_NULL) 5752 5750 { 5753 5751 /* Write operations and not yet finished transfers … … 5774 5772 if ( !pCtl->fChainedTransfer 5775 5773 && !s->fATAPITransfer 5776 && s->uTxDir != PDM BLOCKTXDIR_FROM_DEVICE)5774 && s->uTxDir != PDMMEDIATXDIR_FROM_DEVICE) 5777 5775 { 5778 5776 ataHCSetIRQ(s); … … 6186 6184 ATADevState *pIf = PDMIBASE_2_ATASTATE(pInterface); 6187 6185 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pIf->IBase); 6188 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKPORT, &pIf->IPort);6186 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pIf->IPort); 6189 6187 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pIf->IMountNotify); 6190 6188 return NULL; … … 6195 6193 6196 6194 /** 6197 * @interface_method_impl{PDMI BLOCKPORT,pfnQueryDeviceLocation}6195 * @interface_method_impl{PDMIMEDIAPORT,pfnQueryDeviceLocation} 6198 6196 */ 6199 static DECLCALLBACK(int) ataR3QueryDeviceLocation(PPDMI BLOCKPORT pInterface, const char **ppcszController,6197 static DECLCALLBACK(int) ataR3QueryDeviceLocation(PPDMIMEDIAPORT pInterface, const char **ppcszController, 6200 6198 uint32_t *piInstance, uint32_t *piLUN) 6201 6199 { 6202 ATADevState *pIf = PDMI BLOCKPORT_2_ATASTATE(pInterface);6200 ATADevState *pIf = PDMIMEDIAPORT_2_ATASTATE(pInterface); 6203 6201 PPDMDEVINS pDevIns = pIf->CTX_SUFF(pDevIns); 6204 6202 … … 6387 6385 */ 6388 6386 pIf->pDrvBase = NULL; 6389 pIf->pDrvBlock = NULL; 6390 pIf->pDrvBlockBios = NULL; 6387 pIf->pDrvMedia = NULL; 6391 6388 pIf->pDrvMount = NULL; 6392 6389 … … 6408 6405 { 6409 6406 int rc = VINF_SUCCESS; 6410 PDM BLOCKTYPE enmType;6407 PDMMEDIATYPE enmType; 6411 6408 6412 6409 /* 6413 6410 * Query Block, Bios and Mount interfaces. 6414 6411 */ 6415 pIf->pDrv Block = PDMIBASE_QUERY_INTERFACE(pIf->pDrvBase, PDMIBLOCK);6416 if (!pIf->pDrv Block)6412 pIf->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pIf->pDrvBase, PDMIMEDIA); 6413 if (!pIf->pDrvMedia) 6417 6414 { 6418 6415 AssertMsgFailed(("Configuration error: LUN#%d hasn't a block interface!\n", pIf->iLUN)); … … 6420 6417 } 6421 6418 6422 /** @todo implement the BIOS invisible code path. */6423 pIf->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pIf->pDrvBase, PDMIBLOCKBIOS);6424 if (!pIf->pDrvBlockBios)6425 {6426 AssertMsgFailed(("Configuration error: LUN#%d hasn't a block BIOS interface!\n", pIf->iLUN));6427 return VERR_PDM_MISSING_INTERFACE;6428 }6429 6419 pIf->pDrvMount = PDMIBASE_QUERY_INTERFACE(pIf->pDrvBase, PDMIMOUNT); 6430 6420 … … 6432 6422 * Validate type. 6433 6423 */ 6434 enmType = pIf->pDrv Block->pfnGetType(pIf->pDrvBlock);6435 if ( enmType != PDM BLOCKTYPE_CDROM6436 && enmType != PDM BLOCKTYPE_DVD6437 && enmType != PDM BLOCKTYPE_HARD_DISK)6424 enmType = pIf->pDrvMedia->pfnGetType(pIf->pDrvMedia); 6425 if ( enmType != PDMMEDIATYPE_CDROM 6426 && enmType != PDMMEDIATYPE_DVD 6427 && enmType != PDMMEDIATYPE_HARD_DISK) 6438 6428 { 6439 6429 AssertMsgFailed(("Configuration error: LUN#%d isn't a disk or cd/dvd-rom. enmType=%d\n", pIf->iLUN, enmType)); 6440 6430 return VERR_PDM_UNSUPPORTED_BLOCK_TYPE; 6441 6431 } 6442 if ( ( enmType == PDM BLOCKTYPE_DVD6443 || enmType == PDM BLOCKTYPE_CDROM)6432 if ( ( enmType == PDMMEDIATYPE_DVD 6433 || enmType == PDMMEDIATYPE_CDROM) 6444 6434 && !pIf->pDrvMount) 6445 6435 { … … 6447 6437 return VERR_INTERNAL_ERROR; 6448 6438 } 6449 pIf->fATAPI = enmType == PDM BLOCKTYPE_DVD || enmType == PDMBLOCKTYPE_CDROM;6450 pIf->fATAPIPassthrough = pIf->fATAPI ? (pIf->pDrv Block->pfnSendCmd != NULL) : false;6439 pIf->fATAPI = enmType == PDMMEDIATYPE_DVD || enmType == PDMMEDIATYPE_CDROM; 6440 pIf->fATAPIPassthrough = pIf->fATAPI ? (pIf->pDrvMedia->pfnSendCmd != NULL) : false; 6451 6441 6452 6442 /* … … 6456 6446 pIf->cbSector = 2048; 6457 6447 else 6458 pIf->cbSector = pIf->pDrv Block->pfnGetSectorSize(pIf->pDrvBlock);6448 pIf->cbSector = pIf->pDrvMedia->pfnGetSectorSize(pIf->pDrvMedia); 6459 6449 6460 6450 PVM pVM = PDMDevHlpGetVM(pDevIns); … … 6490 6480 if (pIf->fATAPI) 6491 6481 { 6492 pIf->cTotalSectors = pIf->pDrv Block->pfnGetSize(pIf->pDrvBlock) / pIf->cbSector;6482 pIf->cTotalSectors = pIf->pDrvMedia->pfnGetSize(pIf->pDrvMedia) / pIf->cbSector; 6493 6483 pIf->PCHSGeometry.cCylinders = 0; /* dummy */ 6494 6484 pIf->PCHSGeometry.cHeads = 0; /* dummy */ … … 6498 6488 else 6499 6489 { 6500 pIf->cTotalSectors = pIf->pDrvBlock->pfnGetSize(pIf->pDrvBlock) / pIf->cbSector; 6501 rc = pIf->pDrvBlockBios->pfnGetPCHSGeometry(pIf->pDrvBlockBios, 6502 &pIf->PCHSGeometry); 6490 pIf->cTotalSectors = pIf->pDrvMedia->pfnGetSize(pIf->pDrvMedia) / pIf->cbSector; 6491 rc = pIf->pDrvMedia->pfnBiosGetPCHSGeometry(pIf->pDrvMedia, &pIf->PCHSGeometry); 6503 6492 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 6504 6493 { … … 6524 6513 pIf->PCHSGeometry.cSectors = 63; 6525 6514 /* Set the disk geometry information. Ignore errors. */ 6526 pIf->pDrvBlockBios->pfnSetPCHSGeometry(pIf->pDrvBlockBios, 6527 &pIf->PCHSGeometry); 6515 pIf->pDrvMedia->pfnBiosSetPCHSGeometry(pIf->pDrvMedia, &pIf->PCHSGeometry); 6528 6516 rc = VINF_SUCCESS; 6529 6517 } 6530 6518 LogRel(("PIIX3 ATA: LUN#%d: disk, PCHS=%u/%u/%u, total number of sectors %Ld\n", pIf->iLUN, pIf->PCHSGeometry.cCylinders, pIf->PCHSGeometry.cHeads, pIf->PCHSGeometry.cSectors, pIf->cTotalSectors)); 6531 6519 6532 if (pIf->pDrv Block->pfnDiscard)6520 if (pIf->pDrvMedia->pfnDiscard) 6533 6521 LogRel(("PIIX3 ATA: LUN#%d: TRIM enabled\n", pIf->iLUN)); 6534 6522 } … … 6572 6560 /* the usual paranoia */ 6573 6561 AssertRelease(!pIf->pDrvBase); 6574 AssertRelease(!pIf->pDrv Block);6562 AssertRelease(!pIf->pDrvMedia); 6575 6563 Assert(ATADEVSTATE_2_CONTROLLER(pIf) == pCtl); 6576 6564 Assert(pIf->iLUN == iLUN); … … 6596 6584 { 6597 6585 pIf->pDrvBase = NULL; 6598 pIf->pDrv Block= NULL;6586 pIf->pDrvMedia = NULL; 6599 6587 } 6600 6588 return rc; … … 7692 7680 char szSerial[ATA_SERIAL_NUMBER_LENGTH+1]; 7693 7681 RTUUID Uuid; 7694 if (pIf->pDrv Block)7695 rc = pIf->pDrv Block->pfnGetUuid(pIf->pDrvBlock, &Uuid);7682 if (pIf->pDrvMedia) 7683 rc = pIf->pDrvMedia->pfnGetUuid(pIf->pDrvMedia, &Uuid); 7696 7684 else 7697 7685 RTUuidClear(&Uuid); … … 7794 7782 { 7795 7783 pIf->pDrvBase = NULL; 7796 pIf->pDrv Block= NULL;7784 pIf->pDrvMedia = NULL; 7797 7785 pIf->cbIOBuffer = 0; 7798 7786 pIf->pbIOBufferR3 = NULL; -
trunk/src/VBox/Devices/Storage/DevFdc.cpp
r57358 r59248 141 141 * 142 142 * @implements PDMIBASE 143 * @implements PDMI BLOCKPORT143 * @implements PDMIMEDIAPORT 144 144 * @implements PDMIMOUNTNOTIFY 145 145 */ … … 151 151 R3PTRTYPE(PPDMIBASE) pDrvBase; 152 152 /** Pointer to the attached driver's block interface. */ 153 R3PTRTYPE(PPDMIBLOCK) pDrvBlock; 154 /** Pointer to the attached driver's block bios interface. */ 155 R3PTRTYPE(PPDMIBLOCKBIOS) pDrvBlockBios; 153 R3PTRTYPE(PPDMIMEDIA) pDrvMedia; 156 154 /** Pointer to the attached driver's mount interface. 157 155 * This is NULL if the driver isn't a removable unit. */ … … 160 158 PDMIBASE IBase; 161 159 /** The block port interface. */ 162 PDMI BLOCKPORT IPort;160 PDMIMEDIAPORT IPort; 163 161 /** The mount notify interface. */ 164 162 PDMIMOUNTNOTIFY IMountNotify; … … 196 194 if (fInit) { 197 195 /* Fixate the drive type at init time if possible. */ 198 if (drv->pDrv Block) {199 PDM BLOCKTYPE enmType = drv->pDrvBlock->pfnGetType(drv->pDrvBlock);196 if (drv->pDrvMedia) { 197 PDMMEDIATYPE enmType = drv->pDrvMedia->pfnGetType(drv->pDrvMedia); 200 198 switch (enmType) { 201 case PDM BLOCKTYPE_FLOPPY_360:202 case PDM BLOCKTYPE_FLOPPY_1_20:199 case PDMMEDIATYPE_FLOPPY_360: 200 case PDMMEDIATYPE_FLOPPY_1_20: 203 201 drv->drive = FDRIVE_DRV_120; 204 202 break; 205 case PDM BLOCKTYPE_FLOPPY_720:206 case PDM BLOCKTYPE_FLOPPY_1_44:203 case PDMMEDIATYPE_FLOPPY_720: 204 case PDMMEDIATYPE_FLOPPY_1_44: 207 205 drv->drive = FDRIVE_DRV_144; 208 206 break; 209 207 default: 210 208 AssertFailed(); 211 case PDM BLOCKTYPE_FLOPPY_2_88:209 case PDMMEDIATYPE_FLOPPY_2_88: 212 210 drv->drive = FDRIVE_DRV_288; 213 211 break; 214 case PDM BLOCKTYPE_FLOPPY_FAKE_15_6:212 case PDMMEDIATYPE_FLOPPY_FAKE_15_6: 215 213 drv->drive = FDRIVE_DRV_FAKE_15_6; 216 214 break; 217 case PDM BLOCKTYPE_FLOPPY_FAKE_63_5:215 case PDMMEDIATYPE_FLOPPY_FAKE_63_5: 218 216 drv->drive = FDRIVE_DRV_FAKE_63_5; 219 217 break; … … 439 437 bdrv_get_geometry_hint(drv->bs, &nb_heads, &max_track, &last_sect); 440 438 #else /* VBOX */ 441 if ( drv->pDrv Block439 if ( drv->pDrvMedia 442 440 && drv->pDrvMount 443 441 && drv->pDrvMount->pfnIsMounted (drv->pDrvMount)) { 444 ro = drv->pDrv Block->pfnIsReadOnly (drv->pDrvBlock);442 ro = drv->pDrvMedia->pfnIsReadOnly (drv->pDrvMedia); 445 443 nb_heads = max_track = last_sect = 0; 446 444 #endif /* VBOX */ … … 453 451 #else /* VBOX */ 454 452 { 455 uint64_t size2 = drv->pDrv Block->pfnGetSize (drv->pDrvBlock);453 uint64_t size2 = drv->pDrvMedia->pfnGetSize (drv->pDrvMedia); 456 454 nb_sectors = size2 / FD_SECTOR_LEN; 457 455 } … … 884 882 fdctrl->srb = 0xc0; 885 883 #ifdef VBOX 886 if (!fdctrl->drives[1].pDrv Block)884 if (!fdctrl->drives[1].pDrvMedia) 887 885 #else 888 886 if (!fdctrl->drives[1].bs) … … 1501 1499 drv->Led.Asserted.s.fWriting = drv->Led.Actual.s.fWriting = 1; 1502 1500 1503 rc = drv->pDrv Block->pfnWrite(drv->pDrvBlock, sector_num * FD_SECTOR_LEN,1501 rc = drv->pDrvMedia->pfnWrite(drv->pDrvMedia, sector_num * FD_SECTOR_LEN, 1504 1502 buf, nb_sectors * FD_SECTOR_LEN); 1505 1503 … … 1517 1515 drv->Led.Asserted.s.fReading = drv->Led.Actual.s.fReading = 1; 1518 1516 1519 rc = drv->pDrv Block->pfnRead(drv->pDrvBlock, sector_num * FD_SECTOR_LEN,1517 rc = drv->pDrvMedia->pfnRead(drv->pDrvMedia, sector_num * FD_SECTOR_LEN, 1520 1518 buf, nb_sectors * FD_SECTOR_LEN); 1521 1519 … … 1567 1565 if (cur_drv->bs == NULL) 1568 1566 #else /* !VBOX */ 1569 if (cur_drv->pDrv Block== NULL)1567 if (cur_drv->pDrvMedia == NULL) 1570 1568 #endif 1571 1569 { … … 1861 1859 memset(fdctrl->fifo, 0, FD_SECTOR_LEN); 1862 1860 #ifdef VBOX 1863 if (cur_drv->pDrv Block) {1861 if (cur_drv->pDrvMedia) { 1864 1862 rc = blk_write(cur_drv, fd_sector(cur_drv), fdctrl->fifo, 1); 1865 1863 if (RT_FAILURE (rc)) { … … 2644 2642 2645 2643 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrv->IBase); 2646 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKPORT, &pDrv->IPort);2644 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pDrv->IPort); 2647 2645 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pDrv->IMountNotify); 2648 2646 return NULL; … … 2706 2704 rc = PDMDevHlpDriverAttach (pDevIns, drv->iLUN, &drv->IBase, &drv->pDrvBase, s_apszDesc[drv->iLUN]); 2707 2705 if (RT_SUCCESS (rc)) { 2708 drv->pDrvBlock = PDMIBASE_QUERY_INTERFACE(drv->pDrvBase, PDMIBLOCK); 2709 if (drv->pDrvBlock) { 2710 drv->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(drv->pDrvBase, PDMIBLOCKBIOS); 2711 if (drv->pDrvBlockBios) { 2712 drv->pDrvMount = PDMIBASE_QUERY_INTERFACE(drv->pDrvBase, PDMIMOUNT); 2713 if (drv->pDrvMount) { 2714 fd_init(drv, fInit); 2715 } else { 2716 AssertMsgFailed (("Configuration error: LUN#%d without mountable interface!\n", drv->iLUN)); 2717 rc = VERR_PDM_MISSING_INTERFACE; 2718 } 2719 2706 drv->pDrvMedia = PDMIBASE_QUERY_INTERFACE(drv->pDrvBase, PDMIMEDIA); 2707 if (drv->pDrvMedia) { 2708 drv->pDrvMount = PDMIBASE_QUERY_INTERFACE(drv->pDrvBase, PDMIMOUNT); 2709 if (drv->pDrvMount) { 2710 fd_init(drv, fInit); 2720 2711 } else { 2721 AssertMsgFailed (("Configuration error: LUN#%d hasn't a block BIOSinterface!\n", drv->iLUN));2712 AssertMsgFailed (("Configuration error: LUN#%d without mountable interface!\n", drv->iLUN)); 2722 2713 rc = VERR_PDM_MISSING_INTERFACE; 2723 2714 } … … 2746 2737 if (RT_FAILURE (rc)) { 2747 2738 drv->pDrvBase = NULL; 2748 drv->pDrvBlock = NULL; 2749 drv->pDrvBlockBios = NULL; 2739 drv->pDrvMedia = NULL; 2750 2740 drv->pDrvMount = NULL; 2751 2741 } … … 2787 2777 /* the usual paranoia */ 2788 2778 AssertRelease (!drv->pDrvBase); 2789 AssertRelease (!drv->pDrvBlock); 2790 AssertRelease (!drv->pDrvBlockBios); 2779 AssertRelease (!drv->pDrvMedia); 2791 2780 AssertRelease (!drv->pDrvMount); 2792 2781 … … 2820 2809 fdrive_t *drv = &pThis->drives[iLUN]; 2821 2810 drv->pDrvBase = NULL; 2822 drv->pDrvBlock = NULL; 2823 drv->pDrvBlockBios = NULL; 2811 drv->pDrvMedia = NULL; 2824 2812 drv->pDrvMount = NULL; 2825 2813 break; -
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r57393 r59248 133 133 134 134 /** @copydoc PDMIBLOCK::pfnRead */ 135 static DECLCALLBACK(int) drvHostBaseRead(PPDMI BLOCKpInterface, uint64_t off, void *pvBuf, size_t cbRead)136 { 137 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);135 static DECLCALLBACK(int) drvHostBaseRead(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead) 136 { 137 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 138 138 LogFlow(("%s-%d: drvHostBaseRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", 139 139 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, off, pvBuf, cbRead, pThis->pszDevice)); … … 209 209 210 210 /** @copydoc PDMIBLOCK::pfnWrite */ 211 static DECLCALLBACK(int) drvHostBaseWrite(PPDMI BLOCKpInterface, uint64_t off, const void *pvBuf, size_t cbWrite)212 { 213 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);211 static DECLCALLBACK(int) drvHostBaseWrite(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite) 212 { 213 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 214 214 LogFlow(("%s-%d: drvHostBaseWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n", 215 215 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, off, pvBuf, cbWrite, pThis->pszDevice)); … … 255 255 256 256 /** @copydoc PDMIBLOCK::pfnFlush */ 257 static DECLCALLBACK(int) drvHostBaseFlush(PPDMI BLOCKpInterface)257 static DECLCALLBACK(int) drvHostBaseFlush(PPDMIMEDIA pInterface) 258 258 { 259 259 int rc; 260 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);260 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 261 261 LogFlow(("%s-%d: drvHostBaseFlush: (%s)\n", 262 262 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->pszDevice)); … … 282 282 283 283 /** @copydoc PDMIBLOCK::pfnIsReadOnly */ 284 static DECLCALLBACK(bool) drvHostBaseIsReadOnly(PPDMI BLOCKpInterface)285 { 286 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);284 static DECLCALLBACK(bool) drvHostBaseIsReadOnly(PPDMIMEDIA pInterface) 285 { 286 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 287 287 return pThis->fReadOnly; 288 288 } … … 290 290 291 291 /** @copydoc PDMIBLOCK::pfnGetSize */ 292 static DECLCALLBACK(uint64_t) drvHostBaseGetSize(PPDMI BLOCKpInterface)293 { 294 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);292 static DECLCALLBACK(uint64_t) drvHostBaseGetSize(PPDMIMEDIA pInterface) 293 { 294 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 295 295 RTCritSectEnter(&pThis->CritSect); 296 296 … … 306 306 307 307 /** @copydoc PDMIBLOCK::pfnGetType */ 308 static DECLCALLBACK(PDM BLOCKTYPE) drvHostBaseGetType(PPDMIBLOCKpInterface)309 { 310 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);308 static DECLCALLBACK(PDMMEDIATYPE) drvHostBaseGetType(PPDMIMEDIA pInterface) 309 { 310 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 311 311 LogFlow(("%s-%d: drvHostBaseGetType: returns %d\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->enmType)); 312 312 return pThis->enmType; … … 315 315 316 316 /** @copydoc PDMIBLOCK::pfnGetUuid */ 317 static DECLCALLBACK(int) drvHostBaseGetUuid(PPDMI BLOCKpInterface, PRTUUID pUuid)318 { 319 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);317 static DECLCALLBACK(int) drvHostBaseGetUuid(PPDMIMEDIA pInterface, PRTUUID pUuid) 318 { 319 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 320 320 321 321 *pUuid = pThis->Uuid; … … 327 327 328 328 /** @copydoc PDMIBLOCK::pfnIoBufAlloc */ 329 static DECLCALLBACK(int) drvHostBaseIoBufAlloc(PPDMI BLOCKpInterface, size_t cb, void **ppvNew)329 static DECLCALLBACK(int) drvHostBaseIoBufAlloc(PPDMIMEDIA pInterface, size_t cb, void **ppvNew) 330 330 { 331 331 LogFlowFunc(("\n")); 332 332 int rc; 333 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);333 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 334 334 335 335 void *pvNew = RTMemAlloc(cb); … … 347 347 348 348 /** @copydoc PDMIBLOCK::pfnIoBufFree */ 349 static DECLCALLBACK(int) drvHostBaseIoBufFree(PPDMI BLOCKpInterface, void *pv, size_t cb)349 static DECLCALLBACK(int) drvHostBaseIoBufFree(PPDMIMEDIA pInterface, void *pv, size_t cb) 350 350 { 351 351 LogFlowFunc(("\n")); 352 352 int rc = VINF_SUCCESS; 353 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);353 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 354 354 355 355 NOREF(cb); … … 361 361 362 362 363 364 /* -=-=-=-=- IBlockBios -=-=-=-=- */ 365 366 /** Makes a PDRVHOSTBASE out of a PPDMIBLOCKBIOS. */ 367 #define PDMIBLOCKBIOS_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlockBios))) ) 368 369 370 /** @copydoc PDMIBLOCKBIOS::pfnGetPCHSGeometry */ 371 static DECLCALLBACK(int) drvHostBaseGetPCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry) 372 { 373 PDRVHOSTBASE pThis = PDMIBLOCKBIOS_2_DRVHOSTBASE(pInterface); 363 /** @copydoc PDMIBLOCKBIOS::pfnBiosGetPCHSGeometry */ 364 static DECLCALLBACK(int) drvHostBaseGetPCHSGeometry(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry) 365 { 366 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 374 367 RTCritSectEnter(&pThis->CritSect); 375 368 … … 396 389 397 390 398 /** @copydoc PDMIBLOCKBIOS::pfn SetPCHSGeometry */399 static DECLCALLBACK(int) drvHostBaseSetPCHSGeometry(PPDMI BLOCKBIOSpInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry)400 { 401 PDRVHOSTBASE pThis = PDMIBLOCKBIOS_2_DRVHOSTBASE(pInterface);391 /** @copydoc PDMIBLOCKBIOS::pfnBiosSetPCHSGeometry */ 392 static DECLCALLBACK(int) drvHostBaseSetPCHSGeometry(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry) 393 { 394 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 402 395 LogFlow(("%s-%d: %s: cCylinders=%d cHeads=%d cSectors=%d\n", 403 396 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, __FUNCTION__, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); … … 421 414 422 415 /** @copydoc PDMIBLOCKBIOS::pfnGetLCHSGeometry */ 423 static DECLCALLBACK(int) drvHostBaseGetLCHSGeometry(PPDMI BLOCKBIOSpInterface, PPDMMEDIAGEOMETRY pLCHSGeometry)424 { 425 PDRVHOSTBASE pThis = PDMI BLOCKBIOS_2_DRVHOSTBASE(pInterface);416 static DECLCALLBACK(int) drvHostBaseGetLCHSGeometry(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry) 417 { 418 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 426 419 RTCritSectEnter(&pThis->CritSect); 427 420 … … 449 442 450 443 /** @copydoc PDMIBLOCKBIOS::pfnSetLCHSGeometry */ 451 static DECLCALLBACK(int) drvHostBaseSetLCHSGeometry(PPDMI BLOCKBIOSpInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry)452 { 453 PDRVHOSTBASE pThis = PDMIBLOCKBIOS_2_DRVHOSTBASE(pInterface);444 static DECLCALLBACK(int) drvHostBaseSetLCHSGeometry(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry) 445 { 446 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 454 447 LogFlow(("%s-%d: %s: cCylinders=%d cHeads=%d cSectors=%d\n", 455 448 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, __FUNCTION__, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); … … 473 466 474 467 /** @copydoc PDMIBLOCKBIOS::pfnIsVisible */ 475 static DECLCALLBACK(bool) drvHostBaseIsVisible(PPDMI BLOCKBIOSpInterface)476 { 477 PDRVHOSTBASE pThis = PDMIBLOCKBIOS_2_DRVHOSTBASE(pInterface);468 static DECLCALLBACK(bool) drvHostBaseIsVisible(PPDMIMEDIA pInterface) 469 { 470 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 478 471 return pThis->fBiosVisible; 479 472 } 480 473 481 474 482 /** @copydoc PDMIBLOCKBIOS::pfnGetType */483 static DECLCALLBACK(PDMBLOCKTYPE) drvHostBaseBiosGetType(PPDMIBLOCKBIOS pInterface)484 {485 PDRVHOSTBASE pThis = PDMIBLOCKBIOS_2_DRVHOSTBASE(pInterface);486 return pThis->enmType;487 }488 489 490 475 491 476 /* -=-=-=-=- IMount -=-=-=-=- */ 492 493 /** @copydoc PDMIMOUNT::pfnMount */494 static DECLCALLBACK(int) drvHostBaseMount(PPDMIMOUNT pInterface, const char *pszFilename, const char *pszCoreDriver)495 {496 /* We're not mountable. */497 AssertMsgFailed(("drvHostBaseMount: This shouldn't be called!\n"));498 return VERR_PDM_MEDIA_MOUNTED;499 }500 501 477 502 478 /** @copydoc PDMIMOUNT::pfnUnmount */ … … 622 598 623 599 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 624 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCK, &pThis->IBlock); 625 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->fBiosVisible ? &pThis->IBlockBios : NULL); 600 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIA, &pThis->IMedia); 626 601 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, &pThis->IMount); 627 602 return NULL; … … 1887 1862 * @param enmType Device type. 1888 1863 */ 1889 int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, PDM BLOCKTYPE enmType)1864 int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, PDMMEDIATYPE enmType) 1890 1865 { 1891 1866 PDRVHOSTBASE pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTBASE); … … 1920 1895 pDrvIns->IBase.pfnQueryInterface = drvHostBaseQueryInterface; 1921 1896 1922 /* IBlock. */ 1923 pThis->IBlock.pfnRead = drvHostBaseRead; 1924 pThis->IBlock.pfnWrite = drvHostBaseWrite; 1925 pThis->IBlock.pfnFlush = drvHostBaseFlush; 1926 pThis->IBlock.pfnIsReadOnly = drvHostBaseIsReadOnly; 1927 pThis->IBlock.pfnGetSize = drvHostBaseGetSize; 1928 pThis->IBlock.pfnGetType = drvHostBaseGetType; 1929 pThis->IBlock.pfnGetUuid = drvHostBaseGetUuid; 1930 pThis->IBlock.pfnIoBufAlloc = drvHostBaseIoBufAlloc; 1931 pThis->IBlock.pfnIoBufFree = drvHostBaseIoBufFree; 1932 1933 /* IBlockBios. */ 1934 pThis->IBlockBios.pfnGetPCHSGeometry = drvHostBaseGetPCHSGeometry; 1935 pThis->IBlockBios.pfnSetPCHSGeometry = drvHostBaseSetPCHSGeometry; 1936 pThis->IBlockBios.pfnGetLCHSGeometry = drvHostBaseGetLCHSGeometry; 1937 pThis->IBlockBios.pfnSetLCHSGeometry = drvHostBaseSetLCHSGeometry; 1938 pThis->IBlockBios.pfnIsVisible = drvHostBaseIsVisible; 1939 pThis->IBlockBios.pfnGetType = drvHostBaseBiosGetType; 1897 /* IMedia. */ 1898 pThis->IMedia.pfnRead = drvHostBaseRead; 1899 pThis->IMedia.pfnWrite = drvHostBaseWrite; 1900 pThis->IMedia.pfnFlush = drvHostBaseFlush; 1901 pThis->IMedia.pfnIsReadOnly = drvHostBaseIsReadOnly; 1902 pThis->IMedia.pfnGetSize = drvHostBaseGetSize; 1903 pThis->IMedia.pfnGetType = drvHostBaseGetType; 1904 pThis->IMedia.pfnGetUuid = drvHostBaseGetUuid; 1905 pThis->IMedia.pfnIoBufAlloc = drvHostBaseIoBufAlloc; 1906 pThis->IMedia.pfnIoBufFree = drvHostBaseIoBufFree; 1907 pThis->IMedia.pfnBiosGetPCHSGeometry = drvHostBaseGetPCHSGeometry; 1908 pThis->IMedia.pfnBiosSetPCHSGeometry = drvHostBaseSetPCHSGeometry; 1909 pThis->IMedia.pfnBiosGetLCHSGeometry = drvHostBaseGetLCHSGeometry; 1910 pThis->IMedia.pfnBiosSetLCHSGeometry = drvHostBaseSetLCHSGeometry; 1911 pThis->IMedia.pfnBiosIsVisible = drvHostBaseIsVisible; 1940 1912 1941 1913 /* IMount. */ 1942 pThis->IMount.pfnMount = drvHostBaseMount;1943 1914 pThis->IMount.pfnUnmount = drvHostBaseUnmount; 1944 1915 pThis->IMount.pfnIsMounted = drvHostBaseIsMounted; … … 1950 1921 * Get the IBlockPort & IMountNotify interfaces of the above driver/device. 1951 1922 */ 1952 pThis->pDrv BlockPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIBLOCKPORT);1953 if (!pThis->pDrv BlockPort)1954 { 1955 AssertMsgFailed(("Configuration error: No blockport interface above!\n"));1923 pThis->pDrvMediaPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAPORT); 1924 if (!pThis->pDrvMediaPort) 1925 { 1926 AssertMsgFailed(("Configuration error: No media port interface above!\n")); 1956 1927 return VERR_PDM_MISSING_INTERFACE_ABOVE; 1957 1928 } … … 1985 1956 rc = CFGMR3QueryBool(pCfg, "ReadOnly", &pThis->fReadOnlyConfig); 1986 1957 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1987 pThis->fReadOnlyConfig = enmType == PDM BLOCKTYPE_DVD || enmType == PDMBLOCKTYPE_CDROM ? true : false;1958 pThis->fReadOnlyConfig = enmType == PDMMEDIATYPE_DVD || enmType == PDMMEDIATYPE_CDROM ? true : false; 1988 1959 else if (RT_FAILURE(rc)) 1989 1960 { … … 2112 2083 switch (pThis->enmType) 2113 2084 { 2114 case PDM BLOCKTYPE_FLOPPY_360:2115 case PDM BLOCKTYPE_FLOPPY_720:2116 case PDM BLOCKTYPE_FLOPPY_1_20:2117 case PDM BLOCKTYPE_FLOPPY_1_44:2118 case PDM BLOCKTYPE_FLOPPY_2_88:2119 case PDM BLOCKTYPE_FLOPPY_FAKE_15_6:2120 case PDM BLOCKTYPE_FLOPPY_FAKE_63_5:2085 case PDMMEDIATYPE_FLOPPY_360: 2086 case PDMMEDIATYPE_FLOPPY_720: 2087 case PDMMEDIATYPE_FLOPPY_1_20: 2088 case PDMMEDIATYPE_FLOPPY_1_44: 2089 case PDMMEDIATYPE_FLOPPY_2_88: 2090 case PDMMEDIATYPE_FLOPPY_FAKE_15_6: 2091 case PDMMEDIATYPE_FLOPPY_FAKE_63_5: 2121 2092 if (uDriveType != DRIVE_REMOVABLE) 2122 2093 { … … 2126 2097 } 2127 2098 break; 2128 case PDM BLOCKTYPE_CDROM:2129 case PDM BLOCKTYPE_DVD:2099 case PDMMEDIATYPE_CDROM: 2100 case PDMMEDIATYPE_DVD: 2130 2101 if (uDriveType != DRIVE_CDROM) 2131 2102 { … … 2135 2106 } 2136 2107 break; 2137 case PDM BLOCKTYPE_HARD_DISK:2108 case PDMMEDIATYPE_HARD_DISK: 2138 2109 default: 2139 2110 AssertMsgFailed(("enmType=%d\n", pThis->enmType)); … … 2171 2142 * "media" - actually a complete drive in this case. 2172 2143 */ 2173 pThis->I Block.pfnSendCmd = NULL;2144 pThis->IMedia.pfnSendCmd = NULL; 2174 2145 AssertMsgFailed(("Could not open host device %s, rc=%Rrc\n", pszDevice, rc)); 2175 2146 switch (rc) -
trunk/src/VBox/Devices/Storage/DrvHostBase.h
r56292 r59248 41 41 PPDMDRVINS pDrvIns; 42 42 /** Drive type. */ 43 PDM BLOCKTYPE enmType;43 PDMMEDIATYPE enmType; 44 44 /** Visible to the BIOS. */ 45 45 bool fBiosVisible; … … 64 64 65 65 /** Pointer to the block port interface above us. */ 66 PPDMI BLOCKPORT pDrvBlockPort;66 PPDMIMEDIAPORT pDrvMediaPort; 67 67 /** Pointer to the mount notify interface above us. */ 68 68 PPDMIMOUNTNOTIFY pDrvMountNotify; 69 /** Our block interface. */ 70 PDMIBLOCK IBlock; 71 /** Our block interface. */ 72 PDMIBLOCKBIOS IBlockBios; 69 /** Our media interface. */ 70 PDMIMEDIA IMedia; 73 71 /** Our mountable interface. */ 74 72 PDMIMOUNT IMount; … … 181 179 182 180 183 int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, PDM BLOCKTYPE enmType);181 int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, PDMMEDIATYPE enmType); 184 182 int DRVHostBaseInitFinish(PDRVHOSTBASE pThis); 185 183 int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis); … … 195 193 #define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) ) 196 194 197 /** Makes a PDRVHOSTBASE out of a PPDMI BLOCK. */198 #define PDMI BLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )195 /** Makes a PDRVHOSTBASE out of a PPDMIMEDIA. */ 196 #define PDMIMEDIA_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMedia)) ) 199 197 200 198 RT_C_DECLS_END -
trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
r57442 r59248 151 151 0,0,0,0,0,0,0,0,0,0 152 152 }; 153 rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDM BLOCKTXDIR_NONE, NULL, NULL, NULL, 0, 0);153 rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMMEDIATXDIR_NONE, NULL, NULL, NULL, 0, 0); 154 154 155 155 #elif defined(RT_OS_LINUX) … … 241 241 0,0,0,0,0,0,0,0,0,0 242 242 }; 243 int rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDM BLOCKTXDIR_NONE, NULL, NULL, NULL, 0, 0);243 int rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMMEDIATXDIR_NONE, NULL, NULL, NULL, 0, 0); 244 244 245 245 #elif defined(RT_OS_LINUX) … … 335 335 uint8_t abCmd[16] = { SCSI_TEST_UNIT_READY, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; 336 336 uint8_t abSense[32]; 337 int rc2 = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDM BLOCKTXDIR_NONE, NULL, NULL, abSense, sizeof(abSense), 0);337 int rc2 = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMMEDIATXDIR_NONE, NULL, NULL, abSense, sizeof(abSense), 0); 338 338 if (RT_SUCCESS(rc2)) 339 339 fMediaPresent = true; … … 414 414 415 415 416 /** @copydoc PDMI BLOCK::pfnSendCmd */417 static DECLCALLBACK(int) drvHostDvdSendCmd(PPDMI BLOCKpInterface, const uint8_t *pbCmd,418 PDM BLOCKTXDIR enmTxDir, void *pvBuf, uint32_t *pcbBuf,416 /** @copydoc PDMIMEDIA::pfnSendCmd */ 417 static DECLCALLBACK(int) drvHostDvdSendCmd(PPDMIMEDIA pInterface, const uint8_t *pbCmd, 418 PDMMEDIATXDIR enmTxDir, void *pvBuf, uint32_t *pcbBuf, 419 419 uint8_t *pabSense, size_t cbSense, uint32_t cTimeoutMillies) 420 420 { 421 PDRVHOSTBASE pThis = PDMI BLOCK_2_DRVHOSTBASE(pInterface);421 PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface); 422 422 int rc; 423 423 LogFlow(("%s: cmd[0]=%#04x txdir=%d pcbBuf=%d timeout=%d\n", __FUNCTION__, pbCmd[0], enmTxDir, *pcbBuf, cTimeoutMillies)); … … 428 428 * The command seems to be 12 bytes long, the docs a bit copy&pasty on the command length point... 429 429 */ 430 if (enmTxDir == PDM BLOCKTXDIR_FROM_DEVICE)430 if (enmTxDir == PDMMEDIATXDIR_FROM_DEVICE) 431 431 memset(pvBuf, '\0', *pcbBuf); /* we got read size, but zero it anyway. */ 432 rc = DRVHostBaseScsiCmd(pThis, pbCmd, 12, PDM BLOCKTXDIR_FROM_DEVICE, pvBuf, pcbBuf, pabSense, cbSense, cTimeoutMillies);432 rc = DRVHostBaseScsiCmd(pThis, pbCmd, 12, PDMMEDIATXDIR_FROM_DEVICE, pvBuf, pcbBuf, pabSense, cbSense, cTimeoutMillies); 433 433 if (rc == VERR_UNRESOLVED_ERROR) 434 434 /* sense information set */ … … 441 441 switch (enmTxDir) 442 442 { 443 case PDM BLOCKTXDIR_NONE:443 case PDMMEDIATXDIR_NONE: 444 444 Assert(*pcbBuf == 0); 445 445 direction = CGC_DATA_NONE; 446 446 break; 447 case PDM BLOCKTXDIR_FROM_DEVICE:447 case PDMMEDIATXDIR_FROM_DEVICE: 448 448 Assert(*pcbBuf != 0); 449 449 Assert(*pcbBuf <= SCSI_MAX_BUFFER_SIZE); … … 458 458 direction = CGC_DATA_READ; 459 459 break; 460 case PDM BLOCKTXDIR_TO_DEVICE:460 case PDMMEDIATXDIR_TO_DEVICE: 461 461 Assert(*pcbBuf != 0); 462 462 Assert(*pcbBuf <= SCSI_MAX_BUFFER_SIZE); … … 495 495 switch (enmTxDir) 496 496 { 497 case PDM BLOCKTXDIR_FROM_DEVICE:497 case PDMMEDIATXDIR_FROM_DEVICE: 498 498 memcpy(pvBuf, pThis->pbDoubleBuffer, *pcbBuf); 499 499 break; … … 514 514 switch (enmTxDir) 515 515 { 516 case PDM BLOCKTXDIR_NONE:516 case PDMMEDIATXDIR_NONE: 517 517 Assert(*pcbBuf == 0); 518 518 usc.uscsi_flags = USCSI_READ; … … 520 520 break; 521 521 522 case PDM BLOCKTXDIR_FROM_DEVICE:522 case PDMMEDIATXDIR_FROM_DEVICE: 523 523 Assert(*pcbBuf != 0); 524 524 /* Make sure that the buffer is clear for commands reading … … 532 532 usc.uscsi_flags = USCSI_READ; 533 533 break; 534 case PDM BLOCKTXDIR_TO_DEVICE:534 case PDMMEDIATXDIR_TO_DEVICE: 535 535 Assert(*pcbBuf != 0); 536 536 usc.uscsi_flags = USCSI_WRITE; … … 581 581 switch (enmTxDir) 582 582 { 583 case PDM BLOCKTXDIR_NONE:583 case PDMMEDIATXDIR_NONE: 584 584 direction = SCSI_IOCTL_DATA_UNSPECIFIED; 585 585 break; 586 case PDM BLOCKTXDIR_FROM_DEVICE:586 case PDMMEDIATXDIR_FROM_DEVICE: 587 587 Assert(*pcbBuf != 0); 588 588 /* Make sure that the buffer is clear for commands reading … … 596 596 direction = SCSI_IOCTL_DATA_IN; 597 597 break; 598 case PDM BLOCKTXDIR_TO_DEVICE:598 case PDMMEDIATXDIR_TO_DEVICE: 599 599 direction = SCSI_IOCTL_DATA_OUT; 600 600 break; … … 754 754 * Init instance data. 755 755 */ 756 int rc = DRVHostBaseInitData(pDrvIns, pCfg, PDM BLOCKTYPE_DVD);756 int rc = DRVHostBaseInitData(pDrvIns, pCfg, PDMMEDIATYPE_DVD); 757 757 if (RT_SUCCESS(rc)) 758 758 { … … 775 775 if (RT_SUCCESS(rc) && fPassthrough) 776 776 { 777 pThis->I Block.pfnSendCmd = drvHostDvdSendCmd;777 pThis->IMedia.pfnSendCmd = drvHostDvdSendCmd; 778 778 /* Passthrough requires opening the device in R/W mode. */ 779 779 pThis->fReadOnlyConfig = false; -
trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp
r57358 r59248 188 188 * Init instance data. 189 189 */ 190 int rc = DRVHostBaseInitData(pDrvIns, pCfg, PDM BLOCKTYPE_FLOPPY_1_44);190 int rc = DRVHostBaseInitData(pDrvIns, pCfg, PDMMEDIATYPE_FLOPPY_1_44); 191 191 if (RT_SUCCESS(rc)) 192 192 { -
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r59152 r59248 44 44 * 45 45 * @implements PDMISCSICONNECTOR 46 * @implements PDMI BLOCKASYNCPORT46 * @implements PDMIMEDIAASYNCPORT 47 47 * @implements PDMIMOUNTNOTIFY 48 48 */ … … 55 55 PPDMIBASE pDrvBase; 56 56 /** Pointer to the attached driver's block interface. */ 57 PPDMI BLOCK pDrvBlock;57 PPDMIMEDIA pDrvMedia; 58 58 /** Pointer to the attached driver's async block interface. */ 59 PPDMIBLOCKASYNC pDrvBlockAsync; 60 /** Pointer to the attached driver's block bios interface. */ 61 PPDMIBLOCKBIOS pDrvBlockBios; 59 PPDMIMEDIAASYNC pDrvMediaAsync; 62 60 /** Pointer to the attached driver's mount interface. */ 63 61 PPDMIMOUNT pDrvMount; … … 68 66 /** The scsi connector interface .*/ 69 67 PDMISCSICONNECTOR ISCSIConnector; 70 /** The blockport interface. */71 PDMI BLOCKPORT IPort;72 /** The optional blockasync port interface. */73 PDMI BLOCKASYNCPORT IPortAsync;68 /** The media port interface. */ 69 PDMIMEDIAPORT IPort; 70 /** The optional media async port interface. */ 71 PDMIMEDIAASYNCPORT IPortAsync; 74 72 /** The mount notify interface. */ 75 73 PDMIMOUNTNOTIFY IMountNotify; … … 113 111 #define PDMISCSICONNECTOR_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, ISCSIConnector)) ) 114 112 /** Converts a pointer to DRVSCSI::IPortAsync to a PDRVSCSI. */ 115 #define PDMI BLOCKASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )113 #define PDMIMEDIAASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) ) 116 114 /** Converts a pointer to DRVSCSI::IMountNotify to PDRVSCSI. */ 117 115 #define PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IMountNotify)) ) 118 116 /** Converts a pointer to DRVSCSI::IPort to a PDRVSCSI. */ 119 #define PDMI BLOCKPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )117 #define PDMIMEDIAPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) ) 120 118 121 119 static bool drvscsiIsRedoPossible(int rc) … … 142 140 case VSCSIIOREQTXDIR_FLUSH: 143 141 { 144 rc = pThis->pDrv Block->pfnFlush(pThis->pDrvBlock);142 rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia); 145 143 if ( RT_FAILURE(rc) 146 144 && pThis->cErrors++ < MAX_LOG_REL_ERRORS) … … 171 169 { 172 170 pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1; 173 rc = pThis->pDrv Block->pfnRead(pThis->pDrvBlock, uOffset,171 rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, uOffset, 174 172 paSeg->pvSeg, cbProcess); 175 173 pThis->pLed->Actual.s.fReading = 0; … … 181 179 { 182 180 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 183 rc = pThis->pDrv Block->pfnWrite(pThis->pDrvBlock, uOffset,181 rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, uOffset, 184 182 paSeg->pvSeg, cbProcess); 185 183 pThis->pLed->Actual.s.fWriting = 0; … … 217 215 218 216 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 219 rc = pThis->pDrv Block->pfnDiscard(pThis->pDrvBlock, paRanges, cRanges);217 rc = pThis->pDrvMedia->pfnDiscard(pThis->pDrvMedia, paRanges, cRanges); 220 218 pThis->pLed->Actual.s.fWriting = 0; 221 219 … … 243 241 PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser; 244 242 245 *pcbSize = pThis->pDrv Block->pfnGetSize(pThis->pDrvBlock);243 *pcbSize = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia); 246 244 247 245 return VINF_SUCCESS; … … 253 251 PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser; 254 252 255 *pcbSectorSize = pThis->pDrv Block->pfnGetSectorSize(pThis->pDrvBlock);253 *pcbSectorSize = pThis->pDrvMedia->pfnGetSectorSize(pThis->pDrvMedia); 256 254 257 255 return VINF_SUCCESS; … … 269 267 } 270 268 271 static DECLCALLBACK(int) drvscsiTransferCompleteNotify(PPDMI BLOCKASYNCPORT pInterface, void *pvUser, int rc)272 { 273 PDRVSCSI pThis = PDMI BLOCKASYNCPORT_2_DRVSCSI(pInterface);269 static DECLCALLBACK(int) drvscsiTransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rc) 270 { 271 PDRVSCSI pThis = PDMIMEDIAASYNCPORT_2_DRVSCSI(pInterface); 274 272 VSCSIIOREQ hVScsiIoReq = (VSCSIIOREQ)pvUser; 275 273 VSCSIIOREQTXDIR enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq); … … 332 330 PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser; 333 331 334 if (pThis->pDrv BlockAsync)332 if (pThis->pDrvMediaAsync) 335 333 { 336 334 /* async I/O path. */ … … 345 343 case VSCSIIOREQTXDIR_FLUSH: 346 344 { 347 rc = pThis->pDrv BlockAsync->pfnStartFlush(pThis->pDrvBlockAsync, hVScsiIoReq);345 rc = pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, hVScsiIoReq); 348 346 if ( RT_FAILURE(rc) 349 347 && rc != VERR_VD_ASYNC_IO_IN_PROGRESS … … 362 360 363 361 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 364 rc = pThis->pDrv BlockAsync->pfnStartDiscard(pThis->pDrvBlockAsync, paRanges, cRanges, hVScsiIoReq);362 rc = pThis->pDrvMediaAsync->pfnStartDiscard(pThis->pDrvMediaAsync, paRanges, cRanges, hVScsiIoReq); 365 363 if ( RT_FAILURE(rc) 366 364 && rc != VERR_VD_ASYNC_IO_IN_PROGRESS … … 386 384 { 387 385 pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1; 388 rc = pThis->pDrv BlockAsync->pfnStartRead(pThis->pDrvBlockAsync, uOffset,386 rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, uOffset, 389 387 paSeg, cSeg, cbTransfer, 390 388 hVScsiIoReq); … … 394 392 { 395 393 pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1; 396 rc = pThis->pDrv BlockAsync->pfnStartWrite(pThis->pDrvBlockAsync, uOffset,394 rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, uOffset, 397 395 paSeg, cSeg, cbTransfer, 398 396 hVScsiIoReq); … … 464 462 *pfFeatures = 0; 465 463 466 if ( pThis->pDrv Block->pfnDiscard467 || ( pThis->pDrv BlockAsync468 && pThis->pDrv BlockAsync->pfnStartDiscard))464 if ( pThis->pDrvMedia->pfnDiscard 465 || ( pThis->pDrvMediaAsync 466 && pThis->pDrvMediaAsync->pfnStartDiscard)) 469 467 *pfFeatures |= VSCSI_LUN_FEATURE_UNMAP; 470 468 … … 682 680 683 681 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount); 684 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->pDrvBlockBios);685 682 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 686 683 PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector); 687 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKPORT, &pThis->IPort);684 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pThis->IPort); 688 685 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pThis->IMountNotify); 689 PDMIBASE_RETURN_INTERFACE(pszIID, PDMI BLOCKASYNCPORT, &pThis->IPortAsync);686 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNCPORT, &pThis->IPortAsync); 690 687 return NULL; 691 688 } 692 689 693 static DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMI BLOCKPORT pInterface, const char **ppcszController,690 static DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMIMEDIAPORT pInterface, const char **ppcszController, 694 691 uint32_t *piInstance, uint32_t *piLUN) 695 692 { 696 PDRVSCSI pThis = PDMI BLOCKPORT_2_DRVSCSI(pInterface);693 PDRVSCSI pThis = PDMIMEDIAPORT_2_DRVSCSI(pInterface); 697 694 698 695 return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController, … … 711 708 712 709 /* Ignore the call if we're called while being attached. */ 713 if (!pThis->pDrv Block)710 if (!pThis->pDrvMedia) 714 711 return; 715 712 … … 742 739 PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI); 743 740 744 if (!pThis->pDrv BlockAsync)741 if (!pThis->pDrvMediaAsync) 745 742 { 746 743 if (pThis->hQueueRequests != NIL_RTREQQUEUE) … … 790 787 PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI); 791 788 792 if (pThis->pDrv BlockAsync)789 if (pThis->pDrvMediaAsync) 793 790 { 794 791 if (pThis->StatIoDepth > 0) … … 833 830 PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI); 834 831 835 if (pThis->pDrv BlockAsync)832 if (pThis->pDrvMediaAsync) 836 833 { 837 834 if (pThis->StatIoDepth > 0) … … 967 964 * Query the block and blockbios interfaces. 968 965 */ 969 pThis->pDrv Block = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCK);970 if (!pThis->pDrv Block)966 pThis->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIA); 967 if (!pThis->pDrvMedia) 971 968 { 972 969 AssertMsgFailed(("Configuration error: No block interface!\n")); 973 970 return VERR_PDM_MISSING_INTERFACE; 974 971 } 975 pThis->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKBIOS);976 if (!pThis->pDrvBlockBios)977 {978 AssertMsgFailed(("Configuration error: No block BIOS interface!\n"));979 return VERR_PDM_MISSING_INTERFACE;980 }981 972 982 973 pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT); 983 974 984 975 /* Try to get the optional async block interface. */ 985 pThis->pDrv BlockAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKASYNC);986 987 PDM BLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);976 pThis->pDrvMediaAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIAASYNC); 977 978 PDMMEDIATYPE enmType = pThis->pDrvMedia->pfnGetType(pThis->pDrvMedia); 988 979 VSCSILUNTYPE enmLunType; 989 980 switch (enmType) 990 981 { 991 case PDM BLOCKTYPE_HARD_DISK:982 case PDMMEDIATYPE_HARD_DISK: 992 983 enmLunType = VSCSILUNTYPE_SBC; 993 984 break; 994 case PDM BLOCKTYPE_CDROM:995 case PDM BLOCKTYPE_DVD:985 case PDMMEDIATYPE_CDROM: 986 case PDMMEDIATYPE_DVD: 996 987 enmLunType = VSCSILUNTYPE_MMC; 997 988 break; … … 1001 992 enmType); 1002 993 } 1003 if ( ( enmType == PDM BLOCKTYPE_DVD1004 || enmType == PDM BLOCKTYPE_CDROM)994 if ( ( enmType == PDMMEDIATYPE_DVD 995 || enmType == PDMMEDIATYPE_CDROM) 1005 996 && !pThis->pDrvMount) 1006 997 { … … 1028 1019 if (pThis->pDrvMount) 1029 1020 { 1030 if (pThis->pDrv Block->pfnGetSize(pThis->pDrvBlock))1021 if (pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia)) 1031 1022 { 1032 1023 rc = VINF_SUCCESS; VSCSILunMountNotify(pThis->hVScsiLun); … … 1061 1052 pThis->StatIoDepth = 0; 1062 1053 1063 if (!pThis->pDrv BlockAsync)1054 if (!pThis->pDrvMediaAsync) 1064 1055 { 1065 1056 /* Create request queue. */ … … 1076 1067 LogRel(("SCSI#%d: using async I/O\n", pDrvIns->iInstance)); 1077 1068 1078 if ( pThis->pDrv Block->pfnDiscard1079 || ( pThis->pDrv BlockAsync1080 && pThis->pDrv BlockAsync->pfnStartDiscard))1069 if ( pThis->pDrvMedia->pfnDiscard 1070 || ( pThis->pDrvMediaAsync 1071 && pThis->pDrvMediaAsync->pfnStartDiscard)) 1081 1072 LogRel(("SCSI#%d: Enabled UNMAP support\n", pDrvIns->iInstance)); 1082 1073 -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r58132 r59248 62 62 63 63 64 /** @def VBOX_PERIODIC_FLUSH 65 * Enable support for periodically flushing the VDI to disk. This may prove 66 * useful for those nasty problems with the ultra-slow host filesystems. 67 * If this is enabled, it can be configured via the CFGM key 68 * "VBoxInternal/Devices/piix3ide/0/LUN#<x>/Config/FlushInterval". <x> 69 * must be replaced with the correct LUN number of the disk that should 70 * do the periodic flushes. The value of the key is the number of bytes 71 * written between flushes. A value of 0 (the default) denotes no flushes. */ 72 #define VBOX_PERIODIC_FLUSH 73 74 /** @def VBOX_IGNORE_FLUSH 75 * Enable support for ignoring VDI flush requests. This can be useful for 76 * filesystems that show bad guest IDE write performance (especially with 77 * Windows guests). NOTE that this does not disable the flushes caused by 78 * the periodic flush cache feature above. 79 * If this feature is enabled, it can be configured via the CFGM key 80 * "VBoxInternal/Devices/piix3ide/0/LUN#<x>/Config/IgnoreFlush". <x> 81 * must be replaced with the correct LUN number of the disk that should 82 * ignore flush requests. The value of the key is a boolean. The default 83 * is to ignore flushes, i.e. true. */ 84 #define VBOX_IGNORE_FLUSH 85 64 86 /********************************************************************************************************************************* 65 87 * Defined types, constants and macros * … … 116 138 * @implements PDMIMEDIA 117 139 * @implements PDMIMEDIAASYNC 140 * @implements PDMIMOUNT 118 141 * @implements VDINTERFACEERROR 119 142 * @implements VDINTERFACETCPNET … … 192 215 HBDMGR hHbdMgr; 193 216 217 /** Drive type. */ 218 PDMMEDIATYPE enmType; 219 /** Locked indicator. */ 220 bool fLocked; 221 /** Mountable indicator. */ 222 bool fMountable; 223 /** Visible to the BIOS. */ 224 bool fBiosVisible; 225 #ifdef VBOX_PERIODIC_FLUSH 226 /** HACK: Configuration value for number of bytes written after which to flush. */ 227 uint32_t cbFlushInterval; 228 /** HACK: Current count for the number of bytes written since the last flush. */ 229 uint32_t cbDataWritten; 230 #endif /* VBOX_PERIODIC_FLUSH */ 231 #ifdef VBOX_IGNORE_FLUSH 232 /** HACK: Disable flushes for this drive. */ 233 bool fIgnoreFlush; 234 /** Disable async flushes for this drive. */ 235 bool fIgnoreFlushAsync; 236 #endif /* VBOX_IGNORE_FLUSH */ 237 /** Our mountable interface. */ 238 PDMIMOUNT IMount; 239 /** Pointer to the mount notify interface above us. */ 240 PPDMIMOUNTNOTIFY pDrvMountNotify; 241 /** Uuid of the drive. */ 242 RTUUID Uuid; 243 /** BIOS PCHS Geometry. */ 244 PDMMEDIAGEOMETRY PCHSGeometry; 245 /** BIOS LCHS Geometry. */ 246 PDMMEDIAGEOMETRY LCHSGeometry; 247 194 248 /** Cryptographic support 195 249 * @{ */ … … 256 310 { 257 311 int rc = VINF_SUCCESS; 258 if (!VDIsReadOnly(pThis->pDisk)) 312 if ( pThis->pDisk 313 && !VDIsReadOnly(pThis->pDisk)) 259 314 { 260 315 unsigned uOpenFlags; … … 1643 1698 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1644 1699 1700 /* 1701 * Check the state. 1702 */ 1703 if (!pThis->pDisk) 1704 { 1705 AssertMsgFailed(("Invalid state! Not mounted!\n")); 1706 return VERR_PDM_MEDIA_NOT_MOUNTED; 1707 } 1708 1645 1709 rc = drvvdKeyCheckPrereqs(pThis); 1646 1710 if (RT_FAILURE(rc)) … … 1697 1761 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1698 1762 1763 /* 1764 * Check the state. 1765 */ 1766 if (!pThis->pDisk) 1767 { 1768 AssertMsgFailed(("Invalid state! Not mounted!\n")); 1769 return VERR_PDM_MEDIA_NOT_MOUNTED; 1770 } 1771 1699 1772 if ( pThis->pCfgCrypto 1700 1773 && !pThis->pIfSecKey) … … 1753 1826 off, pvBuf, cbWrite, cbWrite, pvBuf)); 1754 1827 1828 /* 1829 * Check the state. 1830 */ 1831 if (!pThis->pDisk) 1832 { 1833 AssertMsgFailed(("Invalid state! Not mounted!\n")); 1834 return VERR_PDM_MEDIA_NOT_MOUNTED; 1835 } 1836 1837 /* Set an FTM checkpoint as this operation changes the state permanently. */ 1838 PDMDrvHlpFTSetCheckpoint(pThis->pDrvIns, FTMCHECKPOINTTYPE_STORAGE); 1839 1755 1840 int rc = drvvdKeyCheckPrereqs(pThis); 1756 1841 if (RT_FAILURE(rc)) … … 1765 1850 1766 1851 rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite); 1852 #ifdef VBOX_PERIODIC_FLUSH 1853 if (pThis->cbFlushInterval) 1854 { 1855 pThis->cbDataWritten += (uint32_t)cbWrite; 1856 if (pThis->cbDataWritten > pThis->cbFlushInterval) 1857 { 1858 pThis->cbDataWritten = 0; 1859 VDFlush(pThis->pDisk); 1860 } 1861 } 1862 #endif /* VBOX_PERIODIC_FLUSH */ 1863 1767 1864 LogFlowFunc(("returns %Rrc\n", rc)); 1768 1865 return rc; … … 1774 1871 LogFlowFunc(("\n")); 1775 1872 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1873 1874 /* 1875 * Check the state. 1876 */ 1877 if (!pThis->pDisk) 1878 { 1879 AssertMsgFailed(("Invalid state! Not mounted!\n")); 1880 return VERR_PDM_MEDIA_NOT_MOUNTED; 1881 } 1882 1883 #ifdef VBOX_IGNORE_FLUSH 1884 if (pThis->fIgnoreFlush) 1885 return VINF_SUCCESS; 1886 #endif /* VBOX_IGNORE_FLUSH */ 1887 1776 1888 int rc = VDFlush(pThis->pDisk); 1777 1889 LogFlowFunc(("returns %Rrc\n", rc)); … … 1787 1899 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1788 1900 int rc = VINF_SUCCESS; 1901 1902 /* 1903 * Check the state. 1904 */ 1905 if (!pThis->pDisk) 1906 { 1907 AssertMsgFailed(("Invalid state! Not mounted!\n")); 1908 return VERR_PDM_MEDIA_NOT_MOUNTED; 1909 } 1789 1910 1790 1911 /* Note: There is an unavoidable race between destruction and another … … 1868 1989 LogFlowFunc(("\n")); 1869 1990 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1991 1992 /* 1993 * Check the state. 1994 */ 1995 if (!pThis->pDisk) 1996 return 0; 1997 1870 1998 uint64_t cb = VDGetSize(pThis->pDisk, VD_LAST_IMAGE); 1871 1999 LogFlowFunc(("returns %#llx (%llu)\n", cb, cb)); … … 1878 2006 LogFlowFunc(("\n")); 1879 2007 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 2008 2009 /* 2010 * Check the state. 2011 */ 2012 if (!pThis->pDisk) 2013 return 0; 2014 1880 2015 uint32_t cb = VDGetSectorSize(pThis->pDisk, VD_LAST_IMAGE); 1881 2016 LogFlowFunc(("returns %u\n", cb)); … … 1888 2023 LogFlowFunc(("\n")); 1889 2024 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 2025 2026 /* 2027 * Check the state. 2028 */ 2029 if (!pThis->pDisk) 2030 return false; 2031 1890 2032 bool f = VDIsReadOnly(pThis->pDisk); 1891 2033 LogFlowFunc(("returns %d\n", f)); … … 1900 2042 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1901 2043 VDGEOMETRY geo; 2044 2045 /* 2046 * Check the state. 2047 */ 2048 if (!pThis->pDisk) 2049 return VERR_PDM_MEDIA_NOT_MOUNTED; 2050 2051 /* 2052 * Use configured/cached values if present. 2053 */ 2054 if ( pThis->PCHSGeometry.cCylinders > 0 2055 && pThis->PCHSGeometry.cHeads > 0 2056 && pThis->PCHSGeometry.cSectors > 0) 2057 { 2058 *pPCHSGeometry = pThis->PCHSGeometry; 2059 LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors)); 2060 return VINF_SUCCESS; 2061 } 2062 1902 2063 int rc = VDGetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, &geo); 1903 2064 if (RT_SUCCESS(rc)) … … 1906 2067 pPCHSGeometry->cHeads = geo.cHeads; 1907 2068 pPCHSGeometry->cSectors = geo.cSectors; 2069 pThis->PCHSGeometry = *pPCHSGeometry; 1908 2070 } 1909 2071 else … … 1925 2087 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1926 2088 VDGEOMETRY geo; 2089 2090 /* 2091 * Check the state. 2092 */ 2093 if (!pThis->pDisk) 2094 { 2095 AssertMsgFailed(("Invalid state! Not mounted!\n")); 2096 return VERR_PDM_MEDIA_NOT_MOUNTED; 2097 } 2098 1927 2099 geo.cCylinders = pPCHSGeometry->cCylinders; 1928 2100 geo.cHeads = pPCHSGeometry->cHeads; … … 1931 2103 if (rc == VERR_VD_GEOMETRY_NOT_SET) 1932 2104 rc = VERR_PDM_GEOMETRY_NOT_SET; 2105 if (RT_SUCCESS(rc)) 2106 pThis->PCHSGeometry = *pPCHSGeometry; 1933 2107 LogFlowFunc(("returns %Rrc\n", rc)); 1934 2108 return rc; … … 1942 2116 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1943 2117 VDGEOMETRY geo; 2118 2119 /* 2120 * Check the state. 2121 */ 2122 if (!pThis->pDisk) 2123 return VERR_PDM_MEDIA_NOT_MOUNTED; 2124 2125 /* 2126 * Use configured/cached values if present. 2127 */ 2128 if ( pThis->LCHSGeometry.cCylinders > 0 2129 && pThis->LCHSGeometry.cHeads > 0 2130 && pThis->LCHSGeometry.cSectors > 0) 2131 { 2132 *pLCHSGeometry = pThis->LCHSGeometry; 2133 LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors)); 2134 return VINF_SUCCESS; 2135 } 2136 1944 2137 int rc = VDGetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, &geo); 1945 2138 if (RT_SUCCESS(rc)) … … 1948 2141 pLCHSGeometry->cHeads = geo.cHeads; 1949 2142 pLCHSGeometry->cSectors = geo.cSectors; 2143 pThis->LCHSGeometry = *pLCHSGeometry; 1950 2144 } 1951 2145 else … … 1967 2161 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1968 2162 VDGEOMETRY geo; 2163 2164 /* 2165 * Check the state. 2166 */ 2167 if (!pThis->pDisk) 2168 { 2169 AssertMsgFailed(("Invalid state! Not mounted!\n")); 2170 return VERR_PDM_MEDIA_NOT_MOUNTED; 2171 } 2172 1969 2173 geo.cCylinders = pLCHSGeometry->cCylinders; 1970 2174 geo.cHeads = pLCHSGeometry->cHeads; … … 1973 2177 if (rc == VERR_VD_GEOMETRY_NOT_SET) 1974 2178 rc = VERR_PDM_GEOMETRY_NOT_SET; 2179 if (RT_SUCCESS(rc)) 2180 pThis->LCHSGeometry = *pLCHSGeometry; 1975 2181 LogFlowFunc(("returns %Rrc\n", rc)); 1976 2182 return rc; 1977 2183 } 1978 2184 2185 /** @interface_method_impl{PDMIMEDIA,pfnBiosIsVisible} */ 2186 static DECLCALLBACK(bool) drvvdBiosIsVisible(PPDMIMEDIA pInterface) 2187 { 2188 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 2189 LogFlow(("drvvdBiosIsVisible: returns %d\n", pThis->fBiosVisible)); 2190 return pThis->fBiosVisible; 2191 } 2192 2193 /** @interface_method_impl{PDMIMEDIA,pfnGetType} */ 2194 static DECLCALLBACK(PDMMEDIATYPE) drvvdGetType(PPDMIMEDIA pInterface) 2195 { 2196 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 2197 LogFlow(("drvvdBiosIsVisible: returns %d\n", pThis->fBiosVisible)); 2198 return pThis->enmType; 2199 } 2200 1979 2201 /** @interface_method_impl{PDMIMEDIA,pfnGetUuid} */ 1980 2202 static DECLCALLBACK(int) drvvdGetUuid(PPDMIMEDIA pInterface, PRTUUID pUuid) … … 1982 2204 LogFlowFunc(("\n")); 1983 2205 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1984 int rc = VDGetUuid(pThis->pDisk, 0, pUuid); 1985 LogFlowFunc(("returns %Rrc ({%RTuuid})\n", rc, pUuid)); 1986 return rc; 2206 2207 /* 2208 * Copy the uuid. 2209 */ 2210 *pUuid = pThis->Uuid; 2211 LogFlowFunc(("returns {%RTuuid}\n", pUuid)); 2212 return VINF_SUCCESS; 1987 2213 } 1988 2214 … … 2044 2270 2045 2271 2272 /* -=-=-=-=- IMount -=-=-=-=- */ 2273 2274 /** @copydoc PDMIMOUNT::pfnUnmount */ 2275 static DECLCALLBACK(int) drvvdUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject) 2276 { 2277 PVBOXDISK pThis = RT_FROM_MEMBER(pInterface, VBOXDISK, IMount); 2278 2279 /* 2280 * Validate state. 2281 */ 2282 if (!pThis->pDisk) 2283 { 2284 Log(("drvvdUnmount: Not mounted\n")); 2285 return VERR_PDM_MEDIA_NOT_MOUNTED; 2286 } 2287 if (pThis->fLocked && !fForce) 2288 { 2289 Log(("drvvdUnmount: Locked\n")); 2290 return VERR_PDM_MEDIA_LOCKED; 2291 } 2292 2293 /* Media is no longer locked even if it was previously. */ 2294 pThis->fLocked = false; 2295 2296 /* 2297 * Notify driver/device above us. 2298 */ 2299 if (pThis->pDrvMountNotify) 2300 pThis->pDrvMountNotify->pfnUnmountNotify(pThis->pDrvMountNotify); 2301 Log(("drvblockUnmount: success\n")); 2302 return VINF_SUCCESS; 2303 } 2304 2305 2306 /** @copydoc PDMIMOUNT::pfnIsMounted */ 2307 static DECLCALLBACK(bool) drvvdIsMounted(PPDMIMOUNT pInterface) 2308 { 2309 PVBOXDISK pThis = RT_FROM_MEMBER(pInterface, VBOXDISK, IMount); 2310 return pThis->pDisk != NULL; 2311 } 2312 2313 /** @copydoc PDMIMOUNT::pfnLock */ 2314 static DECLCALLBACK(int) drvvdLock(PPDMIMOUNT pInterface) 2315 { 2316 PVBOXDISK pThis = RT_FROM_MEMBER(pInterface, VBOXDISK, IMount); 2317 Log(("drvblockLock: %d -> %d\n", pThis->fLocked, true)); 2318 pThis->fLocked = true; 2319 return VINF_SUCCESS; 2320 } 2321 2322 /** @copydoc PDMIMOUNT::pfnUnlock */ 2323 static DECLCALLBACK(int) drvvdUnlock(PPDMIMOUNT pInterface) 2324 { 2325 PVBOXDISK pThis = RT_FROM_MEMBER(pInterface, VBOXDISK, IMount); 2326 Log(("drvblockUnlock: %d -> %d\n", pThis->fLocked, false)); 2327 pThis->fLocked = false; 2328 return VINF_SUCCESS; 2329 } 2330 2331 /** @copydoc PDMIMOUNT::pfnIsLocked */ 2332 static DECLCALLBACK(bool) drvvdIsLocked(PPDMIMOUNT pInterface) 2333 { 2334 PVBOXDISK pThis = RT_FROM_MEMBER(pInterface, VBOXDISK, IMount); 2335 return pThis->fLocked; 2336 } 2337 2046 2338 /********************************************************************************************************************************* 2047 2339 * Async Media interface methods * … … 2070 2362 int rc = VINF_SUCCESS; 2071 2363 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 2364 2365 /* 2366 * Check the state. 2367 */ 2368 if (!pThis->pDisk) 2369 { 2370 AssertMsgFailed(("Invalid state! Not mounted!\n")); 2371 return VERR_PDM_MEDIA_NOT_MOUNTED; 2372 } 2072 2373 2073 2374 rc = drvvdKeyCheckPrereqs(pThis); … … 2104 2405 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 2105 2406 2407 /* 2408 * Check the state. 2409 */ 2410 if (!pThis->pDisk) 2411 { 2412 AssertMsgFailed(("Invalid state! Not mounted!\n")); 2413 return VERR_PDM_MEDIA_NOT_MOUNTED; 2414 } 2415 2106 2416 rc = drvvdKeyCheckPrereqs(pThis); 2107 2417 if (RT_FAILURE(rc)) … … 2135 2445 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 2136 2446 2447 /* 2448 * Check the state. 2449 */ 2450 if (!pThis->pDisk) 2451 { 2452 AssertMsgFailed(("Invalid state! Not mounted!\n")); 2453 return VERR_PDM_MEDIA_NOT_MOUNTED; 2454 } 2455 2456 #ifdef VBOX_IGNORE_FLUSH 2457 if (pThis->fIgnoreFlushAsync) 2458 return VINF_VD_ASYNC_IO_FINISHED; 2459 #endif /* VBOX_IGNORE_FLUSH */ 2460 2137 2461 if (!pThis->pBlkCache) 2138 2462 rc = VDAsyncFlush(pThis->pDisk, drvvdAsyncReqComplete, pThis, pvUser); … … 2157 2481 LogFlowFunc(("paRanges=%#p cRanges=%u pvUser=%#p\n", 2158 2482 paRanges, cRanges, pvUser)); 2483 2484 /* 2485 * Check the state. 2486 */ 2487 if (!pThis->pDisk) 2488 { 2489 AssertMsgFailed(("Invalid state! Not mounted!\n")); 2490 return VERR_PDM_MEDIA_NOT_MOUNTED; 2491 } 2159 2492 2160 2493 if (!pThis->pBlkCache) … … 2309 2642 2310 2643 2644 /** 2645 * Translates a PDMMEDIATYPE value into a string. 2646 * 2647 * @returns Read only string. 2648 * @param enmType The type value. 2649 */ 2650 static const char *drvvdGetTypeName(PDMMEDIATYPE enmType) 2651 { 2652 switch (enmType) 2653 { 2654 case PDMMEDIATYPE_ERROR: return "ERROR"; 2655 case PDMMEDIATYPE_FLOPPY_360: return "FLOPPY_360"; 2656 case PDMMEDIATYPE_FLOPPY_720: return "FLOPPY_720"; 2657 case PDMMEDIATYPE_FLOPPY_1_20: return "FLOPPY_1_20"; 2658 case PDMMEDIATYPE_FLOPPY_1_44: return "FLOPPY_1_44"; 2659 case PDMMEDIATYPE_FLOPPY_2_88: return "FLOPPY_2_88"; 2660 case PDMMEDIATYPE_FLOPPY_FAKE_15_6: return "FLOPPY_FAKE_15_6"; 2661 case PDMMEDIATYPE_FLOPPY_FAKE_63_5: return "FLOPPY_FAKE_63_5"; 2662 case PDMMEDIATYPE_CDROM: return "CDROM"; 2663 case PDMMEDIATYPE_DVD: return "DVD"; 2664 case PDMMEDIATYPE_HARD_DISK: return "HARD_DISK"; 2665 default: return "Unknown"; 2666 } 2667 } 2668 2669 /** 2670 * Returns the appropriate PDMMEDIATYPE for t he given string. 2671 * 2672 * @returns PDMMEDIATYPE 2673 * @param pszType The string representation of the media type. 2674 */ 2675 static PDMMEDIATYPE drvvdGetMediaTypeFromString(const char *pszType) 2676 { 2677 PDMMEDIATYPE enmType = PDMMEDIATYPE_ERROR; 2678 2679 if (!strcmp(pszType, "HardDisk")) 2680 enmType = PDMMEDIATYPE_HARD_DISK; 2681 else if (!strcmp(pszType, "DVD")) 2682 enmType = PDMMEDIATYPE_DVD; 2683 else if (!strcmp(pszType, "CDROM")) 2684 enmType = PDMMEDIATYPE_CDROM; 2685 else if (!strcmp(pszType, "Floppy 2.88")) 2686 enmType = PDMMEDIATYPE_FLOPPY_2_88; 2687 else if (!strcmp(pszType, "Floppy 1.44")) 2688 enmType = PDMMEDIATYPE_FLOPPY_1_44; 2689 else if (!strcmp(pszType, "Floppy 1.20")) 2690 enmType = PDMMEDIATYPE_FLOPPY_1_20; 2691 else if (!strcmp(pszType, "Floppy 720")) 2692 enmType = PDMMEDIATYPE_FLOPPY_720; 2693 else if (!strcmp(pszType, "Floppy 360")) 2694 enmType = PDMMEDIATYPE_FLOPPY_360; 2695 else if (!strcmp(pszType, "Floppy 15.6")) 2696 enmType = PDMMEDIATYPE_FLOPPY_FAKE_15_6; 2697 else if (!strcmp(pszType, "Floppy 63.5")) 2698 enmType = PDMMEDIATYPE_FLOPPY_FAKE_63_5; 2699 2700 return enmType; 2701 } 2702 2703 /** 2704 * Converts PDMMEDIATYPE to the appropriate VDTYPE. 2705 * 2706 * @returns The VDTYPE. 2707 * @param enmType The PDMMEDIATYPE to convert from. 2708 */ 2709 static VDTYPE drvvdGetVDFromMediaType(PDMMEDIATYPE enmType) 2710 { 2711 if (PDMMEDIATYPE_IS_FLOPPY(enmType)) 2712 return VDTYPE_FLOPPY; 2713 else if (enmType == PDMMEDIATYPE_DVD || enmType == PDMMEDIATYPE_CDROM) 2714 return VDTYPE_DVD; 2715 else if (enmType == PDMMEDIATYPE_HARD_DISK) 2716 return VDTYPE_HDD; 2717 2718 AssertMsgFailed(("Invalid media type %d{%s} given!\n", enmType, drvvdGetTypeName(enmType))); 2719 return VDTYPE_HDD; 2720 } 2721 2311 2722 /********************************************************************************************************************************* 2312 2723 * Base interface methods * … … 2323 2734 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 2324 2735 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIA, &pThis->IMedia); 2736 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->fMountable ? &pThis->IMount : NULL); 2325 2737 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNC, pThis->fAsyncIOSupported ? &pThis->IMediaAsync : NULL); 2326 2738 return NULL; … … 2593 3005 pThis->IMedia.pfnBiosGetLCHSGeometry = drvvdBiosGetLCHSGeometry; 2594 3006 pThis->IMedia.pfnBiosSetLCHSGeometry = drvvdBiosSetLCHSGeometry; 3007 pThis->IMedia.pfnBiosIsVisible = drvvdBiosIsVisible; 3008 pThis->IMedia.pfnGetType = drvvdGetType; 2595 3009 pThis->IMedia.pfnGetUuid = drvvdGetUuid; 2596 3010 pThis->IMedia.pfnDiscard = drvvdDiscard; 2597 3011 pThis->IMedia.pfnIoBufAlloc = drvvdIoBufAlloc; 2598 3012 pThis->IMedia.pfnIoBufFree = drvvdIoBufFree; 3013 pThis->IMedia.pfnSendCmd = NULL; 3014 3015 /* IMount */ 3016 pThis->IMount.pfnUnmount = drvvdUnmount; 3017 pThis->IMount.pfnIsMounted = drvvdIsMounted; 3018 pThis->IMount.pfnLock = drvvdLock; 3019 pThis->IMount.pfnUnlock = drvvdUnlock; 3020 pThis->IMount.pfnIsLocked = drvvdIsLocked; 2599 3021 2600 3022 /* IMediaAsync */ … … 2623 3045 /* Try to attach async media port interface above.*/ 2624 3046 pThis->pDrvMediaAsyncPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAASYNCPORT); 3047 pThis->pDrvMountNotify = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMOUNTNOTIFY); 2625 3048 2626 3049 /* Before we access any VD API load all given plugins. */ … … 2639 3062 bool fInformAboutZeroBlocks = false; 2640 3063 bool fSkipConsistencyChecks = false; 3064 bool fEmptyDrive = false; 2641 3065 unsigned iLevel = 0; 2642 3066 PCFGMNODE pCurNode = pCfg; 2643 VDTYPE enmType = VDTYPE_HDD;2644 3067 2645 3068 for (;;) … … 2657 3080 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0BlockCache\0" 2658 3081 "CachePath\0CacheFormat\0Discard\0InformAboutZeroBlocks\0" 2659 "SkipConsistencyChecks\0"); 3082 "SkipConsistencyChecks\0" 3083 "SubType\0Locked\0BIOSVisible\0Cylinders\0Heads\0Sectors\0Mountable\0" 3084 "EmptyDrive\0" 3085 #if defined(VBOX_PERIODIC_FLUSH) || defined(VBOX_IGNORE_FLUSH) 3086 "FlushInterval\0IgnoreFlush\0IgnoreFlushAsync\0" 3087 #endif /* !(VBOX_PERIODIC_FLUSH || VBOX_IGNORE_FLUSH) */ 3088 ); 2660 3089 } 2661 3090 else … … 2807 3236 } 2808 3237 2809 char *psz ;2810 3238 char *psz = NULL; 3239 rc = CFGMR3QueryStringAlloc(pCfg, "Type", &psz); 2811 3240 if (RT_FAILURE(rc)) 2812 { 2813 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type")); 2814 break; 2815 } 2816 else if (!strcmp(psz, "HardDisk")) 2817 enmType = VDTYPE_HDD; 2818 else if (!strcmp(psz, "DVD")) 2819 enmType = VDTYPE_DVD; 2820 else if (!strcmp(psz, "Floppy")) 2821 enmType = VDTYPE_FLOPPY; 2822 else 2823 { 2824 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS, 2825 N_("Unknown type \"%s\""), psz); 3241 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the sub type")); 3242 pThis->enmType = drvvdGetMediaTypeFromString(psz); 3243 if (pThis->enmType == PDMMEDIATYPE_ERROR) 3244 { 3245 PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS, 3246 N_("Unknown type \"%s\""), psz); 2826 3247 MMR3HeapFree(psz); 2827 break;3248 return VERR_PDM_BLOCK_UNKNOWN_TYPE; 2828 3249 } 2829 3250 MMR3HeapFree(psz); psz = NULL; … … 2849 3270 } 2850 3271 } 3272 3273 /* Mountable */ 3274 rc = CFGMR3QueryBoolDef(pCfg, "Mountable", &pThis->fMountable, false); 3275 if (RT_FAILURE(rc)) 3276 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Mountable\" from the config")); 3277 3278 /* Locked */ 3279 rc = CFGMR3QueryBoolDef(pCfg, "Locked", &pThis->fLocked, false); 3280 if (RT_FAILURE(rc)) 3281 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Locked\" from the config")); 3282 3283 /* BIOS visible */ 3284 rc = CFGMR3QueryBoolDef(pCfg, "BIOSVisible", &pThis->fBiosVisible, true); 3285 if (RT_FAILURE(rc)) 3286 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"BIOSVisible\" from the config")); 3287 3288 /* Cylinders */ 3289 rc = CFGMR3QueryU32Def(pCfg, "Cylinders", &pThis->LCHSGeometry.cCylinders, 0); 3290 if (RT_FAILURE(rc)) 3291 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Cylinders\" from the config")); 3292 3293 /* Heads */ 3294 rc = CFGMR3QueryU32Def(pCfg, "Heads", &pThis->LCHSGeometry.cHeads, 0); 3295 if (RT_FAILURE(rc)) 3296 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Heads\" from the config")); 3297 3298 /* Sectors */ 3299 rc = CFGMR3QueryU32Def(pCfg, "Sectors", &pThis->LCHSGeometry.cSectors, 0); 3300 if (RT_FAILURE(rc)) 3301 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Sectors\" from the config")); 3302 3303 /* Uuid */ 3304 rc = CFGMR3QueryStringAlloc(pCfg, "Uuid", &psz); 3305 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 3306 RTUuidClear(&pThis->Uuid); 3307 else if (RT_SUCCESS(rc)) 3308 { 3309 rc = RTUuidFromStr(&pThis->Uuid, psz); 3310 if (RT_FAILURE(rc)) 3311 { 3312 PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Uuid from string failed on \"%s\""), psz); 3313 MMR3HeapFree(psz); 3314 return rc; 3315 } 3316 MMR3HeapFree(psz); psz = NULL; 3317 } 3318 else 3319 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Uuid\" from the config")); 3320 3321 #ifdef VBOX_PERIODIC_FLUSH 3322 rc = CFGMR3QueryU32Def(pCfg, "FlushInterval", &pThis->cbFlushInterval, 0); 3323 if (RT_FAILURE(rc)) 3324 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"FlushInterval\" from the config")); 3325 #endif /* VBOX_PERIODIC_FLUSH */ 3326 3327 #ifdef VBOX_IGNORE_FLUSH 3328 rc = CFGMR3QueryBoolDef(pCfg, "IgnoreFlush", &pThis->fIgnoreFlush, true); 3329 if (RT_FAILURE(rc)) 3330 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlush\" from the config")); 3331 3332 if (pThis->fIgnoreFlush) 3333 LogRel(("DrvVD: Flushes will be ignored\n")); 3334 else 3335 LogRel(("DrvVD: Flushes will be passed to the disk\n")); 3336 3337 rc = CFGMR3QueryBoolDef(pCfg, "IgnoreFlushAsync", &pThis->fIgnoreFlushAsync, false); 3338 if (RT_FAILURE(rc)) 3339 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlushAsync\" from the config")); 3340 3341 if (pThis->fIgnoreFlushAsync) 3342 LogRel(("DrvVD: Async flushes will be ignored\n")); 3343 else 3344 LogRel(("DrvVD: Async flushes will be passed to the disk\n")); 3345 #endif /* VBOX_IGNORE_FLUSH */ 3346 3347 rc = CFGMR3QueryBoolDef(pCurNode, "EmptyDrive", &fEmptyDrive, false); 3348 if (RT_FAILURE(rc)) 3349 { 3350 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 3351 N_("DrvVD: Configuration error: Querying \"EmptyDrive\" as boolean failed")); 3352 break; 3353 } 2851 3354 } 2852 3355 … … 2858 3361 } 2859 3362 2860 /* 2861 * Create the image container and the necessary interfaces. 2862 */ 2863 if (RT_SUCCESS(rc)) 3363 if (!fEmptyDrive) 2864 3364 { 2865 3365 /* 2866 * The image has a bandwidth group but the host cache is enabled. 2867 * Use the async I/O framework but tell it to enable the host cache. 3366 * Create the image container and the necessary interfaces. 2868 3367 */ 2869 if (!fUseNewIo && pThis->pszBwGroup)2870 {2871 pThis->fAsyncIoWithHostCache = true;2872 fUseNewIo = true;2873 }2874 2875 /** @todo quick hack to work around problems in the async I/O2876 * implementation (rw semaphore thread ownership problem)2877 * while a merge is running. Remove once this is fixed. */2878 if (pThis->fMergePending)2879 fUseNewIo = false;2880 2881 if (RT_SUCCESS(rc) && pThis->fMergePending)2882 {2883 rc = RTSemFastMutexCreate(&pThis->MergeCompleteMutex);2884 if (RT_SUCCESS(rc))2885 rc = RTSemRWCreate(&pThis->MergeLock);2886 if (RT_SUCCESS(rc))2887 {2888 pThis->VDIfThreadSync.pfnStartRead = drvvdThreadStartRead;2889 pThis->VDIfThreadSync.pfnFinishRead = drvvdThreadFinishRead;2890 pThis->VDIfThreadSync.pfnStartWrite = drvvdThreadStartWrite;2891 pThis->VDIfThreadSync.pfnFinishWrite = drvvdThreadFinishWrite;2892 2893 rc = VDInterfaceAdd(&pThis->VDIfThreadSync.Core, "DrvVD_ThreadSync", VDINTERFACETYPE_THREADSYNC,2894 pThis, sizeof(VDINTERFACETHREADSYNC), &pThis->pVDIfsDisk);2895 }2896 else2897 {2898 rc = PDMDRV_SET_ERROR(pDrvIns, rc,2899 N_("DrvVD: Failed to create semaphores for \"MergePending\""));2900 }2901 }2902 2903 3368 if (RT_SUCCESS(rc)) 2904 3369 { 2905 rc = VDCreate(pThis->pVDIfsDisk, enmType, &pThis->pDisk);2906 /* Error message is already set correctly. */2907 }2908 }2909 2910 if (pThis->pDrvMediaAsyncPort && fUseNewIo)2911 pThis->fAsyncIOSupported = true;2912 2913 uint64_t tsStart = RTTimeNanoTS();2914 2915 unsigned iImageIdx = 0;2916 while (pCurNode && RT_SUCCESS(rc))2917 {2918 /* Allocate per-image data. */2919 PVBOXIMAGE pImage = drvvdNewImage(pThis);2920 if (!pImage)2921 {2922 rc = VERR_NO_MEMORY;2923 break;2924 }2925 2926 /*2927 * Read the image configuration.2928 */2929 rc = CFGMR3QueryStringAlloc(pCurNode, "Path", &pszName);2930 if (RT_FAILURE(rc))2931 {2932 rc = PDMDRV_SET_ERROR(pDrvIns, rc,2933 N_("DrvVD: Configuration error: Querying \"Path\" as string failed"));2934 break;2935 }2936 2937 rc = CFGMR3QueryStringAlloc(pCurNode, "Format", &pszFormat);2938 if (RT_FAILURE(rc))2939 {2940 rc = PDMDRV_SET_ERROR(pDrvIns, rc,2941 N_("DrvVD: Configuration error: Querying \"Format\" as string failed"));2942 break;2943 }2944 2945 bool fMergeSource;2946 rc = CFGMR3QueryBoolDef(pCurNode, "MergeSource", &fMergeSource, false);2947 if (RT_FAILURE(rc))2948 {2949 rc = PDMDRV_SET_ERROR(pDrvIns, rc,2950 N_("DrvVD: Configuration error: Querying \"MergeSource\" as boolean failed"));2951 break;2952 }2953 if (fMergeSource)2954 {2955 if (pThis->uMergeSource == VD_LAST_IMAGE)2956 pThis->uMergeSource = iImageIdx;2957 else2958 {2959 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,2960 N_("DrvVD: Configuration error: Multiple \"MergeSource\" occurrences"));2961 break;2962 }2963 }2964 2965 bool fMergeTarget;2966 rc = CFGMR3QueryBoolDef(pCurNode, "MergeTarget", &fMergeTarget, false);2967 if (RT_FAILURE(rc))2968 {2969 rc = PDMDRV_SET_ERROR(pDrvIns, rc,2970 N_("DrvVD: Configuration error: Querying \"MergeTarget\" as boolean failed"));2971 break;2972 }2973 if (fMergeTarget)2974 {2975 if (pThis->uMergeTarget == VD_LAST_IMAGE)2976 pThis->uMergeTarget = iImageIdx;2977 else2978 {2979 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,2980 N_("DrvVD: Configuration error: Multiple \"MergeTarget\" occurrences"));2981 break;2982 }2983 }2984 2985 PCFGMNODE pCfgVDConfig = CFGMR3GetChild(pCurNode, "VDConfig");2986 pImage->VDIfConfig.pfnAreKeysValid = drvvdCfgAreKeysValid;2987 pImage->VDIfConfig.pfnQuerySize = drvvdCfgQuerySize;2988 pImage->VDIfConfig.pfnQuery = drvvdCfgQuery;2989 pImage->VDIfConfig.pfnQueryBytes = NULL;2990 rc = VDInterfaceAdd(&pImage->VDIfConfig.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG,2991 pCfgVDConfig, sizeof(VDINTERFACECONFIG), &pImage->pVDIfsImage);2992 AssertRC(rc);2993 2994 /* Check VDConfig for encryption config. */2995 if (pCfgVDConfig)2996 pThis->pCfgCrypto = CFGMR3GetChild(pCfgVDConfig, "CRYPT");2997 2998 if (pThis->pCfgCrypto)2999 {3000 /* Setup VDConfig interface for disk encryption support. */3001 pThis->VDIfCfg.pfnAreKeysValid = drvvdCfgAreKeysValid;3002 pThis->VDIfCfg.pfnQuerySize = drvvdCfgQuerySize;3003 pThis->VDIfCfg.pfnQuery = drvvdCfgQuery;3004 pThis->VDIfCfg.pfnQueryBytes = NULL;3005 3006 pThis->VDIfCrypto.pfnKeyRetain = drvvdCryptoKeyRetain;3007 pThis->VDIfCrypto.pfnKeyRelease = drvvdCryptoKeyRelease;3008 pThis->VDIfCrypto.pfnKeyStorePasswordRetain = drvvdCryptoKeyStorePasswordRetain;3009 pThis->VDIfCrypto.pfnKeyStorePasswordRelease = drvvdCryptoKeyStorePasswordRelease;3010 }3011 3012 /* Unconditionally insert the TCPNET interface, don't bother to check3013 * if an image really needs it. Will be ignored. Since the TCPNET3014 * interface is per image we could make this more flexible in the3015 * future if we want to. */3016 /* Construct TCPNET callback table depending on the config. This is3017 * done unconditionally, as uninterested backends will ignore it. */3018 if (fHostIP)3019 {3020 pImage->VDIfTcpNet.pfnSocketCreate = drvvdTcpSocketCreate;3021 pImage->VDIfTcpNet.pfnSocketDestroy = drvvdTcpSocketDestroy;3022 pImage->VDIfTcpNet.pfnClientConnect = drvvdTcpClientConnect;3023 pImage->VDIfTcpNet.pfnIsClientConnected = drvvdTcpIsClientConnected;3024 pImage->VDIfTcpNet.pfnClientClose = drvvdTcpClientClose;3025 pImage->VDIfTcpNet.pfnSelectOne = drvvdTcpSelectOne;3026 pImage->VDIfTcpNet.pfnRead = drvvdTcpRead;3027 pImage->VDIfTcpNet.pfnWrite = drvvdTcpWrite;3028 pImage->VDIfTcpNet.pfnSgWrite = drvvdTcpSgWrite;3029 pImage->VDIfTcpNet.pfnReadNB = drvvdTcpReadNB;3030 pImage->VDIfTcpNet.pfnWriteNB = drvvdTcpWriteNB;3031 pImage->VDIfTcpNet.pfnSgWriteNB = drvvdTcpSgWriteNB;3032 pImage->VDIfTcpNet.pfnFlush = drvvdTcpFlush;3033 pImage->VDIfTcpNet.pfnSetSendCoalescing = drvvdTcpSetSendCoalescing;3034 pImage->VDIfTcpNet.pfnGetLocalAddress = drvvdTcpGetLocalAddress;3035 pImage->VDIfTcpNet.pfnGetPeerAddress = drvvdTcpGetPeerAddress;3036 3037 3370 /* 3038 * There is a 15ms delay between receiving the data and marking the socket 3039 * as readable on Windows XP which hurts async I/O performance of 3040 * TCP backends badly. Provide a different select method without 3041 * using poll on XP. 3042 * This is only used on XP because it is not as efficient as the one using poll 3043 * and all other Windows versions are working fine. 3371 * The image has a bandwidth group but the host cache is enabled. 3372 * Use the async I/O framework but tell it to enable the host cache. 3044 3373 */ 3045 char szOS[64]; 3046 memset(szOS, 0, sizeof(szOS)); 3047 rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, &szOS[0], sizeof(szOS)); 3048 3049 if (RT_SUCCESS(rc) && !strncmp(szOS, "Windows XP", 10)) 3050 { 3051 LogRel(("VD: Detected Windows XP, disabled poll based waiting for TCP\n")); 3052 pImage->VDIfTcpNet.pfnSelectOneEx = drvvdTcpSelectOneExNoPoll; 3053 } 3054 else 3055 pImage->VDIfTcpNet.pfnSelectOneEx = drvvdTcpSelectOneExPoll; 3056 3057 pImage->VDIfTcpNet.pfnPoke = drvvdTcpPoke; 3058 } 3059 else 3060 { 3061 #ifndef VBOX_WITH_INIP 3062 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 3063 RT_SRC_POS, N_("DrvVD: Configuration error: TCP over Internal Networking not compiled in")); 3064 #else /* VBOX_WITH_INIP */ 3065 pImage->VDIfTcpNet.pfnSocketCreate = drvvdINIPSocketCreate; 3066 pImage->VDIfTcpNet.pfnSocketDestroy = drvvdINIPSocketDestroy; 3067 pImage->VDIfTcpNet.pfnClientConnect = drvvdINIPClientConnect; 3068 pImage->VDIfTcpNet.pfnClientClose = drvvdINIPClientClose; 3069 pImage->VDIfTcpNet.pfnIsClientConnected = drvvdINIPIsClientConnected; 3070 pImage->VDIfTcpNet.pfnSelectOne = drvvdINIPSelectOne; 3071 pImage->VDIfTcpNet.pfnRead = drvvdINIPRead; 3072 pImage->VDIfTcpNet.pfnWrite = drvvdINIPWrite; 3073 pImage->VDIfTcpNet.pfnSgWrite = drvvdINIPSgWrite; 3074 pImage->VDIfTcpNet.pfnFlush = drvvdINIPFlush; 3075 pImage->VDIfTcpNet.pfnSetSendCoalescing = drvvdINIPSetSendCoalescing; 3076 pImage->VDIfTcpNet.pfnGetLocalAddress = drvvdINIPGetLocalAddress; 3077 pImage->VDIfTcpNet.pfnGetPeerAddress = drvvdINIPGetPeerAddress; 3078 pImage->VDIfTcpNet.pfnSelectOneEx = drvvdINIPSelectOneEx; 3079 pImage->VDIfTcpNet.pfnPoke = drvvdINIPPoke; 3080 #endif /* VBOX_WITH_INIP */ 3081 } 3082 rc = VDInterfaceAdd(&pImage->VDIfTcpNet.Core, "DrvVD_TCPNET", 3083 VDINTERFACETYPE_TCPNET, NULL, 3084 sizeof(VDINTERFACETCPNET), &pImage->pVDIfsImage); 3085 AssertRC(rc); 3086 3087 /* Insert the custom I/O interface only if we're told to use new IO. 3088 * Since the I/O interface is per image we could make this more 3089 * flexible in the future if we want to. */ 3090 if (fUseNewIo) 3091 { 3092 #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION 3093 pImage->VDIfIo.pfnOpen = drvvdAsyncIOOpen; 3094 pImage->VDIfIo.pfnClose = drvvdAsyncIOClose; 3095 pImage->VDIfIo.pfnGetSize = drvvdAsyncIOGetSize; 3096 pImage->VDIfIo.pfnSetSize = drvvdAsyncIOSetSize; 3097 pImage->VDIfIo.pfnReadSync = drvvdAsyncIOReadSync; 3098 pImage->VDIfIo.pfnWriteSync = drvvdAsyncIOWriteSync; 3099 pImage->VDIfIo.pfnFlushSync = drvvdAsyncIOFlushSync; 3100 pImage->VDIfIo.pfnReadAsync = drvvdAsyncIOReadAsync; 3101 pImage->VDIfIo.pfnWriteAsync = drvvdAsyncIOWriteAsync; 3102 pImage->VDIfIo.pfnFlushAsync = drvvdAsyncIOFlushAsync; 3103 #else /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3104 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 3105 RT_SRC_POS, N_("DrvVD: Configuration error: Async Completion Framework not compiled in")); 3106 #endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3107 if (RT_SUCCESS(rc)) 3108 rc = VDInterfaceAdd(&pImage->VDIfIo.Core, "DrvVD_IO", VDINTERFACETYPE_IO, 3109 pThis, sizeof(VDINTERFACEIO), &pImage->pVDIfsImage); 3110 AssertRC(rc); 3111 } 3112 3113 /* 3114 * Open the image. 3115 */ 3116 unsigned uOpenFlags; 3117 if (fReadOnly || pThis->fTempReadOnly || iLevel != 0) 3118 uOpenFlags = VD_OPEN_FLAGS_READONLY; 3119 else 3120 uOpenFlags = VD_OPEN_FLAGS_NORMAL; 3121 if (fHonorZeroWrites) 3122 uOpenFlags |= VD_OPEN_FLAGS_HONOR_ZEROES; 3123 if (pThis->fAsyncIOSupported) 3124 uOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO; 3125 if (pThis->fShareable) 3126 uOpenFlags |= VD_OPEN_FLAGS_SHAREABLE; 3127 if (fDiscard && iLevel == 0) 3128 uOpenFlags |= VD_OPEN_FLAGS_DISCARD; 3129 if (fInformAboutZeroBlocks) 3130 uOpenFlags |= VD_OPEN_FLAGS_INFORM_ABOUT_ZERO_BLOCKS; 3131 if ( (uOpenFlags & VD_OPEN_FLAGS_READONLY) 3132 && fSkipConsistencyChecks) 3133 uOpenFlags |= VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS; 3134 3135 /* Try to open backend in async I/O mode first. */ 3136 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 3137 if (rc == VERR_NOT_SUPPORTED) 3138 { 3139 pThis->fAsyncIOSupported = false; 3140 uOpenFlags &= ~VD_OPEN_FLAGS_ASYNC_IO; 3141 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 3142 } 3143 3144 if (rc == VERR_VD_DISCARD_NOT_SUPPORTED) 3145 { 3146 fDiscard = false; 3147 uOpenFlags &= ~VD_OPEN_FLAGS_DISCARD; 3148 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 3149 } 3150 3151 if (!fDiscard) 3152 { 3153 pThis->IMedia.pfnDiscard = NULL; 3154 pThis->IMediaAsync.pfnStartDiscard = NULL; 3155 } 3156 3157 if (RT_SUCCESS(rc)) 3158 { 3159 LogFunc(("%d - Opened '%s' in %s mode\n", 3160 iLevel, pszName, 3161 VDIsReadOnly(pThis->pDisk) ? "read-only" : "read-write")); 3162 if ( VDIsReadOnly(pThis->pDisk) 3163 && !fReadOnly 3164 && !fMaybeReadOnly 3165 && !pThis->fTempReadOnly 3166 && iLevel == 0) 3167 { 3168 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_VD_IMAGE_READ_ONLY, RT_SRC_POS, 3169 N_("Failed to open image '%s' for writing due to wrong permissions"), 3170 pszName); 3171 break; 3172 } 3173 } 3174 else 3175 { 3176 rc = PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, 3177 N_("Failed to open image '%s' in %s mode"), pszName, 3178 (uOpenFlags & VD_OPEN_FLAGS_READONLY) ? "read-only" : "read-write"); 3179 break; 3180 } 3181 3182 3183 MMR3HeapFree(pszName); 3184 pszName = NULL; 3185 MMR3HeapFree(pszFormat); 3186 pszFormat = NULL; 3187 3188 /* next */ 3189 iLevel--; 3190 iImageIdx++; 3191 pCurNode = CFGMR3GetParent(pCurNode); 3192 } 3193 3194 LogRel(("VD: Opening the disk took %lld ns\n", RTTimeNanoTS() - tsStart)); 3195 3196 /* Open the cache image if set. */ 3197 if ( RT_SUCCESS(rc) 3198 && RT_VALID_PTR(pszCachePath)) 3199 { 3200 /* Insert the custom I/O interface only if we're told to use new IO. 3201 * Since the I/O interface is per image we could make this more 3202 * flexible in the future if we want to. */ 3203 if (fUseNewIo) 3204 { 3205 #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION 3206 pThis->VDIfIoCache.pfnOpen = drvvdAsyncIOOpen; 3207 pThis->VDIfIoCache.pfnClose = drvvdAsyncIOClose; 3208 pThis->VDIfIoCache.pfnGetSize = drvvdAsyncIOGetSize; 3209 pThis->VDIfIoCache.pfnSetSize = drvvdAsyncIOSetSize; 3210 pThis->VDIfIoCache.pfnReadSync = drvvdAsyncIOReadSync; 3211 pThis->VDIfIoCache.pfnWriteSync = drvvdAsyncIOWriteSync; 3212 pThis->VDIfIoCache.pfnFlushSync = drvvdAsyncIOFlushSync; 3213 pThis->VDIfIoCache.pfnReadAsync = drvvdAsyncIOReadAsync; 3214 pThis->VDIfIoCache.pfnWriteAsync = drvvdAsyncIOWriteAsync; 3215 pThis->VDIfIoCache.pfnFlushAsync = drvvdAsyncIOFlushAsync; 3216 #else /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3217 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 3218 RT_SRC_POS, N_("DrvVD: Configuration error: Async Completion Framework not compiled in")); 3219 #endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3220 if (RT_SUCCESS(rc)) 3221 rc = VDInterfaceAdd(&pThis->VDIfIoCache.Core, "DrvVD_IO", VDINTERFACETYPE_IO, 3222 pThis, sizeof(VDINTERFACEIO), &pThis->pVDIfsCache); 3223 AssertRC(rc); 3224 } 3225 3226 rc = VDCacheOpen(pThis->pDisk, pszCacheFormat, pszCachePath, VD_OPEN_FLAGS_NORMAL, pThis->pVDIfsCache); 3227 if (RT_FAILURE(rc)) 3228 rc = PDMDRV_SET_ERROR(pDrvIns, rc, N_("DrvVD: Could not open cache image")); 3229 } 3230 3231 if (RT_VALID_PTR(pszCachePath)) 3232 MMR3HeapFree(pszCachePath); 3233 if (RT_VALID_PTR(pszCacheFormat)) 3234 MMR3HeapFree(pszCacheFormat); 3235 3236 if ( RT_SUCCESS(rc) 3237 && pThis->fMergePending 3238 && ( pThis->uMergeSource == VD_LAST_IMAGE 3239 || pThis->uMergeTarget == VD_LAST_IMAGE)) 3240 { 3241 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3242 N_("DrvVD: Configuration error: Inconsistent image merge data")); 3243 } 3244 3245 /* Create the block cache if enabled. */ 3246 if ( fUseBlockCache 3247 && !pThis->fShareable 3248 && !fDiscard 3249 && !pThis->pCfgCrypto /* Disk encryption disables the block cache for security reasons */ 3250 && RT_SUCCESS(rc)) 3251 { 3252 /* 3253 * We need a unique ID for the block cache (to identify the owner of data 3254 * blocks in a saved state). UUIDs are not really suitable because 3255 * there are image formats which don't support them. Furthermore it is 3256 * possible that a new diff image was attached after a saved state 3257 * which changes the UUID. 3258 * However the device "name + device instance + LUN" triple the disk is 3259 * attached to is always constant for saved states. 3260 */ 3261 char *pszId = NULL; 3262 uint32_t iInstance, iLUN; 3263 const char *pcszController; 3264 3265 rc = pThis->pDrvMediaPort->pfnQueryDeviceLocation(pThis->pDrvMediaPort, &pcszController, 3266 &iInstance, &iLUN); 3267 if (RT_FAILURE(rc)) 3268 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3269 N_("DrvVD: Configuration error: Could not query device data")); 3270 else 3271 { 3272 int cbStr = RTStrAPrintf(&pszId, "%s-%d-%d", pcszController, iInstance, iLUN); 3273 3274 if (cbStr > 0) 3275 { 3276 rc = PDMDrvHlpBlkCacheRetain(pDrvIns, &pThis->pBlkCache, 3277 drvvdBlkCacheXferComplete, 3278 drvvdBlkCacheXferEnqueue, 3279 drvvdBlkCacheXferEnqueueDiscard, 3280 pszId); 3281 if (rc == VERR_NOT_SUPPORTED) 3374 if (!fUseNewIo && pThis->pszBwGroup) 3375 { 3376 pThis->fAsyncIoWithHostCache = true; 3377 fUseNewIo = true; 3378 } 3379 3380 /** @todo quick hack to work around problems in the async I/O 3381 * implementation (rw semaphore thread ownership problem) 3382 * while a merge is running. Remove once this is fixed. */ 3383 if (pThis->fMergePending) 3384 fUseNewIo = false; 3385 3386 if (RT_SUCCESS(rc) && pThis->fMergePending) 3387 { 3388 rc = RTSemFastMutexCreate(&pThis->MergeCompleteMutex); 3389 if (RT_SUCCESS(rc)) 3390 rc = RTSemRWCreate(&pThis->MergeLock); 3391 if (RT_SUCCESS(rc)) 3282 3392 { 3283 LogRel(("VD: Block cache is not supported\n")); 3284 rc = VINF_SUCCESS; 3393 pThis->VDIfThreadSync.pfnStartRead = drvvdThreadStartRead; 3394 pThis->VDIfThreadSync.pfnFinishRead = drvvdThreadFinishRead; 3395 pThis->VDIfThreadSync.pfnStartWrite = drvvdThreadStartWrite; 3396 pThis->VDIfThreadSync.pfnFinishWrite = drvvdThreadFinishWrite; 3397 3398 rc = VDInterfaceAdd(&pThis->VDIfThreadSync.Core, "DrvVD_ThreadSync", VDINTERFACETYPE_THREADSYNC, 3399 pThis, sizeof(VDINTERFACETHREADSYNC), &pThis->pVDIfsDisk); 3285 3400 } 3286 3401 else 3287 AssertRC(rc); 3288 3289 RTStrFree(pszId); 3402 { 3403 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 3404 N_("DrvVD: Failed to create semaphores for \"MergePending\"")); 3405 } 3406 } 3407 3408 if (RT_SUCCESS(rc)) 3409 { 3410 rc = VDCreate(pThis->pVDIfsDisk, drvvdGetVDFromMediaType(pThis->enmType), &pThis->pDisk); 3411 /* Error message is already set correctly. */ 3412 } 3413 } 3414 3415 if (pThis->pDrvMediaAsyncPort && fUseNewIo) 3416 pThis->fAsyncIOSupported = true; 3417 3418 uint64_t tsStart = RTTimeNanoTS(); 3419 3420 unsigned iImageIdx = 0; 3421 while (pCurNode && RT_SUCCESS(rc)) 3422 { 3423 /* Allocate per-image data. */ 3424 PVBOXIMAGE pImage = drvvdNewImage(pThis); 3425 if (!pImage) 3426 { 3427 rc = VERR_NO_MEMORY; 3428 break; 3429 } 3430 3431 /* 3432 * Read the image configuration. 3433 */ 3434 rc = CFGMR3QueryStringAlloc(pCurNode, "Path", &pszName); 3435 if (RT_FAILURE(rc)) 3436 { 3437 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 3438 N_("DrvVD: Configuration error: Querying \"Path\" as string failed")); 3439 break; 3440 } 3441 3442 rc = CFGMR3QueryStringAlloc(pCurNode, "Format", &pszFormat); 3443 if (RT_FAILURE(rc)) 3444 { 3445 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 3446 N_("DrvVD: Configuration error: Querying \"Format\" as string failed")); 3447 break; 3448 } 3449 3450 bool fMergeSource; 3451 rc = CFGMR3QueryBoolDef(pCurNode, "MergeSource", &fMergeSource, false); 3452 if (RT_FAILURE(rc)) 3453 { 3454 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 3455 N_("DrvVD: Configuration error: Querying \"MergeSource\" as boolean failed")); 3456 break; 3457 } 3458 if (fMergeSource) 3459 { 3460 if (pThis->uMergeSource == VD_LAST_IMAGE) 3461 pThis->uMergeSource = iImageIdx; 3462 else 3463 { 3464 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3465 N_("DrvVD: Configuration error: Multiple \"MergeSource\" occurrences")); 3466 break; 3467 } 3468 } 3469 3470 bool fMergeTarget; 3471 rc = CFGMR3QueryBoolDef(pCurNode, "MergeTarget", &fMergeTarget, false); 3472 if (RT_FAILURE(rc)) 3473 { 3474 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 3475 N_("DrvVD: Configuration error: Querying \"MergeTarget\" as boolean failed")); 3476 break; 3477 } 3478 if (fMergeTarget) 3479 { 3480 if (pThis->uMergeTarget == VD_LAST_IMAGE) 3481 pThis->uMergeTarget = iImageIdx; 3482 else 3483 { 3484 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3485 N_("DrvVD: Configuration error: Multiple \"MergeTarget\" occurrences")); 3486 break; 3487 } 3488 } 3489 3490 PCFGMNODE pCfgVDConfig = CFGMR3GetChild(pCurNode, "VDConfig"); 3491 pImage->VDIfConfig.pfnAreKeysValid = drvvdCfgAreKeysValid; 3492 pImage->VDIfConfig.pfnQuerySize = drvvdCfgQuerySize; 3493 pImage->VDIfConfig.pfnQuery = drvvdCfgQuery; 3494 pImage->VDIfConfig.pfnQueryBytes = NULL; 3495 rc = VDInterfaceAdd(&pImage->VDIfConfig.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 3496 pCfgVDConfig, sizeof(VDINTERFACECONFIG), &pImage->pVDIfsImage); 3497 AssertRC(rc); 3498 3499 /* Check VDConfig for encryption config. */ 3500 if (pCfgVDConfig) 3501 pThis->pCfgCrypto = CFGMR3GetChild(pCfgVDConfig, "CRYPT"); 3502 3503 if (pThis->pCfgCrypto) 3504 { 3505 /* Setup VDConfig interface for disk encryption support. */ 3506 pThis->VDIfCfg.pfnAreKeysValid = drvvdCfgAreKeysValid; 3507 pThis->VDIfCfg.pfnQuerySize = drvvdCfgQuerySize; 3508 pThis->VDIfCfg.pfnQuery = drvvdCfgQuery; 3509 pThis->VDIfCfg.pfnQueryBytes = NULL; 3510 3511 pThis->VDIfCrypto.pfnKeyRetain = drvvdCryptoKeyRetain; 3512 pThis->VDIfCrypto.pfnKeyRelease = drvvdCryptoKeyRelease; 3513 pThis->VDIfCrypto.pfnKeyStorePasswordRetain = drvvdCryptoKeyStorePasswordRetain; 3514 pThis->VDIfCrypto.pfnKeyStorePasswordRelease = drvvdCryptoKeyStorePasswordRelease; 3515 } 3516 3517 /* Unconditionally insert the TCPNET interface, don't bother to check 3518 * if an image really needs it. Will be ignored. Since the TCPNET 3519 * interface is per image we could make this more flexible in the 3520 * future if we want to. */ 3521 /* Construct TCPNET callback table depending on the config. This is 3522 * done unconditionally, as uninterested backends will ignore it. */ 3523 if (fHostIP) 3524 { 3525 pImage->VDIfTcpNet.pfnSocketCreate = drvvdTcpSocketCreate; 3526 pImage->VDIfTcpNet.pfnSocketDestroy = drvvdTcpSocketDestroy; 3527 pImage->VDIfTcpNet.pfnClientConnect = drvvdTcpClientConnect; 3528 pImage->VDIfTcpNet.pfnIsClientConnected = drvvdTcpIsClientConnected; 3529 pImage->VDIfTcpNet.pfnClientClose = drvvdTcpClientClose; 3530 pImage->VDIfTcpNet.pfnSelectOne = drvvdTcpSelectOne; 3531 pImage->VDIfTcpNet.pfnRead = drvvdTcpRead; 3532 pImage->VDIfTcpNet.pfnWrite = drvvdTcpWrite; 3533 pImage->VDIfTcpNet.pfnSgWrite = drvvdTcpSgWrite; 3534 pImage->VDIfTcpNet.pfnReadNB = drvvdTcpReadNB; 3535 pImage->VDIfTcpNet.pfnWriteNB = drvvdTcpWriteNB; 3536 pImage->VDIfTcpNet.pfnSgWriteNB = drvvdTcpSgWriteNB; 3537 pImage->VDIfTcpNet.pfnFlush = drvvdTcpFlush; 3538 pImage->VDIfTcpNet.pfnSetSendCoalescing = drvvdTcpSetSendCoalescing; 3539 pImage->VDIfTcpNet.pfnGetLocalAddress = drvvdTcpGetLocalAddress; 3540 pImage->VDIfTcpNet.pfnGetPeerAddress = drvvdTcpGetPeerAddress; 3541 3542 /* 3543 * There is a 15ms delay between receiving the data and marking the socket 3544 * as readable on Windows XP which hurts async I/O performance of 3545 * TCP backends badly. Provide a different select method without 3546 * using poll on XP. 3547 * This is only used on XP because it is not as efficient as the one using poll 3548 * and all other Windows versions are working fine. 3549 */ 3550 char szOS[64]; 3551 memset(szOS, 0, sizeof(szOS)); 3552 rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, &szOS[0], sizeof(szOS)); 3553 3554 if (RT_SUCCESS(rc) && !strncmp(szOS, "Windows XP", 10)) 3555 { 3556 LogRel(("VD: Detected Windows XP, disabled poll based waiting for TCP\n")); 3557 pImage->VDIfTcpNet.pfnSelectOneEx = drvvdTcpSelectOneExNoPoll; 3558 } 3559 else 3560 pImage->VDIfTcpNet.pfnSelectOneEx = drvvdTcpSelectOneExPoll; 3561 3562 pImage->VDIfTcpNet.pfnPoke = drvvdTcpPoke; 3290 3563 } 3291 3564 else 3565 { 3566 #ifndef VBOX_WITH_INIP 3567 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 3568 RT_SRC_POS, N_("DrvVD: Configuration error: TCP over Internal Networking not compiled in")); 3569 #else /* VBOX_WITH_INIP */ 3570 pImage->VDIfTcpNet.pfnSocketCreate = drvvdINIPSocketCreate; 3571 pImage->VDIfTcpNet.pfnSocketDestroy = drvvdINIPSocketDestroy; 3572 pImage->VDIfTcpNet.pfnClientConnect = drvvdINIPClientConnect; 3573 pImage->VDIfTcpNet.pfnClientClose = drvvdINIPClientClose; 3574 pImage->VDIfTcpNet.pfnIsClientConnected = drvvdINIPIsClientConnected; 3575 pImage->VDIfTcpNet.pfnSelectOne = drvvdINIPSelectOne; 3576 pImage->VDIfTcpNet.pfnRead = drvvdINIPRead; 3577 pImage->VDIfTcpNet.pfnWrite = drvvdINIPWrite; 3578 pImage->VDIfTcpNet.pfnSgWrite = drvvdINIPSgWrite; 3579 pImage->VDIfTcpNet.pfnFlush = drvvdINIPFlush; 3580 pImage->VDIfTcpNet.pfnSetSendCoalescing = drvvdINIPSetSendCoalescing; 3581 pImage->VDIfTcpNet.pfnGetLocalAddress = drvvdINIPGetLocalAddress; 3582 pImage->VDIfTcpNet.pfnGetPeerAddress = drvvdINIPGetPeerAddress; 3583 pImage->VDIfTcpNet.pfnSelectOneEx = drvvdINIPSelectOneEx; 3584 pImage->VDIfTcpNet.pfnPoke = drvvdINIPPoke; 3585 #endif /* VBOX_WITH_INIP */ 3586 } 3587 rc = VDInterfaceAdd(&pImage->VDIfTcpNet.Core, "DrvVD_TCPNET", 3588 VDINTERFACETYPE_TCPNET, NULL, 3589 sizeof(VDINTERFACETCPNET), &pImage->pVDIfsImage); 3590 AssertRC(rc); 3591 3592 /* Insert the custom I/O interface only if we're told to use new IO. 3593 * Since the I/O interface is per image we could make this more 3594 * flexible in the future if we want to. */ 3595 if (fUseNewIo) 3596 { 3597 #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION 3598 pImage->VDIfIo.pfnOpen = drvvdAsyncIOOpen; 3599 pImage->VDIfIo.pfnClose = drvvdAsyncIOClose; 3600 pImage->VDIfIo.pfnGetSize = drvvdAsyncIOGetSize; 3601 pImage->VDIfIo.pfnSetSize = drvvdAsyncIOSetSize; 3602 pImage->VDIfIo.pfnReadSync = drvvdAsyncIOReadSync; 3603 pImage->VDIfIo.pfnWriteSync = drvvdAsyncIOWriteSync; 3604 pImage->VDIfIo.pfnFlushSync = drvvdAsyncIOFlushSync; 3605 pImage->VDIfIo.pfnReadAsync = drvvdAsyncIOReadAsync; 3606 pImage->VDIfIo.pfnWriteAsync = drvvdAsyncIOWriteAsync; 3607 pImage->VDIfIo.pfnFlushAsync = drvvdAsyncIOFlushAsync; 3608 #else /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3609 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 3610 RT_SRC_POS, N_("DrvVD: Configuration error: Async Completion Framework not compiled in")); 3611 #endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3612 if (RT_SUCCESS(rc)) 3613 rc = VDInterfaceAdd(&pImage->VDIfIo.Core, "DrvVD_IO", VDINTERFACETYPE_IO, 3614 pThis, sizeof(VDINTERFACEIO), &pImage->pVDIfsImage); 3615 AssertRC(rc); 3616 } 3617 3618 /* 3619 * Open the image. 3620 */ 3621 unsigned uOpenFlags; 3622 if (fReadOnly || pThis->fTempReadOnly || iLevel != 0) 3623 uOpenFlags = VD_OPEN_FLAGS_READONLY; 3624 else 3625 uOpenFlags = VD_OPEN_FLAGS_NORMAL; 3626 if (fHonorZeroWrites) 3627 uOpenFlags |= VD_OPEN_FLAGS_HONOR_ZEROES; 3628 if (pThis->fAsyncIOSupported) 3629 uOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO; 3630 if (pThis->fShareable) 3631 uOpenFlags |= VD_OPEN_FLAGS_SHAREABLE; 3632 if (fDiscard && iLevel == 0) 3633 uOpenFlags |= VD_OPEN_FLAGS_DISCARD; 3634 if (fInformAboutZeroBlocks) 3635 uOpenFlags |= VD_OPEN_FLAGS_INFORM_ABOUT_ZERO_BLOCKS; 3636 if ( (uOpenFlags & VD_OPEN_FLAGS_READONLY) 3637 && fSkipConsistencyChecks) 3638 uOpenFlags |= VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS; 3639 3640 /* Try to open backend in async I/O mode first. */ 3641 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 3642 if (rc == VERR_NOT_SUPPORTED) 3643 { 3644 pThis->fAsyncIOSupported = false; 3645 uOpenFlags &= ~VD_OPEN_FLAGS_ASYNC_IO; 3646 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 3647 } 3648 3649 if (rc == VERR_VD_DISCARD_NOT_SUPPORTED) 3650 { 3651 fDiscard = false; 3652 uOpenFlags &= ~VD_OPEN_FLAGS_DISCARD; 3653 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 3654 } 3655 3656 if (!fDiscard) 3657 { 3658 pThis->IMedia.pfnDiscard = NULL; 3659 pThis->IMediaAsync.pfnStartDiscard = NULL; 3660 } 3661 3662 if (RT_SUCCESS(rc)) 3663 { 3664 LogFunc(("%d - Opened '%s' in %s mode\n", 3665 iLevel, pszName, 3666 VDIsReadOnly(pThis->pDisk) ? "read-only" : "read-write")); 3667 if ( VDIsReadOnly(pThis->pDisk) 3668 && !fReadOnly 3669 && !fMaybeReadOnly 3670 && !pThis->fTempReadOnly 3671 && iLevel == 0) 3672 { 3673 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_VD_IMAGE_READ_ONLY, RT_SRC_POS, 3674 N_("Failed to open image '%s' for writing due to wrong permissions"), 3675 pszName); 3676 break; 3677 } 3678 } 3679 else 3680 { 3681 rc = PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, 3682 N_("Failed to open image '%s' in %s mode"), pszName, 3683 (uOpenFlags & VD_OPEN_FLAGS_READONLY) ? "read-only" : "read-write"); 3684 break; 3685 } 3686 3687 MMR3HeapFree(pszName); 3688 pszName = NULL; 3689 MMR3HeapFree(pszFormat); 3690 pszFormat = NULL; 3691 3692 /* next */ 3693 iLevel--; 3694 iImageIdx++; 3695 pCurNode = CFGMR3GetParent(pCurNode); 3696 } 3697 3698 LogRel(("VD: Opening the disk took %lld ns\n", RTTimeNanoTS() - tsStart)); 3699 3700 /* Open the cache image if set. */ 3701 if ( RT_SUCCESS(rc) 3702 && RT_VALID_PTR(pszCachePath)) 3703 { 3704 /* Insert the custom I/O interface only if we're told to use new IO. 3705 * Since the I/O interface is per image we could make this more 3706 * flexible in the future if we want to. */ 3707 if (fUseNewIo) 3708 { 3709 #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION 3710 pThis->VDIfIoCache.pfnOpen = drvvdAsyncIOOpen; 3711 pThis->VDIfIoCache.pfnClose = drvvdAsyncIOClose; 3712 pThis->VDIfIoCache.pfnGetSize = drvvdAsyncIOGetSize; 3713 pThis->VDIfIoCache.pfnSetSize = drvvdAsyncIOSetSize; 3714 pThis->VDIfIoCache.pfnReadSync = drvvdAsyncIOReadSync; 3715 pThis->VDIfIoCache.pfnWriteSync = drvvdAsyncIOWriteSync; 3716 pThis->VDIfIoCache.pfnFlushSync = drvvdAsyncIOFlushSync; 3717 pThis->VDIfIoCache.pfnReadAsync = drvvdAsyncIOReadAsync; 3718 pThis->VDIfIoCache.pfnWriteAsync = drvvdAsyncIOWriteAsync; 3719 pThis->VDIfIoCache.pfnFlushAsync = drvvdAsyncIOFlushAsync; 3720 #else /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3721 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, 3722 RT_SRC_POS, N_("DrvVD: Configuration error: Async Completion Framework not compiled in")); 3723 #endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 3724 if (RT_SUCCESS(rc)) 3725 rc = VDInterfaceAdd(&pThis->VDIfIoCache.Core, "DrvVD_IO", VDINTERFACETYPE_IO, 3726 pThis, sizeof(VDINTERFACEIO), &pThis->pVDIfsCache); 3727 AssertRC(rc); 3728 } 3729 3730 rc = VDCacheOpen(pThis->pDisk, pszCacheFormat, pszCachePath, VD_OPEN_FLAGS_NORMAL, pThis->pVDIfsCache); 3731 if (RT_FAILURE(rc)) 3732 rc = PDMDRV_SET_ERROR(pDrvIns, rc, N_("DrvVD: Could not open cache image")); 3733 } 3734 3735 if (RT_VALID_PTR(pszCachePath)) 3736 MMR3HeapFree(pszCachePath); 3737 if (RT_VALID_PTR(pszCacheFormat)) 3738 MMR3HeapFree(pszCacheFormat); 3739 3740 if ( RT_SUCCESS(rc) 3741 && pThis->fMergePending 3742 && ( pThis->uMergeSource == VD_LAST_IMAGE 3743 || pThis->uMergeTarget == VD_LAST_IMAGE)) 3744 { 3745 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3746 N_("DrvVD: Configuration error: Inconsistent image merge data")); 3747 } 3748 3749 /* Create the block cache if enabled. */ 3750 if ( fUseBlockCache 3751 && !pThis->fShareable 3752 && !fDiscard 3753 && !pThis->pCfgCrypto /* Disk encryption disables the block cache for security reasons */ 3754 && RT_SUCCESS(rc)) 3755 { 3756 /* 3757 * We need a unique ID for the block cache (to identify the owner of data 3758 * blocks in a saved state). UUIDs are not really suitable because 3759 * there are image formats which don't support them. Furthermore it is 3760 * possible that a new diff image was attached after a saved state 3761 * which changes the UUID. 3762 * However the device "name + device instance + LUN" triple the disk is 3763 * attached to is always constant for saved states. 3764 */ 3765 char *pszId = NULL; 3766 uint32_t iInstance, iLUN; 3767 const char *pcszController; 3768 3769 rc = pThis->pDrvMediaPort->pfnQueryDeviceLocation(pThis->pDrvMediaPort, &pcszController, 3770 &iInstance, &iLUN); 3771 if (RT_FAILURE(rc)) 3292 3772 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3293 N_("DrvVD: Out of memory when creating block cache")); 3773 N_("DrvVD: Configuration error: Could not query device data")); 3774 else 3775 { 3776 int cbStr = RTStrAPrintf(&pszId, "%s-%d-%d", pcszController, iInstance, iLUN); 3777 3778 if (cbStr > 0) 3779 { 3780 rc = PDMDrvHlpBlkCacheRetain(pDrvIns, &pThis->pBlkCache, 3781 drvvdBlkCacheXferComplete, 3782 drvvdBlkCacheXferEnqueue, 3783 drvvdBlkCacheXferEnqueueDiscard, 3784 pszId); 3785 if (rc == VERR_NOT_SUPPORTED) 3786 { 3787 LogRel(("VD: Block cache is not supported\n")); 3788 rc = VINF_SUCCESS; 3789 } 3790 else 3791 AssertRC(rc); 3792 3793 RTStrFree(pszId); 3794 } 3795 else 3796 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES, 3797 N_("DrvVD: Out of memory when creating block cache")); 3798 } 3294 3799 } 3295 } 3296 3297 if (RT_SUCCESS(rc)) 3298 rc = drvvdSetupFilters(pThis, pCfg); 3299 3300 /* 3301 * Register a load-done callback so we can undo TempReadOnly config before 3302 * we get to drvvdResume. Autoamtically deregistered upon destruction. 3303 */ 3304 if (RT_SUCCESS(rc)) 3305 rc = PDMDrvHlpSSMRegisterEx(pDrvIns, 0 /* version */, 0 /* cbGuess */, 3306 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/, 3307 NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/, 3308 NULL /*pfnDonePrep*/, NULL /*pfnLoadExec*/, drvvdLoadDone); 3309 3310 /* Setup the boot acceleration stuff if enabled. */ 3311 if (RT_SUCCESS(rc) && pThis->fBootAccelEnabled) 3312 { 3313 pThis->cbDisk = VDGetSize(pThis->pDisk, VD_LAST_IMAGE); 3314 Assert(pThis->cbDisk > 0); 3315 pThis->pbData = (uint8_t *)RTMemAllocZ(pThis->cbBootAccelBuffer); 3316 if (pThis->pbData) 3800 3801 if (RT_SUCCESS(rc)) 3802 rc = drvvdSetupFilters(pThis, pCfg); 3803 3804 /* 3805 * Register a load-done callback so we can undo TempReadOnly config before 3806 * we get to drvvdResume. Autoamtically deregistered upon destruction. 3807 */ 3808 if (RT_SUCCESS(rc)) 3809 rc = PDMDrvHlpSSMRegisterEx(pDrvIns, 0 /* version */, 0 /* cbGuess */, 3810 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/, 3811 NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/, 3812 NULL /*pfnDonePrep*/, NULL /*pfnLoadExec*/, drvvdLoadDone); 3813 3814 /* Setup the boot acceleration stuff if enabled. */ 3815 if (RT_SUCCESS(rc) && pThis->fBootAccelEnabled) 3317 3816 { 3318 pThis->fBootAccelActive = true; 3319 pThis->offDisk = 0; 3320 pThis->cbDataValid = 0; 3321 LogRel(("VD: Boot acceleration enabled\n")); 3817 pThis->cbDisk = VDGetSize(pThis->pDisk, VD_LAST_IMAGE); 3818 Assert(pThis->cbDisk > 0); 3819 pThis->pbData = (uint8_t *)RTMemAllocZ(pThis->cbBootAccelBuffer); 3820 if (pThis->pbData) 3821 { 3822 pThis->fBootAccelActive = true; 3823 pThis->offDisk = 0; 3824 pThis->cbDataValid = 0; 3825 LogRel(("VD: Boot acceleration enabled\n")); 3826 } 3827 else 3828 LogRel(("VD: Boot acceleration, out of memory, disabled\n")); 3322 3829 } 3323 else 3324 LogRel(("VD: Boot acceleration, out of memory, disabled\n")); 3325 } 3830 3831 if ( RTUuidIsNull(&pThis->Uuid) 3832 && pThis->enmType == PDMMEDIATYPE_HARD_DISK) 3833 rc = VDGetUuid(pThis->pDisk, 0, &pThis->Uuid); 3834 3835 /* 3836 * Automatically upgrade the floppy drive if the specified one is too 3837 * small to represent the whole boot time image. (We cannot do this later 3838 * since the BIOS (and others) gets the info via CMOS.) 3839 * 3840 * This trick should make 2.88 images as well as the fake 15.6 and 63.5 MB 3841 * images despite the hardcoded default 1.44 drive. 3842 */ 3843 if ( PDMMEDIATYPE_IS_FLOPPY(pThis->enmType) 3844 && pThis->pDisk) 3845 { 3846 uint64_t const cbFloppyImg = VDGetSize(pThis->pDisk, VD_LAST_IMAGE); 3847 PDMMEDIATYPE const enmCfgType = pThis->enmType; 3848 switch (enmCfgType) 3849 { 3850 default: 3851 AssertFailed(); 3852 case PDMMEDIATYPE_FLOPPY_360: 3853 if (cbFloppyImg > 40 * 2 * 9 * 512) 3854 pThis->enmType = PDMMEDIATYPE_FLOPPY_720; 3855 /* fall thru */ 3856 case PDMMEDIATYPE_FLOPPY_720: 3857 if (cbFloppyImg > 80 * 2 * 14 * 512) 3858 pThis->enmType = PDMMEDIATYPE_FLOPPY_1_20; 3859 /* fall thru */ 3860 case PDMMEDIATYPE_FLOPPY_1_20: 3861 if (cbFloppyImg > 80 * 2 * 20 * 512) 3862 pThis->enmType = PDMMEDIATYPE_FLOPPY_1_44; 3863 /* fall thru */ 3864 case PDMMEDIATYPE_FLOPPY_1_44: 3865 if (cbFloppyImg > 80 * 2 * 24 * 512) 3866 pThis->enmType = PDMMEDIATYPE_FLOPPY_2_88; 3867 /* fall thru */ 3868 case PDMMEDIATYPE_FLOPPY_2_88: 3869 if (cbFloppyImg > 80 * 2 * 48 * 512) 3870 pThis->enmType = PDMMEDIATYPE_FLOPPY_FAKE_15_6; 3871 /* fall thru */ 3872 case PDMMEDIATYPE_FLOPPY_FAKE_15_6: 3873 if (cbFloppyImg > 255 * 2 * 63 * 512) 3874 pThis->enmType = PDMMEDIATYPE_FLOPPY_FAKE_63_5; 3875 case PDMMEDIATYPE_FLOPPY_FAKE_63_5: 3876 if (cbFloppyImg > 255 * 2 * 255 * 512) 3877 LogRel(("Warning: Floppy image is larger that 63.5 MB! (%llu bytes)\n", cbFloppyImg)); 3878 break; 3879 } 3880 if (pThis->enmType != enmCfgType) 3881 LogRel(("DrvVD: Automatically upgraded floppy drive from %s to %s to better support the %u byte image\n", 3882 drvvdGetTypeName(enmCfgType), drvvdGetTypeName(pThis->enmType), cbFloppyImg)); 3883 } 3884 } /* !fEmptyDrive */ 3326 3885 3327 3886 if (RT_FAILURE(rc)) -
trunk/src/VBox/Devices/build/VBoxDD.cpp
r57989 r59248 222 222 if (RT_FAILURE(rc)) 223 223 return rc; 224 rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvBlock);225 if (RT_FAILURE(rc))226 return rc;227 224 rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvVD); 228 225 if (RT_FAILURE(rc)) … … 238 235 return rc; 239 236 #endif 240 rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvMediaISO);241 if (RT_FAILURE(rc))242 return rc;243 rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvRawImage);244 if (RT_FAILURE(rc))245 return rc;246 237 rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvNAT); 247 238 if (RT_FAILURE(rc)) -
trunk/src/VBox/Devices/build/VBoxDD.h
r57989 r59248 92 92 extern const PDMDRVREG g_DrvMouseQueue; 93 93 extern const PDMDRVREG g_DrvKeyboardQueue; 94 extern const PDMDRVREG g_DrvBlock;95 94 extern const PDMDRVREG g_DrvVBoxHDD; 96 95 extern const PDMDRVREG g_DrvVD; 97 96 extern const PDMDRVREG g_DrvHostDVD; 98 97 extern const PDMDRVREG g_DrvHostFloppy; 99 extern const PDMDRVREG g_DrvMediaISO;100 extern const PDMDRVREG g_DrvRawImage;101 98 extern const PDMDRVREG g_DrvISCSI; 102 99 extern const PDMDRVREG g_DrvISCSITransportTcp; -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r59183 r59248 892 892 GEN_CHECK_OFF(ATADevState, cErrors); 893 893 GEN_CHECK_OFF(ATADevState, pDrvBase); 894 GEN_CHECK_OFF(ATADevState, pDrvBlock); 895 GEN_CHECK_OFF(ATADevState, pDrvBlockBios); 894 GEN_CHECK_OFF(ATADevState, pDrvMedia); 896 895 GEN_CHECK_OFF(ATADevState, pDrvMount); 897 896 GEN_CHECK_OFF(ATADevState, IBase); … … 1349 1348 GEN_CHECK_OFF(AHCIPort, u32CurrentCommandSlot); 1350 1349 GEN_CHECK_OFF(AHCIPort, pDrvBase); 1351 GEN_CHECK_OFF(AHCIPort, pDrvBlock); 1352 GEN_CHECK_OFF(AHCIPort, pDrvBlockAsync); 1353 GEN_CHECK_OFF(AHCIPort, pDrvBlockBios); 1350 GEN_CHECK_OFF(AHCIPort, pDrvMedia); 1351 GEN_CHECK_OFF(AHCIPort, pDrvMediaAsync); 1354 1352 GEN_CHECK_OFF(AHCIPort, pDrvMount); 1355 1353 GEN_CHECK_OFF(AHCIPort, IBase); -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r59229 r59248 4294 4294 else 4295 4295 { 4296 InsertConfigString(pLunL0, "Driver", "Block"); 4296 #if 0 /* Enable for I/O debugging */ 4297 InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0); 4298 InsertConfigString(pLunL0, "Driver", "DiskIntegrity"); 4299 InsertConfigNode(pLunL0, "Config", &pCfg); 4300 InsertConfigInteger(pCfg, "CheckConsistency", 0); 4301 InsertConfigInteger(pCfg, "CheckDoubleCompletions", 1); 4302 #endif 4303 4304 InsertConfigString(pLunL0, "Driver", "VD"); 4297 4305 InsertConfigNode(pLunL0, "Config", &pCfg); 4298 4306 switch (enmType) … … 4350 4358 /* Index of last image */ 4351 4359 uImage--; 4352 4353 #if 0 /* Enable for I/O debugging */4354 InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);4355 InsertConfigString(pLunL0, "Driver", "DiskIntegrity");4356 InsertConfigNode(pLunL0, "Config", &pCfg);4357 InsertConfigInteger(pCfg, "CheckConsistency", 0);4358 InsertConfigInteger(pCfg, "CheckDoubleCompletions", 1);4359 #endif4360 4361 InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);4362 InsertConfigString(pLunL1, "Driver", "VD");4363 InsertConfigNode(pLunL1, "Config", &pCfg);4364 4360 4365 4361 # ifdef VBOX_WITH_EXTPACK … … 4436 4432 } 4437 4433 4438 switch (enmType)4439 {4440 case DeviceType_DVD:4441 InsertConfigString(pCfg, "Type", "DVD");4442 break;4443 case DeviceType_Floppy:4444 InsertConfigString(pCfg, "Type", "Floppy");4445 break;4446 case DeviceType_HardDisk:4447 default:4448 InsertConfigString(pCfg, "Type", "HardDisk");4449 }4450 4451 4434 if (pcszBwGroup) 4452 4435 InsertConfigString(pCfg, "BwGroup", pcszBwGroup); … … 4500 4483 if (fEncrypted) 4501 4484 m_cDisksEncrypted++; 4485 } 4486 else 4487 { 4488 /* Set empty drive flag for DVD or floppy without media. */ 4489 if ( enmType == DeviceType_DVD 4490 || enmType == DeviceType_Floppy) 4491 InsertConfigInteger(pCfg, "EmptyDrive", 1); 4502 4492 } 4503 4493 }
Note:
See TracChangeset
for help on using the changeset viewer.