Initial Multi adapter changes.

Change-Id: Iedfd8928e887c6412f8df9a2fba2aac13e285ef3
diff --git a/Source/GmmLib/CMakeLists.txt b/Source/GmmLib/CMakeLists.txt
index c3fa2ff..2e634eb 100644
--- a/Source/GmmLib/CMakeLists.txt
+++ b/Source/GmmLib/CMakeLists.txt
@@ -24,11 +24,11 @@
 project(igfx_gmmumd)
 
 # GmmLib Api Version used for so naming
-set(GMMLIB_API_MAJOR_VERSION 11)
+set(GMMLIB_API_MAJOR_VERSION 12)
 set(GMMLIB_API_MINOR_VERSION 0)
 
 if(NOT DEFINED MAJOR_VERSION)
-	set(MAJOR_VERSION 11)
+	set(MAJOR_VERSION 12)
 endif()
 
 if(NOT DEFINED MINOR_VERSION)
diff --git a/Source/GmmLib/GlobalInfo/GmmLibDllMain.cpp b/Source/GmmLib/GlobalInfo/GmmLibDllMain.cpp
index 14c14f8..1036f85 100755
--- a/Source/GmmLib/GlobalInfo/GmmLibDllMain.cpp
+++ b/Source/GmmLib/GlobalInfo/GmmLibDllMain.cpp
@@ -85,46 +85,36 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
-/// First Call to GMM Lib DLL/so to initialize singleton global context
-/// and create client context
-///
+// First Call to GMM Lib DLL/so to initialize singleton global context
+// and create client context
 /////////////////////////////////////////////////////////////////////////////////////
-#ifdef _WIN32
-extern "C" GMM_LIB_API GMM_CLIENT_CONTEXT *GMM_STDCALL GmmInit(const PLATFORM           Platform,
-                                                               const SKU_FEATURE_TABLE *pSkuTable,
-                                                               const WA_TABLE *         pWaTable,
-                                                               const GT_SYSTEM_INFO *   pGtSysInfo,
-                                                               GMM_CLIENT               ClientType)
-#else
-extern "C" GMM_LIB_API GMM_CLIENT_CONTEXT *GMM_STDCALL GmmInit(const PLATFORM Platform,
-                                                               const void *   pSkuTable,
-                                                               const void *   pWaTable,
-                                                               const void *   pGtSysInfo,
-                                                               GMM_CLIENT     ClientType)
-#endif
+extern "C" GMM_LIB_API GMM_STATUS GMM_STDCALL InitializeGmm(GMM_INIT_IN_ARGS *pInArgs, GMM_INIT_OUT_ARGS *pOutArgs)
 {
-    GMM_STATUS          Status         = GMM_SUCCESS;
-    GMM_CLIENT_CONTEXT *pClientContext = NULL;
+    GMM_STATUS Status = GMM_ERROR;
 
-
-    Status = GmmCreateSingletonContext(Platform, pSkuTable, pWaTable, pGtSysInfo);
-
-    if(Status == GMM_SUCCESS)
+    if(pInArgs && pOutArgs)
     {
-        pClientContext = GmmCreateClientContext(ClientType);
+
+        Status = GmmCreateSingletonContext(pInArgs->Platform, pInArgs->pSkuTable, pInArgs->pWaTable, pInArgs->pGtSysInfo);
+
+        if(Status == GMM_SUCCESS)
+        {
+            pOutArgs->pGmmClientContext = GmmCreateClientContext(pInArgs->ClientType);
+        }
     }
 
-    return pClientContext;
+    return Status;
 }
 
-
 /////////////////////////////////////////////////////////////////////////////////////
-/// Destroys singleton global context and client context
-///
+// Destroys singleton global context and client context
 /////////////////////////////////////////////////////////////////////////////////////
-extern "C" GMM_LIB_API void GMM_STDCALL GmmDestroy(GMM_CLIENT_CONTEXT *pGmmClientContext)
+extern "C" GMM_LIB_API void GMM_STDCALL GmmDestroy(GMM_INIT_OUT_ARGS *pInArgs)
 {
-    GmmDestroySingletonContext();
-    GmmDeleteClientContext(pGmmClientContext);
+    if(pInArgs && pInArgs->pGmmClientContext)
+    {
+        GmmDeleteClientContext(pInArgs->pGmmClientContext);
+        GmmDestroySingletonContext();
+    }
 }
 #endif // GMM_LIB_DLL
diff --git a/Source/GmmLib/ULT/GmmCommonULT.cpp b/Source/GmmLib/ULT/GmmCommonULT.cpp
index 0498c78..2fa1172 100644
--- a/Source/GmmLib/ULT/GmmCommonULT.cpp
+++ b/Source/GmmLib/ULT/GmmCommonULT.cpp
@@ -57,6 +57,9 @@
 {
     printf("%s\n", __FUNCTION__);
 
+    GMM_INIT_IN_ARGS  InArgs;
+    GMM_INIT_OUT_ARGS OutArgs;
+
     if(GfxPlatform.eProductFamily == IGFX_UNKNOWN ||
        GfxPlatform.eRenderCoreFamily == IGFX_UNKNOWN_CORE)
     {
@@ -66,20 +69,23 @@
 
     AllocateAdapterInfo();
 
+    InArgs.ClientType = GMM_EXCITE_VISTA;
+    InArgs.pGtSysInfo = &pGfxAdapterInfo->SystemInfo;
+    InArgs.pSkuTable  = &pGfxAdapterInfo->SkuTable;
+    InArgs.pWaTable   = &pGfxAdapterInfo->WaTable;
+    InArgs.Platform   = GfxPlatform;
+
     hGmmLib = dlopen(GMM_UMD_DLL, RTLD_LAZY);
     ASSERT_TRUE(hGmmLib);
 
-    *(void **)(&pfnGmmInit)    = dlsym(hGmmLib, "GmmInit");
+    *(void **)(&pfnGmmInit)    = dlsym(hGmmLib, "InitializeGmm");
     *(void **)(&pfnGmmDestroy) = dlsym(hGmmLib, "GmmDestroy");
 
     ASSERT_TRUE(pfnGmmInit);
     ASSERT_TRUE(pfnGmmDestroy);
 
-    pGmmULTClientContext = pfnGmmInit(GfxPlatform,
-                                      &pGfxAdapterInfo->SkuTable,
-                                      &pGfxAdapterInfo->WaTable,
-                                      &pGfxAdapterInfo->SystemInfo,
-                                      GMM_EXCITE_VISTA);
+    pfnGmmInit(&InArgs, &OutArgs);
+    pGmmULTClientContext = OutArgs.pGmmClientContext;
 
     ASSERT_TRUE(pGmmULTClientContext);
 }
@@ -88,7 +94,10 @@
 {
     printf("%s\n", __FUNCTION__);
 
-    pfnGmmDestroy(static_cast<GMM_CLIENT_CONTEXT *>(pGmmULTClientContext));
+    GMM_INIT_OUT_ARGS OutArgs;
+    OutArgs.pGmmClientContext = static_cast<GMM_CLIENT_CONTEXT *>(pGmmULTClientContext);
+
+    pfnGmmDestroy(&OutArgs);
 
     if(hGmmLib)
     {
diff --git a/Source/GmmLib/ULT/GmmCommonULT.h b/Source/GmmLib/ULT/GmmCommonULT.h
index d62e3d3..2f07252 100644
--- a/Source/GmmLib/ULT/GmmCommonULT.h
+++ b/Source/GmmLib/ULT/GmmCommonULT.h
@@ -24,21 +24,8 @@
 
 #include "stdafx.h"
 
-typedef GMM_CLIENT_CONTEXT *(GMM_STDCALL * PFNGMMINIT)
-#ifdef _WIN32
-    (const PLATFORM,
-    const SKU_FEATURE_TABLE *,
-    const WA_TABLE *,
-    const GT_SYSTEM_INFO *,
-    GMM_CLIENT);
-#else
-    (const PLATFORM Platform,
-    const void *   pSkuTable,
-    const void *   pWaTable,
-    const void *   pGtSysInfo,
-    GMM_CLIENT ClientType);
-#endif
-typedef void(GMM_STDCALL *PFNGMMDESTROY)(GMM_CLIENT_CONTEXT *);
+typedef GMM_STATUS (GMM_STDCALL *PFNGMMINIT)(GMM_INIT_IN_ARGS *pInArgs, GMM_INIT_OUT_ARGS *pOutArgs);
+typedef void(GMM_STDCALL *PFNGMMDESTROY)(GMM_INIT_OUT_ARGS *pInArgs);
 
 class CommonULT : public testing::Test
 {
diff --git a/Source/GmmLib/inc/External/Common/GmmLibDll.h b/Source/GmmLib/inc/External/Common/GmmLibDll.h
index 3156d16..0d5cba3 100755
--- a/Source/GmmLib/inc/External/Common/GmmLibDll.h
+++ b/Source/GmmLib/inc/External/Common/GmmLibDll.h
@@ -24,6 +24,21 @@
 #include "GmmCommonExt.h"
 #include "GmmInfo.h"
 
+typedef struct _GMM_INIT_IN_ARGS_
+{
+    PLATFORM           Platform;
+    void              *pSkuTable;
+    void              *pWaTable;
+    void              *pGtSysInfo;
+    uint32_t           FileDescriptor;
+    GMM_CLIENT ClientType;
+} GMM_INIT_IN_ARGS;
+
+typedef struct _GMM_INIT_OUT_ARGS_
+{
+    GMM_CLIENT_CONTEXT *pGmmClientContext;
+} GMM_INIT_OUT_ARGS;
+
 // Interfaces exported from  GMM Lib DLL
 typedef struct _GmmExportEntries
 {
@@ -54,6 +69,8 @@
 /// Only function exported from GMM lib DLL.
 /////////////////////////////////////////////////////////////////////////////////////
     GMM_LIB_API GMM_STATUS GMM_STDCALL OpenGmm(GmmExportEntries *pm_GmmFuncs);
+    GMM_LIB_API GMM_STATUS GMM_STDCALL InitializeGmm(GMM_INIT_IN_ARGS *pInArgs, GMM_INIT_OUT_ARGS *pOutArgs);
+    GMM_LIB_API void GMM_STDCALL GmmDestroy(GMM_INIT_OUT_ARGS *pInArgs);
 
 #ifdef __cplusplus
 }
diff --git a/Source/GmmLib/inc/External/Common/GmmLibDllName.h b/Source/GmmLib/inc/External/Common/GmmLibDllName.h
index 31b0d1c..8890894 100755
--- a/Source/GmmLib/inc/External/Common/GmmLibDllName.h
+++ b/Source/GmmLib/inc/External/Common/GmmLibDllName.h
@@ -23,23 +23,23 @@
 
 #if defined(_WIN64 ) || defined(__x86_64__) || defined(__LP64__)
     #define GMM_ENTRY_NAME      "OpenGmm"
-    #define GMM_INIT_NAME       "GmmInit"
+    #define GMM_INIT_NAME       "InitializeGmm"
     #define GMM_DESTROY_NAME    "GmmDestroy"
 
     #if defined(_WIN64)
         #define GMM_UMD_DLL     "igdgmm64.dll"
     #else
-        #define GMM_UMD_DLL     "libigdgmm.so.11"
+        #define GMM_UMD_DLL     "libigdgmm.so.12"
     #endif
 #else
     #define GMM_ENTRY_NAME      "_OpenGmm@4"
 
-    #define GMM_INIT_NAME       "_GmmInit@48"
+    #define GMM_INIT_NAME       "_InitializeGmm@8"
     #define GMM_DESTROY_NAME    "_GmmDestroy@4"
 
     #if defined(_WIN32)
         #define GMM_UMD_DLL     "igdgmm32.dll"
     #else
-        #define GMM_UMD_DLL     "libigdgmm.so.11"
+        #define GMM_UMD_DLL     "libigdgmm.so.12"
     #endif
 #endif
diff --git a/Source/inc/umKmInc/sharedata.h b/Source/inc/umKmInc/sharedata.h
index 94a17d6..31dddc3 100644
--- a/Source/inc/umKmInc/sharedata.h
+++ b/Source/inc/umKmInc/sharedata.h
@@ -134,6 +134,22 @@
     uint32_t                                   ActiveDisplay;
 } KM_DEFERRED_WAIT_INFO;
 
+// struct to hold Adapter's BDF
+typedef struct _ADAPTER_BDF_
+{
+    union
+    {
+        struct
+        {
+            uint32_t    Bus         : 8;
+            uint32_t    Device      : 8;
+            uint32_t    Function    : 8;
+            uint32_t    Reserved    : 8;
+        };
+        uint32_t    Data;
+    };
+}ADAPTER_BDF;
+
 // Private data structure for D3D callback QueryAdapterInfoCB
 
 //===========================================================================