Writing a Linux device driver
struct module_symbol *syms;
struct module_ref *deps;
struct module_ref *refs;
int (*init)(void);
void (*cleanup)(void);
const struct exception_table_entry *ex_table_start;
const struct exception_table_entry *ex_table_end;
#ifdef __alpha__
unsigned long gp;
#endif
};
All of the pointer fields, with the exception of next and refs, are
expected to point within the module body and be initialized as appropriate
for kernel space, i.e. relocated with the rest of the module.
Return Values
On success, zero is returned. On error, -1 is returned
and errno is set appropriately.
Errors
EPERM The user is not the superuser.
ENOENT No module by that name exists.
EINVAL Some image slot filled in incorrectly, image->name
does not correspond to the original module name,
some image->deps entry does not correspond to a
loaded module, or some other similar inconsistency.
EBUSY The module's initialization routine failed.
EFAULT name or image is outside the program's accessible
address space.
cleanup_module attempts to remove an unused loadable module entry. If
name is NULL, all unused modules marked auto clean will be removed.
Return Values
On success, zero is returned. On error, -1 is returned and errno is
set appropriately.
Errors
EPERM The user is not the superuser.
ENOENT No module by that name exists.
EINVAL name was the empty string.
EBUSY The module is in use.
EFAULT name is outside the program's accessible address
space.
This simple module is called skull, short for Simple Kernel Utility For
Loading Localities.
General flags used for compiling any driver are
-D__KERNEL__ _DMODULE -O -Wall -I$(INCLUDEDIR)
Note: The INCLUDEDIR should contain the header files of the kernel source.
Module code has to be recompiled for each version of the kernel that it
will be linked to. Each module defines a symbol called kernel_version
which is defined in <linux/module.h>. In case of a version mismatch, use
- « first
- ‹ previous
- of 3
- next ›
- last »