• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _LINUX_MODULE_H
16 #define _LINUX_MODULE_H
17 
18 #include "linux/kernel.h"
19 #include "linux/moduleparam.h"
20 #include "linux/list.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25 
26 typedef int (*InitcallFunc)(void);
27 
28 #define __used  __attribute__((__used__))
29 #define DEFINE_INITCALL(f, level) \
30     static InitcallFunc sfn_##f##level __used __attribute__((section(".initcall"#level".init"))) = {f}
31 
32 /* startup levels follow linux kernel levels */
33 #define LEVEL_PURE      0
34 #define LEVEL_CORE      1
35 #define LEVEL_POSTCORE  2
36 #define LEVEL_ARCH      3
37 #define LEVEL_SUBSYS    4
38 #define LEVEL_FS        5
39 #define LEVEL_DEVICE    6
40 #define LEVEL_LATE      7
41 
42 #define INITCALL(f, l)          DEFINE_INITCALL(f, l)
43 
44 /* liteos startup initcalls declaration interface */
45 #define PURE_INITCALL(f)        INITCALL(f, LEVEL_PURE)
46 #define CORE_INITCALL(f)        INITCALL(f, LEVEL_CORE)
47 #define PPOSTCORE_INITCALL(f)   INITCALL(f, LEVEL_POSTCORE)
48 #define ARCH_INITCALL(f)        INITCALL(f, LEVEL_ARCH)
49 #define SUBSYS_INITCALL(f)      INITCALL(f, LEVEL_SUBSYS)
50 #define FS_INITCALL(f)          INITCALL(f, LEVEL_FS)
51 #define DEVICE_INITCALL(f)      INITCALL(f, LEVEL_DEVICE)
52 #define LATE_INITCALL(f)        INITCALL(f, LEVEL_LATE)
53 
54 /* compatible with Linux initcalls declaration interface */
55 #define pure_initcall(f)        PURE_INITCALL(f)
56 #define core_initcall(f)        CORE_INITCALL(f)
57 #define postcore_initcall(f)    PPOSTCORE_INITCALL(f)
58 #define arch_initcall(f)        ARCH_INITCALL(f)
59 #define subsys_initcall(f)      SUBSYS_INITCALL(f)
60 #define fs_initcall(f)          FS_INITCALL(f)
61 #define device_initcall(f)      DEVICE_INITCALL(f)
62 #define late_initcall(f)        LATE_INITCALL(f)
63 #define _initcall(f)            device_initcall(f)
64 #define module_init(f)          device_initcall(f)
65 #define module_exit(f)
66 
67 /* execute initcalls, the order of dependencies at different startup levels is guaranteed by the registered user */
68 extern UINT32 DoInitcalls(void);
69 
70 #define module_param_named(u, v, t, f)
71 #define MODULE_PARM_DESC(_parm, desc)
72 #define MODULE_AUTHOR(a)
73 #define MODULE_DESCRIPTION(d)
74 #ifndef MODULE_LICENSE
75 #define MODULE_LICENSE(s)
76 #endif
77 #define MODULE_VERSION(v)
78 #define module_param_array(name, type, nump, perm)
79 #define THIS_MODULE ((struct module *)0)
80 
81 struct module {
82 };
83 
try_module_get(struct module * module)84 static inline int try_module_get(struct module *module)
85 {
86     return 1;
87 }
88 
module_put(struct module * module)89 static inline void module_put(struct module *module)
90 {
91 }
92 
93 #ifdef __cplusplus
94 }
95 #endif /* __cplusplus */
96 
97 #endif /* _LINUX_MODULE_H */
98