1 #ifndef __NOUVEAU_INSTMEM_H__
2 #define __NOUVEAU_INSTMEM_H__
4 #include <core/subdev.h>
5 #include <core/device.h>
8 struct nouveau_instobj {
9 struct nouveau_object base;
10 struct list_head head;
16 static inline struct nouveau_instobj *
19 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
20 if (unlikely(!nv_iclass(obj, NV_MEMOBJ_CLASS)))
21 nv_assert("BAD CAST -> NvMemObj, %08x", nv_hclass(obj));
26 #define nouveau_instobj_create(p,e,o,d) \
27 nouveau_instobj_create_((p), (e), (o), sizeof(**d), (void **)d)
28 #define nouveau_instobj_init(p) \
29 nouveau_object_init(&(p)->base)
30 #define nouveau_instobj_fini(p,s) \
31 nouveau_object_fini(&(p)->base, (s))
33 int nouveau_instobj_create_(struct nouveau_object *, struct nouveau_object *,
34 struct nouveau_oclass *, int, void **);
35 void nouveau_instobj_destroy(struct nouveau_instobj *);
37 void _nouveau_instobj_dtor(struct nouveau_object *);
38 #define _nouveau_instobj_init nouveau_object_init
39 #define _nouveau_instobj_fini nouveau_object_fini
41 struct nouveau_instmem {
42 struct nouveau_subdev base;
43 struct list_head list;
46 int (*alloc)(struct nouveau_instmem *, struct nouveau_object *,
47 u32 size, u32 align, struct nouveau_object **);
50 static inline struct nouveau_instmem *
51 nouveau_instmem(void *obj)
53 /* nv04/nv40 impls need to create objects in their constructor,
54 * which is before the subdev pointer is valid
56 if (nv_iclass(obj, NV_SUBDEV_CLASS) &&
57 nv_subidx(obj) == NVDEV_SUBDEV_INSTMEM)
60 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_INSTMEM];
63 #define nouveau_instmem_create(p,e,o,d) \
64 nouveau_instmem_create_((p), (e), (o), sizeof(**d), (void **)d)
65 #define nouveau_instmem_destroy(p) \
66 nouveau_subdev_destroy(&(p)->base)
67 int nouveau_instmem_create_(struct nouveau_object *, struct nouveau_object *,
68 struct nouveau_oclass *, int, void **);
69 int nouveau_instmem_init(struct nouveau_instmem *);
70 int nouveau_instmem_fini(struct nouveau_instmem *, bool);
72 #define _nouveau_instmem_dtor _nouveau_subdev_dtor
73 int _nouveau_instmem_init(struct nouveau_object *);
74 int _nouveau_instmem_fini(struct nouveau_object *, bool);
76 extern struct nouveau_oclass nv04_instmem_oclass;
77 extern struct nouveau_oclass nv40_instmem_oclass;
78 extern struct nouveau_oclass nv50_instmem_oclass;