Hardware Reference
In-Depth Information
+
return
0
;
+}
+
+
static
void
__exit hello_end
(
void
)
+{
+
printk
(
KERN_INFO
"Goodbye Boris
\n
"
);
+}
+
+
module_init
(
hello_start
);
+
module_exit
(
hello_end
);
+
+
MODULE_AUTHOR
(
"Boris Houndleroy"
);
+
MODULE_DESCRIPTION
(
"Hello World Example"
);
+
MODULE_LICENSE
(
"GPL"
);
Here's how to use it:
1. Install the kernel sources (
Recipe 7.5
).
2. Change to the kernel directory (
cd bb-kernel/KERNEL
).
3. Add
Example 7-4
to a file named
hello.patch
in the
bb-kernel/KERNEL
directory.
4. Run the following commands:
host$
cd bb-kernel/KERNEL
host$
patch -p1 < hello.patch
patching file hello/Makefile
patching file hello/hello.c
The output of the
patch
command apprises you of what it's doing. Look in the
hello
dir-
ectory to see what was created:
host$
cd hello
host$
ls
hello.c Makefile