1 | #ifndef __NOUVEAU_ENGCTX_H__ |
2 | #define __NOUVEAU_ENGCTX_H__ |
3 | |
4 | #include <core/object.h> |
5 | #include <core/gpuobj.h> |
6 | |
7 | #include <subdev/vm.h> |
8 | |
9 | #define NV_ENGCTX_(eng,var) (NV_ENGCTX_CLASS | ((var) << 8) | (eng)) |
10 | #define NV_ENGCTX(name,var) NV_ENGCTX_(NVDEV_ENGINE_##name, (var)) |
11 | |
12 | struct nouveau_engctx { |
13 | struct nouveau_gpuobj base; |
14 | struct nouveau_vma vma; |
15 | struct list_head head; |
16 | unsigned long save; |
17 | u64 addr; |
18 | }; |
19 | |
20 | static inline struct nouveau_engctx * |
21 | nv_engctx(void *obj) |
22 | { |
23 | #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA |
24 | if (unlikely(!nv_iclass(obj, NV_ENGCTX_CLASS))) |
25 | nv_assert("BAD CAST -> NvEngCtx, %08x" , nv_hclass(obj)); |
26 | #endif |
27 | return obj; |
28 | } |
29 | |
30 | #define nouveau_engctx_create(p,e,c,g,s,a,f,d) \ |
31 | nouveau_engctx_create_((p), (e), (c), (g), (s), (a), (f), \ |
32 | sizeof(**d), (void **)d) |
33 | |
34 | int nouveau_engctx_create_(struct nouveau_object *, struct nouveau_object *, |
35 | struct nouveau_oclass *, struct nouveau_object *, |
36 | u32 size, u32 align, u32 flags, |
37 | int length, void **data); |
38 | void nouveau_engctx_destroy(struct nouveau_engctx *); |
39 | int nouveau_engctx_init(struct nouveau_engctx *); |
40 | int nouveau_engctx_fini(struct nouveau_engctx *, bool suspend); |
41 | |
42 | int _nouveau_engctx_ctor(struct nouveau_object *, struct nouveau_object *, |
43 | struct nouveau_oclass *, void *, u32, |
44 | struct nouveau_object **); |
45 | void _nouveau_engctx_dtor(struct nouveau_object *); |
46 | int _nouveau_engctx_init(struct nouveau_object *); |
47 | int _nouveau_engctx_fini(struct nouveau_object *, bool suspend); |
48 | #define _nouveau_engctx_rd32 _nouveau_gpuobj_rd32 |
49 | #define _nouveau_engctx_wr32 _nouveau_gpuobj_wr32 |
50 | |
51 | struct nouveau_object *nouveau_engctx_get(struct nouveau_engine *, u64 addr); |
52 | void nouveau_engctx_put(struct nouveau_object *); |
53 | |
54 | #endif |
55 | |