You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This patch uses the relative path to Linux kernel headers in source tree
rather than what they are usually inclused in LKM. It would be great to
introduce \href with appropriate hyperlinks to Linux kernel tree.
In early kernel versions you had to use the \cpp|init_module| and \cpp|cleanup_module| functions, as in the first hello world example, but these days you can name those anything you want by using the \cpp|module_init| and \cpp|module_exit| macros.
310
-
These macros are defined in \verb|linux/init.h|.
310
+
These macros are defined in \verb|include/linux/init.h|.
311
311
The only requirement is that your init and cleanup functions must be defined before calling the those macros, otherwise you'll get compilation errors.
312
312
Here is an example of this technique:
313
313
@@ -326,11 +326,11 @@ \subsection{Hello and Goodbye}
326
326
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
327
327
\end{code}
328
328
329
-
Now have a look at \verb|linux/drivers/char/Makefile| for a real world example.
329
+
Now have a look at \verb|drivers/char/Makefile| for a real world example.
330
330
As you can see, some things get hardwired into the kernel (\verb|obj-y|) but where are all those \verb|obj-m| gone?
331
331
Those familiar with shell scripts will easily be able to spot them.
332
332
For those not, the \verb|obj-$(CONFIG_FOO)| entries you see everywhere expand into \verb|obj-y| or \verb|obj-m|, depending on whether the \verb|CONFIG_FOO| variable has been set to y or m.
333
-
While we are at it, those were exactly the kind of variables that you have set in the \verb|linux/.config| file, the last time when you said make menuconfig or something like that.
333
+
While we are at it, those were exactly the kind of variables that you have set in the \verb|.config| file in the top-level directory of Linux kernel source tree, the last time when you said make menuconfig or something like that.
334
334
335
335
\subsection{The \_\_init and \_\_exit Macros}
336
336
\label{init_n_exit}
@@ -344,7 +344,7 @@ \subsection{The \_\_init and \_\_exit Macros}
344
344
The \cpp|__exit| macro causes the omission of the function when the module is built into the kernel, and like \cpp|__init|, has no effect for loadable modules.
345
345
Again, if you consider when the cleanup function runs, this makes complete sense; built-in drivers do not need a cleanup function, while loadable modules do.
346
346
347
-
These macros are defined in \verb|linux/init.h| and serve to free up kernel memory.
347
+
These macros are defined in \verb|include/linux/init.h| and serve to free up kernel memory.
348
348
When you boot your kernel and see something like Freeing unused kernel memory: 236k freed, this is precisely what the kernel is freeing.
349
349
350
350
\samplec{examples/hello-3.c}
@@ -361,7 +361,7 @@ \subsection{Licensing and Module Documentation}
361
361
362
362
You can use a few macros to indicate the license for your module.
363
363
Some examples are "GPL", "GPL v2", "GPL and additional rights", "Dual BSD/GPL", "Dual MIT/GPL", "Dual MPL/GPL" and "Proprietary".
364
-
They are defined within \verb|linux/module.h|.
364
+
They are defined within \verb|include/linux/module.h|.
365
365
366
366
To reference what license you're using a macro is available called \cpp|MODULE_LICENSE|.
367
367
This and a few other macros describing the module are illustrated in the below example.
@@ -521,7 +521,7 @@ \subsection{Building modules for a precompiled kernel}
521
521
522
522
Let's focus again on the previous error message: a closer look at the version magic strings suggests that, even with two configuration files which are exactly the same, a slight difference in the version magic could be possible, and it is sufficient to prevent insertion of the module into the kernel.
523
523
That slight difference, namely the custom string which appears in the module's version magic and not in the kernel's one, is due to a modification with respect to the original, in the makefile that some distribution include.
524
-
Then, examine your \verb|linux/Makefile|, and make sure that the specified version information matches exactly the one used for your current kernel.
524
+
Then, examine your \verb|Makefile|, and make sure that the specified version information matches exactly the one used for your current kernel.
0 commit comments