1 #ifndef __NVKM_FALCON_H__
2 #define __NVKM_FALCON_H__
3 #include <core/engctx.h>
4 struct nvkm_fifo_chan;
5 
6 struct nvkm_falcon_chan {
7 	struct nvkm_engctx base;
8 };
9 
10 #define nvkm_falcon_context_create(p,e,c,g,s,a,f,d)                         \
11 	nvkm_engctx_create((p), (e), (c), (g), (s), (a), (f), (d))
12 #define nvkm_falcon_context_destroy(d)                                      \
13 	nvkm_engctx_destroy(&(d)->base)
14 #define nvkm_falcon_context_init(d)                                         \
15 	nvkm_engctx_init(&(d)->base)
16 #define nvkm_falcon_context_fini(d,s)                                       \
17 	nvkm_engctx_fini(&(d)->base, (s))
18 
19 #define _nvkm_falcon_context_ctor _nvkm_engctx_ctor
20 #define _nvkm_falcon_context_dtor _nvkm_engctx_dtor
21 #define _nvkm_falcon_context_init _nvkm_engctx_init
22 #define _nvkm_falcon_context_fini _nvkm_engctx_fini
23 #define _nvkm_falcon_context_rd32 _nvkm_engctx_rd32
24 #define _nvkm_falcon_context_wr32 _nvkm_engctx_wr32
25 
26 struct nvkm_falcon_data {
27 	bool external;
28 };
29 
30 #include <core/engine.h>
31 
32 struct nvkm_falcon {
33 	struct nvkm_engine engine;
34 	const struct nvkm_falcon_func *func;
35 
36 	u32 addr;
37 	u8  version;
38 	u8  secret;
39 
40 	struct nvkm_memory *core;
41 	bool external;
42 
43 	struct {
44 		u32 limit;
45 		u32 *data;
46 		u32  size;
47 	} code;
48 
49 	struct {
50 		u32 limit;
51 		u32 *data;
52 		u32  size;
53 	} data;
54 };
55 
56 struct nvkm_falcon_func {
57 	void (*intr)(struct nvkm_falcon *, struct nvkm_fifo_chan *);
58 };
59 
60 #define nv_falcon(priv) ((struct nvkm_falcon *)priv)
61 
62 #define nvkm_falcon_create(a,p,e,c,b,d,i,f,r)                                 \
63 	nvkm_falcon_create_((a), (p), (e), (c), (b), (d), (i), (f),              \
64 			       sizeof(**r),(void **)r)
65 #define nvkm_falcon_destroy(p)                                              \
66 	nvkm_engine_destroy(&(p)->engine)
67 #define nvkm_falcon_init(p) ({                                              \
68 	struct nvkm_falcon *_falcon = (p);                                   \
69 	_nvkm_falcon_init(nv_object(_falcon));                               \
70 })
71 #define nvkm_falcon_fini(p,s) ({                                            \
72 	struct nvkm_falcon *_falcon = (p);                                   \
73 	_nvkm_falcon_fini(nv_object(_falcon), (s));                          \
74 })
75 
76 int nvkm_falcon_create_(const struct nvkm_falcon_func *,
77 			struct nvkm_object *, struct nvkm_object *,
78 			struct nvkm_oclass *, u32, bool, const char *,
79 			const char *, int, void **);
80 #define _nvkm_falcon_dtor _nvkm_engine_dtor
81 int  _nvkm_falcon_init(struct nvkm_object *);
82 int  _nvkm_falcon_fini(struct nvkm_object *, bool);
83 #endif
84