Commit | Line | Data |
---|---|---|
a04d0423 BS |
1 | #ifndef __NVIF_OBJECT_H__ |
2 | #define __NVIF_OBJECT_H__ | |
3 | ||
4 | #include <nvif/os.h> | |
5 | ||
6 | struct nvif_object { | |
a01ca78c | 7 | struct nvif_client *client; |
a04d0423 | 8 | struct nvif_object *parent; |
a04d0423 BS |
9 | u32 handle; |
10 | u32 oclass; | |
a04d0423 | 11 | void *priv; /*XXX: hack */ |
a04d0423 | 12 | struct { |
3cfb2fac | 13 | void __iomem *ptr; |
a04d0423 BS |
14 | u32 size; |
15 | } map; | |
16 | }; | |
17 | ||
a01ca78c | 18 | int nvif_object_init(struct nvif_object *, u32 handle, u32 oclass, void *, u32, |
a04d0423 BS |
19 | struct nvif_object *); |
20 | void nvif_object_fini(struct nvif_object *); | |
a04d0423 BS |
21 | int nvif_object_ioctl(struct nvif_object *, void *, u32, void **); |
22 | int nvif_object_sclass(struct nvif_object *, u32 *, int); | |
23 | u32 nvif_object_rd(struct nvif_object *, int, u64); | |
24 | void nvif_object_wr(struct nvif_object *, int, u64, u32); | |
25 | int nvif_object_mthd(struct nvif_object *, u32, void *, u32); | |
26 | int nvif_object_map(struct nvif_object *); | |
27 | void nvif_object_unmap(struct nvif_object *); | |
28 | ||
29 | #define nvif_object(a) (a)->object | |
30 | ||
a01ca78c BS |
31 | #define nvif_rd(a,f,b,c) ({ \ |
32 | struct nvif_object *_object = (a); \ | |
a04d0423 BS |
33 | u32 _data; \ |
34 | if (likely(_object->map.ptr)) \ | |
a01ca78c | 35 | _data = f((u8 __iomem *)_object->map.ptr + (c)); \ |
a04d0423 | 36 | else \ |
a01ca78c | 37 | _data = nvif_object_rd(_object, (b), (c)); \ |
a04d0423 BS |
38 | _data; \ |
39 | }) | |
a01ca78c BS |
40 | #define nvif_wr(a,f,b,c,d) ({ \ |
41 | struct nvif_object *_object = (a); \ | |
a04d0423 | 42 | if (likely(_object->map.ptr)) \ |
a01ca78c | 43 | f((d), (u8 __iomem *)_object->map.ptr + (c)); \ |
a04d0423 | 44 | else \ |
a01ca78c | 45 | nvif_object_wr(_object, (b), (c), (d)); \ |
a04d0423 | 46 | }) |
a01ca78c BS |
47 | #define nvif_rd08(a,b) ({ ((u8)nvif_rd((a), ioread8, 1, (b))); }) |
48 | #define nvif_rd16(a,b) ({ ((u16)nvif_rd((a), ioread16_native, 2, (b))); }) | |
49 | #define nvif_rd32(a,b) ({ ((u32)nvif_rd((a), ioread32_native, 4, (b))); }) | |
50 | #define nvif_wr08(a,b,c) nvif_wr((a), iowrite8, 1, (b), (u8)(c)) | |
51 | #define nvif_wr16(a,b,c) nvif_wr((a), iowrite16_native, 2, (b), (u16)(c)) | |
52 | #define nvif_wr32(a,b,c) nvif_wr((a), iowrite32_native, 4, (b), (u32)(c)) | |
a04d0423 | 53 | #define nvif_mask(a,b,c,d) ({ \ |
a01ca78c BS |
54 | struct nvif_object *__object = (a); \ |
55 | u32 _addr = (b), _data = nvif_rd32(__object, _addr); \ | |
56 | nvif_wr32(__object, _addr, (_data & ~(c)) | (d)); \ | |
57 | _data; \ | |
a04d0423 BS |
58 | }) |
59 | ||
a01ca78c | 60 | #define nvif_mthd(a,b,c,d) nvif_object_mthd((a), (b), (c), (d)) |
a04d0423 BS |
61 | |
62 | /*XXX*/ | |
63 | #include <core/object.h> | |
a01ca78c BS |
64 | #define nvxx_object(a) ({ \ |
65 | struct nvif_object *_object = (a); \ | |
66 | (struct nvkm_object *)_object->priv; \ | |
67 | }) | |
a04d0423 | 68 | #endif |