1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVIF_OBJECT_H__
3 #define __NVIF_OBJECT_H__
14 struct nvif_client
*client
;
17 void *priv
; /*XXX: hack */
24 int nvif_object_init(struct nvif_object
*, u32 handle
, s32 oclass
, void *, u32
,
25 struct nvif_object
*);
26 void nvif_object_fini(struct nvif_object
*);
27 int nvif_object_ioctl(struct nvif_object
*, void *, u32
, void **);
28 int nvif_object_sclass_get(struct nvif_object
*, struct nvif_sclass
**);
29 void nvif_object_sclass_put(struct nvif_sclass
**);
30 u32
nvif_object_rd(struct nvif_object
*, int, u64
);
31 void nvif_object_wr(struct nvif_object
*, int, u64
, u32
);
32 int nvif_object_mthd(struct nvif_object
*, u32
, void *, u32
);
33 int nvif_object_map_handle(struct nvif_object
*, void *, u32
,
34 u64
*handle
, u64
*length
);
35 void nvif_object_unmap_handle(struct nvif_object
*);
36 int nvif_object_map(struct nvif_object
*, void *, u32
);
37 void nvif_object_unmap(struct nvif_object
*);
39 #define nvif_handle(a) (unsigned long)(void *)(a)
40 #define nvif_object(a) (a)->object
42 #define nvif_rd(a,f,b,c) ({ \
43 struct nvif_object *_object = (a); \
45 if (likely(_object->map.ptr)) \
46 _data = f((u8 __iomem *)_object->map.ptr + (c)); \
48 _data = nvif_object_rd(_object, (b), (c)); \
51 #define nvif_wr(a,f,b,c,d) ({ \
52 struct nvif_object *_object = (a); \
53 if (likely(_object->map.ptr)) \
54 f((d), (u8 __iomem *)_object->map.ptr + (c)); \
56 nvif_object_wr(_object, (b), (c), (d)); \
58 #define nvif_rd08(a,b) ({ ((u8)nvif_rd((a), ioread8, 1, (b))); })
59 #define nvif_rd16(a,b) ({ ((u16)nvif_rd((a), ioread16_native, 2, (b))); })
60 #define nvif_rd32(a,b) ({ ((u32)nvif_rd((a), ioread32_native, 4, (b))); })
61 #define nvif_wr08(a,b,c) nvif_wr((a), iowrite8, 1, (b), (u8)(c))
62 #define nvif_wr16(a,b,c) nvif_wr((a), iowrite16_native, 2, (b), (u16)(c))
63 #define nvif_wr32(a,b,c) nvif_wr((a), iowrite32_native, 4, (b), (u32)(c))
64 #define nvif_mask(a,b,c,d) ({ \
65 struct nvif_object *__object = (a); \
66 u32 _addr = (b), _data = nvif_rd32(__object, _addr); \
67 nvif_wr32(__object, _addr, (_data & ~(c)) | (d)); \
71 #define nvif_mthd(a,b,c,d) nvif_object_mthd((a), (b), (c), (d))
78 #define nvif_mclass(o,m) ({ \
79 struct nvif_object *object = (o); \
80 struct nvif_sclass *sclass; \
81 const typeof(m[0]) *mclass = (m); \
85 cnt = nvif_object_sclass_get(object, &sclass); \
87 for (i = 0; ret < 0 && mclass[i].oclass; i++) { \
88 for (j = 0; j < cnt; j++) { \
89 if (mclass[i].oclass == sclass[j].oclass && \
90 mclass[i].version >= sclass[j].minver && \
91 mclass[i].version <= sclass[j].maxver) { \
97 nvif_object_sclass_put(&sclass); \
103 #include <core/object.h>
104 #define nvxx_object(a) ({ \
105 struct nvif_object *_object = (a); \
106 (struct nvkm_object *)_object->priv; \