1 #ifndef _G_PHYS_MEM_NVOC_H_ 2 #define _G_PHYS_MEM_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 2018-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_phys_mem_nvoc.h" 33 34 #ifndef _PHYSICAL_MEMORY_H_ 35 #define _PHYSICAL_MEMORY_H_ 36 37 #include "mem_mgr/mem.h" 38 39 /*! 40 * Allocator for NV01_MEMORY_LOCAL_PHYSICAL 41 * 42 * Linear view for all video memory (similar to /dev/mem). 43 */ 44 #ifdef NVOC_PHYS_MEM_H_PRIVATE_ACCESS_ALLOWED 45 #define PRIVATE_FIELD(x) x 46 #else 47 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x) 48 #endif 49 struct PhysicalMemory { 50 const struct NVOC_RTTI *__nvoc_rtti; 51 struct Memory __nvoc_base_Memory; 52 struct Object *__nvoc_pbase_Object; 53 struct RsResource *__nvoc_pbase_RsResource; 54 struct RmResourceCommon *__nvoc_pbase_RmResourceCommon; 55 struct RmResource *__nvoc_pbase_RmResource; 56 struct Memory *__nvoc_pbase_Memory; 57 struct PhysicalMemory *__nvoc_pbase_PhysicalMemory; 58 NvBool (*__physmemCanCopy__)(struct PhysicalMemory *); 59 NV_STATUS (*__physmemCheckMemInterUnmap__)(struct PhysicalMemory *, NvBool); 60 NvBool (*__physmemShareCallback__)(struct PhysicalMemory *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *); 61 NV_STATUS (*__physmemMapTo__)(struct PhysicalMemory *, RS_RES_MAP_TO_PARAMS *); 62 NV_STATUS (*__physmemGetMapAddrSpace__)(struct PhysicalMemory *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *); 63 NvU32 (*__physmemGetRefCount__)(struct PhysicalMemory *); 64 void (*__physmemAddAdditionalDependants__)(struct RsClient *, struct PhysicalMemory *, RsResourceRef *); 65 NV_STATUS (*__physmemControl_Prologue__)(struct PhysicalMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 66 NvBool (*__physmemIsGpuMapAllowed__)(struct PhysicalMemory *, struct OBJGPU *); 67 NV_STATUS (*__physmemUnmapFrom__)(struct PhysicalMemory *, RS_RES_UNMAP_FROM_PARAMS *); 68 void (*__physmemControl_Epilogue__)(struct PhysicalMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 69 NV_STATUS (*__physmemControlLookup__)(struct PhysicalMemory *, struct RS_RES_CONTROL_PARAMS_INTERNAL *, const struct NVOC_EXPORTED_METHOD_DEF **); 70 NV_STATUS (*__physmemControl__)(struct PhysicalMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 71 NV_STATUS (*__physmemUnmap__)(struct PhysicalMemory *, CALL_CONTEXT *, RsCpuMapping *); 72 NV_STATUS (*__physmemGetMemInterMapParams__)(struct PhysicalMemory *, RMRES_MEM_INTER_MAP_PARAMS *); 73 NV_STATUS (*__physmemGetMemoryMappingDescriptor__)(struct PhysicalMemory *, MEMORY_DESCRIPTOR **); 74 NV_STATUS (*__physmemControlFilter__)(struct PhysicalMemory *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 75 NV_STATUS (*__physmemControlSerialization_Prologue__)(struct PhysicalMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 76 NV_STATUS (*__physmemIsReady__)(struct PhysicalMemory *, NvBool); 77 NV_STATUS (*__physmemCheckCopyPermissions__)(struct PhysicalMemory *, struct OBJGPU *, NvHandle); 78 void (*__physmemPreDestruct__)(struct PhysicalMemory *); 79 NV_STATUS (*__physmemIsDuplicate__)(struct PhysicalMemory *, NvHandle, NvBool *); 80 void (*__physmemControlSerialization_Epilogue__)(struct PhysicalMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *); 81 NV_STATUS (*__physmemMap__)(struct PhysicalMemory *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *); 82 NvBool (*__physmemAccessCallback__)(struct PhysicalMemory *, struct RsClient *, void *, RsAccessRight); 83 }; 84 85 #ifndef __NVOC_CLASS_PhysicalMemory_TYPEDEF__ 86 #define __NVOC_CLASS_PhysicalMemory_TYPEDEF__ 87 typedef struct PhysicalMemory PhysicalMemory; 88 #endif /* __NVOC_CLASS_PhysicalMemory_TYPEDEF__ */ 89 90 #ifndef __nvoc_class_id_PhysicalMemory 91 #define __nvoc_class_id_PhysicalMemory 0x5fccf2 92 #endif /* __nvoc_class_id_PhysicalMemory */ 93 94 extern const struct NVOC_CLASS_DEF __nvoc_class_def_PhysicalMemory; 95 96 #define __staticCast_PhysicalMemory(pThis) \ 97 ((pThis)->__nvoc_pbase_PhysicalMemory) 98 99 #ifdef __nvoc_phys_mem_h_disabled 100 #define __dynamicCast_PhysicalMemory(pThis) ((PhysicalMemory*)NULL) 101 #else //__nvoc_phys_mem_h_disabled 102 #define __dynamicCast_PhysicalMemory(pThis) \ 103 ((PhysicalMemory*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(PhysicalMemory))) 104 #endif //__nvoc_phys_mem_h_disabled 105 106 107 NV_STATUS __nvoc_objCreateDynamic_PhysicalMemory(PhysicalMemory**, Dynamic*, NvU32, va_list); 108 109 NV_STATUS __nvoc_objCreate_PhysicalMemory(PhysicalMemory**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams); 110 #define __objCreate_PhysicalMemory(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \ 111 __nvoc_objCreate_PhysicalMemory((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams) 112 113 #define physmemCanCopy(pPhysicalMemory) physmemCanCopy_DISPATCH(pPhysicalMemory) 114 #define physmemCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) physmemCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided) 115 #define physmemShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) physmemShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy) 116 #define physmemMapTo(pResource, pParams) physmemMapTo_DISPATCH(pResource, pParams) 117 #define physmemGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) physmemGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace) 118 #define physmemGetRefCount(pResource) physmemGetRefCount_DISPATCH(pResource) 119 #define physmemAddAdditionalDependants(pClient, pResource, pReference) physmemAddAdditionalDependants_DISPATCH(pClient, pResource, pReference) 120 #define physmemControl_Prologue(pResource, pCallContext, pParams) physmemControl_Prologue_DISPATCH(pResource, pCallContext, pParams) 121 #define physmemIsGpuMapAllowed(pMemory, pGpu) physmemIsGpuMapAllowed_DISPATCH(pMemory, pGpu) 122 #define physmemUnmapFrom(pResource, pParams) physmemUnmapFrom_DISPATCH(pResource, pParams) 123 #define physmemControl_Epilogue(pResource, pCallContext, pParams) physmemControl_Epilogue_DISPATCH(pResource, pCallContext, pParams) 124 #define physmemControlLookup(pResource, pParams, ppEntry) physmemControlLookup_DISPATCH(pResource, pParams, ppEntry) 125 #define physmemControl(pMemory, pCallContext, pParams) physmemControl_DISPATCH(pMemory, pCallContext, pParams) 126 #define physmemUnmap(pMemory, pCallContext, pCpuMapping) physmemUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping) 127 #define physmemGetMemInterMapParams(pMemory, pParams) physmemGetMemInterMapParams_DISPATCH(pMemory, pParams) 128 #define physmemGetMemoryMappingDescriptor(pMemory, ppMemDesc) physmemGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc) 129 #define physmemControlFilter(pResource, pCallContext, pParams) physmemControlFilter_DISPATCH(pResource, pCallContext, pParams) 130 #define physmemControlSerialization_Prologue(pResource, pCallContext, pParams) physmemControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams) 131 #define physmemIsReady(pMemory, bCopyConstructorContext) physmemIsReady_DISPATCH(pMemory, bCopyConstructorContext) 132 #define physmemCheckCopyPermissions(pMemory, pDstGpu, hDstClientNvBool) physmemCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, hDstClientNvBool) 133 #define physmemPreDestruct(pResource) physmemPreDestruct_DISPATCH(pResource) 134 #define physmemIsDuplicate(pMemory, hMemory, pDuplicate) physmemIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate) 135 #define physmemControlSerialization_Epilogue(pResource, pCallContext, pParams) physmemControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams) 136 #define physmemMap(pMemory, pCallContext, pParams, pCpuMapping) physmemMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping) 137 #define physmemAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) physmemAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight) 138 NvBool physmemCanCopy_IMPL(struct PhysicalMemory *pPhysicalMemory); 139 140 static inline NvBool physmemCanCopy_DISPATCH(struct PhysicalMemory *pPhysicalMemory) { 141 return pPhysicalMemory->__physmemCanCopy__(pPhysicalMemory); 142 } 143 144 static inline NV_STATUS physmemCheckMemInterUnmap_DISPATCH(struct PhysicalMemory *pMemory, NvBool bSubdeviceHandleProvided) { 145 return pMemory->__physmemCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided); 146 } 147 148 static inline NvBool physmemShareCallback_DISPATCH(struct PhysicalMemory *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) { 149 return pResource->__physmemShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy); 150 } 151 152 static inline NV_STATUS physmemMapTo_DISPATCH(struct PhysicalMemory *pResource, RS_RES_MAP_TO_PARAMS *pParams) { 153 return pResource->__physmemMapTo__(pResource, pParams); 154 } 155 156 static inline NV_STATUS physmemGetMapAddrSpace_DISPATCH(struct PhysicalMemory *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) { 157 return pMemory->__physmemGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace); 158 } 159 160 static inline NvU32 physmemGetRefCount_DISPATCH(struct PhysicalMemory *pResource) { 161 return pResource->__physmemGetRefCount__(pResource); 162 } 163 164 static inline void physmemAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct PhysicalMemory *pResource, RsResourceRef *pReference) { 165 pResource->__physmemAddAdditionalDependants__(pClient, pResource, pReference); 166 } 167 168 static inline NV_STATUS physmemControl_Prologue_DISPATCH(struct PhysicalMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 169 return pResource->__physmemControl_Prologue__(pResource, pCallContext, pParams); 170 } 171 172 static inline NvBool physmemIsGpuMapAllowed_DISPATCH(struct PhysicalMemory *pMemory, struct OBJGPU *pGpu) { 173 return pMemory->__physmemIsGpuMapAllowed__(pMemory, pGpu); 174 } 175 176 static inline NV_STATUS physmemUnmapFrom_DISPATCH(struct PhysicalMemory *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) { 177 return pResource->__physmemUnmapFrom__(pResource, pParams); 178 } 179 180 static inline void physmemControl_Epilogue_DISPATCH(struct PhysicalMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 181 pResource->__physmemControl_Epilogue__(pResource, pCallContext, pParams); 182 } 183 184 static inline NV_STATUS physmemControlLookup_DISPATCH(struct PhysicalMemory *pResource, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams, const struct NVOC_EXPORTED_METHOD_DEF **ppEntry) { 185 return pResource->__physmemControlLookup__(pResource, pParams, ppEntry); 186 } 187 188 static inline NV_STATUS physmemControl_DISPATCH(struct PhysicalMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 189 return pMemory->__physmemControl__(pMemory, pCallContext, pParams); 190 } 191 192 static inline NV_STATUS physmemUnmap_DISPATCH(struct PhysicalMemory *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) { 193 return pMemory->__physmemUnmap__(pMemory, pCallContext, pCpuMapping); 194 } 195 196 static inline NV_STATUS physmemGetMemInterMapParams_DISPATCH(struct PhysicalMemory *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) { 197 return pMemory->__physmemGetMemInterMapParams__(pMemory, pParams); 198 } 199 200 static inline NV_STATUS physmemGetMemoryMappingDescriptor_DISPATCH(struct PhysicalMemory *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) { 201 return pMemory->__physmemGetMemoryMappingDescriptor__(pMemory, ppMemDesc); 202 } 203 204 static inline NV_STATUS physmemControlFilter_DISPATCH(struct PhysicalMemory *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 205 return pResource->__physmemControlFilter__(pResource, pCallContext, pParams); 206 } 207 208 static inline NV_STATUS physmemControlSerialization_Prologue_DISPATCH(struct PhysicalMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 209 return pResource->__physmemControlSerialization_Prologue__(pResource, pCallContext, pParams); 210 } 211 212 static inline NV_STATUS physmemIsReady_DISPATCH(struct PhysicalMemory *pMemory, NvBool bCopyConstructorContext) { 213 return pMemory->__physmemIsReady__(pMemory, bCopyConstructorContext); 214 } 215 216 static inline NV_STATUS physmemCheckCopyPermissions_DISPATCH(struct PhysicalMemory *pMemory, struct OBJGPU *pDstGpu, NvHandle hDstClientNvBool) { 217 return pMemory->__physmemCheckCopyPermissions__(pMemory, pDstGpu, hDstClientNvBool); 218 } 219 220 static inline void physmemPreDestruct_DISPATCH(struct PhysicalMemory *pResource) { 221 pResource->__physmemPreDestruct__(pResource); 222 } 223 224 static inline NV_STATUS physmemIsDuplicate_DISPATCH(struct PhysicalMemory *pMemory, NvHandle hMemory, NvBool *pDuplicate) { 225 return pMemory->__physmemIsDuplicate__(pMemory, hMemory, pDuplicate); 226 } 227 228 static inline void physmemControlSerialization_Epilogue_DISPATCH(struct PhysicalMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) { 229 pResource->__physmemControlSerialization_Epilogue__(pResource, pCallContext, pParams); 230 } 231 232 static inline NV_STATUS physmemMap_DISPATCH(struct PhysicalMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) { 233 return pMemory->__physmemMap__(pMemory, pCallContext, pParams, pCpuMapping); 234 } 235 236 static inline NvBool physmemAccessCallback_DISPATCH(struct PhysicalMemory *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) { 237 return pResource->__physmemAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight); 238 } 239 240 NV_STATUS physmemConstruct_IMPL(struct PhysicalMemory *arg_pPhysicalMemory, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams); 241 242 #define __nvoc_physmemConstruct(arg_pPhysicalMemory, arg_pCallContext, arg_pParams) physmemConstruct_IMPL(arg_pPhysicalMemory, arg_pCallContext, arg_pParams) 243 #undef PRIVATE_FIELD 244 245 246 #endif 247 248 #ifdef __cplusplus 249 } // extern "C" 250 #endif 251 #endif // _G_PHYS_MEM_NVOC_H_ 252