| 1 | #ifndef __NOUVEAU_GPUOBJ_H__ |
| 2 | #define __NOUVEAU_GPUOBJ_H__ |
| 3 | |
| 4 | #include <core/object.h> |
| 5 | #include <core/device.h> |
| 6 | #include <core/parent.h> |
| 7 | #include <core/mm.h> |
| 8 | |
| 9 | struct nouveau_vma; |
| 10 | struct nouveau_vm; |
| 11 | |
| 12 | #define NVOBJ_FLAG_ZERO_ALLOC 0x00000001 |
| 13 | #define NVOBJ_FLAG_ZERO_FREE 0x00000002 |
| 14 | #define NVOBJ_FLAG_HEAP 0x00000004 |
| 15 | |
| 16 | struct nouveau_gpuobj { |
| 17 | struct nouveau_object base; |
| 18 | struct nouveau_object *parent; |
| 19 | struct nouveau_mm_node *node; |
| 20 | struct nouveau_mm heap; |
| 21 | |
| 22 | u32 flags; |
| 23 | u64 addr; |
| 24 | u32 size; |
| 25 | }; |
| 26 | |
| 27 | static inline struct nouveau_gpuobj * |
| 28 | nv_gpuobj(void *obj) |
| 29 | { |
| 30 | #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA |
| 31 | if (unlikely(!nv_iclass(obj, NV_GPUOBJ_CLASS))) |
| 32 | nv_assert("BAD CAST -> NvGpuObj, %08x" , nv_hclass(obj)); |
| 33 | #endif |
| 34 | return obj; |
| 35 | } |
| 36 | |
| 37 | #define nouveau_gpuobj_create(p,e,c,v,g,s,a,f,d) \ |
| 38 | nouveau_gpuobj_create_((p), (e), (c), (v), (g), (s), (a), (f), \ |
| 39 | sizeof(**d), (void **)d) |
| 40 | #define nouveau_gpuobj_init(p) nouveau_object_init(&(p)->base) |
| 41 | #define nouveau_gpuobj_fini(p,s) nouveau_object_fini(&(p)->base, (s)) |
| 42 | int nouveau_gpuobj_create_(struct nouveau_object *, struct nouveau_object *, |
| 43 | struct nouveau_oclass *, u32 pclass, |
| 44 | struct nouveau_object *, u32 size, u32 align, |
| 45 | u32 flags, int length, void **); |
| 46 | void nouveau_gpuobj_destroy(struct nouveau_gpuobj *); |
| 47 | |
| 48 | int nouveau_gpuobj_new(struct nouveau_object *, struct nouveau_object *, |
| 49 | u32 size, u32 align, u32 flags, |
| 50 | struct nouveau_gpuobj **); |
| 51 | int nouveau_gpuobj_dup(struct nouveau_object *, struct nouveau_gpuobj *, |
| 52 | struct nouveau_gpuobj **); |
| 53 | |
| 54 | int nouveau_gpuobj_map(struct nouveau_gpuobj *, u32 acc, struct nouveau_vma *); |
| 55 | int nouveau_gpuobj_map_vm(struct nouveau_gpuobj *, struct nouveau_vm *, |
| 56 | u32 access, struct nouveau_vma *); |
| 57 | void nouveau_gpuobj_unmap(struct nouveau_vma *); |
| 58 | |
| 59 | static inline void |
| 60 | nouveau_gpuobj_ref(struct nouveau_gpuobj *obj, struct nouveau_gpuobj **ref) |
| 61 | { |
| 62 | nouveau_object_ref(&obj->base, (struct nouveau_object **)ref); |
| 63 | } |
| 64 | |
| 65 | void _nouveau_gpuobj_dtor(struct nouveau_object *); |
| 66 | int _nouveau_gpuobj_init(struct nouveau_object *); |
| 67 | int _nouveau_gpuobj_fini(struct nouveau_object *, bool); |
| 68 | u32 _nouveau_gpuobj_rd32(struct nouveau_object *, u64); |
| 69 | void _nouveau_gpuobj_wr32(struct nouveau_object *, u64, u32); |
| 70 | |
| 71 | #endif |
| 72 | |