1 #ifndef _G_HW_RESOURCES_NVOC_H_
2 #define _G_HW_RESOURCES_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_hw_resources_nvoc.h"
33 
34 #ifndef _HW_RESOURCES_H_
35 #define _HW_RESOURCES_H_
36 
37 #include "mem_mgr/mem.h"
38 
39 /*!
40  * Allocator for normal virtual, video and system memory
41  */
42 #ifdef NVOC_HW_RESOURCES_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 MemoryHwResources {
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 MemoryHwResources *__nvoc_pbase_MemoryHwResources;
56     NvBool (*__hwresCanCopy__)(struct MemoryHwResources *);
57     NV_STATUS (*__hwresCheckMemInterUnmap__)(struct MemoryHwResources *, NvBool);
58     NvBool (*__hwresShareCallback__)(struct MemoryHwResources *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *);
59     NV_STATUS (*__hwresMapTo__)(struct MemoryHwResources *, RS_RES_MAP_TO_PARAMS *);
60     NV_STATUS (*__hwresGetMapAddrSpace__)(struct MemoryHwResources *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *);
61     NvU32 (*__hwresGetRefCount__)(struct MemoryHwResources *);
62     void (*__hwresAddAdditionalDependants__)(struct RsClient *, struct MemoryHwResources *, RsResourceRef *);
63     NV_STATUS (*__hwresControl_Prologue__)(struct MemoryHwResources *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
64     NvBool (*__hwresIsGpuMapAllowed__)(struct MemoryHwResources *, struct OBJGPU *);
65     NV_STATUS (*__hwresUnmapFrom__)(struct MemoryHwResources *, RS_RES_UNMAP_FROM_PARAMS *);
66     void (*__hwresControl_Epilogue__)(struct MemoryHwResources *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
67     NV_STATUS (*__hwresControlLookup__)(struct MemoryHwResources *, struct RS_RES_CONTROL_PARAMS_INTERNAL *, const struct NVOC_EXPORTED_METHOD_DEF **);
68     NV_STATUS (*__hwresControl__)(struct MemoryHwResources *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
69     NV_STATUS (*__hwresUnmap__)(struct MemoryHwResources *, CALL_CONTEXT *, RsCpuMapping *);
70     NV_STATUS (*__hwresGetMemInterMapParams__)(struct MemoryHwResources *, RMRES_MEM_INTER_MAP_PARAMS *);
71     NV_STATUS (*__hwresGetMemoryMappingDescriptor__)(struct MemoryHwResources *, MEMORY_DESCRIPTOR **);
72     NV_STATUS (*__hwresControlFilter__)(struct MemoryHwResources *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
73     NV_STATUS (*__hwresControlSerialization_Prologue__)(struct MemoryHwResources *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
74     NV_STATUS (*__hwresIsReady__)(struct MemoryHwResources *, NvBool);
75     NV_STATUS (*__hwresCheckCopyPermissions__)(struct MemoryHwResources *, struct OBJGPU *, struct Device *);
76     void (*__hwresPreDestruct__)(struct MemoryHwResources *);
77     NV_STATUS (*__hwresIsDuplicate__)(struct MemoryHwResources *, NvHandle, NvBool *);
78     void (*__hwresControlSerialization_Epilogue__)(struct MemoryHwResources *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
79     NV_STATUS (*__hwresMap__)(struct MemoryHwResources *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *);
80     NvBool (*__hwresAccessCallback__)(struct MemoryHwResources *, struct RsClient *, void *, RsAccessRight);
81 };
82 
83 #ifndef __NVOC_CLASS_MemoryHwResources_TYPEDEF__
84 #define __NVOC_CLASS_MemoryHwResources_TYPEDEF__
85 typedef struct MemoryHwResources MemoryHwResources;
86 #endif /* __NVOC_CLASS_MemoryHwResources_TYPEDEF__ */
87 
88 #ifndef __nvoc_class_id_MemoryHwResources
89 #define __nvoc_class_id_MemoryHwResources 0x9a2a71
90 #endif /* __nvoc_class_id_MemoryHwResources */
91 
92 extern const struct NVOC_CLASS_DEF __nvoc_class_def_MemoryHwResources;
93 
94 #define __staticCast_MemoryHwResources(pThis) \
95     ((pThis)->__nvoc_pbase_MemoryHwResources)
96 
97 #ifdef __nvoc_hw_resources_h_disabled
98 #define __dynamicCast_MemoryHwResources(pThis) ((MemoryHwResources*)NULL)
99 #else //__nvoc_hw_resources_h_disabled
100 #define __dynamicCast_MemoryHwResources(pThis) \
101     ((MemoryHwResources*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(MemoryHwResources)))
102 #endif //__nvoc_hw_resources_h_disabled
103 
104 
105 NV_STATUS __nvoc_objCreateDynamic_MemoryHwResources(MemoryHwResources**, Dynamic*, NvU32, va_list);
106 
107 NV_STATUS __nvoc_objCreate_MemoryHwResources(MemoryHwResources**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams);
108 #define __objCreate_MemoryHwResources(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \
109     __nvoc_objCreate_MemoryHwResources((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams)
110 
111 #define hwresCanCopy(pMemoryHwResources) hwresCanCopy_DISPATCH(pMemoryHwResources)
112 #define hwresCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) hwresCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided)
113 #define hwresShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) hwresShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy)
114 #define hwresMapTo(pResource, pParams) hwresMapTo_DISPATCH(pResource, pParams)
115 #define hwresGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) hwresGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace)
116 #define hwresGetRefCount(pResource) hwresGetRefCount_DISPATCH(pResource)
117 #define hwresAddAdditionalDependants(pClient, pResource, pReference) hwresAddAdditionalDependants_DISPATCH(pClient, pResource, pReference)
118 #define hwresControl_Prologue(pResource, pCallContext, pParams) hwresControl_Prologue_DISPATCH(pResource, pCallContext, pParams)
119 #define hwresIsGpuMapAllowed(pMemory, pGpu) hwresIsGpuMapAllowed_DISPATCH(pMemory, pGpu)
120 #define hwresUnmapFrom(pResource, pParams) hwresUnmapFrom_DISPATCH(pResource, pParams)
121 #define hwresControl_Epilogue(pResource, pCallContext, pParams) hwresControl_Epilogue_DISPATCH(pResource, pCallContext, pParams)
122 #define hwresControlLookup(pResource, pParams, ppEntry) hwresControlLookup_DISPATCH(pResource, pParams, ppEntry)
123 #define hwresControl(pMemory, pCallContext, pParams) hwresControl_DISPATCH(pMemory, pCallContext, pParams)
124 #define hwresUnmap(pMemory, pCallContext, pCpuMapping) hwresUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping)
125 #define hwresGetMemInterMapParams(pMemory, pParams) hwresGetMemInterMapParams_DISPATCH(pMemory, pParams)
126 #define hwresGetMemoryMappingDescriptor(pMemory, ppMemDesc) hwresGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc)
127 #define hwresControlFilter(pResource, pCallContext, pParams) hwresControlFilter_DISPATCH(pResource, pCallContext, pParams)
128 #define hwresControlSerialization_Prologue(pResource, pCallContext, pParams) hwresControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams)
129 #define hwresIsReady(pMemory, bCopyConstructorContext) hwresIsReady_DISPATCH(pMemory, bCopyConstructorContext)
130 #define hwresCheckCopyPermissions(pMemory, pDstGpu, pDstDevice) hwresCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, pDstDevice)
131 #define hwresPreDestruct(pResource) hwresPreDestruct_DISPATCH(pResource)
132 #define hwresIsDuplicate(pMemory, hMemory, pDuplicate) hwresIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate)
133 #define hwresControlSerialization_Epilogue(pResource, pCallContext, pParams) hwresControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams)
134 #define hwresMap(pMemory, pCallContext, pParams, pCpuMapping) hwresMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping)
135 #define hwresAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) hwresAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight)
136 NvBool hwresCanCopy_IMPL(struct MemoryHwResources *pMemoryHwResources);
137 
138 static inline NvBool hwresCanCopy_DISPATCH(struct MemoryHwResources *pMemoryHwResources) {
139     return pMemoryHwResources->__hwresCanCopy__(pMemoryHwResources);
140 }
141 
142 static inline NV_STATUS hwresCheckMemInterUnmap_DISPATCH(struct MemoryHwResources *pMemory, NvBool bSubdeviceHandleProvided) {
143     return pMemory->__hwresCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided);
144 }
145 
146 static inline NvBool hwresShareCallback_DISPATCH(struct MemoryHwResources *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) {
147     return pResource->__hwresShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy);
148 }
149 
150 static inline NV_STATUS hwresMapTo_DISPATCH(struct MemoryHwResources *pResource, RS_RES_MAP_TO_PARAMS *pParams) {
151     return pResource->__hwresMapTo__(pResource, pParams);
152 }
153 
154 static inline NV_STATUS hwresGetMapAddrSpace_DISPATCH(struct MemoryHwResources *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) {
155     return pMemory->__hwresGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace);
156 }
157 
158 static inline NvU32 hwresGetRefCount_DISPATCH(struct MemoryHwResources *pResource) {
159     return pResource->__hwresGetRefCount__(pResource);
160 }
161 
162 static inline void hwresAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct MemoryHwResources *pResource, RsResourceRef *pReference) {
163     pResource->__hwresAddAdditionalDependants__(pClient, pResource, pReference);
164 }
165 
166 static inline NV_STATUS hwresControl_Prologue_DISPATCH(struct MemoryHwResources *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
167     return pResource->__hwresControl_Prologue__(pResource, pCallContext, pParams);
168 }
169 
170 static inline NvBool hwresIsGpuMapAllowed_DISPATCH(struct MemoryHwResources *pMemory, struct OBJGPU *pGpu) {
171     return pMemory->__hwresIsGpuMapAllowed__(pMemory, pGpu);
172 }
173 
174 static inline NV_STATUS hwresUnmapFrom_DISPATCH(struct MemoryHwResources *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) {
175     return pResource->__hwresUnmapFrom__(pResource, pParams);
176 }
177 
178 static inline void hwresControl_Epilogue_DISPATCH(struct MemoryHwResources *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
179     pResource->__hwresControl_Epilogue__(pResource, pCallContext, pParams);
180 }
181 
182 static inline NV_STATUS hwresControlLookup_DISPATCH(struct MemoryHwResources *pResource, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams, const struct NVOC_EXPORTED_METHOD_DEF **ppEntry) {
183     return pResource->__hwresControlLookup__(pResource, pParams, ppEntry);
184 }
185 
186 static inline NV_STATUS hwresControl_DISPATCH(struct MemoryHwResources *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
187     return pMemory->__hwresControl__(pMemory, pCallContext, pParams);
188 }
189 
190 static inline NV_STATUS hwresUnmap_DISPATCH(struct MemoryHwResources *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) {
191     return pMemory->__hwresUnmap__(pMemory, pCallContext, pCpuMapping);
192 }
193 
194 static inline NV_STATUS hwresGetMemInterMapParams_DISPATCH(struct MemoryHwResources *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) {
195     return pMemory->__hwresGetMemInterMapParams__(pMemory, pParams);
196 }
197 
198 static inline NV_STATUS hwresGetMemoryMappingDescriptor_DISPATCH(struct MemoryHwResources *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) {
199     return pMemory->__hwresGetMemoryMappingDescriptor__(pMemory, ppMemDesc);
200 }
201 
202 static inline NV_STATUS hwresControlFilter_DISPATCH(struct MemoryHwResources *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
203     return pResource->__hwresControlFilter__(pResource, pCallContext, pParams);
204 }
205 
206 static inline NV_STATUS hwresControlSerialization_Prologue_DISPATCH(struct MemoryHwResources *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
207     return pResource->__hwresControlSerialization_Prologue__(pResource, pCallContext, pParams);
208 }
209 
210 static inline NV_STATUS hwresIsReady_DISPATCH(struct MemoryHwResources *pMemory, NvBool bCopyConstructorContext) {
211     return pMemory->__hwresIsReady__(pMemory, bCopyConstructorContext);
212 }
213 
214 static inline NV_STATUS hwresCheckCopyPermissions_DISPATCH(struct MemoryHwResources *pMemory, struct OBJGPU *pDstGpu, struct Device *pDstDevice) {
215     return pMemory->__hwresCheckCopyPermissions__(pMemory, pDstGpu, pDstDevice);
216 }
217 
218 static inline void hwresPreDestruct_DISPATCH(struct MemoryHwResources *pResource) {
219     pResource->__hwresPreDestruct__(pResource);
220 }
221 
222 static inline NV_STATUS hwresIsDuplicate_DISPATCH(struct MemoryHwResources *pMemory, NvHandle hMemory, NvBool *pDuplicate) {
223     return pMemory->__hwresIsDuplicate__(pMemory, hMemory, pDuplicate);
224 }
225 
226 static inline void hwresControlSerialization_Epilogue_DISPATCH(struct MemoryHwResources *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
227     pResource->__hwresControlSerialization_Epilogue__(pResource, pCallContext, pParams);
228 }
229 
230 static inline NV_STATUS hwresMap_DISPATCH(struct MemoryHwResources *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) {
231     return pMemory->__hwresMap__(pMemory, pCallContext, pParams, pCpuMapping);
232 }
233 
234 static inline NvBool hwresAccessCallback_DISPATCH(struct MemoryHwResources *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) {
235     return pResource->__hwresAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight);
236 }
237 
238 NV_STATUS hwresConstruct_IMPL(struct MemoryHwResources *arg_pMemoryHwResources, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams);
239 
240 #define __nvoc_hwresConstruct(arg_pMemoryHwResources, arg_pCallContext, arg_pParams) hwresConstruct_IMPL(arg_pMemoryHwResources, arg_pCallContext, arg_pParams)
241 void hwresDestruct_IMPL(struct MemoryHwResources *pMemoryHwResources);
242 
243 #define __nvoc_hwresDestruct(pMemoryHwResources) hwresDestruct_IMPL(pMemoryHwResources)
244 #undef PRIVATE_FIELD
245 
246 
247 #endif
248 
249 #ifdef __cplusplus
250 } // extern "C"
251 #endif
252 #endif // _G_HW_RESOURCES_NVOC_H_
253