mirror of
https://github.com/bashrc/LKMPG.git
synced 2018-06-11 03:06:54 +02:00
3.16
This commit is contained in:
@@ -310,7 +310,7 @@ Here's another exercise for the reader. See that comment above the return statem
|
||||
|
||||
** Hello World (part 2): Hello and Goodbye
|
||||
|
||||
As of Linux 2.4, you can rename the init and cleanup functions of your modules; they no longer have to be called init_module() and cleanup_module() respectively. This is done with the module_init() and module_exit() macros. These macros are defined in *linux/init.h*. The only caveat is that your init and cleanup functions must be defined before calling the macros, otherwise you'll get compilation errors. Here's an example of this technique:
|
||||
As of Linux 2.4, you can rename the init and cleanup functions of your modules; they no longer have to be called init_module() and cleanup_module() respectively. This is done with the *module_init()* and *module_exit()* macros. These macros are defined in *linux/init.h*. The only caveat is that your init and cleanup functions must be defined before calling the macros, otherwise you'll get compilation errors. Here's an example of this technique:
|
||||
|
||||
*** Example: hello-2.c
|
||||
#+BEGIN_SRC c
|
||||
@@ -401,7 +401,7 @@ Warning: loading xxxxxx.ko will taint the kernel: no license
|
||||
Module xxxxxx loaded, with warnings
|
||||
#+END_SRC
|
||||
|
||||
In kernel 2.4 and later, a mechanism was devised to identify code licensed under the GPL (and friends) so people can be warned that the code is non open-source. This is accomplished by the MODULE_LICENSE() macro which is demonstrated in the next piece of code. By setting the license to GPL, you can keep the warning from being printed. This license mechanism is defined and documented in linux/module.h:
|
||||
In kernel 2.4 and later, a mechanism was devised to identify code licensed under the GPL (and friends) so people can be warned that the code is non open-source. This is accomplished by the *MODULE_LICENSE()* macro which is demonstrated in the next piece of code. By setting the license to GPL, you can keep the warning from being printed. This license mechanism is defined and documented in *linux/module.h*:
|
||||
|
||||
#+BEGIN_SRC c
|
||||
/*
|
||||
@@ -434,14 +434,13 @@ In kernel 2.4 and later, a mechanism was devised to identify code licensed under
|
||||
*/
|
||||
#+END_SRC
|
||||
|
||||
Similarly, MODULE_DESCRIPTION() is used to describe what the module does, MODULE_AUTHOR() declares the module's author, and MODULE_SUPPORTED_DEVICE() declares what types of devices the module supports.
|
||||
Similarly, *MODULE_DESCRIPTION()* is used to describe what the module does, *MODULE_AUTHOR()* declares the module's author, and *MODULE_SUPPORTED_DEVICE()* declares what types of devices the module supports.
|
||||
|
||||
These macros are all defined in linux/module.h and aren't used by the kernel itself. They're simply for documentation and can be viewed by a tool like objdump. As an exercise to the reader, try and search fo these macros in linux/drivers to see how module authors use these macros to document their modules.
|
||||
These macros are all defined in *linux/module.h* and aren't used by the kernel itself. They're simply for documentation and can be viewed by a tool like objdump. As an exercise to the reader, try and search fo these macros in *linux/drivers* to see how module authors use these macros to document their modules.
|
||||
|
||||
I'd recommend to use something like grep -inr MODULE_AUTHOR * in /usr/src/linux-2.6.x/ . People unfamiliar with command line tools will probably like some web base solution, search for sites that offer kernel trees that got indexed with LXR. (or setup it up on your local machine).
|
||||
|
||||
Users of traditional Unix editors, like emacs or vi will also find tag files useful. They can be generated by make tags or make TAGS in /usr/src/linux-2.6.x/ . Once you've got such a tagfile in your kerneltree you can put the cursor on some function call and use some key combination to directly jump to the definition function.
|
||||
I'd recommend to use something like grep -inr MODULE_AUTHOR * in /usr/src/linux-3.16.x/ . People unfamiliar with command line tools will probably like some web base solution, search for sites that offer kernel trees that got indexed with LXR. (or setup it up on your local machine).
|
||||
|
||||
Users of traditional Unix editors, like emacs or vi will also find tag files useful. They can be generated by make tags or make TAGS in /usr/src/linux-3.16.x/ . Once you've got such a tagfile in your kerneltree you can put the cursor on some function call and use some key combination to directly jump to the definition function.
|
||||
|
||||
*** Example: hello-4.c
|
||||
#+BEGIN_SRC c
|
||||
|
||||
Reference in New Issue
Block a user