-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocs
More file actions
103 lines (62 loc) · 2 KB
/
docs
File metadata and controls
103 lines (62 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
README
======
This directory contains examples of kernel modules that implement
certain interfaces we have found to be essential for kernel driver
driver (pseudo or otherwise).
Specifically the interfaces we wish to show are the:
- procfs
- helloworld
- tabularasa
- ioctrl
- helloworld
- tabularasa
- blankslate
- timers
- sysfs
- blankslate
- kernel signals
- kernel parameters
- helloworld
- Bootstrapping for a module is a little more lengthy than most
programming.
- To create a module at all there will need to be a minimum of the
following things:
- the module:
- source (.c)
- header (.h)
- Makefile
- the user side library as an api
- a user level test program
- And typically some datastreams post processing
Examples
********
**tabularasa**
- It is a little more complex than the simplest possible module as it
incorporates the minimal about of stuff requried to make a non
trivial module.
- It demonstrates:
- Setting module level variable via IOCTL
- protecting said variable via a mutex
- Reading the variable from the procfs
- How to use procfs (albeit simply). Prints "Hello World! I am
<tabularasa_module_name>" to ``/proc/tabularasa`` where
tabularasa_module_name is a module level variable::
$ cat /proc/tabularasa
Hello World! I am tabularasa
- To execute this example first you must build the module::
$ cd <kr>/examples/kmods/tabularasa/kmods
$ make module
- Install the module::
$ make install
- This will run a :samp:`sudo insmod tabularasa`
- Make the user library and program::
$ make prog
- This will make a build directory under the tabularasa directory.
- Contains the compiled *truser* program and *libtabularasa* library
- Execute the user program::
$ make run
Hello World! I am tabularasa
Hello World! I am skynet
Hello World! I am john-conner
Hello World! I am t-800
Hello World! I am terminator