| 1 | #ifndef __NOUVEAU_NAMEDB_H__ |
| 2 | #define __NOUVEAU_NAMEDB_H__ |
| 3 | |
| 4 | #include <core/parent.h> |
| 5 | |
| 6 | struct nouveau_handle; |
| 7 | |
| 8 | struct nouveau_namedb { |
| 9 | struct nouveau_parent base; |
| 10 | rwlock_t lock; |
| 11 | struct list_head list; |
| 12 | }; |
| 13 | |
| 14 | static inline struct nouveau_namedb * |
| 15 | nv_namedb(void *obj) |
| 16 | { |
| 17 | #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA |
| 18 | if (unlikely(!nv_iclass(obj, NV_NAMEDB_CLASS))) |
| 19 | nv_assert("BAD CAST -> NvNameDB, %08x" , nv_hclass(obj)); |
| 20 | #endif |
| 21 | return obj; |
| 22 | } |
| 23 | |
| 24 | #define nouveau_namedb_create(p,e,c,v,s,m,d) \ |
| 25 | nouveau_namedb_create_((p), (e), (c), (v), (s), (m), \ |
| 26 | sizeof(**d), (void **)d) |
| 27 | #define nouveau_namedb_init(p) \ |
| 28 | nouveau_parent_init(&(p)->base) |
| 29 | #define nouveau_namedb_fini(p,s) \ |
| 30 | nouveau_parent_fini(&(p)->base, (s)) |
| 31 | #define nouveau_namedb_destroy(p) do \ |
| 32 | { \ |
| 33 | rwlock_destroy(&(p)->lock); \ |
| 34 | nouveau_parent_destroy(&(p)->base); \ |
| 35 | } while (0) |
| 36 | |
| 37 | int nouveau_namedb_create_(struct nouveau_object *, struct nouveau_object *, |
| 38 | struct nouveau_oclass *, u32 pclass, |
| 39 | struct nouveau_oclass *, u64 engcls, |
| 40 | int size, void **); |
| 41 | |
| 42 | int _nouveau_namedb_ctor(struct nouveau_object *, struct nouveau_object *, |
| 43 | struct nouveau_oclass *, void *, u32, |
| 44 | struct nouveau_object **); |
| 45 | #define _nouveau_namedb_dtor _nouveau_parent_dtor |
| 46 | #define _nouveau_namedb_init _nouveau_parent_init |
| 47 | #define _nouveau_namedb_fini _nouveau_parent_fini |
| 48 | |
| 49 | int nouveau_namedb_insert(struct nouveau_namedb *, u32 name, |
| 50 | struct nouveau_object *, struct nouveau_handle *); |
| 51 | void nouveau_namedb_remove(struct nouveau_handle *); |
| 52 | |
| 53 | struct nouveau_handle *nouveau_namedb_get(struct nouveau_namedb *, u32); |
| 54 | struct nouveau_handle *nouveau_namedb_get_class(struct nouveau_namedb *, u16); |
| 55 | struct nouveau_handle *nouveau_namedb_get_vinst(struct nouveau_namedb *, u64); |
| 56 | struct nouveau_handle *nouveau_namedb_get_cinst(struct nouveau_namedb *, u32); |
| 57 | void nouveau_namedb_put(struct nouveau_handle *); |
| 58 | |
| 59 | #endif |
| 60 | |