4 #include <lwk/kernel.h>
8 * Drivers may set DRIVER_NAME before including this header.
9 * Otherwise, the KBUILD name is used.
12 #define DRIVER_NAME KBUILD_MODNAME
16 * Driver parameter names have the form:
18 * driver_name.parameter_name
21 * To set integer parameter foo in driver bar, add this
22 * to the kernel boot command line:
26 #define __DRIVER_PARAM_PREFIX DRIVER_NAME "."
29 * For driver parameters. Parameters can be configured via the
30 * kernel boot command line or some other platform-dependent
33 #include <lwk/params.h>
35 #define driver_param(name, type) \
36 __param_named(__DRIVER_PARAM_PREFIX, name, name, type)
38 #define driver_param_named(name, value, type) \
39 __param_named(__DRIVER_PARAM_PREFIX, name, value, type)
41 #define driver_param_string(name, string, len) \
42 __param_string(__DRIVER_PARAM_PREFIX, name, string, len)
44 #define driver_param_array(name, type, nump) \
45 __param_array_named(__DRIVER_PARAM_PREFIX, name, name, type, nump)
47 #define driver_param_array_named(name, array, type, nump) \
48 __param_array_named(__DRIVER_PARAM_PREFIX, name, array, type, nump)
51 * Every driver defines one of these structures via the
52 * driver_init() macro. The structure gets placed in the
53 * __driver_table ELF section and the kernel walks this table
54 * to find/initialize all drivers in the system.
57 const char * name; // name of the driver
58 void (*init)(void); // driver initialization function
59 int init_called; // set when .init() has been called,
60 // used to prevent double inits.
64 * This adds a function to the __driver_table ELF section.
66 #define driver_init(init_func) \
67 static char __driver_name[] = DRIVER_NAME; \
68 static struct driver_info const __driver_info \
70 __attribute__ ((unused,__section__ ("__driver_table"), \
71 aligned(sizeof(void *)))) \
72 = { __driver_name, init_func };
75 * The __driver_table ELF section is surrounded by these symbols,
76 * which are defined in the platform's linker script.
78 extern struct driver_info __start___driver_table[];
79 extern struct driver_info __stop___driver_table[];
82 * This is a placeholder. Currently drivers are never unloaded once loaded.
84 #define driver_exit(exit_func)
86 extern int driver_init_by_name(const char *name);