Skip to content

Commit fd80f6b

Browse files
author
jason_yao
committed
update
1 parent ff9a003 commit fd80f6b

47 files changed

Lines changed: 7579 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
5.49 KB
Binary file not shown.
3.14 KB
Binary file not shown.
4.54 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cmd_/home/dennis/book_sourcecode/chap01/demodev.ko := ld -r -m elf_x86_64 -T /home/dennis/Linux/linux-3.1.6/scripts/module-common.lds --build-id -o /home/dennis/book_sourcecode/chap01/demodev.ko /home/dennis/book_sourcecode/chap01/demodev.o /home/dennis/book_sourcecode/chap01/demodev.mod.o

example/深入Linux設備驅動程序內核機制/chap01/.demodev.mod.o.cmd

Lines changed: 489 additions & 0 deletions
Large diffs are not rendered by default.

example/深入Linux設備驅動程序內核機制/chap01/.demodev.o.cmd

Lines changed: 487 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/home/dennis/book_sourcecode/chap01/demodev.ko
2+
/home/dennis/book_sourcecode/chap01/demodev.o
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Chap1: a simple demo kernel module
2+
obj-m := demodev.o
3+
KERNELDIR := /lib/modules/$(shell uname -r)/build
4+
PWD := $(shell pwd)
5+
6+
default:
7+
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
8+
clean:
9+
rm -f *.o *.ko *.mod.* *.order *.symvers
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set module parameters with below command:
2+
3+
#insmod demodev.ko dolphin=5 demodev_str="hello,world"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <linux/module.h>
2+
#include <linux/kernel.h>
3+
4+
//exported function
5+
static void my_exp_function(void)
6+
{
7+
printk(KERN_INFO "A function exported to the external world...\n");
8+
}
9+
10+
EXPORT_SYMBOL(my_exp_function);
11+
12+
//module parameters
13+
int dolphin;
14+
module_param(dolphin, int, 0);
15+
16+
static char demodev_str[64] = "kernel module:demodev";
17+
module_param_string(demodev_str, demodev_str, sizeof(demodev_str), 0);//(name, string, length, perm)
18+
19+
static int demodev_init(void)
20+
{
21+
printk(KERN_INFO "demodev_init(): dolphin=%d, demodev_str=%s\n", dolphin, demodev_str);
22+
return 0;
23+
}
24+
25+
static void demodev_exit(void)
26+
{
27+
printk(KERN_INFO "demodev_exit()\n");
28+
}
29+
30+
module_init(demodev_init);
31+
module_exit(demodev_exit);
32+
33+
MODULE_LICENSE("GPL");
34+
MODULE_AUTHOR("dennis chen @ AMDLinuxFGL");
35+
MODULE_DESCRIPTION("A simple kernel module as an illustration");

0 commit comments

Comments
 (0)