1 #ifndef _G_OS_DESC_MEM_NVOC_H_
2 #define _G_OS_DESC_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_os_desc_mem_nvoc.h"
33 
34 #ifndef _OS_DESC_MEMORY_H_
35 #define _OS_DESC_MEMORY_H_
36 
37 #include "mem_mgr/mem.h"
38 
39 /*!
40  * Bind memory allocated through os descriptor
41  */
42 
43 // Private field names are wrapped in PRIVATE_FIELD, which does nothing for
44 // the matching C source file, but causes diagnostics to be issued if another
45 // source file references the field.
46 #ifdef NVOC_OS_DESC_MEM_H_PRIVATE_ACCESS_ALLOWED
47 #define PRIVATE_FIELD(x) x
48 #else
49 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
50 #endif
51 
52 struct OsDescMemory {
53     const struct NVOC_RTTI *__nvoc_rtti;
54     struct Memory __nvoc_base_Memory;
55     struct Object *__nvoc_pbase_Object;
56     struct RsResource *__nvoc_pbase_RsResource;
57     struct RmResourceCommon *__nvoc_pbase_RmResourceCommon;
58     struct RmResource *__nvoc_pbase_RmResource;
59     struct Memory *__nvoc_pbase_Memory;
60     struct OsDescMemory *__nvoc_pbase_OsDescMemory;
61     NvBool (*__osdescCanCopy__)(struct OsDescMemory *);
62     NV_STATUS (*__osdescCheckMemInterUnmap__)(struct OsDescMemory *, NvBool);
63     NvBool (*__osdescShareCallback__)(struct OsDescMemory *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *);
64     NV_STATUS (*__osdescMapTo__)(struct OsDescMemory *, RS_RES_MAP_TO_PARAMS *);
65     NV_STATUS (*__osdescGetMapAddrSpace__)(struct OsDescMemory *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *);
66     NvBool (*__osdescIsExportAllowed__)(struct OsDescMemory *);
67     NvU32 (*__osdescGetRefCount__)(struct OsDescMemory *);
68     void (*__osdescAddAdditionalDependants__)(struct RsClient *, struct OsDescMemory *, RsResourceRef *);
69     NV_STATUS (*__osdescControl_Prologue__)(struct OsDescMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
70     NvBool (*__osdescIsGpuMapAllowed__)(struct OsDescMemory *, struct OBJGPU *);
71     NV_STATUS (*__osdescUnmapFrom__)(struct OsDescMemory *, RS_RES_UNMAP_FROM_PARAMS *);
72     void (*__osdescControl_Epilogue__)(struct OsDescMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
73     NV_STATUS (*__osdescControl__)(struct OsDescMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
74     NV_STATUS (*__osdescUnmap__)(struct OsDescMemory *, CALL_CONTEXT *, RsCpuMapping *);
75     NV_STATUS (*__osdescGetMemInterMapParams__)(struct OsDescMemory *, RMRES_MEM_INTER_MAP_PARAMS *);
76     NV_STATUS (*__osdescGetMemoryMappingDescriptor__)(struct OsDescMemory *, MEMORY_DESCRIPTOR **);
77     NV_STATUS (*__osdescControlFilter__)(struct OsDescMemory *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
78     NV_STATUS (*__osdescControlSerialization_Prologue__)(struct OsDescMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
79     NvBool (*__osdescIsPartialUnmapSupported__)(struct OsDescMemory *);
80     NV_STATUS (*__osdescIsReady__)(struct OsDescMemory *, NvBool);
81     NV_STATUS (*__osdescCheckCopyPermissions__)(struct OsDescMemory *, struct OBJGPU *, struct Device *);
82     void (*__osdescPreDestruct__)(struct OsDescMemory *);
83     NV_STATUS (*__osdescIsDuplicate__)(struct OsDescMemory *, NvHandle, NvBool *);
84     void (*__osdescControlSerialization_Epilogue__)(struct OsDescMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
85     NV_STATUS (*__osdescMap__)(struct OsDescMemory *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *);
86     NvBool (*__osdescAccessCallback__)(struct OsDescMemory *, struct RsClient *, void *, RsAccessRight);
87 };
88 
89 #ifndef __NVOC_CLASS_OsDescMemory_TYPEDEF__
90 #define __NVOC_CLASS_OsDescMemory_TYPEDEF__
91 typedef struct OsDescMemory OsDescMemory;
92 #endif /* __NVOC_CLASS_OsDescMemory_TYPEDEF__ */
93 
94 #ifndef __nvoc_class_id_OsDescMemory
95 #define __nvoc_class_id_OsDescMemory 0xb3dacd
96 #endif /* __nvoc_class_id_OsDescMemory */
97 
98 extern const struct NVOC_CLASS_DEF __nvoc_class_def_OsDescMemory;
99 
100 #define __staticCast_OsDescMemory(pThis) \
101     ((pThis)->__nvoc_pbase_OsDescMemory)
102 
103 #ifdef __nvoc_os_desc_mem_h_disabled
104 #define __dynamicCast_OsDescMemory(pThis) ((OsDescMemory*)NULL)
105 #else //__nvoc_os_desc_mem_h_disabled
106 #define __dynamicCast_OsDescMemory(pThis) \
107     ((OsDescMemory*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(OsDescMemory)))
108 #endif //__nvoc_os_desc_mem_h_disabled
109 
110 
111 NV_STATUS __nvoc_objCreateDynamic_OsDescMemory(OsDescMemory**, Dynamic*, NvU32, va_list);
112 
113 NV_STATUS __nvoc_objCreate_OsDescMemory(OsDescMemory**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams);
114 #define __objCreate_OsDescMemory(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \
115     __nvoc_objCreate_OsDescMemory((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams)
116 
117 #define osdescCanCopy(pOsDescMemory) osdescCanCopy_DISPATCH(pOsDescMemory)
118 #define osdescCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) osdescCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided)
119 #define osdescShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) osdescShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy)
120 #define osdescMapTo(pResource, pParams) osdescMapTo_DISPATCH(pResource, pParams)
121 #define osdescGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) osdescGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace)
122 #define osdescIsExportAllowed(pMemory) osdescIsExportAllowed_DISPATCH(pMemory)
123 #define osdescGetRefCount(pResource) osdescGetRefCount_DISPATCH(pResource)
124 #define osdescAddAdditionalDependants(pClient, pResource, pReference) osdescAddAdditionalDependants_DISPATCH(pClient, pResource, pReference)
125 #define osdescControl_Prologue(pResource, pCallContext, pParams) osdescControl_Prologue_DISPATCH(pResource, pCallContext, pParams)
126 #define osdescIsGpuMapAllowed(pMemory, pGpu) osdescIsGpuMapAllowed_DISPATCH(pMemory, pGpu)
127 #define osdescUnmapFrom(pResource, pParams) osdescUnmapFrom_DISPATCH(pResource, pParams)
128 #define osdescControl_Epilogue(pResource, pCallContext, pParams) osdescControl_Epilogue_DISPATCH(pResource, pCallContext, pParams)
129 #define osdescControl(pMemory, pCallContext, pParams) osdescControl_DISPATCH(pMemory, pCallContext, pParams)
130 #define osdescUnmap(pMemory, pCallContext, pCpuMapping) osdescUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping)
131 #define osdescGetMemInterMapParams(pMemory, pParams) osdescGetMemInterMapParams_DISPATCH(pMemory, pParams)
132 #define osdescGetMemoryMappingDescriptor(pMemory, ppMemDesc) osdescGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc)
133 #define osdescControlFilter(pResource, pCallContext, pParams) osdescControlFilter_DISPATCH(pResource, pCallContext, pParams)
134 #define osdescControlSerialization_Prologue(pResource, pCallContext, pParams) osdescControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams)
135 #define osdescIsPartialUnmapSupported(pResource) osdescIsPartialUnmapSupported_DISPATCH(pResource)
136 #define osdescIsReady(pMemory, bCopyConstructorContext) osdescIsReady_DISPATCH(pMemory, bCopyConstructorContext)
137 #define osdescCheckCopyPermissions(pMemory, pDstGpu, pDstDevice) osdescCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, pDstDevice)
138 #define osdescPreDestruct(pResource) osdescPreDestruct_DISPATCH(pResource)
139 #define osdescIsDuplicate(pMemory, hMemory, pDuplicate) osdescIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate)
140 #define osdescControlSerialization_Epilogue(pResource, pCallContext, pParams) osdescControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams)
141 #define osdescMap(pMemory, pCallContext, pParams, pCpuMapping) osdescMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping)
142 #define osdescAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) osdescAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight)
143 NvBool osdescCanCopy_IMPL(struct OsDescMemory *pOsDescMemory);
144 
osdescCanCopy_DISPATCH(struct OsDescMemory * pOsDescMemory)145 static inline NvBool osdescCanCopy_DISPATCH(struct OsDescMemory *pOsDescMemory) {
146     return pOsDescMemory->__osdescCanCopy__(pOsDescMemory);
147 }
148 
osdescCheckMemInterUnmap_DISPATCH(struct OsDescMemory * pMemory,NvBool bSubdeviceHandleProvided)149 static inline NV_STATUS osdescCheckMemInterUnmap_DISPATCH(struct OsDescMemory *pMemory, NvBool bSubdeviceHandleProvided) {
150     return pMemory->__osdescCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided);
151 }
152 
osdescShareCallback_DISPATCH(struct OsDescMemory * pResource,struct RsClient * pInvokingClient,struct RsResourceRef * pParentRef,RS_SHARE_POLICY * pSharePolicy)153 static inline NvBool osdescShareCallback_DISPATCH(struct OsDescMemory *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) {
154     return pResource->__osdescShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy);
155 }
156 
osdescMapTo_DISPATCH(struct OsDescMemory * pResource,RS_RES_MAP_TO_PARAMS * pParams)157 static inline NV_STATUS osdescMapTo_DISPATCH(struct OsDescMemory *pResource, RS_RES_MAP_TO_PARAMS *pParams) {
158     return pResource->__osdescMapTo__(pResource, pParams);
159 }
160 
osdescGetMapAddrSpace_DISPATCH(struct OsDescMemory * pMemory,CALL_CONTEXT * pCallContext,NvU32 mapFlags,NV_ADDRESS_SPACE * pAddrSpace)161 static inline NV_STATUS osdescGetMapAddrSpace_DISPATCH(struct OsDescMemory *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) {
162     return pMemory->__osdescGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace);
163 }
164 
osdescIsExportAllowed_DISPATCH(struct OsDescMemory * pMemory)165 static inline NvBool osdescIsExportAllowed_DISPATCH(struct OsDescMemory *pMemory) {
166     return pMemory->__osdescIsExportAllowed__(pMemory);
167 }
168 
osdescGetRefCount_DISPATCH(struct OsDescMemory * pResource)169 static inline NvU32 osdescGetRefCount_DISPATCH(struct OsDescMemory *pResource) {
170     return pResource->__osdescGetRefCount__(pResource);
171 }
172 
osdescAddAdditionalDependants_DISPATCH(struct RsClient * pClient,struct OsDescMemory * pResource,RsResourceRef * pReference)173 static inline void osdescAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct OsDescMemory *pResource, RsResourceRef *pReference) {
174     pResource->__osdescAddAdditionalDependants__(pClient, pResource, pReference);
175 }
176 
osdescControl_Prologue_DISPATCH(struct OsDescMemory * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)177 static inline NV_STATUS osdescControl_Prologue_DISPATCH(struct OsDescMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
178     return pResource->__osdescControl_Prologue__(pResource, pCallContext, pParams);
179 }
180 
osdescIsGpuMapAllowed_DISPATCH(struct OsDescMemory * pMemory,struct OBJGPU * pGpu)181 static inline NvBool osdescIsGpuMapAllowed_DISPATCH(struct OsDescMemory *pMemory, struct OBJGPU *pGpu) {
182     return pMemory->__osdescIsGpuMapAllowed__(pMemory, pGpu);
183 }
184 
osdescUnmapFrom_DISPATCH(struct OsDescMemory * pResource,RS_RES_UNMAP_FROM_PARAMS * pParams)185 static inline NV_STATUS osdescUnmapFrom_DISPATCH(struct OsDescMemory *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) {
186     return pResource->__osdescUnmapFrom__(pResource, pParams);
187 }
188 
osdescControl_Epilogue_DISPATCH(struct OsDescMemory * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)189 static inline void osdescControl_Epilogue_DISPATCH(struct OsDescMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
190     pResource->__osdescControl_Epilogue__(pResource, pCallContext, pParams);
191 }
192 
osdescControl_DISPATCH(struct OsDescMemory * pMemory,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)193 static inline NV_STATUS osdescControl_DISPATCH(struct OsDescMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
194     return pMemory->__osdescControl__(pMemory, pCallContext, pParams);
195 }
196 
osdescUnmap_DISPATCH(struct OsDescMemory * pMemory,CALL_CONTEXT * pCallContext,RsCpuMapping * pCpuMapping)197 static inline NV_STATUS osdescUnmap_DISPATCH(struct OsDescMemory *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) {
198     return pMemory->__osdescUnmap__(pMemory, pCallContext, pCpuMapping);
199 }
200 
osdescGetMemInterMapParams_DISPATCH(struct OsDescMemory * pMemory,RMRES_MEM_INTER_MAP_PARAMS * pParams)201 static inline NV_STATUS osdescGetMemInterMapParams_DISPATCH(struct OsDescMemory *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) {
202     return pMemory->__osdescGetMemInterMapParams__(pMemory, pParams);
203 }
204 
osdescGetMemoryMappingDescriptor_DISPATCH(struct OsDescMemory * pMemory,MEMORY_DESCRIPTOR ** ppMemDesc)205 static inline NV_STATUS osdescGetMemoryMappingDescriptor_DISPATCH(struct OsDescMemory *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) {
206     return pMemory->__osdescGetMemoryMappingDescriptor__(pMemory, ppMemDesc);
207 }
208 
osdescControlFilter_DISPATCH(struct OsDescMemory * pResource,struct CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)209 static inline NV_STATUS osdescControlFilter_DISPATCH(struct OsDescMemory *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
210     return pResource->__osdescControlFilter__(pResource, pCallContext, pParams);
211 }
212 
osdescControlSerialization_Prologue_DISPATCH(struct OsDescMemory * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)213 static inline NV_STATUS osdescControlSerialization_Prologue_DISPATCH(struct OsDescMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
214     return pResource->__osdescControlSerialization_Prologue__(pResource, pCallContext, pParams);
215 }
216 
osdescIsPartialUnmapSupported_DISPATCH(struct OsDescMemory * pResource)217 static inline NvBool osdescIsPartialUnmapSupported_DISPATCH(struct OsDescMemory *pResource) {
218     return pResource->__osdescIsPartialUnmapSupported__(pResource);
219 }
220 
osdescIsReady_DISPATCH(struct OsDescMemory * pMemory,NvBool bCopyConstructorContext)221 static inline NV_STATUS osdescIsReady_DISPATCH(struct OsDescMemory *pMemory, NvBool bCopyConstructorContext) {
222     return pMemory->__osdescIsReady__(pMemory, bCopyConstructorContext);
223 }
224 
osdescCheckCopyPermissions_DISPATCH(struct OsDescMemory * pMemory,struct OBJGPU * pDstGpu,struct Device * pDstDevice)225 static inline NV_STATUS osdescCheckCopyPermissions_DISPATCH(struct OsDescMemory *pMemory, struct OBJGPU *pDstGpu, struct Device *pDstDevice) {
226     return pMemory->__osdescCheckCopyPermissions__(pMemory, pDstGpu, pDstDevice);
227 }
228 
osdescPreDestruct_DISPATCH(struct OsDescMemory * pResource)229 static inline void osdescPreDestruct_DISPATCH(struct OsDescMemory *pResource) {
230     pResource->__osdescPreDestruct__(pResource);
231 }
232 
osdescIsDuplicate_DISPATCH(struct OsDescMemory * pMemory,NvHandle hMemory,NvBool * pDuplicate)233 static inline NV_STATUS osdescIsDuplicate_DISPATCH(struct OsDescMemory *pMemory, NvHandle hMemory, NvBool *pDuplicate) {
234     return pMemory->__osdescIsDuplicate__(pMemory, hMemory, pDuplicate);
235 }
236 
osdescControlSerialization_Epilogue_DISPATCH(struct OsDescMemory * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)237 static inline void osdescControlSerialization_Epilogue_DISPATCH(struct OsDescMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
238     pResource->__osdescControlSerialization_Epilogue__(pResource, pCallContext, pParams);
239 }
240 
osdescMap_DISPATCH(struct OsDescMemory * pMemory,CALL_CONTEXT * pCallContext,struct RS_CPU_MAP_PARAMS * pParams,RsCpuMapping * pCpuMapping)241 static inline NV_STATUS osdescMap_DISPATCH(struct OsDescMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) {
242     return pMemory->__osdescMap__(pMemory, pCallContext, pParams, pCpuMapping);
243 }
244 
osdescAccessCallback_DISPATCH(struct OsDescMemory * pResource,struct RsClient * pInvokingClient,void * pAllocParams,RsAccessRight accessRight)245 static inline NvBool osdescAccessCallback_DISPATCH(struct OsDescMemory *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) {
246     return pResource->__osdescAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight);
247 }
248 
249 NV_STATUS osdescConstruct_IMPL(struct OsDescMemory *arg_pOsDescMemory, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams);
250 
251 #define __nvoc_osdescConstruct(arg_pOsDescMemory, arg_pCallContext, arg_pParams) osdescConstruct_IMPL(arg_pOsDescMemory, arg_pCallContext, arg_pParams)
252 #undef PRIVATE_FIELD
253 
254 
255 #endif
256 
257 #ifdef __cplusplus
258 } // extern "C"
259 #endif
260 
261 #endif // _G_OS_DESC_MEM_NVOC_H_
262