xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h (revision e0bf6c5ca2d3281f231c5f0c9bf145e9513644de)
1 #ifndef __NVKM_INSTMEM_PRIV_H__
2 #define __NVKM_INSTMEM_PRIV_H__
3 #include <subdev/instmem.h>
4 
5 struct nvkm_instobj_impl {
6 	struct nvkm_oclass base;
7 };
8 
9 struct nvkm_instobj_args {
10 	u32 size;
11 	u32 align;
12 };
13 
14 #define nvkm_instobj_create(p,e,o,d)                                        \
15 	nvkm_instobj_create_((p), (e), (o), sizeof(**d), (void **)d)
16 #define nvkm_instobj_destroy(p) ({                                          \
17 	struct nvkm_instobj *iobj = (p);                                    \
18 	_nvkm_instobj_dtor(nv_object(iobj));                                \
19 })
20 #define nvkm_instobj_init(p)                                                \
21 	nvkm_object_init(&(p)->base)
22 #define nvkm_instobj_fini(p,s)                                              \
23 	nvkm_object_fini(&(p)->base, (s))
24 
25 int  nvkm_instobj_create_(struct nvkm_object *, struct nvkm_object *,
26 			     struct nvkm_oclass *, int, void **);
27 void _nvkm_instobj_dtor(struct nvkm_object *);
28 #define _nvkm_instobj_init nvkm_object_init
29 #define _nvkm_instobj_fini nvkm_object_fini
30 
31 struct nvkm_instmem_impl {
32 	struct nvkm_oclass base;
33 	struct nvkm_oclass *instobj;
34 };
35 
36 #define nvkm_instmem_create(p,e,o,d)                                        \
37 	nvkm_instmem_create_((p), (e), (o), sizeof(**d), (void **)d)
38 #define nvkm_instmem_destroy(p)                                             \
39 	nvkm_subdev_destroy(&(p)->base)
40 #define nvkm_instmem_init(p) ({                                             \
41 	struct nvkm_instmem *imem = (p);                                    \
42 	_nvkm_instmem_init(nv_object(imem));                                \
43 })
44 #define nvkm_instmem_fini(p,s) ({                                           \
45 	struct nvkm_instmem *imem = (p);                                    \
46 	_nvkm_instmem_fini(nv_object(imem), (s));                           \
47 })
48 
49 int nvkm_instmem_create_(struct nvkm_object *, struct nvkm_object *,
50 			    struct nvkm_oclass *, int, void **);
51 #define _nvkm_instmem_dtor _nvkm_subdev_dtor
52 int _nvkm_instmem_init(struct nvkm_object *);
53 int _nvkm_instmem_fini(struct nvkm_object *, bool);
54 #endif
55