如何开发Linux内核?

Posted yangzhenping

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何开发Linux内核?相关的知识,希望对你有一定的参考价值。

??

如何开发Linux内核?


推荐这篇文章:

http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html


下面是在Ubuntu下的输出:

[email protected]  # make
make: Warning: File `Makefile‘ has modification time 11 s in the future
make -C /lib/modules/3.13.0-24-generic/build M=/root modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-24-generic‘
make[2]: Warning: File `/root/Makefile‘ has modification time 10 s in the future
  CC [M]  /root/hello-1.o
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
  Building modules, stage 2.
make[2]: Warning: File `/root/Makefile‘ has modification time 8.9 s in the future
  MODPOST 1 modules
  CC      /root/hello-1.mod.o
  LD [M]  /root/hello-1.ko
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-24-generic‘
make: warning:  Clock skew detected.  Your build may be incomplete.

~
[email protected]  # ls
A    B.c        hello-1.ko     hello-1.o  modules.order             MyFirstJavaProgram.java
A.c  dns        hello-1.mod.c  IP.txt     Module.symvers            SumOfN-thPowersIsAnN-thPower
B    hello-1.c  hello-1.mod.o  Makefile   MyFirstJavaProgram.class  SumOfN-thPowersIsAnN-thPower.c

~
[email protected]  # insmod ./hello-1.ko

~
[email protected]  # cat /var/log/kern.log
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.312610] hello_1: module license ‘unspecified‘ taints kernel.
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.312617] Disabling lock debugging due to kernel taint
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.312641] hello_1: module verification failed: signature and/or  required key missing - tainting kernel
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.313139] Hello world 1.

~
[email protected]  # cat /proc/modules
hello_1 12426 0 - Live 0xffffffffa01e9000 (POF)
nls_iso8859_1 12713 0 - Live 0xffffffffa01e4000
joydev 17381 0 - Live 0xffffffffa0183000
hid_generic 12548 0 - Live 0xffffffffa01db000
udf 89723 0 - Live 0xffffffffa01c4000
crc_itu_t 12707 1 udf, Live 0xffffffffa01bf000
psmouse 102222 0 - Live 0xffffffffa01a5000
serio_raw 13462 0 - Live 0xffffffffa017e000
hid_hyperv 13059 0 - Live 0xffffffffa012e000
hyperv_keyboard 12777 0 - Live 0xffffffffa00c6000
hid 106148 2 hid_generic,hid_hyperv, Live 0xffffffffa018a000
nfsd 280297 2 - Live 0xffffffffa0135000
auth_rpcgss 59338 1 nfsd, Live 0xffffffffa011e000
nfs_acl 12837 1 nfsd, Live 0xffffffffa00c1000
nfs 236636 0 - Live 0xffffffffa00e3000
hyperv_fb 17593 1 - Live 0xffffffffa00bb000
i2c_piix4 22155 0 - Live 0xffffffffa00b0000
lockd 93977 2 nfsd,nfs, Live 0xffffffffa00cb000
mac_hid 13205 0 - Live 0xffffffffa004f000
sunrpc 284404 6 nfsd,auth_rpcgss,nfs_acl,nfs,lockd, Live 0xffffffffa0069000
fscache 63988 1 nfs, Live 0xffffffffa0058000
lp 17759 0 - Live 0xffffffffa0028000
parport 42348 1 lp, Live 0xffffffffa0043000
hv_utils 19003 0 - Live 0xffffffffa003d000
hv_storvsc 17785 2 - Live 0xffffffffa0010000
hv_vmbus 50383 5 hid_hyperv,hyperv_keyboard,hyperv_fb,hv_utils,hv_storvsc, Live 0xffffffffa002f000
floppy 69370 0 - Live 0xffffffffa0016000
tulip 59672 0 - Live 0xffffffffa0000000

~
[email protected]  # rmmod hello-1

~
[email protected]  # cat /proc/modules
nls_iso8859_1 12713 0 - Live 0xffffffffa01e4000
joydev 17381 0 - Live 0xffffffffa0183000
hid_generic 12548 0 - Live 0xffffffffa01db000
udf 89723 0 - Live 0xffffffffa01c4000
crc_itu_t 12707 1 udf, Live 0xffffffffa01bf000
psmouse 102222 0 - Live 0xffffffffa01a5000
serio_raw 13462 0 - Live 0xffffffffa017e000
hid_hyperv 13059 0 - Live 0xffffffffa012e000
hyperv_keyboard 12777 0 - Live 0xffffffffa00c6000
hid 106148 2 hid_generic,hid_hyperv, Live 0xffffffffa018a000
nfsd 280297 2 - Live 0xffffffffa0135000
auth_rpcgss 59338 1 nfsd, Live 0xffffffffa011e000
nfs_acl 12837 1 nfsd, Live 0xffffffffa00c1000
nfs 236636 0 - Live 0xffffffffa00e3000
hyperv_fb 17593 1 - Live 0xffffffffa00bb000
i2c_piix4 22155 0 - Live 0xffffffffa00b0000
lockd 93977 2 nfsd,nfs, Live 0xffffffffa00cb000
mac_hid 13205 0 - Live 0xffffffffa004f000
sunrpc 284404 6 nfsd,auth_rpcgss,nfs_acl,nfs,lockd, Live 0xffffffffa0069000
fscache 63988 1 nfs, Live 0xffffffffa0058000
lp 17759 0 - Live 0xffffffffa0028000
parport 42348 1 lp, Live 0xffffffffa0043000
hv_utils 19003 0 - Live 0xffffffffa003d000
hv_storvsc 17785 2 - Live 0xffffffffa0010000
hv_vmbus 50383 5 hid_hyperv,hyperv_keyboard,hyperv_fb,hv_utils,hv_storvsc, Live 0xffffffffa002f000
floppy 69370 0 - Live 0xffffffffa0016000
tulip 59672 0 - Live 0xffffffffa0000000

~
[email protected]  # cat /var/log/kern.log
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.312610] hello_1: module license ‘unspecified‘ taints kernel.
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.312617] Disabling lock debugging due to kernel taint
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.312641] hello_1: module verification failed: signature and/or  required key missing - tainting kernel
Feb  2 00:48:18 cmt-ub14x64-02 kernel: [8216591.313139] Hello world 1.
Feb  2 00:53:10 cmt-ub14x64-02 kernel: [8216883.303516] Goodbye world 1.

以上是关于如何开发Linux内核?的主要内容,如果未能解决你的问题,请参考以下文章

Linux内核开发基础

如何在 linux 中禁用内核模块签名

为什么要学习Linux内核,如何学习?

Linux开发,内核代码,找不到内核宏定义,找不到内核函数

Linux开发,内核代码,找不到内核宏定义,找不到内核函数

linux内核,驱动,应用程三者的概念和之间的关系