1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 #include <linux/module.h>
19
20 #include "mod_ext.h"
21
22 extern int HI_LOG(hi_s32 level, hi_mod_id mod_id, const char *fmt, ...);
23 EXPORT_SYMBOL(HI_LOG);
24
25 /*************************MOD********************/
26 EXPORT_SYMBOL(cmpi_get_module_name);
27 EXPORT_SYMBOL(cmpi_get_module_by_id);
28 EXPORT_SYMBOL(cmpi_get_module_func_by_id);
29 EXPORT_SYMBOL(cmpi_stop_modules);
30 EXPORT_SYMBOL(cmpi_query_modules);
31 EXPORT_SYMBOL(cmpi_exit_modules);
32 EXPORT_SYMBOL(cmpi_init_modules);
33 EXPORT_SYMBOL(cmpi_register_module);
34 EXPORT_SYMBOL(cmpi_unregister_module);
35
36 /******* create node /proc/sys/dev/debug/proc_message_enable ************/
37 extern hi_s32 g_proc_enable;
38 EXPORT_SYMBOL(g_proc_enable);
39
40 static struct ctl_table comm_eproc_table[] = {
41 {
42 .procname = "proc_message_enable",
43 .data = &g_proc_enable,
44 .maxlen = sizeof(g_proc_enable),
45 .mode = 0644, /* 0644 Node permission */
46 .proc_handler = proc_dointvec
47 },
48 {}
49 };
50
51 static struct ctl_table comm_dir_table[] = {
52 {
53 .procname = "debug",
54 .mode = 0555, /* 0555 Node permission */
55 .child = comm_eproc_table
56 },
57 {}
58 };
59
60 static struct ctl_table comm_parent_tbl[] = {
61 {
62 .procname = "dev",
63 .mode = 0555, /* 0555 Node permission */
64 .child = comm_dir_table
65 },
66 {}
67 };
68
69 static struct ctl_table_header *comm_eproc_tbl_head;
70
comm_init_proc_ctrl(void)71 int __init comm_init_proc_ctrl(void)
72 {
73 comm_eproc_tbl_head = register_sysctl_table(comm_parent_tbl);
74 if (comm_eproc_tbl_head == HI_NULL)
75 return -ENOMEM;
76 return 0;
77 }
78
comm_exit_proc_ctrl(void)79 void comm_exit_proc_ctrl(void)
80 {
81 unregister_sysctl_table(comm_eproc_tbl_head);
82 }
83
84 extern int comm_init(void);
85 extern void comm_exit(void);
86
base_mod_init(void)87 static int __init base_mod_init(void)
88 {
89 comm_init();
90
91 /* init proc switch */
92 if (comm_init_proc_ctrl() != HI_SUCCESS) {
93 comm_exit();
94 return -1;
95 }
96
97 return 0;
98 }
base_mod_exit(void)99 static void __exit base_mod_exit(void)
100 {
101 comm_exit_proc_ctrl();
102 comm_exit();
103 }
104
105 module_init(base_mod_init);
106 module_exit(base_mod_exit);
107
108 MODULE_LICENSE("GPL");
109
110