1 #ifndef _G_STANDARD_MEM_NVOC_H_ 2 #define _G_STANDARD_MEM_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 1993-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 11 * SPDX-License-Identifier: MIT 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a 14 * copy of this software and associated documentation files (the "Software"), 15 * to deal in the Software without restriction, including without limitation 16 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 * and/or sell copies of the Software, and to permit persons to whom the 18 * Software is furnished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 * DEALINGS IN THE SOFTWARE. 30 */ 31 32 #include "g_standard_mem_nvoc.h" 33 34 #ifndef _STANDARD_MEMORY_H_ 35 #define _STANDARD_MEMORY_H_ 36 37 #include "mem_mgr/mem.h" 38 39 #include "ctrl/ctrl003e.h" 40 41 typedef struct MEMORY_ALLOCATION_REQUEST MEMORY_ALLOCATION_REQUEST; 42 43 struct MemoryManager; 44 45 #ifndef __NVOC_CLASS_MemoryManager_TYPEDEF__ 46 #define __NVOC_CLASS_MemoryManager_TYPEDEF__ 47 typedef struct MemoryManager MemoryManager; 48 #endif /* __NVOC_CLASS_MemoryManager_TYPEDEF__ */ 49 50 #ifndef __nvoc_class_id_MemoryManager 51 #define __nvoc_class_id_MemoryManager 0x22ad47 52 #endif /* __nvoc_class_id_MemoryManager */ 53 54 55 /*! 56 * Allocator for normal virtual, video and system memory 57 */ 58 #ifdef NVOC_STANDARD_MEM_H_PRIVATE_ACCESS_ALLOWED 59 #define PRIVATE_FIELD(x) x 60 #else 61 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x) 62 #endif 63 struct StandardMemory { 64 const struct NVOC_RTTI *__nvoc_rtti; 65 struct Memory __nvoc_base_Memory; 66 struct Object *__nvoc_pbase_Object; 67 struct RsResource *__nvoc_pbase_RsResource; 68 struct RmResourceCommon *__nvoc_pbase_RmResourceCommon; 69 struct RmResource *__nvoc_pbase_RmResource; 70 struct Memory *__nvoc_pbase_Memory; 71 struct StandardMemory *__nvoc_pbase_StandardMemory; 72 NvBool (*__stdmemCanCopy__)(struct StandardMemory *); 73 NV_STATUS (*__stdmemCheckMemInterUnmap__)(struct StandardMemory *, NvBool); 74 NvBool (*__stdmemShareCallback__)(struct StandardMemory *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *); 75 NV_STATUS (*__stdmemMapTo__)(struct StandardMemory *, RS_RES_MAP_TO_PARAMS *); 76 NV_STATUS (*__stdmemGetMapAddrSpace__)(struct StandardMemory *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *); 77 NvU32 (*__stdmemGetRefCount__)(struct StandardMemory *); 78 void (*__stdmemAddAdditionalDependants__)(struct RsClient *, struct StandardMemory *, RsResourceRef *); 79 NV_STATUS (*__stdmemControl_Prologue__)(struct StandardMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 80 NvBool (*__stdmemIsGpuMapAllowed__)(struct StandardMemory *, struct OBJGPU *); 81 NV_STATUS (*__stdmemUnmapFrom__)(struct StandardMemory *, RS_RES_UNMAP_FROM_PARAMS *); 82 void (*__stdmemControl_Epilogue__)(struct StandardMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 83 NV_STATUS (*__stdmemControlLookup__)(struct StandardMemory *, struct RS_RES_CONTROL_PARAMS_INTERNAL *, const struct NVOC_EXPORTED_METHOD_DEF **); 84 NV_STATUS (*__stdmemControl__)(struct StandardMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 85 NV_STATUS (*__stdmemUnmap__)(struct StandardMemory *, CALL_CONTEXT *, RsCpuMapping *); 86 NV_STATUS (*__stdmemGetMemInterMapParams__)(struct StandardMemory *, RMRES_MEM_INTER_MAP_PARAMS *); 87 NV_STATUS (*__stdmemGetMemoryMappingDescriptor__)(struct StandardMemory *, MEMORY_DESCRIPTOR **); 88 NV_STATUS (*__stdmemControlFilter__)(struct StandardMemory *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 89 NV_STATUS (*__stdmemControlSerialization_Prologue__)(struct StandardMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 90 NV_STATUS (*__stdmemIsReady__)(struct StandardMemory *, NvBool); 91 NV_STATUS (*__stdmemCheckCopyPermissions__)(struct StandardMemory *, struct OBJGPU *, struct Device *); 92 void (*__stdmemPreDestruct__)(struct StandardMemory *); 93 NV_STATUS (*__stdmemIsDuplicate__)(struct StandardMemory *, NvHandle, NvBool *); 94 void (*__stdmemControlSerialization_Epilogue__)(struct StandardMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 95 NV_STATUS (*__stdmemMap__)(struct StandardMemory *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *); 96 NvBool (*__stdmemAccessCallback__)(struct StandardMemory *, struct RsClient *, void *, RsAccessRight); 97 }; 98 99 #ifndef __NVOC_CLASS_StandardMemory_TYPEDEF__ 100 #define __NVOC_CLASS_StandardMemory_TYPEDEF__ 101 typedef struct StandardMemory StandardMemory; 102 #endif /* __NVOC_CLASS_StandardMemory_TYPEDEF__ */ 103 104 #ifndef __nvoc_class_id_StandardMemory 105 #define __nvoc_class_id_StandardMemory 0x897bf7 106 #endif /* __nvoc_class_id_StandardMemory */ 107 108 extern const struct NVOC_CLASS_DEF __nvoc_class_def_StandardMemory; 109 110 #define __staticCast_StandardMemory(pThis) \ 111 ((pThis)->__nvoc_pbase_StandardMemory) 112 113 #ifdef __nvoc_standard_mem_h_disabled 114 #define __dynamicCast_StandardMemory(pThis) ((StandardMemory*)NULL) 115 #else //__nvoc_standard_mem_h_disabled 116 #define __dynamicCast_StandardMemory(pThis) \ 117 ((StandardMemory*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(StandardMemory))) 118 #endif //__nvoc_standard_mem_h_disabled 119 120 121 NV_STATUS __nvoc_objCreateDynamic_StandardMemory(StandardMemory**, Dynamic*, NvU32, va_list); 122 123 NV_STATUS __nvoc_objCreate_StandardMemory(StandardMemory**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams); 124 #define __objCreate_StandardMemory(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \ 125 __nvoc_objCreate_StandardMemory((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams) 126 127 #define stdmemCanCopy(pStandardMemory) stdmemCanCopy_DISPATCH(pStandardMemory) 128 #define stdmemCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) stdmemCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided) 129 #define stdmemShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) stdmemShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy) 130 #define stdmemMapTo(pResource, pParams) stdmemMapTo_DISPATCH(pResource, pParams) 131 #define stdmemGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) stdmemGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace) 132 #define stdmemGetRefCount(pResource) stdmemGetRefCount_DISPATCH(pResource) 133 #define stdmemAddAdditionalDependants(pClient, pResource, pReference) stdmemAddAdditionalDependants_DISPATCH(pClient, pResource, pReference) 134 #define stdmemControl_Prologue(pResource, pCallContext, pParams) stdmemControl_Prologue_DISPATCH(pResource, pCallContext, pParams) 135 #define stdmemIsGpuMapAllowed(pMemory, pGpu) stdmemIsGpuMapAllowed_DISPATCH(pMemory, pGpu) 136 #define stdmemUnmapFrom(pResource, pParams) stdmemUnmapFrom_DISPATCH(pResource, pParams) 137 #define stdmemControl_Epilogue(pResource, pCallContext, pParams) stdmemControl_Epilogue_DISPATCH(pResource, pCallContext, pParams) 138 #define stdmemControlLookup(pResource, pParams, ppEntry) stdmemControlLookup_DISPATCH(pResource, pParams, ppEntry) 139 #define stdmemControl(pMemory, pCallContext, pParams) stdmemControl_DISPATCH(pMemory, pCallContext, pParams) 140 #define stdmemUnmap(pMemory, pCallContext, pCpuMapping) stdmemUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping) 141 #define stdmemGetMemInterMapParams(pMemory, pParams) stdmemGetMemInterMapParams_DISPATCH(pMemory, pParams) 142 #define stdmemGetMemoryMappingDescriptor(pMemory, ppMemDesc) stdmemGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc) 143 #define stdmemControlFilter(pResource, pCallContext, pParams) stdmemControlFilter_DISPATCH(pResource, pCallContext, pParams) 144 #define stdmemControlSerialization_Prologue(pResource, pCallContext, pParams) stdmemControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams) 145 #define stdmemIsReady(pMemory, bCopyConstructorContext) stdmemIsReady_DISPATCH(pMemory, bCopyConstructorContext) 146 #define stdmemCheckCopyPermissions(pMemory, pDstGpu, pDstDevice) stdmemCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, pDstDevice) 147 #define stdmemPreDestruct(pResource) stdmemPreDestruct_DISPATCH(pResource) 148 #define stdmemIsDuplicate(pMemory, hMemory, pDuplicate) stdmemIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate) 149 #define stdmemControlSerialization_Epilogue(pResource, pCallContext, pParams) stdmemControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams) 150 #define stdmemMap(pMemory, pCallContext, pParams, pCpuMapping) stdmemMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping) 151 #define stdmemAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) stdmemAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight) 152 NvU64 stdmemGetSysmemPageSize_IMPL(struct OBJGPU *pGpu, struct StandardMemory *pMemory); 153 154 155 #ifdef __nvoc_standard_mem_h_disabled 156 static inline NvU64 stdmemGetSysmemPageSize(struct OBJGPU *pGpu, struct StandardMemory *pMemory) { 157 NV_ASSERT_FAILED_PRECOMP("StandardMemory was disabled!"); 158 return 0; 159 } 160 #else //__nvoc_standard_mem_h_disabled 161 #define stdmemGetSysmemPageSize(pGpu, pMemory) stdmemGetSysmemPageSize_IMPL(pGpu, pMemory) 162 #endif //__nvoc_standard_mem_h_disabled 163 164 #define stdmemGetSysmemPageSize_HAL(pGpu, pMemory) stdmemGetSysmemPageSize(pGpu, pMemory) 165 166 NvBool stdmemCanCopy_IMPL(struct StandardMemory *pStandardMemory); 167 168 static inline NvBool stdmemCanCopy_DISPATCH(struct StandardMemory *pStandardMemory) { 169 return pStandardMemory->__stdmemCanCopy__(pStandardMemory); 170 } 171 172 static inline NV_STATUS stdmemCheckMemInterUnmap_DISPATCH(struct StandardMemory *pMemory, NvBool bSubdeviceHandleProvided) { 173 return pMemory->__stdmemCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided); 174 } 175 176 static inline NvBool stdmemShareCallback_DISPATCH(struct StandardMemory *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) { 177 return pResource->__stdmemShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy); 178 } 179 180 static inline NV_STATUS stdmemMapTo_DISPATCH(struct StandardMemory *pResource, RS_RES_MAP_TO_PARAMS *pParams) { 181 return pResource->__stdmemMapTo__(pResource, pParams); 182 } 183 184 static inline NV_STATUS stdmemGetMapAddrSpace_DISPATCH(struct StandardMemory *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) { 185 return pMemory->__stdmemGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace); 186 } 187 188 static inline NvU32 stdmemGetRefCount_DISPATCH(struct StandardMemory *pResource) { 189 return pResource->__stdmemGetRefCount__(pResource); 190 } 191 192 static inline void stdmemAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct StandardMemory *pResource, RsResourceRef *pReference) { 193 pResource->__stdmemAddAdditionalDependants__(pClient, pResource, pReference); 194 } 195 196 static inline NV_STATUS stdmemControl_Prologue_DISPATCH(struct StandardMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 197 return pResource->__stdmemControl_Prologue__(pResource, pCallContext, pParams); 198 } 199 200 static inline NvBool stdmemIsGpuMapAllowed_DISPATCH(struct StandardMemory *pMemory, struct OBJGPU *pGpu) { 201 return pMemory->__stdmemIsGpuMapAllowed__(pMemory, pGpu); 202 } 203 204 static inline NV_STATUS stdmemUnmapFrom_DISPATCH(struct StandardMemory *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) { 205 return pResource->__stdmemUnmapFrom__(pResource, pParams); 206 } 207 208 static inline void stdmemControl_Epilogue_DISPATCH(struct StandardMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 209 pResource->__stdmemControl_Epilogue__(pResource, pCallContext, pParams); 210 } 211 212 static inline NV_STATUS stdmemControlLookup_DISPATCH(struct StandardMemory *pResource, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams, const struct NVOC_EXPORTED_METHOD_DEF **ppEntry) { 213 return pResource->__stdmemControlLookup__(pResource, pParams, ppEntry); 214 } 215 216 static inline NV_STATUS stdmemControl_DISPATCH(struct StandardMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 217 return pMemory->__stdmemControl__(pMemory, pCallContext, pParams); 218 } 219 220 static inline NV_STATUS stdmemUnmap_DISPATCH(struct StandardMemory *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) { 221 return pMemory->__stdmemUnmap__(pMemory, pCallContext, pCpuMapping); 222 } 223 224 static inline NV_STATUS stdmemGetMemInterMapParams_DISPATCH(struct StandardMemory *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) { 225 return pMemory->__stdmemGetMemInterMapParams__(pMemory, pParams); 226 } 227 228 static inline NV_STATUS stdmemGetMemoryMappingDescriptor_DISPATCH(struct StandardMemory *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) { 229 return pMemory->__stdmemGetMemoryMappingDescriptor__(pMemory, ppMemDesc); 230 } 231 232 static inline NV_STATUS stdmemControlFilter_DISPATCH(struct StandardMemory *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 233 return pResource->__stdmemControlFilter__(pResource, pCallContext, pParams); 234 } 235 236 static inline NV_STATUS stdmemControlSerialization_Prologue_DISPATCH(struct StandardMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 237 return pResource->__stdmemControlSerialization_Prologue__(pResource, pCallContext, pParams); 238 } 239 240 static inline NV_STATUS stdmemIsReady_DISPATCH(struct StandardMemory *pMemory, NvBool bCopyConstructorContext) { 241 return pMemory->__stdmemIsReady__(pMemory, bCopyConstructorContext); 242 } 243 244 static inline NV_STATUS stdmemCheckCopyPermissions_DISPATCH(struct StandardMemory *pMemory, struct OBJGPU *pDstGpu, struct Device *pDstDevice) { 245 return pMemory->__stdmemCheckCopyPermissions__(pMemory, pDstGpu, pDstDevice); 246 } 247 248 static inline void stdmemPreDestruct_DISPATCH(struct StandardMemory *pResource) { 249 pResource->__stdmemPreDestruct__(pResource); 250 } 251 252 static inline NV_STATUS stdmemIsDuplicate_DISPATCH(struct StandardMemory *pMemory, NvHandle hMemory, NvBool *pDuplicate) { 253 return pMemory->__stdmemIsDuplicate__(pMemory, hMemory, pDuplicate); 254 } 255 256 static inline void stdmemControlSerialization_Epilogue_DISPATCH(struct StandardMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 257 pResource->__stdmemControlSerialization_Epilogue__(pResource, pCallContext, pParams); 258 } 259 260 static inline NV_STATUS stdmemMap_DISPATCH(struct StandardMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) { 261 return pMemory->__stdmemMap__(pMemory, pCallContext, pParams, pCpuMapping); 262 } 263 264 static inline NvBool stdmemAccessCallback_DISPATCH(struct StandardMemory *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) { 265 return pResource->__stdmemAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight); 266 } 267 268 NV_STATUS stdmemConstruct_IMPL(struct StandardMemory *arg_pStandardMemory, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams); 269 270 #define __nvoc_stdmemConstruct(arg_pStandardMemory, arg_pCallContext, arg_pParams) stdmemConstruct_IMPL(arg_pStandardMemory, arg_pCallContext, arg_pParams) 271 NV_STATUS stdmemValidateParams_IMPL(struct OBJGPU *pGpu, NvHandle hClient, NV_MEMORY_ALLOCATION_PARAMS *pAllocData); 272 273 #define stdmemValidateParams(pGpu, hClient, pAllocData) stdmemValidateParams_IMPL(pGpu, hClient, pAllocData) 274 void stdmemDumpInputAllocParams_IMPL(NV_MEMORY_ALLOCATION_PARAMS *pAllocData, CALL_CONTEXT *pCallContext); 275 276 #define stdmemDumpInputAllocParams(pAllocData, pCallContext) stdmemDumpInputAllocParams_IMPL(pAllocData, pCallContext) 277 void stdmemDumpOutputAllocParams_IMPL(NV_MEMORY_ALLOCATION_PARAMS *pAllocData); 278 279 #define stdmemDumpOutputAllocParams(pAllocData) stdmemDumpOutputAllocParams_IMPL(pAllocData) 280 NvU64 stdmemQueryPageSize_IMPL(struct MemoryManager *pMemoryManager, NvHandle hClient, NV_MEMORY_ALLOCATION_PARAMS *pAllocData); 281 282 #define stdmemQueryPageSize(pMemoryManager, hClient, pAllocData) stdmemQueryPageSize_IMPL(pMemoryManager, hClient, pAllocData) 283 #undef PRIVATE_FIELD 284 285 286 #endif 287 288 #ifdef __cplusplus 289 } // extern "C" 290 #endif 291 #endif // _G_STANDARD_MEM_NVOC_H_ 292