1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/ftrace.h>
3 #include <linux/tracepoint.h>
4 #include <linux/kernel.h>
5 #include <linux/module.h>
6 #include <linux/init.h>
7 #include <linux/rv.h>
8 #include <rv/instrumentation.h>
9 #include <rv/da_monitor.h>
10 
11 #define MODULE_NAME "MODEL_NAME"
12 
13 /*
14  * XXX: include required tracepoint headers, e.g.,
15  * #include <linux/trace/events/sched.h>
16  */
17 #include <trace/events/rv.h>
18 
19 /*
20  * This is the self-generated part of the monitor. Generally, there is no need
21  * to touch this section.
22  */
23 #include "MODEL_NAME.h"
24 
25 /*
26  * Declare the deterministic automata monitor.
27  *
28  * The rv monitor reference is needed for the monitor declaration.
29  */
30 static struct rv_monitor rv_MODEL_NAME;
31 DECLARE_DA_MON_PER_CPU(MODEL_NAME, MIN_TYPE);
32 
33 /*
34  * This is the instrumentation part of the monitor.
35  *
36  * This is the section where manual work is required. Here the kernel events
37  * are translated into model's event.
38  *
39  */
40 TRACEPOINT_HANDLERS_SKEL
enable_MODEL_NAME(void)41 static int enable_MODEL_NAME(void)
42 {
43 	int retval;
44 
45 	retval = da_monitor_init_MODEL_NAME();
46 	if (retval)
47 		return retval;
48 
49 TRACEPOINT_ATTACH
50 
51 	return 0;
52 }
53 
disable_MODEL_NAME(void)54 static void disable_MODEL_NAME(void)
55 {
56 	rv_MODEL_NAME.enabled = 0;
57 
58 TRACEPOINT_DETACH
59 
60 	da_monitor_destroy_MODEL_NAME();
61 }
62 
63 /*
64  * This is the monitor register section.
65  */
66 static struct rv_monitor rv_MODEL_NAME = {
67 	.name = "MODEL_NAME",
68 	.description = "auto-generated MODEL_NAME",
69 	.enable = enable_MODEL_NAME,
70 	.disable = disable_MODEL_NAME,
71 	.reset = da_monitor_reset_all_MODEL_NAME,
72 	.enabled = 0,
73 };
74 
register_MODEL_NAME(void)75 static int __init register_MODEL_NAME(void)
76 {
77 	rv_register_monitor(&rv_MODEL_NAME);
78 	return 0;
79 }
80 
unregister_MODEL_NAME(void)81 static void __exit unregister_MODEL_NAME(void)
82 {
83 	rv_unregister_monitor(&rv_MODEL_NAME);
84 }
85 
86 module_init(register_MODEL_NAME);
87 module_exit(unregister_MODEL_NAME);
88 
89 MODULE_LICENSE("GPL");
90 MODULE_AUTHOR("dot2k: auto-generated");
91 MODULE_DESCRIPTION("MODEL_NAME");
92