linux是基于模块的,所有的驱动都是模块化的:
管理模块的命令:
1、
列出系统中所有已经加载的模块的大小与名称等:lsmod或者cat /proc/modules
ty@tonylinux:~$ lsmod
Module Size Used by
rfcomm 40216 0
l2cap 26244 5 rfcomm
bluetooth 50020 4 rfcomm,l2cap
ppdev 9220 0
radeon 116000 1
drm 73236 2 radeon
speedstep_centrino 8400 1
cpufreq_userspace 4696 1
cpufreq_stats 5636 0
freq_table 4740 2 speedstep_centrino,cpufreq_stats
cpufreq_powersave 1920 0
cpufreq_ondemand 6428 0
cpufreq_conservative 7332 0
video 16260 0
tc1100_wmi 6916 0
sony_acpi 5644 0
pcc_acpi 12416 0
hotkey 11556 0
dev_acpi 11140 0
container 4608 0
button 6672 0
acpi_sbs 19980 0
battery 9988 1 acpi_sbs
ac 5252 1 acpi_sbs
i2c_acpi_ec 5120 1 acpi_sbs
i2c_core 21904 1 i2c_acpi_ec
nls_utf8 2176 2
ntfs 103536 2
nls_iso8859_1 4224 1
nls_cp437 5888 1
vfat 13440 1
fat 53020 1 vfat
ipv6 265728 6
dm_mod 58936 1
md_mod 72532 0
lp 11844 0
af_packet 22920 2
wlan_wep 6912 1
tg3 101764 0
pcmcia 40508 0
joydev 10048 0
rtc 13492 0
tsdev 8000 0
pcspkr 2180 0
yenta_socket 28428 3
rsrc_nonstatic 13440 1 yenta_socket
pcmcia_core 42640 3 pcmcia,yenta_socket,rsrc_nonstatic
floppy 62148 0
parport_pc 35780 1
parport 36296 3 ppdev,lp,parport_pc
usbhid 39904 0
psmouse 36100 0
serio_raw 7300 0
ath_pci 80540 0
ath_rate_sample 17160 1 ath_pci
wlan 144924 4 wlan_wep,ath_pci,ath_rate_sample
ath_hal 148816 3 ath_pci,ath_rate_sample
snd_intel8x0 33692 4
snd_ac97_codec 93216 1 snd_intel8x0
snd_ac97_bus 2304 1 snd_ac97_codec
snd_pcm_oss 53664 0
snd_mixer_oss 18688 1 snd_pcm_oss
snd_pcm 89864 4 snd_intel8x0,snd_ac97_codec,snd_pcm_oss
snd_timer 25220 3 snd_pcm
snd 55268 11 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer
soundcore 10208 1 snd
snd_page_alloc 10632 2 snd_intel8x0,snd_pcm
shpchp 45632 0
pci_hotplug 29236 1 shpchp
intel_agp 22940 1
agpgart 34888 2 drm,intel_agp
evdev 9856 2
ext3 135816 2
jbd 58772 1 ext3
ide_generic 1536 0
ehci_hcd 34184 0
uhci_hcd 33808 0
usbcore 130820 4 usbhid,ehci_hcd,uhci_hcd
ide_cd 33028 2
cdrom 38560 1 ide_cd
ide_disk 17664 7
piix 11012 1
generic 5124 0
thermal 13576 0
processor 23360 2 speedstep_centrino,thermal
fan 4868 0
capability 5000 0
commoncap 7296 1 capability
vga16fb 13704 1
vgastate 10368 1 vga16fb
fbcon 42784 72
tileblit 2816 1 fbcon
font 8320 1 fbcon
bitblit 6272 1 fbcon
softcursor 2304 1 bitblit
ty@tonylinux:~$ cat /proc/modules
rfcomm 40216 0 - Live 0xf8dee000
l2cap 26244 5 rfcomm, Live 0xf8db2000
bluetooth 50020 4 rfcomm,l2cap, Live 0xf8dc2000
ppdev 9220 0 - Live 0xf8d88000
radeon 116000 1 - Live 0xf8dd0000
drm 73236 2 radeon, Live 0xf8d9f000
speedstep_centrino 8400 1 - Live 0xf8ty@tonylinux:~$ cat /proc/modules
rfcomm 40216 0 - Live 0xf8dee000
l2cap 26244 5 rfcomm, Live 0xf8db2000
bluetooth 50020 4 rfcomm,l2cap, Live 0xf8dc2000
ppdev 9220 0 - Live 0xf8d88000
radeon 116000 1 - Live 0xf8dd0000
drm 73236 2 radeon, Live 0xf8d9f000
speedstep_centrino 8400 1 - Live 0xf8d7e000
cpufreq_userspace 4696 1 - Live 0xf8d7b000
cpufreq_stats 5636 0 - Live 0xf8d78000
freq_table 4740 2 speedstep_centrino,cpufreq_stats, Live 0xf8d75000
cpufreq_powersave 1920 0 - Live 0xf8c81000
cpufreq_ondemand 6428 0 - Live 0xf8d72000
cpufreq_conservative 7332 0 - Live 0xf8d6f000
video 16260 0 - Live 0xf8cc6000
tc1100_wmi 6916 0 - Live 0xf8d68000
sony_acpi 5644 0 - Live 0xf8d59000
pcc_acpi 12416 0 - Live 0xf8d63000
hotkey 11556 0 - Live 0xf8d55000
dev_acpi 11140 0 - Live 0xf8cee000
container 4608 0 - Live 0xf8ccf000
button 6672 0 - Live 0xf8cb4000
acpi_sbs 19980 0 - Live 0xf8d5d000
battery 9988 1 acpi_sbs, Live 0xf8ccb000
ac 5252 1 acpi_sbs, Live 0xf8cc3000
i2c_acpi_ec 5120 1 acpi_sbs, Live 0xf8cb7000
i2c_core 21904 1 i2c_acpi_ec, Live 0xf8cbc000
nls_utf8 2176 2 - Live 0xf8ad2000
ntfs 103536 2 - Live 0xf8cd3000
nls_iso8859_1 4224 1 - Live 0xf8c6d000
nls_cp437 5888 1 - Live 0xf8b16000
vfat 13440 1 - Live 0xf8b11000
fat 53020 1 vfat, Live 0xf8ca6000
ipv6 265728 6 - Live 0xf8cf2000
dm_mod 58936 1 - Live 0xf8c96000
md_mod 72532 0 - Live 0xf8c83000
lp 11844 0 - Live 0xf8949000
af_packet 22920 2 - Live 0xf8ad8000
wlan_wep 6912 1 - Live 0xf8ac1000
tg3 101764 0 - Live 0xf8b19000
pcmcia 40508 0 - Live 0xf8af1000
joydev 10048 0 - Live 0xf8acc000
rtc 13492 0 - Live 0xf8ac7000
tsdev 8000 0 - Live 0xf8915000
pcspkr 2180 0 - Live 0xf89fc000
yenta_socket 28428 3 - Live 0xf8aac000
rsrc_nonstatic 13440 1 yenta_socket, Live 0xf8aa7000
pcmcia_core 42640 3 pcmcia,yenta_socket,rsrc_nonstatic, Live 0xf8ab5000
floppy 62148 0 - Live 0xf8a1f000
parport_pc 35780 1 - Live 0xf8a9d000
parport 36296 3 ppdev,lp,parport_pc, Live 0xf8a93000
usbhid 39904 0 - Live 0xf8a09000
psmouse 36100 0 - Live 0xf8a15000
serio_raw 7300 0 - Live 0xf894d000
ath_pci 80540 0 - Live 0xf8a7e000
ath_rate_sample 17160 1 ath_pci, Live 0xf89f3000
wlan 144924 4 wlan_wep,ath_pci,ath_rate_sample, Live 0xf8a59000
ath_hal 148816 3 ath_pci,ath_rate_sample, Live 0xf8a33000
snd_intel8x0 33692 4 - Live 0xf89ff000
snd_ac97_codec 93216 1 snd_intel8x0, Live 0xf89c1000
snd_ac97_bus 2304 1 snd_ac97_codec, Live 0xf88ca000
snd_pcm_oss 53664 0 - Live 0xf8970000
snd_mixer_oss 18688 1 snd_pcm_oss, Live 0xf896a000
snd_pcm 89864 4 snd_intel8x0,snd_ac97_codec,snd_pcm_oss, Live 0xf89dc000
snd_timer 25220 3 snd_pcm, Live 0xf8952000
snd 55268 11 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer, Live 0xf895b000
soundcore 10208 1 snd, Live 0xf8911000
snd_page_alloc 10632 2 snd_intel8x0,snd_pcm, Live 0xf890d000
shpchp 45632 0 - Live 0xf8918000
pci_hotplug 29236 1 shpchp, Live 0xf88ba000
intel_agp 22940 1 - Live 0xf88c3000
agpgart 34888 2 drm,intel_agp, Live 0xf88fe000
evdev 9856 2 - Live 0xf888d000
ext3 135816 2 - Live 0xf8926000
jbd 58772 1 ext3, Live 0xf88ee000
ide_generic 1536 0 - Live 0xf8886000
ehci_hcd 34184 0 - Live 0xf88b0000
uhci_hcd 33808 0 - Live 0xf88a6000
usbcore 130820 4 usbhid,ehci_hcd,uhci_hcd, Live 0xf88cd000
ide_cd 33028 0 - Live 0xf889c000
cdrom 38560 1 ide_cd, Live 0xf8891000
ide_disk 17664 7 - Live 0xf886e000
piix 11012 1 - Live 0xf8880000
generic 5124 0 - Live 0xf886b000
thermal 13576 0 - Live 0xf887b000
processor 23360 2 speedstep_centrino,thermal, Live 0xf8874000
fan 4868 0 - Live 0xf8868000
capability 5000 0 - Live 0xf8865000
commoncap 7296 1 capability, Live 0xf880a000
vga16fb 13704 1 - Live 0xf8846000
vgastate 10368 1 vga16fb, Live 0xf882e000
fbcon 42784 72 - Live 0xf883a000
tileblit 2816 1 fbcon, Live 0xf8806000
font 8320 1 fbcon, Live 0xf882a000
bitblit 6272 1 fbcon, Live 0xf880d000
softcursor 2304 1 bitblit, Live 0xf8808000
d7e000
cpufreq_userspace 4696 1 - Live 0xf8d7b000
cpufreq_stats 5636 0 - Live 0xf8d78000
freq_table 4740 2 speedstep_centrino,cpufreq_stats, Live 0xf8d75000
cpufreq_powersave 1920 0 - Live 0xf8c81000
cpufreq_ondemand 6428 0 - Live 0xf8d72000
cpufreq_conservative 7332 0 - Live 0xf8d6f000
video 16260 0 - Live 0xf8cc6000
tc1100_wmi 6916 0 - Live 0xf8d68000
sony_acpi 5644 0 - Live 0xf8d59000
pcc_acpi 12416 0 - Live 0xf8d63000
hotkey 11556 0 - Live 0xf8d55000
dev_acpi 11140 0 - Live 0xf8cee000
container 4608 0 - Live 0xf8ccf000
button 6672 0 - Live 0xf8cb4000
acpi_sbs 19980 0 - Live 0xf8d5d000
battery 9988 1 acpi_sbs, Live 0xf8ccb000
ac 5252 1 acpi_sbs, Live 0xf8cc3000
i2c_acpi_ec 5120 1 acpi_sbs, Live 0xf8cb7000
i2c_core 21904 1 i2c_acpi_ec, Live 0xf8cbc000
nls_utf8 2176 2 - Live 0xf8ad2000
ntfs 103536 2 - Live 0xf8cd3000
nls_iso8859_1 4224 1 - Live 0xf8c6d000
nls_cp437 5888 1 - Live 0xf8b16000
vfat 13440 1 - Live 0xf8b11000
fat 53020 1 vfat, Live 0xf8ca6000
ipv6 265728 6 - Live 0xf8cf2000
dm_mod 58936 1 - Live 0xf8c96000
md_mod 72532 0 - Live 0xf8c83000
lp 11844 0 - Live 0xf8949000
af_packet 22920 2 - Live 0xf8ad8000
wlan_wep 6912 1 - Live 0xf8ac1000
tg3 101764 0 - Live 0xf8b19000
pcmcia 40508 0 - Live 0xf8af1000
joydev 10048 0 - Live 0xf8acc000
rtc 13492 0 - Live 0xf8ac7000
tsdev 8000 0 - Live 0xf8915000
pcspkr 2180 0 - Live 0xf89fc000
yenta_socket 28428 3 - Live 0xf8aac000
rsrc_nonstatic 13440 1 yenta_socket, Live 0xf8aa7000
pcmcia_core 42640 3 pcmcia,yenta_socket,rsrc_nonstatic, Live 0xf8ab5000
floppy 62148 0 - Live 0xf8a1f000
parport_pc 35780 1 - Live 0xf8a9d000
parport 36296 3 ppdev,lp,parport_pc, Live 0xf8a93000
usbhid 39904 0 - Live 0xf8a09000
psmouse 36100 0 - Live 0xf8a15000
serio_raw 7300 0 - Live 0xf894d000
ath_pci 80540 0 - Live 0xf8a7e000
ath_rate_sample 17160 1 ath_pci, Live 0xf89f3000
wlan 144924 4 wlan_wep,ath_pci,ath_rate_sample, Live 0xf8a59000
ath_hal 148816 3 ath_pci,ath_rate_sample, Live 0xf8a33000
snd_intel8x0 33692 4 - Live 0xf89ff000
snd_ac97_codec 93216 1 snd_intel8x0, Live 0xf89c1000
snd_ac97_bus 2304 1 snd_ac97_codec, Live 0xf88ca000
snd_pcm_oss 53664 0 - Live 0xf8970000
snd_mixer_oss 18688 1 snd_pcm_oss, Live 0xf896a000
snd_pcm 89864 4 snd_intel8x0,snd_ac97_codec,snd_pcm_oss, Live 0xf89dc000
snd_timer 25220 3 snd_pcm, Live 0xf8952000
snd 55268 11 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer, Live 0xf895b000
soundcore 10208 1 snd, Live 0xf8911000
snd_page_alloc 10632 2 snd_intel8x0,snd_pcm, Live 0xf890d000
shpchp 45632 0 - Live 0xf8918000
pci_hotplug 29236 1 shpchp, Live 0xf88ba000
intel_agp 22940 1 - Live 0xf88c3000
agpgart 34888 2 drm,intel_agp, Live 0xf88fe000
evdev 9856 2 - Live 0xf888d000
ext3 135816 2 - Live 0xf8926000
jbd 58772 1 ext3, Live 0xf88ee000
ide_generic 1536 0 - Live 0xf8886000
ehci_hcd 34184 0 - Live 0xf88b0000
uhci_hcd 33808 0 - Live 0xf88a6000
usbcore 130820 4 usbhid,ehci_hcd,uhci_hcd, Live 0xf88cd000
ide_cd 33028 0 - Live 0xf889c000
cdrom 38560 1 ide_cd, Live 0xf8891000
ide_disk 17664 7 - Live 0xf886e000
piix 11012 1 - Live 0xf8880000
generic 5124 0 - Live 0xf886b000
thermal 13576 0 - Live 0xf887b000
processor 23360 2 speedstep_centrino,thermal, Live 0xf8874000
fan 4868 0 - Live 0xf8868000
capability 5000 0 - Live 0xf8865000
commoncap 7296 1 capability, Live 0xf880a000
vga16fb 13704 1 - Live 0xf8846000
vgastate 10368 1 vga16fb, Live 0xf882e000
fbcon 42784 72 - Live 0xf883a000
tileblit 2816 1 fbcon, Live 0xf8806000
font 8320 1 fbcon, Live 0xf882a000
bitblit 6272 1 fbcon, Live 0xf880d000
softcursor 2304 1 bitblit, Live 0xf8808000
我们可以看到这两者命令执行的结果一致。
2、
modinfo 查看模块信息:
modinfo 可以查看模块的信息,通过查看模块信息来判定这个模块的用途;
ty@tonylinux:~$ modinfo bluetooth
filename: /lib/modules/2.6.15-27-386/kernel/net/bluetooth/bluetooth.ko
author: Maxim Krasnyansky , Marcel Holtmann
description: Bluetooth Core ver 2.8
version: 2.8
license: GPL
alias: net-pf-31
vermagic: 2.6.15-27-386 preempt 486 gcc-4.0
depends:
srcversion: 7EE5558C84FD3DB2B68971C
3、
modprobe 挂载新模块以及新模块相依赖的模块
modprobe 我们常用的功能就是挂载模块,在挂载某个内核模块的同时,这个模块所依赖的模块也被同时挂载;这是于insmod挂载模块有区别的地方。当然modprobe 也有列出内核所有模块,还有移除模块的功能;下在我们举个例子说一说咱们常用的功能和参数;
modprobe -c
odprobe -c 可以查看modules 的配置文件,比如模块的别名是什么等;
modprobe -l 是列出内核中所有的模块,包括已挂载和未挂载的;通过modprobe -l ,我们能查看到我们所需要的模块,然后根据我们的需要来挂载;
[root@localhost beinan]# modprobe 模块名 注:挂载一个模块;
root@localhost beinan]# modprobe -r 模块名 注:移除已加载的模块,和rmmod 功能相同;
4、
rmmod 移除已挂载模块
rmmod 模块名
5、depmod 创建模块依赖关系的列表
这
个模块管理工具是创建模块依赖关系的列表,有几个参数我们注意一下就行了,目前的的Linux
发行版所用的内核是2.6x版本,是自动解决依赖关系,所以这个命令知道就行了;模块之前也有依赖关系,比如我们想驱动USB
移动硬盘,目前有两种驱动,一种是udev ,在内核中有,但目前不太稳定;另一种办法是用usb-storage驱动,而usb-storage
依赖的模块是scsi 模块,所以我们要用usb-storage 的模块,也得把scsi 安装
该命令为modules.dep 文件或映射文件创建依赖关系,modules.dep文件位于 /lib/modules/2.6.15-27-i386;这是我的电脑的目录文件。
6、insmod 挂载模块
insmod
这个工具,和modprobe 有点类似,但功能上没有modprobe 强,modprobe
在挂载模块是不用指定模块文件的路径,也不用带文件的后缀.o 或.ko ;而insmod
需要的是模块的所在目录的绝对路径,并且一定要带有模块文件名后缀的(modulefile.o 或modulesfile.ko );
[root@localhost beinan]# insmod /lib/modules/2.6.11-1.1369_FC4/kernel/drivers/net/tg3.ko
模块的配置文件 modules.conf 或 modprobe.conf
内
核模块的开机自动挂载模块一般是位于一个配置文件,一般的Linux发行版本都有 /etc/modules.conf 或
/etc/modprobe.conf 。比如Fedora Core 4.0 内核模块开机自动加载文件是 /etc/modprobe.conf
;在这个文件中,一般是写入模块的加载命令或模块的别名的定义等;比如我们在modules.conf 中可能会发行类似的一行 ;
通
过源码编译驱动一般是./configure ;make;make install ,有时程序不提供./configure
,我们可以make或make install ,或者执行make;make install ;如果不能make install
,则需要我们自己复制.o或者.ko文件到 /lib/modules/内核版本/kernel/目录 或
/lib/modules/内核版本/kernel/drivers 目录中相应的驱动目录;
这个还是自己尝试吧,说也说不清楚,遇到问题后就知道怎么弄了;具体的还是驱动的REAME和INSTALL为准;
阅读(2789) | 评论(0) | 转发(0) |