1 #ifndef _G_OBJECT_NVOC_H_ 2 #define _G_OBJECT_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 2015-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 /* 33 * This file is part of the NVOC runtime. 34 */ 35 36 #include "g_object_nvoc.h" 37 38 #ifndef _NVOC_OBJECT_H_ 39 #define _NVOC_OBJECT_H_ 40 41 #include "nvtypes.h" 42 #include "nvstatus.h" 43 44 #include "nvoc/prelude.h" 45 46 struct Object; 47 48 #ifndef __NVOC_CLASS_Object_TYPEDEF__ 49 #define __NVOC_CLASS_Object_TYPEDEF__ 50 typedef struct Object Object; 51 #endif /* __NVOC_CLASS_Object_TYPEDEF__ */ 52 53 #ifndef __nvoc_class_id_Object 54 #define __nvoc_class_id_Object 0x497031 55 #endif /* __nvoc_class_id_Object */ 56 57 58 struct NVOC_CLASS_INFO; 59 60 /*! 61 * Tracks the head of an object's child list, and the next object in its 62 * parent's child list. 63 */ 64 struct NVOC_CHILD_TREE 65 { 66 struct Object *pChild; 67 struct Object *pSibling; 68 }; 69 70 //! The base class of all instantiable NVOC objects. 71 #ifdef NVOC_OBJECT_H_PRIVATE_ACCESS_ALLOWED 72 #define PRIVATE_FIELD(x) x 73 #else 74 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x) 75 #endif 76 struct Object { 77 const struct NVOC_RTTI *__nvoc_rtti; 78 struct Object *__nvoc_pbase_Object; 79 struct Object *pParent; 80 struct NVOC_CHILD_TREE childTree; 81 NvU32 ipVersion; 82 NvU32 createFlags; 83 }; 84 85 #ifndef __NVOC_CLASS_Object_TYPEDEF__ 86 #define __NVOC_CLASS_Object_TYPEDEF__ 87 typedef struct Object Object; 88 #endif /* __NVOC_CLASS_Object_TYPEDEF__ */ 89 90 #ifndef __nvoc_class_id_Object 91 #define __nvoc_class_id_Object 0x497031 92 #endif /* __nvoc_class_id_Object */ 93 94 extern const struct NVOC_CLASS_DEF __nvoc_class_def_Object; 95 96 #define __staticCast_Object(pThis) \ 97 ((pThis)->__nvoc_pbase_Object) 98 99 #ifdef __nvoc_object_h_disabled 100 #define __dynamicCast_Object(pThis) ((Object*)NULL) 101 #else //__nvoc_object_h_disabled 102 #define __dynamicCast_Object(pThis) \ 103 ((Object*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(Object))) 104 #endif //__nvoc_object_h_disabled 105 106 107 NV_STATUS __nvoc_objCreateDynamic_Object(Object**, Dynamic*, NvU32, va_list); 108 109 NV_STATUS __nvoc_objCreate_Object(Object**, Dynamic*, NvU32); 110 #define __objCreate_Object(ppNewObj, pParent, createFlags) \ 111 __nvoc_objCreate_Object((ppNewObj), staticCast((pParent), Dynamic), (createFlags)) 112 113 void objAddChild_IMPL(struct Object *pObj, struct Object *pChild); 114 115 #ifdef __nvoc_object_h_disabled 116 static inline void objAddChild(struct Object *pObj, struct Object *pChild) { 117 NV_ASSERT_FAILED_PRECOMP("Object was disabled!"); 118 } 119 #else //__nvoc_object_h_disabled 120 #define objAddChild(pObj, pChild) objAddChild_IMPL(pObj, pChild) 121 #endif //__nvoc_object_h_disabled 122 123 void objRemoveChild_IMPL(struct Object *pObj, struct Object *pChild); 124 125 #ifdef __nvoc_object_h_disabled 126 static inline void objRemoveChild(struct Object *pObj, struct Object *pChild) { 127 NV_ASSERT_FAILED_PRECOMP("Object was disabled!"); 128 } 129 #else //__nvoc_object_h_disabled 130 #define objRemoveChild(pObj, pChild) objRemoveChild_IMPL(pObj, pChild) 131 #endif //__nvoc_object_h_disabled 132 133 struct Object *objGetChild_IMPL(struct Object *pObj); 134 135 #ifdef __nvoc_object_h_disabled 136 static inline struct Object *objGetChild(struct Object *pObj) { 137 NV_ASSERT_FAILED_PRECOMP("Object was disabled!"); 138 return NULL; 139 } 140 #else //__nvoc_object_h_disabled 141 #define objGetChild(pObj) objGetChild_IMPL(pObj) 142 #endif //__nvoc_object_h_disabled 143 144 struct Object *objGetSibling_IMPL(struct Object *pObj); 145 146 #ifdef __nvoc_object_h_disabled 147 static inline struct Object *objGetSibling(struct Object *pObj) { 148 NV_ASSERT_FAILED_PRECOMP("Object was disabled!"); 149 return NULL; 150 } 151 #else //__nvoc_object_h_disabled 152 #define objGetSibling(pObj) objGetSibling_IMPL(pObj) 153 #endif //__nvoc_object_h_disabled 154 155 struct Object *objGetDirectParent_IMPL(struct Object *pObj); 156 157 #ifdef __nvoc_object_h_disabled 158 static inline struct Object *objGetDirectParent(struct Object *pObj) { 159 NV_ASSERT_FAILED_PRECOMP("Object was disabled!"); 160 return NULL; 161 } 162 #else //__nvoc_object_h_disabled 163 #define objGetDirectParent(pObj) objGetDirectParent_IMPL(pObj) 164 #endif //__nvoc_object_h_disabled 165 166 #undef PRIVATE_FIELD 167 168 169 // 170 // IP versioning definitions are temporary until NVOC halspec support is 171 // finished. 172 // 173 // IP_VERSION format as defined by the hardware engines. 174 // A _MAJOR value of 0 means the object has no version number. 175 // 176 177 #define NV_ODB_IP_VER_DEV 7:0 /* R-IVF */ 178 #define NV_ODB_IP_VER_ECO 15:8 /* R-IVF */ 179 #define NV_ODB_IP_VER_MINOR 23:16 /* R-IVF */ 180 #define NV_ODB_IP_VER_MAJOR 31:24 /* R-IVF */ 181 182 #define IPVersion(pObj) staticCast((pObj), Object)->ipVersion 183 // v0 .. v1 inclusive 184 #define IsIPVersionInRange(pObj, v0, v1) ((IPVersion(pObj) >= (v0)) && (IPVersion(pObj) <= (v1))) 185 186 #endif 187 188 #ifdef __cplusplus 189 } // extern "C" 190 #endif 191 #endif // _G_OBJECT_NVOC_H_ 192