1 /*============================================================================== 2 Copyright(c) 2017 Intel Corporation 3 4 Permission is hereby granted, free of charge, to any person obtaining a 5 copy of this software and associated documentation files(the "Software"), 6 to deal in the Software without restriction, including without limitation 7 the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 and / or sell copies of the Software, and to permit persons to whom the 9 Software is furnished to do so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included 12 in all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 OTHER DEALINGS IN THE SOFTWARE. 21 ============================================================================*/ 22 #pragma once 23 24 #ifdef __cplusplus 25 #include "GmmMemAllocator.hpp" 26 #include "GmmResourceInfoExt.h" 27 28 #if LHDM 29 // Applicable upto Gen9, Gen11+ gmmlib provides Cross-OS Fixed MOCS table as default support. 30 #define GMM_DYNAMIC_MOCS_TABLE 31 #define GMM_FIXED_MOCS_TABLE // Use for Gen11+ 32 #endif 33 34 ///////////////////////////////////////////////////////////////////////////////////// 35 /// @file GmmCachePolicyCommon.h 36 /// @brief This file contains Gmm Cache Policy functions 37 ///////////////////////////////////////////////////////////////////////////////////// 38 namespace GmmLib 39 { 40 ///////////////////////////////////////////////////////////////////////// 41 /// Contains the Gmm Cache Policy functions common for Linux and Windows 42 /// implementation. This class is inherited by gen specific class so 43 /// so clients shouldn't have to ever interact with this class directly. 44 ///////////////////////////////////////////////////////////////////////// 45 46 class Context; 47 class NON_PAGED_SECTION GmmCachePolicyCommon : 48 public GmmMemAllocator 49 { 50 protected: 51 Context * pGmmLibContext; 52 uint32_t NumPATRegisters; 53 uint32_t NumMOCSRegisters; 54 55 public: 56 GMM_CACHE_POLICY_ELEMENT *pCachePolicy; 57 58 /* Constructor */ 59 GmmCachePolicyCommon(GMM_CACHE_POLICY_ELEMENT *pCachePolicy, Context *pGmmLibContext); 60 61 /* Function prototypes */ 62 GMM_GFX_MEMORY_TYPE GetWantedMemoryType(GMM_CACHE_POLICY_ELEMENT CachePolicy); 63 64 #define DEFINE_CP_ELEMENT(Usage, llc, ellc, l3, wt, age, aom, lecc_scc, l3_scc, scf, sso, cos, hdcl1, l3evict, segov, glbgo, uclookup, l1cc, l2cc, l4cc, coherency, l3cc, l3clos, igPAT)\ 65 do { \ 66 pCachePolicy[Usage].LLC = (llc); \ 67 pCachePolicy[Usage].ELLC = (ellc); \ 68 pCachePolicy[Usage].L3 = (l3); \ 69 pCachePolicy[Usage].WT = (wt); \ 70 pCachePolicy[Usage].AGE = (age); \ 71 pCachePolicy[Usage].AOM = (aom); \ 72 pCachePolicy[Usage].LeCC_SCC = (lecc_scc); \ 73 pCachePolicy[Usage].L3_SCC = (l3_scc); \ 74 pCachePolicy[Usage].SCF = (scf); \ 75 pCachePolicy[Usage].SSO = (sso); \ 76 pCachePolicy[Usage].CoS = (cos); \ 77 pCachePolicy[Usage].HDCL1 = (hdcl1); \ 78 pCachePolicy[Usage].L3Eviction = (l3evict); \ 79 pCachePolicy[Usage].SegOv = (segov); \ 80 pCachePolicy[Usage].GlbGo = (glbgo); \ 81 pCachePolicy[Usage].UcLookup = (uclookup); \ 82 pCachePolicy[Usage].L1CC = (l1cc); \ 83 pCachePolicy[Usage].Initialized = 1; \ 84 pCachePolicy[Usage].L2CC = (l2cc); \ 85 pCachePolicy[Usage].L4CC = (l4cc); \ 86 pCachePolicy[Usage].Coherency = (coherency); \ 87 pCachePolicy[Usage].L3CC = (l3cc); \ 88 pCachePolicy[Usage].L3CLOS = (l3clos); \ 89 pCachePolicy[Usage].IgnorePAT = (igPAT); \ 90 } while (0) 91 92 MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL CachePolicyGetOriginalMemoryObject(GMM_RESOURCE_INFO *pResInfo); 93 MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL CachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage); 94 GMM_PTE_CACHE_CONTROL_BITS GMM_STDCALL CachePolicyGetPteType(GMM_RESOURCE_USAGE_TYPE Usage); 95 96 /* Virtual functions prototype*/ 97 virtual uint8_t GMM_STDCALL CachePolicyIsUsagePTECached(GMM_RESOURCE_USAGE_TYPE Usage) = 0; 98 virtual GMM_STATUS InitCachePolicy() = 0; GetMaxSpecialMocsIndex()99 virtual uint32_t GetMaxSpecialMocsIndex() 100 { 101 return 0; 102 } ~GmmCachePolicyCommon()103 virtual ~GmmCachePolicyCommon() 104 { 105 } 106 virtual uint32_t GMM_STDCALL CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable); 107 uint32_t GMM_STDCALL CachePolicyGetNumPATRegisters(); 108 virtual uint32_t GMM_STDCALL GetSurfaceStateL1CachePolicy(GMM_RESOURCE_USAGE_TYPE Usage); 109 }; 110 } 111 #endif // #ifdef __cplusplus 112