Add new generic API in Clientcontext for getting DeviceCB
 and saving this in clientcontext for later use.

unlink getting same info from the existing API's
CreatePageatlbMgrObject. use the saved info
from the ClientContext.

Change-Id: I477db65c161701d002880ab04f874c2761f4d3e3
diff --git a/Source/GmmLib/CMakeLists.txt b/Source/GmmLib/CMakeLists.txt
index db4373d..c3fa2ff 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 10)
+set(GMMLIB_API_MAJOR_VERSION 11)
 set(GMMLIB_API_MINOR_VERSION 0)
 
 if(NOT DEFINED MAJOR_VERSION)
-	set(MAJOR_VERSION 10)
+	set(MAJOR_VERSION 11)
 endif()
 
 if(NOT DEFINED MINOR_VERSION)
diff --git a/Source/GmmLib/GlobalInfo/GmmClientContext.cpp b/Source/GmmLib/GlobalInfo/GmmClientContext.cpp
index 51258f0..592dcbb 100644
--- a/Source/GmmLib/GlobalInfo/GmmClientContext.cpp
+++ b/Source/GmmLib/GlobalInfo/GmmClientContext.cpp
@@ -37,7 +37,9 @@
 GmmLib::GmmClientContext::GmmClientContext(GMM_CLIENT ClientType)
     : ClientType(),
       pUmdAdapter(),
-      pGmmUmdContext()
+      pGmmUmdContext(),
+      DeviceCB(),
+      IsDeviceCbReceived(0)
 {
     this->ClientType = ClientType;
 }
@@ -470,8 +472,25 @@
 /// Member function of ClientContext class for creation of PAgeTableMgr Object .
 /// @see        GmmLib::GMM_PAGETABLE_MGR::GMM_PAGETABLE_MGR
 ///
+/// @param[in] TTFags
+/// @return     Pointer to GMM_PAGETABLE_MGR class.
+/////////////////////////////////////////////////////////////////////////////////////
+GMM_PAGETABLE_MGR* GMM_STDCALL GmmLib::GmmClientContext::CreatePageTblMgrObject(uint32_t TTFlags)
+{
+    if (!IsDeviceCbReceived)
+    {
+        GMM_ASSERTDPF(0, "Device_callbacks not set");
+        return NULL;
+    }
+
+    return CreatePageTblMgrObject(&DeviceCB, TTFlags);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// Member function of ClientContext class for creation of PAgeTableMgr Object .
+/// @see        GmmLib::GMM_PAGETABLE_MGR::GMM_PAGETABLE_MGR
+///
 /// @param[in] pDevCb: Pointer to GMM_DEVICE_CALLBACKS_INT
-/// @param[in] pTTCB: Pointer to GMM_TRANSLATIONTABLE_CALLBACKS
 /// @param[in] TTFags
 /// @return     Pointer to GMM_PAGETABLE_MGR class.
 //TBD: move the code to new overloaded the API and remove this API once all clients are moved to new API.
@@ -603,12 +622,33 @@
     }
 }
 #endif
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// Member function of ClientContext class for creation of PAgeTableMgr Object .
+/// @see        GmmLib::GMM_PAGETABLE_MGR::GMM_PAGETABLE_MGR
+///
+/// @param[in] TTFags
+/// @return     Pointer to GMM_PAGETABLE_MGR class.
+/////////////////////////////////////////////////////////////////////////////////////
+GMM_PAGETABLE_MGR* GMM_STDCALL GmmLib::GmmClientContext::CreatePageTblMgrObject(uint32_t TTFlags,
+                                                         GmmClientAllocationCallbacks* pAllocCbs)
+{
+    if (!IsDeviceCbReceived)
+    {
+        GMM_ASSERTDPF(0, "Device_callbacks not set");
+        return NULL;
+    }
+    return CreatePageTblMgrObject(
+        &DeviceCB,
+        TTFlags,
+        pAllocCbs);
+}
+
 /////////////////////////////////////////////////////////////////////////////////////
 /// Member function of ClientContext class for creation of PAgeTableMgr Object .
 /// @see        GmmLib::GMM_PAGETABLE_MGR::GMM_PAGETABLE_MGR
 ///
 /// @param[in] pDevCb: Pointer to GMM_DEVICE_CALLBACKS_INT
-/// @param[in] pTTCB: Pointer to GMM_TRANSLATIONTABLE_CALLBACKS
 /// @param[in] TTFags
 /// @return     Pointer to GMM_PAGETABLE_MGR class.
 /// TBD: move the code to new overloaded the API and remove this API once all clients are moved to new API.
@@ -646,6 +686,27 @@
     }
 }
 
+////////////////////////////////////////////////////////////////////////////////////
+/// Member function of ClientContext class for doing device specific operations.
+/// Clients must call it before any Gfx resource (incl. svm)
+/// is mapped, must happen before any use of GfxPartition, or PageTableMgr init.
+/// @param[in]  DeviceInfo : Pointer to info related to Device Operations.
+/// @return     GMM_STATUS.
+//////////////////////////////////////////////////////////////////////////////////////////
+GMM_STATUS GMM_STDCALL GmmLib::GmmClientContext::GmmSetDeviceInfo(GMM_DEVICE_INFO* DeviceInfo)
+{
+    GMM_STATUS Status = GMM_SUCCESS;
+
+    if (DeviceInfo == NULL || DeviceInfo->pDeviceCb == NULL)
+    {
+        return GMM_INVALIDPARAM;
+    }
+
+    DeviceCB = *(DeviceInfo->pDeviceCb);
+    IsDeviceCbReceived = 1;
+    return Status;
+}
+
 /////////////////////////////////////////////////////////////////////////////////////
 /// Gmm lib DLL exported C wrapper for creating GmmLib::GmmClientContext object
 /// @see        Class GmmLib::GmmClientContext
diff --git a/Source/GmmLib/inc/External/Common/GmmClientContext.h b/Source/GmmLib/inc/External/Common/GmmClientContext.h
index 8dcca1f..525585a 100644
--- a/Source/GmmLib/inc/External/Common/GmmClientContext.h
+++ b/Source/GmmLib/inc/External/Common/GmmClientContext.h
@@ -47,6 +47,17 @@
     PFN_ClientFreeFunction                  pfnFree;
 } GmmClientAllocationCallbacks;
 
+//===========================================================================
+// typedef:
+//      GMM_DEVICE_OPERATION
+//
+// Description:
+//     Decribes compoents required for device operations.
+//---------------------------------------------- ------------------------------
+typedef struct _GMM_DEVICE_INFO_REC
+{
+    GMM_DEVICE_CALLBACKS_INT     *pDeviceCb;
+}GMM_DEVICE_INFO;
 
 #ifdef __cplusplus
 #include "GmmMemAllocator.hpp"
@@ -71,7 +82,9 @@
         ///< Placeholders for storing UMD context. Actual UMD context that needs to be stored here is TBD
         void                             *pUmdAdapter;
         GMM_UMD_CONTEXT                  *pGmmUmdContext;
-
+        GMM_DEVICE_CALLBACKS_INT          DeviceCB;       //OS-specific defn: Will be used by Clients to send as input arguments.
+        // Flag to indicate Device_callbacks received.
+        uint8_t             IsDeviceCbReceived;
     public:
         /* Constructor */
         GmmClientContext(GMM_CLIENT ClientType);
@@ -122,6 +135,12 @@
         GMM_VIRTUAL GMM_RESOURCE_INFO* GMM_STDCALL       CopyResInfoObject(GMM_RESOURCE_INFO *pSrcRes);
         GMM_VIRTUAL void GMM_STDCALL                     ResMemcpy(void *pDst, void *pSrc);
         GMM_VIRTUAL void  GMM_STDCALL                    DestroyResInfoObject(GMM_RESOURCE_INFO    *pResInfo);
+        /* PageTableMgr Creation and Destroy API's */
+        GMM_VIRTUAL GMM_PAGETABLE_MGR* GMM_STDCALL      CreatePageTblMgrObject(GMM_DEVICE_CALLBACKS_INT* pDevCb, uint32_t TTFlags);
+        GMM_VIRTUAL GMM_PAGETABLE_MGR* GMM_STDCALL      CreatePageTblMgrObject(uint32_t TTFlags);
+        /* PageTableMgr Creation and Destroy API's */
+        GMM_VIRTUAL void GMM_STDCALL                    DestroyPageTblMgrObject(GMM_PAGETABLE_MGR* pPageTableMgr);
+
         
 #ifdef GMM_LIB_DLL
         /* ResourceInfo and PageTableMgr Create and Destroy APIs with Client provided Memory Allocators */
@@ -130,18 +149,17 @@
         GMM_VIRTUAL void  GMM_STDCALL                    DestroyResInfoObject(GMM_RESOURCE_INFO    *pResInfo,
                                                                               GmmClientAllocationCallbacks *pAllocCbs);
 #endif
-         
-        /* PageTableMgr Creation and Destroy API's */
-        GMM_VIRTUAL GMM_PAGETABLE_MGR*  GMM_STDCALL      CreatePageTblMgrObject(GMM_DEVICE_CALLBACKS_INT *pDevCb, uint32_t TTFlags);
-        /* PageTableMgr Creation and Destroy API's */
-        GMM_VIRTUAL void GMM_STDCALL                    DestroyPageTblMgrObject(GMM_PAGETABLE_MGR    *pPageTableMgr);
-        
+
         GMM_VIRTUAL GMM_PAGETABLE_MGR* GMM_STDCALL      CreatePageTblMgrObject(
                                                         GMM_DEVICE_CALLBACKS_INT* pDevCb,
                                                         uint32_t TTFlags,
                                                         GmmClientAllocationCallbacks* pAllocCbs);
+        GMM_VIRTUAL GMM_PAGETABLE_MGR* GMM_STDCALL      CreatePageTblMgrObject(
+                                                        uint32_t TTFlags,
+                                                        GmmClientAllocationCallbacks* pAllocCbs);
         GMM_VIRTUAL void GMM_STDCALL                    DestroyPageTblMgrObject(GMM_PAGETABLE_MGR* pPageTableMgr,
                                                         GmmClientAllocationCallbacks* pAllocCbs);
+        GMM_VIRTUAL GMM_STATUS GMM_STDCALL              GmmSetDeviceInfo(GMM_DEVICE_INFO* DeviceInfo);
     };
 }
 
diff --git a/Source/GmmLib/inc/External/Common/GmmLibDllName.h b/Source/GmmLib/inc/External/Common/GmmLibDllName.h
index 8d16227..31b0d1c 100755
--- a/Source/GmmLib/inc/External/Common/GmmLibDllName.h
+++ b/Source/GmmLib/inc/External/Common/GmmLibDllName.h
@@ -29,7 +29,7 @@
     #if defined(_WIN64)
         #define GMM_UMD_DLL     "igdgmm64.dll"
     #else
-        #define GMM_UMD_DLL     "libigdgmm.so.10"
+        #define GMM_UMD_DLL     "libigdgmm.so.11"
     #endif
 #else
     #define GMM_ENTRY_NAME      "_OpenGmm@4"
@@ -40,6 +40,6 @@
     #if defined(_WIN32)
         #define GMM_UMD_DLL     "igdgmm32.dll"
     #else
-        #define GMM_UMD_DLL     "libigdgmm.so.10"
+        #define GMM_UMD_DLL     "libigdgmm.so.11"
     #endif
 #endif