XenevaOS
Loading...
Searching...
No Matches
module.h
Go to the documentation of this file.
1#ifndef __LINUX_MODULE_H__
2#define __LINUX_MODULE_H__
3
4/*
5 * export.h is pulled in here because tty_buffer.c -- like every mainline
6 * source file that exports symbols -- includes only <linux/module.h> and
7 * calls EXPORT_SYMBOL_GPL(). mainline's module.h does include export.h; DCL's
8 * did not, because nothing had included module.h for an export before.
9 */
10#include <linux/export.h>
11/*
12 * init.h owns module_init() -- it maps it to DCL_INITCALL(fn), which stamps
13 * the named global __dcl_initcall_<fn> that DclRunInitcalls() runs. module.h
14 * used to define module_init() itself, as an empty macro, which meant a
15 * driver compiled here registered nothing at all and the only symptom was
16 * "probe never called". Including init.h and dropping the local definition is
17 * what makes module_init() actually mean something.
18 */
19#include <linux/init.h>
20
21/*
22 * KBUILD_MODNAME -- mainline's kbuild passes -DKBUILD_MODNAME='"name"' for
23 * every module it compiles, and a driver uses it for .driver.name. DCL's
24 * build does the same for sources under ../Vendored (KernelAA64/Makefile
25 * passes $(basename $(notdir $<)) on the compile line), so a vendored driver
26 * carries its own name with no per-file edit.
27 *
28 * The fallback below is for anything else that includes this header without
29 * that flag -- DCL and KernelAA64 sources -- which is why it must never be a
30 * plausible driver name: it is a placeholder, and if it ever shows up in a
31 * log line it means someone compiled a module outside the vendored rule.
32 */
33#ifndef KBUILD_MODNAME
34#define KBUILD_MODNAME "dcl-module"
35#endif
36
37#define module_exit(func)
38
39/*
40 * module_driver() -- mainline's bus-driver registration helper (upstream:
41 * include/linux/device/driver.h). Two details in its shape are what other
42 * DCL pieces are built on:
43 *
44 * - the init function it generates is named __driver##_init, taking the
45 * driver variable's name; module_init then stamps that name into
46 * __dcl_initcall_<...>_init, the name DclRunInitcalls() (DCL/
47 * linux_mm_shim.c) calls. drm_module.h's
48 * drm_module_pci_driver_if_modeset(bochs_pci_driver, bochs_modeset)
49 * therefore produces __dcl_initcall_bochs_pci_driver_init.
50 *
51 * - it takes the registration function as a macro argument and calls it
52 * with the driver, so drm_module.h can slip the
53 * drm_firmware_drivers_only() test between module_init and
54 * pci_register_driver without this header knowing about DRM.
55 *
56 * Mainline also generates an exit half (__driver##_exit -> __unregister) and
57 * passes it to module_exit(). DCL has no unload and module_exit above is
58 * empty, so that half would be a static function with no reference --
59 * -Wunused-function on every build. Dropped rather than silenced; it returns
60 * with module_exit() if unloading ever exists.
61 */
62#define module_driver(__driver, __register, __unregister, ...) \
63static int __init __driver##_init(void) \
64{ \
65 return __register(&(__driver), ##__VA_ARGS__); \
66} \
67module_init(__driver##_init)
68
69/*
70 * module_param_named() / module_param() / MODULE_PARM_DESC() -- no-ops, for
71 * the same reason MODULE_LICENSE() above is.
72 *
73 * mainline's module_param_named(name, value, type, perm) *declares* nothing:
74 * `value` must already exist as a variable in the file, and the macro only
75 * arranges for a boot-time setter and a sysfs entry to reach it. That is why
76 * this can be empty without breaking compilation -- vkms_drv.c writes
77 *
78 * static bool enable_cursor = true;
79 * module_param_named(enable_cursor, enable_cursor, bool, 0444);
80 *
81 * where the declaration on the first line is what the compiler sees and the
82 * second contributes nothing to it. The five vkms params are then read as
83 * plain statics, so their compiled behaviour is exactly their initialisers:
84 * cursor and writeback on, overlay and plane-pipeline off, default device
85 * created. Those defaults match mainline's, because mainline's defaults are
86 * the initialisers and not the parameter machinery.
87 *
88 * What is given up is the ability to change them: no boot argument, no
89 * /sys/module/<name>/parameters/. vkms is built into the image rather than
90 * loaded, so there is no module directory to hang a sysfs entry off, and
91 * nothing in this tree passes kernel command-line arguments to a driver.
92 * A driver that needs a runtime-configurable option has to reach for DCL's
93 * own config surface instead of this one.
94 *
95 * module_param() is the same macro with the variable named for itself, and
96 * both expand `value` in the no-op so a caller writing a complex expression
97 * there still gets a compile error rather than silent acceptance.
98 */
99#define module_param_named(name, value, type, perm)
100#define module_param(name, type, perm)
101#define MODULE_PARM_DESC(name, description)
102
103#define MODULE_LICENSE(x)
104#define MODULE_AUTHOR(x)
105#define MODULE_DESCRIPTION(x)
106#define MODULE_VERSION(x)
107#define MODULE_ALIAS(x)
108#define MODULE_DEVICE_TABLE(type, table)
109#define MODULE_INFO(info, val)
110#define THIS_MODULE ((void *)0)
111
112/* The input core takes a module reference while an input device is alive.
113 * DCL has no module refcount; the body in DCL/linux_input_shim.c is a no-op. */
114void __module_get(void* module);
115
116
117#define try_module_get(m) (1)
118#define module_put(m) do {} while (0)
119
120/*
121 * MODULE_IMPORT_NS(ns) -- mainline's symbol-namespace import, a modpost-time
122 * annotation that produces no code. It needs a name here only because
123 * drm_gem_framebuffer_helper.c:23 spells `MODULE_IMPORT_NS("DMA_BUF");` at
124 * file scope: undefined, the preprocessor leaves the identifier standing and
125 * the line decays to a declaration with no type, which clang reports as
126 * "type specifier missing, defaults to 'int'".
127 *
128 * Empty, like the MODULE_* block above, and for the same reason.
129 */
130#define MODULE_IMPORT_NS(ns)
131
132#endif
void __module_get(void *module)