Skip to content

Commit 5a30b1b

Browse files
committed
module parameters working except for array
1 parent 60624aa commit 5a30b1b

File tree

11 files changed

+518
-222
lines changed

11 files changed

+518
-222
lines changed

book.md

+8
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,11 @@ loses text layer
225225
get number of pages of djvu:
226226

227227
djvm -l speak\ chinese\ 2.djvu | sed -nre '$ s/.+#([0-9]+).+/\1/p'
228+
229+
# pdfcrop
230+
231+
remove empty margins of pdf files
232+
233+
greatly increases filesize (10x)
234+
235+
pdfcrop a.pdf

image/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ bottom 50 percent:
238238

239239
### color
240240

241+
- `-colorspace Gray`: convert to grayscale
242+
243+
convert in.png -colorspace Gray out.png
244+
241245
- `-monochrome`: monochrome image. == -depth 1? but not in practice =)
242246

243247
- `-depth`: number of bits per pixel.

kernel-module/cheat.c

-178
This file was deleted.
File renamed without changes.

kernel-module/Makefile renamed to kernel/Makefile

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
override IN_DIR ?= ./
77
override IN_EXTS ?= .c
88
override LOG_PATH ?= /var/log/syslog
9-
override OUT_DIR := ./
10-
#override OUT_DIR := _out/
11-
override OUT_EXT := .ko
12-
override OBJ_EXT := .o
13-
override RUN ?= cheat
14-
15-
INS := $(filter-out %.mod.c, $(foreach IN_EXT, $(IN_EXTS), $(wildcard $(IN_DIR)*$(IN_EXT))))
16-
INS := $(foreach IN_EXT, $(IN_EXTS), $(wildcard $(IN_DIR)*$(IN_EXT)))
9+
override OUT_DIR ?= ./
10+
#override OUT_DIR ?= _out/
11+
override OUT_EXT ?= .ko
12+
override OBJ_EXT ?= .o
13+
override RUN ?= main
14+
15+
INS := $(filter-out %.mod.c, $(foreach IN_EXT, $(IN_EXTS), $(wildcard $(IN_DIR)*$(IN_EXT))))
16+
INS := $(foreach IN_EXT, $(IN_EXTS), $(wildcard $(IN_DIR)*$(IN_EXT)))
1717
INS_NODIR := $(notdir $(INS))
1818
OBJS_NODIR := $(addsuffix $(OBJ_EXT), $(basename $(INS_NODIR)))
1919
OBJS := $(addprefix $(OUT_DIR), $(OBJS_NODIR))
@@ -23,7 +23,7 @@ RUN_EXT := $(RUN)$(OUT_EXT)
2323

2424
#TODO why this does not work but the next line does? there is no `:` version of `+=`: it depends on how it is first defined. If if is first defined with `:`: then `+=` is `:`
2525
#obj-m += $(OBJS)
26-
obj-m += hello_world.o cheat.o
26+
obj-m += hello_world.o main.o
2727

2828
.PHONY: all clean ins rm run
2929

@@ -49,7 +49,8 @@ clean:
4949
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
5050

5151
ins: all
52-
sudo insmod $(RUN_EXT)
52+
sudo insmod $(RUN_EXT) param_i=1 param_s="bbb"
53+
#sudo insmod $(RUN_EXT) param_i=1 param_s="bbb" param_is="1,1,1"
5354

5455
# view system log file for printk messages
5556
log:
File renamed without changes.

kernel.md renamed to kernel/index.md

+70-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interpreter, the X server, etc. The extra user space services are specified by t
4444
of the linux kernel.
4545

4646
You cannot use user space libs such as libc to program the kernel,
47-
since the kernel itself itself if need to be working for user space to work. TODO confirm
47+
since the kernel itself itself if need to be working for user space to work.
4848

4949
# user programs
5050

@@ -60,6 +60,15 @@ probably via the `write` system call.
6060

6161
Another simple example is file io.
6262

63+
## floating point
64+
65+
you cannto use floating point operations on kernel code because that would incur too much overhead
66+
of saving floating point registers on some architectures, so don't do it.
67+
68+
## memory
69+
70+
memory is much more restrictive than in user applictions, so be extra cautious to use little memory
71+
6372
# rings
6473

6574
x86 implemented concept
@@ -75,11 +84,68 @@ linux uses 2:
7584

7685
this is used to separate who can do what
7786

78-
# install a new kernel
87+
# test a new kernel
88+
89+
## compile and install
90+
91+
this is a very slow test mechanism since you need to reboot everytime.
92+
93+
<www.cyberciti.biz/tips/compiling-linux-kernel-26.html>
94+
95+
get the source:
96+
97+
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
98+
99+
clean everything:
100+
101+
make mrproper
102+
103+
generate the `.config` file:
104+
105+
make menuconfig
106+
107+
this opens up a ncurses interface which allows you to choose amongst tons of options
108+
which determine which features your kernel will include or not.
109+
110+
then go on to `save` to save to the `.config` file and then exit
111+
112+
build:
113+
114+
make -j5
115+
116+
`-j` tells make to spawn several process, which is useful if you have a multicore processor.
117+
it is recommend to use
118+
119+
n = number of processors + 1
120+
121+
this may take more than one hour.
122+
123+
install:
124+
125+
sudo make modules_install -j5
126+
sudo make install -j5
127+
128+
this will place:
129+
130+
- the compiled kernel under `/boot/vmlinuz-<version>`
131+
- config file `.config` as `/boot/config-<version>`
132+
- `System.map` under `/boot/System.map-<version>`.
133+
134+
This contains symbolic debug information.
135+
136+
- `/lib/modules/<version>/` for the modules
137+
138+
configure grub: TODO
139+
140+
## kernel module
141+
142+
can be inserted and removed while the kernel runs.
79143

80-
TODO
144+
However, if you make an error at startup (dereference null pointer for example),
145+
the kernel module may become impossible to reinsert without a reboot.
146+
<http://unix.stackexchange.com/questions/78858/cannot-remove-or-reinsert-kernel-module-after-error-while-inserting-it-without-r/>
81147

82-
also considering installing a module instead of hacking the kernel if a module would do
148+
## kernel virtual machine
83149

84150
# get kernel version
85151

0 commit comments

Comments
 (0)