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