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