1 #ifndef _G_MEM_LIST_NVOC_H_
2 #define _G_MEM_LIST_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_mem_list_nvoc.h"
33 
34 #ifndef _MEMORY_LIST_H_
35 #define _MEMORY_LIST_H_
36 
37 #include "mem_mgr/mem.h"
38 
39 /*!
40  * These classes are used by the vGPU support to create memory objects for memory
41  * assigned to a guest VM.
42  */
43 #ifdef NVOC_MEM_LIST_H_PRIVATE_ACCESS_ALLOWED
44 #define PRIVATE_FIELD(x) x
45 #else
46 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
47 #endif
48 struct MemoryList {
49     const struct NVOC_RTTI *__nvoc_rtti;
50     struct Memory __nvoc_base_Memory;
51     struct Object *__nvoc_pbase_Object;
52     struct RsResource *__nvoc_pbase_RsResource;
53     struct RmResourceCommon *__nvoc_pbase_RmResourceCommon;
54     struct RmResource *__nvoc_pbase_RmResource;
55     struct Memory *__nvoc_pbase_Memory;
56     struct MemoryList *__nvoc_pbase_MemoryList;
57     NvBool (*__memlistCanCopy__)(struct MemoryList *);
58     NV_STATUS (*__memlistCheckMemInterUnmap__)(struct MemoryList *, NvBool);
59     NvBool (*__memlistShareCallback__)(struct MemoryList *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *);
60     NV_STATUS (*__memlistMapTo__)(struct MemoryList *, RS_RES_MAP_TO_PARAMS *);
61     NV_STATUS (*__memlistGetMapAddrSpace__)(struct MemoryList *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *);
62     NvBool (*__memlistIsExportAllowed__)(struct MemoryList *);
63     NvU32 (*__memlistGetRefCount__)(struct MemoryList *);
64     void (*__memlistAddAdditionalDependants__)(struct RsClient *, struct MemoryList *, RsResourceRef *);
65     NV_STATUS (*__memlistControl_Prologue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
66     NvBool (*__memlistIsGpuMapAllowed__)(struct MemoryList *, struct OBJGPU *);
67     NV_STATUS (*__memlistUnmapFrom__)(struct MemoryList *, RS_RES_UNMAP_FROM_PARAMS *);
68     void (*__memlistControl_Epilogue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
69     NV_STATUS (*__memlistControlLookup__)(struct MemoryList *, struct RS_RES_CONTROL_PARAMS_INTERNAL *, const struct NVOC_EXPORTED_METHOD_DEF **);
70     NV_STATUS (*__memlistControl__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
71     NV_STATUS (*__memlistUnmap__)(struct MemoryList *, CALL_CONTEXT *, RsCpuMapping *);
72     NV_STATUS (*__memlistGetMemInterMapParams__)(struct MemoryList *, RMRES_MEM_INTER_MAP_PARAMS *);
73     NV_STATUS (*__memlistGetMemoryMappingDescriptor__)(struct MemoryList *, MEMORY_DESCRIPTOR **);
74     NV_STATUS (*__memlistControlFilter__)(struct MemoryList *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
75     NV_STATUS (*__memlistControlSerialization_Prologue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
76     NV_STATUS (*__memlistIsReady__)(struct MemoryList *, NvBool);
77     NV_STATUS (*__memlistCheckCopyPermissions__)(struct MemoryList *, struct OBJGPU *, struct Device *);
78     void (*__memlistPreDestruct__)(struct MemoryList *);
79     NV_STATUS (*__memlistIsDuplicate__)(struct MemoryList *, NvHandle, NvBool *);
80     void (*__memlistControlSerialization_Epilogue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
81     NV_STATUS (*__memlistMap__)(struct MemoryList *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *);
82     NvBool (*__memlistAccessCallback__)(struct MemoryList *, struct RsClient *, void *, RsAccessRight);
83 };
84 
85 #ifndef __NVOC_CLASS_MemoryList_TYPEDEF__
86 #define __NVOC_CLASS_MemoryList_TYPEDEF__
87 typedef struct MemoryList MemoryList;
88 #endif /* __NVOC_CLASS_MemoryList_TYPEDEF__ */
89 
90 #ifndef __nvoc_class_id_MemoryList
91 #define __nvoc_class_id_MemoryList 0x298f78
92 #endif /* __nvoc_class_id_MemoryList */
93 
94 extern const struct NVOC_CLASS_DEF __nvoc_class_def_MemoryList;
95 
96 #define __staticCast_MemoryList(pThis) \
97     ((pThis)->__nvoc_pbase_MemoryList)
98 
99 #ifdef __nvoc_mem_list_h_disabled
100 #define __dynamicCast_MemoryList(pThis) ((MemoryList*)NULL)
101 #else //__nvoc_mem_list_h_disabled
102 #define __dynamicCast_MemoryList(pThis) \
103     ((MemoryList*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(MemoryList)))
104 #endif //__nvoc_mem_list_h_disabled
105 
106 
107 NV_STATUS __nvoc_objCreateDynamic_MemoryList(MemoryList**, Dynamic*, NvU32, va_list);
108 
109 NV_STATUS __nvoc_objCreate_MemoryList(MemoryList**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams);
110 #define __objCreate_MemoryList(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \
111     __nvoc_objCreate_MemoryList((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams)
112 
113 #define memlistCanCopy(pMemoryList) memlistCanCopy_DISPATCH(pMemoryList)
114 #define memlistCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) memlistCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided)
115 #define memlistShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) memlistShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy)
116 #define memlistMapTo(pResource, pParams) memlistMapTo_DISPATCH(pResource, pParams)
117 #define memlistGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) memlistGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace)
118 #define memlistIsExportAllowed(pMemory) memlistIsExportAllowed_DISPATCH(pMemory)
119 #define memlistGetRefCount(pResource) memlistGetRefCount_DISPATCH(pResource)
120 #define memlistAddAdditionalDependants(pClient, pResource, pReference) memlistAddAdditionalDependants_DISPATCH(pClient, pResource, pReference)
121 #define memlistControl_Prologue(pResource, pCallContext, pParams) memlistControl_Prologue_DISPATCH(pResource, pCallContext, pParams)
122 #define memlistIsGpuMapAllowed(pMemory, pGpu) memlistIsGpuMapAllowed_DISPATCH(pMemory, pGpu)
123 #define memlistUnmapFrom(pResource, pParams) memlistUnmapFrom_DISPATCH(pResource, pParams)
124 #define memlistControl_Epilogue(pResource, pCallContext, pParams) memlistControl_Epilogue_DISPATCH(pResource, pCallContext, pParams)
125 #define memlistControlLookup(pResource, pParams, ppEntry) memlistControlLookup_DISPATCH(pResource, pParams, ppEntry)
126 #define memlistControl(pMemory, pCallContext, pParams) memlistControl_DISPATCH(pMemory, pCallContext, pParams)
127 #define memlistUnmap(pMemory, pCallContext, pCpuMapping) memlistUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping)
128 #define memlistGetMemInterMapParams(pMemory, pParams) memlistGetMemInterMapParams_DISPATCH(pMemory, pParams)
129 #define memlistGetMemoryMappingDescriptor(pMemory, ppMemDesc) memlistGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc)
130 #define memlistControlFilter(pResource, pCallContext, pParams) memlistControlFilter_DISPATCH(pResource, pCallContext, pParams)
131 #define memlistControlSerialization_Prologue(pResource, pCallContext, pParams) memlistControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams)
132 #define memlistIsReady(pMemory, bCopyConstructorContext) memlistIsReady_DISPATCH(pMemory, bCopyConstructorContext)
133 #define memlistCheckCopyPermissions(pMemory, pDstGpu, pDstDevice) memlistCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, pDstDevice)
134 #define memlistPreDestruct(pResource) memlistPreDestruct_DISPATCH(pResource)
135 #define memlistIsDuplicate(pMemory, hMemory, pDuplicate) memlistIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate)
136 #define memlistControlSerialization_Epilogue(pResource, pCallContext, pParams) memlistControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams)
137 #define memlistMap(pMemory, pCallContext, pParams, pCpuMapping) memlistMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping)
138 #define memlistAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) memlistAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight)
139 NvBool memlistCanCopy_IMPL(struct MemoryList *pMemoryList);
140 
141 static inline NvBool memlistCanCopy_DISPATCH(struct MemoryList *pMemoryList) {
142     return pMemoryList->__memlistCanCopy__(pMemoryList);
143 }
144 
145 static inline NV_STATUS memlistCheckMemInterUnmap_DISPATCH(struct MemoryList *pMemory, NvBool bSubdeviceHandleProvided) {
146     return pMemory->__memlistCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided);
147 }
148 
149 static inline NvBool memlistShareCallback_DISPATCH(struct MemoryList *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) {
150     return pResource->__memlistShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy);
151 }
152 
153 static inline NV_STATUS memlistMapTo_DISPATCH(struct MemoryList *pResource, RS_RES_MAP_TO_PARAMS *pParams) {
154     return pResource->__memlistMapTo__(pResource, pParams);
155 }
156 
157 static inline NV_STATUS memlistGetMapAddrSpace_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) {
158     return pMemory->__memlistGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace);
159 }
160 
161 static inline NvBool memlistIsExportAllowed_DISPATCH(struct MemoryList *pMemory) {
162     return pMemory->__memlistIsExportAllowed__(pMemory);
163 }
164 
165 static inline NvU32 memlistGetRefCount_DISPATCH(struct MemoryList *pResource) {
166     return pResource->__memlistGetRefCount__(pResource);
167 }
168 
169 static inline void memlistAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct MemoryList *pResource, RsResourceRef *pReference) {
170     pResource->__memlistAddAdditionalDependants__(pClient, pResource, pReference);
171 }
172 
173 static inline NV_STATUS memlistControl_Prologue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
174     return pResource->__memlistControl_Prologue__(pResource, pCallContext, pParams);
175 }
176 
177 static inline NvBool memlistIsGpuMapAllowed_DISPATCH(struct MemoryList *pMemory, struct OBJGPU *pGpu) {
178     return pMemory->__memlistIsGpuMapAllowed__(pMemory, pGpu);
179 }
180 
181 static inline NV_STATUS memlistUnmapFrom_DISPATCH(struct MemoryList *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) {
182     return pResource->__memlistUnmapFrom__(pResource, pParams);
183 }
184 
185 static inline void memlistControl_Epilogue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
186     pResource->__memlistControl_Epilogue__(pResource, pCallContext, pParams);
187 }
188 
189 static inline NV_STATUS memlistControlLookup_DISPATCH(struct MemoryList *pResource, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams, const struct NVOC_EXPORTED_METHOD_DEF **ppEntry) {
190     return pResource->__memlistControlLookup__(pResource, pParams, ppEntry);
191 }
192 
193 static inline NV_STATUS memlistControl_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
194     return pMemory->__memlistControl__(pMemory, pCallContext, pParams);
195 }
196 
197 static inline NV_STATUS memlistUnmap_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) {
198     return pMemory->__memlistUnmap__(pMemory, pCallContext, pCpuMapping);
199 }
200 
201 static inline NV_STATUS memlistGetMemInterMapParams_DISPATCH(struct MemoryList *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) {
202     return pMemory->__memlistGetMemInterMapParams__(pMemory, pParams);
203 }
204 
205 static inline NV_STATUS memlistGetMemoryMappingDescriptor_DISPATCH(struct MemoryList *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) {
206     return pMemory->__memlistGetMemoryMappingDescriptor__(pMemory, ppMemDesc);
207 }
208 
209 static inline NV_STATUS memlistControlFilter_DISPATCH(struct MemoryList *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
210     return pResource->__memlistControlFilter__(pResource, pCallContext, pParams);
211 }
212 
213 static inline NV_STATUS memlistControlSerialization_Prologue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
214     return pResource->__memlistControlSerialization_Prologue__(pResource, pCallContext, pParams);
215 }
216 
217 static inline NV_STATUS memlistIsReady_DISPATCH(struct MemoryList *pMemory, NvBool bCopyConstructorContext) {
218     return pMemory->__memlistIsReady__(pMemory, bCopyConstructorContext);
219 }
220 
221 static inline NV_STATUS memlistCheckCopyPermissions_DISPATCH(struct MemoryList *pMemory, struct OBJGPU *pDstGpu, struct Device *pDstDevice) {
222     return pMemory->__memlistCheckCopyPermissions__(pMemory, pDstGpu, pDstDevice);
223 }
224 
225 static inline void memlistPreDestruct_DISPATCH(struct MemoryList *pResource) {
226     pResource->__memlistPreDestruct__(pResource);
227 }
228 
229 static inline NV_STATUS memlistIsDuplicate_DISPATCH(struct MemoryList *pMemory, NvHandle hMemory, NvBool *pDuplicate) {
230     return pMemory->__memlistIsDuplicate__(pMemory, hMemory, pDuplicate);
231 }
232 
233 static inline void memlistControlSerialization_Epilogue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
234     pResource->__memlistControlSerialization_Epilogue__(pResource, pCallContext, pParams);
235 }
236 
237 static inline NV_STATUS memlistMap_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) {
238     return pMemory->__memlistMap__(pMemory, pCallContext, pParams, pCpuMapping);
239 }
240 
241 static inline NvBool memlistAccessCallback_DISPATCH(struct MemoryList *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) {
242     return pResource->__memlistAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight);
243 }
244 
245 NV_STATUS memlistConstruct_IMPL(struct MemoryList *arg_pMemoryList, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams);
246 
247 #define __nvoc_memlistConstruct(arg_pMemoryList, arg_pCallContext, arg_pParams) memlistConstruct_IMPL(arg_pMemoryList, arg_pCallContext, arg_pParams)
248 #undef PRIVATE_FIELD
249 
250 
251 #endif
252 
253 #ifdef __cplusplus
254 } // extern "C"
255 #endif
256 
257 #endif // _G_MEM_LIST_NVOC_H_
258