Index: trunk/include/VBox/pdmifs.h
===================================================================
--- trunk/include/VBox/pdmifs.h	(revision 25971)
+++ trunk/include/VBox/pdmifs.h	(revision 25974)
@@ -46,20 +46,4 @@
  * @{
  */
-/** PDMISTREAM              - The stream driver interface           (Up)    No coupling.
- * Used by a char driver to implement PDMINTERFACE_CHAR. */
-#define PDMINTERFACE_STREAM                     "d1a5bf5e-3d2c-449a-bde9-addd7920b71f"
-/** PDMIBLOCKPORT           - The block notify interface            (Down)  Coupled with PDMINTERFACE_BLOCK. */
-#define PDMINTERFACE_BLOCK_PORT                 "e87fa1ab-92d5-4100-8712-fe2a0c042faf"
-/** PDMIBLOCK               - The block driver interface            (Up)    Coupled with PDMINTERFACE_BLOCK_PORT. */
-#define PDMINTERFACE_BLOCK                      "0a5f3156-8b21-4cf5-83fd-e097281d2900"
-/** PDMIBLOCKBIOS           - The block bios interface.             (External) */
-#define PDMINTERFACE_BLOCK_BIOS                 "477c3eee-a48d-48a9-82fd-2a54de16b2e9"
-/** PDMIMOUNTNOTIFY         - The mountable notification interface. (Down)  Coupled with PDMINTERFACE_MOUNT. */
-#define PDMINTERFACE_MOUNT_NOTIFY               "fa143ac9-9fc6-498e-997f-945380a558f9"
-/** PDMIMOUNT               - The mountable interface.              (Up)    Coupled with PDMINTERFACE_MOUNT_NOTIFY. */
-#define PDMINTERFACE_MOUNT                      "8e5a009a-6032-4ca1-9d86-a388d8eaf926"
-/** PDMIMEDIA               - The media interface.                  (Up)    No coupling.
- * Used by a block unit driver to implement PDMINTERFACE_BLOCK and PDMINTERFACE_BLOCK_BIOS. */
-#define PDMINTERFACE_MEDIA                      "f5bb07c9-2843-46f8-a56f-cc090b6e5bac"
 /** PDMIISCSITRANSPORT      - The iSCSI transport interface         (Up)    No coupling.
  * used by the iSCSI media driver.  */
@@ -71,13 +55,4 @@
  * notify port used by the iSCSI media driver.  */
 #define PDMINTERFACE_ISCSITRANSPORTASYNCPORT    "6ab0fbf1-aa72-4b27-bc46-f58896ba0392"
-/** PDMIMEDIAASYNC          - Async version of the media interface  (Down)  Coupled with PDMINTERFACE_MEDIA_ASYNC_PORT. */
-#define PDMINTERFACE_MEDIA_ASYNC                "d7bc3c90-e686-4d9c-a7bc-6c6742e452ec"
-/** PDMIMEDIAASYNCPORT      - Async version of the media interface  (Up)    Coupled with PDMINTERFACE_MEDIA_ASYNC. */
-#define PDMINTERFACE_MEDIA_ASYNC_PORT           "22d38853-901f-4a71-9670-4d9da6e82317"
-/** PDMIBLOCKASYNC          - Async version of the block interface  (Down)  Coupled with PDMINTERFACE_BLOCK_ASYNC_PORT. */
-#define PDMINTERFACE_BLOCK_ASYNC                "142cd775-3be6-4c9f-9e3d-68969c3d4779"
-/** PDMIBLOCKASYNCPORT      - Async version of the block interface  (Up)    Coupled with PDMINTERFACE_BLOCK_ASYNC. */
-#define PDMINTERFACE_BLOCK_ASYNC_PORT           "e3bdc0cb-9d99-41dd-8eec-0dc8cf5b2a92"
-
 
 /** PDMINETWORKPORT         - The network port interface.           (Down)  Coupled with PDMINTERFACE_NETWORK_CONNECTOR. */
@@ -164,10 +139,30 @@
  * @returns Correctly typed PDMIBASE::pfnQueryInterface return value.
  *
- * @param    pIBase         Pointer to the base interface.
- * @param    InterfaceType  The interface type name.  The interface ID is
+ * @param   pIBase          Pointer to the base interface.
+ * @param   InterfaceType   The interface type name.  The interface ID is
  *                          derived from this by appending _IID.
  */
 #define PDMIBASE_QUERY_INTERFACE(pIBase, InterfaceType)  \
     ( (InterfaceType *)(pIBase)->pfnQueryInterface(pIBase, InterfaceType##_IID ) )
+
+/**
+ * Helper macro for implementing PDMIBASE::pfnQueryInterface.
+ *
+ * Return @a pInterface if @a pszIID matches the @a InterfaceType.  This will
+ * perform basic type checking.
+ *
+ * @param   pszIID          The ID of the interface that is being queried.
+ * @param   InterfaceType   The interface type name.  The interface ID is
+ *                          derived from this by appending _IID.
+ * @param   pInterface      The interface address expression.
+ */
+#define PDMIBASE_RETURN_INTERFACE(pszIID, InterfaceType, pInterface)  \
+    do { \
+        if (RTUuidCompare2Strs((pszIID), InterfaceType##_IID) == 0) \
+        { \
+            InterfaceType *pReturnInterfaceTypeCheck = (pInterface); \
+            return pReturnInterfaceTypeCheck; \
+        } \
+    } while (0)
 
 
@@ -654,4 +649,15 @@
 /** PDMIDISPLAYCONNECTOR interface ID. */
 #define PDMIDISPLAYCONNECTOR_IID                "c7a1b36d-8dfc-421d-b71f-3a0eeaf733e6"
+
+
+/**
+ * Block notify interface (down).
+ * Pair with PDMIBLOCK.
+ */
+typedef PDMIDUMMY PDMIBLOCKPORT;
+/** PDMIBLOCKPORT interface ID. */
+#define PDMIBLOCKPORT_IID                 "e87fa1ab-92d5-4100-8712-fe2a0c042faf"
+/** Pointer to a block notify interface (dummy). */
+typedef PDMIBLOCKPORT *PPDMIBLOCKPORT;
 
 
@@ -692,16 +698,9 @@
 } PDMBLOCKTXDIR;
 
-/**
- * Block notify interface.
- * Pair with PDMIBLOCK.
- */
-typedef PDMIDUMMY PDMIBLOCKPORT;
-/** Pointer to a block notify interface (dummy). */
-typedef PDMIBLOCKPORT *PPDMIBLOCKPORT;
 
 /** Pointer to a block interface. */
 typedef struct PDMIBLOCK *PPDMIBLOCK;
 /**
- * Block interface.
+ * Block interface (up).
  * Pair with PDMIBLOCKPORT.
  */
@@ -796,4 +795,6 @@
     DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIBLOCK pInterface, PRTUUID pUuid));
 } PDMIBLOCK;
+/** PDMIBLOCK interface ID. */
+#define PDMIBLOCK_IID                           "0a5f3156-8b21-4cf5-83fd-e097281d2900"
 
 
@@ -801,5 +802,5 @@
 typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY;
 /**
- * Block interface.
+ * Block interface (up).
  * Pair with PDMIMOUNT.
  */
@@ -821,10 +822,12 @@
     DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface));
 } PDMIMOUNTNOTIFY;
-
-
-/* Pointer to mount interface. */
+/** PDMIMOUNTNOTIFY interface ID. */
+#define PDMIMOUNTNOTIFY_IID                     "fa143ac9-9fc6-498e-997f-945380a558f9"
+
+
+/** Pointer to mount interface. */
 typedef struct PDMIMOUNT *PPDMIMOUNT;
 /**
- * Mount interface.
+ * Mount interface (down).
  * Pair with PDMIMOUNTNOTIFY.
  */
@@ -895,5 +898,8 @@
      */
     DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface));
-} PDMIBLOCKMOUNT;
+} PDMIMOUNT;
+/** PDMIMOUNT interface ID. */
+#define PDMIMOUNT_IID                           "8e5a009a-6032-4ca1-9d86-a388d8eaf926"
+
 
 /**
@@ -918,6 +924,6 @@
 typedef struct PDMIMEDIA *PPDMIMEDIA;
 /**
- * Media interface.
- * Makes up the foundation for PDMIBLOCK and PDMIBLOCKBIOS.
+ * Media interface (up).
+ * Makes up the foundation for PDMIBLOCK and PDMIBLOCKBIOS.  No interface pair.
  */
 typedef struct PDMIMEDIA
@@ -1040,4 +1046,6 @@
 
 } PDMIMEDIA;
+/** PDMIMEDIA interface ID. */
+#define PDMIMEDIA_IID                           "f5bb07c9-2843-46f8-a56f-cc090b6e5bac"
 
 
@@ -1045,5 +1053,5 @@
 typedef struct PDMIBLOCKBIOS *PPDMIBLOCKBIOS;
 /**
- * Media BIOS interface.
+ * Media BIOS interface (Up / External).
  * The interface the getting and setting properties which the BIOS/CMOS care about.
  */
@@ -1124,4 +1132,6 @@
 
 } PDMIBLOCKBIOS;
+/** PDMIBLOCKBIOS interface ID. */
+#define PDMIBLOCKBIOS_IID                       "477c3eee-a48d-48a9-82fd-2a54de16b2e9"
 
 
@@ -1302,5 +1312,5 @@
 typedef struct PDMIBLOCKASYNCPORT *PPDMIBLOCKASYNCPORT;
 /**
- * Asynchronous block notify interface.
+ * Asynchronous block notify interface (up).
  * Pair with PDMIBLOCKASYNC.
  */
@@ -1317,4 +1327,7 @@
     DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIBLOCKASYNCPORT pInterface, void *pvUser));
 } PDMIBLOCKASYNCPORT;
+/** PDMIBLOCKASYNCPORT interface ID. */
+#define PDMIBLOCKASYNCPORT_IID                  "e3bdc0cb-9d99-41dd-8eec-0dc8cf5b2a92"
+
 
 
@@ -1322,5 +1335,5 @@
 typedef struct PDMIBLOCKASYNC *PPDMIBLOCKASYNC;
 /**
- * Asynchronous block interface.
+ * Asynchronous block interface (down).
  * Pair with PDMIBLOCKASYNCPORT.
  */
@@ -1356,4 +1369,6 @@
 
 } PDMIBLOCKASYNC;
+/** PDMIBLOCKASYNC interface ID. */
+#define PDMIBLOCKASYNC_IID                      "142cd775-3be6-4c9f-9e3d-68969c3d4779"
 
 
@@ -1361,6 +1376,6 @@
 typedef struct PDMIMEDIAASYNCPORT *PPDMIMEDIAASYNCPORT;
 /**
- * Asynchronous media interface.
- * Makes up the fundation for PDMIBLOCKASYNC and PDMIBLOCKBIOS.
+ * Asynchronous version of the media interface (up).
+ * Pair with PDMIMEDIAASYNC.
  */
 typedef struct PDMIMEDIAASYNCPORT
@@ -1376,4 +1391,6 @@
     DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIMEDIAASYNCPORT pInterface, void *pvUser));
 } PDMIMEDIAASYNCPORT;
+/** PDMIMEDIAASYNCPORT interface ID. */
+#define PDMIMEDIAASYNCPORT_IID                  "22d38853-901f-4a71-9670-4d9da6e82317"
 
 
@@ -1381,6 +1398,6 @@
 typedef struct PDMIMEDIAASYNC *PPDMIMEDIAASYNC;
 /**
- * Asynchronous media interface.
- * Makes up the fundation for PDMIBLOCKASYNC and PDMIBLOCKBIOS.
+ * Asynchronous version of PDMIMEDIA (down).
+ * Pair with PDMIMEDIAASYNCPORT.
  */
 typedef struct PDMIMEDIAASYNC
@@ -1415,4 +1432,6 @@
 
 } PDMIMEDIAASYNC;
+/** PDMIMEDIAASYNC interface ID. */
+#define PDMIMEDIAASYNC_IID                      "d7bc3c90-e686-4d9c-a7bc-6c6742e452ec"
 
 
@@ -1527,6 +1546,6 @@
 typedef struct PDMISTREAM *PPDMISTREAM;
 /**
- * Stream interface.
- * Makes up the foundation for PDMICHARCONNECTOR.
+ * Stream interface (up).
+ * Makes up the foundation for PDMICHARCONNECTOR.  No pair interface.
  */
 typedef struct PDMISTREAM
@@ -1554,4 +1573,6 @@
     DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMISTREAM pInterface, const void *pvBuf, size_t *cbWrite));
 } PDMISTREAM;
+/** PDMISTREAM interface ID. */
+#define PDMISTREAM_IID                          "d1a5bf5e-3d2c-449a-bde9-addd7920b71f"
 
 
