当前位置:首页 » 操作系统 » linux驱动自动加载驱动

linux驱动自动加载驱动

发布时间: 2023-05-14 01:49:57

1. linux驱动程序有几种加载方式以及它们之间的区别

linux关于总线、设备、驱动的注册顺序
设备挂接到总线上时,与总线上的所有驱动进行匹配(用bus_type.match进行匹配),
如果匹配成功,则调用bus_type.probe或者driver.probe初始化该设备,挂接到总线上
如果匹配失败,则只是将该设备挂接到总线上。
驱动挂接到总线上时,与总线上的所有设备进行匹配(用bus_type.match进行匹配),
如果匹配成功,则调用bus_type.probe或者driver.probe初始化该设备;挂接到总线上
如果匹配失败,则只是将该驱动挂接到总线上。
需要重点关注的是总线的匹配函数match(),驱动的初始化函数probe()
1.
platform_bus_type--总线先被kenrel注册。
2.
系统初始化过程中调用platform_add_devices或者platform_device_register,将平台设备(platform
devices)注册到平台总线中(platform_bus_type)
3.
平台驱动(platform
driver)与平台设备(platform
device)的关联是在platform_driver_register或者driver_register中实现,一般这个函数在驱动的初始化过程调用。
通过这三步,就将平台总线,设备,驱动关联起来。
1.
platform
bus先被kenrel注册。
------------------------------------------------------
do_basic_setup()
-->-driver_init()
-->-platform_bus_init()-->bus_register()
2.
系统初始化过程中调用platform_add_devices或者platform_device_register,将平台设备(platform
devices)注册到平台总线中(platform_bus_type)
------------------------------------------------------
系统启动阶段,总线的驱动链表还是空的,所以启动阶段的platform_add_devices()只负责将设备添加到总线的设备链表上。

2. linux系统中哪个命令可以用来加载驱动程序

在2.4内核中,加载驱动命令为:insmod ,删除模块为:rmmod;
在2.6以上内核中,除了insmod与rmmod外,加载命令还有modprobe;
insmod与modprobe不同之处:
insmod 绝对路径/××.o,而modprobe ××即可,不用加.ko或.o后缀,也不用加路径;最重要的一点是:modprobe同时会加载当前模块所依赖的其它模块;
lsmod查看当前加载到内核中的所有驱动模块,同时提供其它一些信息,比如其它模块是否在使用另一个模块。

3. linux 安装了驱动后,怎么运行驱动

linux的驱动一般有两种格式,分别为:tar和rpm格式。
rpm安装步骤:

1.将驱动程序文件bcm5700-.src.rpm复制到一个临时目录中,并在此目录中运行以下命令:
rpm –ivh bcm5700-.src.rpm
2.运行以下命令切换到驱动目录中:
cd /usr/src/redhat/SPECS/
3.此目录中会生成一个名字为bcm5700.spec的文件,运行以下命令对驱动程序进行编译
rpmbuild –bb bcm5700.spec (对4.x.x版本的RPM适用)或 rpm -bb bcm5700.spec
4.运行以下命令切换到RPM目录中:
cd /usr/src/redhat/RPMS/i386/
5.运行以下命令安装驱动程序:
rpm –ivh bcm5700-.i386.rpm (对于Red Hat 7.2, 7.3, 2.1AS和其他包含老版本驱动的系统需要使用--force的参数,强制用新的驱动替换系统自带的老版本驱动)
6.运行以下命令加载驱动模块:
insmod bcm5700
7.运行kudzu命令,系统会自动搜索到硬件,进行配置即可。
或者重新启动系统,启动过程中系统会自动找到硬件,进行相应配置即可。
tar格式安装步骤:
1. 将驱动程序压缩文件bcm5700-.tar.gz复制到一个临时目录中,并使用以下命令解压缩:
tar xvzf bcm5700-.tar.gz
2.构建驱动程序为运行内核可加载模块
cd bcm5700-/src
make
3.加载测试
insmod bcm5700
4.加载驱动程序
make install
5.重新启动系统,启动过程中找到硬件,进行相应配置。
或者直接运行kudzu命令,系统会自动搜索到硬件,进行配置即可。

4. 在LINUX中如何加载驱动网卡

显卡安装:
一、下载驱动程序
首先要找到显卡for
Linux的驱动程序。现在绝大多数的3D显卡都已有了for
Linux的驱动程序,可到各显卡厂商的主页或Linux的相关站点上去寻找。在安装显卡时,服务器根据显卡的情况来加载不同的显示模块,如果显示模块加载不正确,显卡就不能正常显示。
二、装载磁盘驱动器
Linux需要装载磁盘驱动器才能读取文件。启动Linux后,在字符界面下输入“mount
-t
vfat
/dev/hda1
/mnt/winc”命令,将C盘装载到Linux下。需要注意的是,如果下载的是压缩文件,选择的是在Linux下解压,就得先进行装载磁盘驱动器这一步,再进行文件的解压缩。
三、拷贝文件
将XF86_SVGA文件拷贝到/usr/X11R6/bin目录下。注意,这是针对Red
Hat版本来说,其它版本的路径不一定相同。“cp
/mnt/winc/win98/TEMP/XF86_SVGA
/usr/X11R6/bin”(根据自己的情况灵活掌握,关键是路径一定要正确,还要分清字母的大小写)。如果系统提示有同名文件,问是否覆盖,一定要选择“y”。这些旧文件可能是以前安装显卡时加载的,没有实际用处。在输入文件名的时候,输完XF86后按一下Tab键,再接着输SVGA,下划线_就可以出来了,按键盘上的下划线键是没用的,切记。
四、配置显卡
文件拷贝完成后,输入Xconfigurator,启动显卡配置程序。我在显卡列表中仍然没有找到Trident
Blade
3D,于是选最后一个选项“Unlist”,然后选择加载的显示模块为SVGA,再选择显示器型号、显存大小、刷新频率
总结:在Linux下安装显卡驱动程序,首先要下载显卡支持Linux的驱动程序,再将其拷贝到/usr/X11R6/bin目录下,然后启动显卡配置程序进行配置即可。
网卡、声卡等驱动安装可以依此类推

5. 在LINUX中如何加载驱动网卡

直接找好对应的驱动 一般都会有readme 或者install 之类的说明文档来告诉你如何去安装这个网卡驱动的

Linux* Base Driver for the Atheros(R) AR8121/AR8113 PCI-E Ethernet Adapter
==========================================================================

Contents
========

- In This Release
- Building and Installation
- Command Line Parameters
- Additional Configurations
- Known Issues
- Support

In This Release
===============

This file describes the Linux* Base Driver for the Atheros(R) AR8121/AR8113 PCI-E
Ethernet Adapter, version 1.0.0.5 This driver supports the 2.4.x and 2.6.x kernels.

This driver is only supported as a loadable mole at this time. Atheros is not
supplying patches against the kernel source to allow for static linking of
the driver. For questions related to hardware requirements, refer to the
documentation supplied with your Atheros(R) adapter. All hardware
requirements listed apply to use with Linux.

Building and Installation
=========================

To build a binary RPM* package of this driver, run 'rpmbuild -tb
<filename.tar.gz>'. Replace <filename.tar.gz> with the specific filename of
the driver.

NOTE: For the build to work properly, the currently running kernel MUST match
the version and configuration of the installed kernel sources. If you
have just recompiled the kernel reboot the system now.

RPM functionality has only been tested in Red Hat distributions.

1. Move the base driver tar file to the directory of your choice. For example,
use /home/username/arl1e or /usr/local/src/arl1e.

2. Untar/unzip archive:

tar zxf arl1e-x.x.x.x.tar.gz

3. Change to the driver src directory:

cd arl1e-x.x.x.x/src/

4. Compile the driver mole:

make install

The binary will be installed as:

/lib/moles/<KERNEL VERSION>/kernel/drivers/net/arl1e.[k]o

The install locations listed above are the default locations. They might
not be correct for certain Linux distributions. For more information,
see the ldistrib.txt file included in the driver tar.

5. Install the mole:

insmod arl1e <parameter>=<value>

6. Assign an IP address to the interface by entering the following, where
x is the interface number:

ifconfig ethx <IP_address>

7. Verify that the interface works. Enter the following, where <IP_address>
is the IP address for another machine on the same subnet as the interface
that is being tested:

ping <IP_address>

Command Line Parameters
=======================

If the driver is built as a mole, the following optional parameters are
used by entering them on the command line with the modprobe or insmod command
using this syntax:

modprobe arl1e [<option>=<VAL1>,<VAL2>,...]

insmod arl1e [<option>=<VAL1>,<VAL2>,...]

For example, with two L001 PCIE adapters, entering:

insmod arl1e TxMemSize=80,128
loads the arl1e driver with 8KB TX memory for the first adapter and 10KB TX memory
for the second adapter.

The default value for each parameter is generally the recommended setting,
unless otherwise noted.

NOTES: A descriptor describes a data buffer and attributes related to the
data buffer. This information is accessed by the hardware.

media_type
Valid Range: 0-4
0 - auto-negotiate at all supported speeds
1 - only link at 1000Mbps Full Duplex
2 - only link at 100Mbps Full Duplex
3 - only link at 100Mbps Half Duplex
4 - only link at 10Mbps Full Duplex
5 - only link at 10Mbps Half Duplex
Default Value: 0
media_type forces the line speed/plex to the specified value in
megabits per second(Mbps). If this parameter is not specified or is set
to 0 and the link partner is set to auto-negotiate, the board will
auto-detect the correct speed.

int_mod_timer
Valid Range: 50-65000
Default Value: 100
This value represents the minmum interval between interrupts controller
generated.

RxMemBlock
Valid Range: 16-512
Default Value: 64
This value is the number of receice memory block allocated by the driver.
Increasing this value allows the driver to buffer more incoming packets.
Each memory block is 1536 bytes.

NOTE: Depending on the available system resources, the request for a
higher number of receive descriptors may be denied. In this case,
use a lower number.

TxMemSize
Valid Range: 4-64
Default Value: 8
This value is the number KB of transmit memory allocated by the driver.
Increasing this value allows the driver to queue more transmits.

NOTE: Depending on the available system resources, the request for a
higher number of transmit descriptors may be denied. In this case,
use a lower number.

FlashVendor
Valid Range: 0-2
Default Value: 0
This value standards on vendor of spi flash used by the adapter.
0 for Atmel, 1 for SST, 2 for ST

Additional Configurations
=========================

Configuring the Driver on Different Distributions
-------------------------------------------------

Configuring a network driver to load properly when the system is started is
distribution dependent. Typically, the configuration process involves adding
an alias line to /etc/moles.conf as well as editing other system startup
scripts and/or configuration files. Many popular Linux distributions ship
with tools to make these changes for you. To learn the proper way to
configure a network device for your system, refer to your distribution
documentation. If ring this process you are asked for the driver or mole
name, the name for the Linux Base Driver for the Atheros AR8121/AR8113 is arl1e

As an example, if you install the arl1e driver for two AR8121/AR8113 adapters
(eth0 and eth1) and set the speed and plex to 10full and 100half, add the
following to moles.conf:

alias eth0 arl1e
alias eth1 arl1e
options arl1e Speed=10,100 Duplex=2,1

Viewing Link Messages
---------------------

Link messages will not be displayed to the console if the distribution is
restricting system messages. In order to see network driver link messages
on your console, set dmesg to eight by entering the following:

dmesg -n 8

NOTE: This setting is not saved across reboots.

Known Issues
============

NOTE: For distribution-specific information, see the ldistrib.txt file
included in the driver tar.

Driver Compilation
------------------

When trying to compile the driver by running make install, the following
error may occur:

"Linux kernel source not configured - missing version.h"

To solve this issue, create the version.h file by going to the Linux source
tree and entering:

make include/linux/version.h.

Support
=======

For general information, go to the Atheros support website at:

http://support.atheros.com

If an issue is identified with the released source code on the supported
kernel with a supported adapter, email the specific information related to
the issue to [email protected]

License
=======

This software program is released under the terms of a license agreement
between you ('Licensee') and Atheros. Do not use or load this software or any
associated materials (collectively, the 'Software') until you have carefully
read the full terms and conditions of the LICENSE located in this software
package. By loading or using the Software, you agree to the terms of this
Agreement. If you do not agree with the terms of this Agreement, do not
install or use the Software.

* Other names and brands may be claimed as the property of others.

6. linux中动态加载驱动的过程是怎么样的,能给个详细的吗

介绍个动态加载模块的过程

在该驱动中,我们假设对键盘的获取是以0.2s为周期执行。源代码如下

static struct timer_list timer;///////我们定义的定时器,也许你会问timer_list是什么来的,其实一看名称就应该就知道了,而为什么要用到list那么多定时器呢?其实在linux中还有很多相同的定义,比如说信号,我们定义的也是信号集,你可以定义该list是一个元素的,也可以是多个的。所以对于 timer_list就可以这样描述:在未来某一个特定时刻执行某一系列特定任务的功能。下面我们还会给出内核中timer_list的具体描述,^_^ 好像我的话又说多了

static int Keypad_starttimer(void)
{
init_timer(&timer);//初始化定时器结构
timer.function=Keypad_timer;//超时服务程序
timer.expires=jiffies+20;//当前时刻加0.2s
add_timer(&timer);
return 0;
}
///超时服务程序
static void Keypad_timer(unsigned long data)
{
read_xy();
}

/////////接下来说下timer-list这个数据结构,如果你不感兴趣的话可以跳过,该结构在include\linux\timer.h中定义
struct timer_list
{
struct list_head entry;
unsigned long expries;
spinlock_t lock;
unsigned long magic;
void (*function)(unsigned long);
unsigner long data;
struct tvec_t_base_s *base;
}

七.利用等待队列实现阻塞型I\O

在用户程序执行读操作的时候有可能尚且没有数据可以读取,为此需要让read操作等待,直到有数据可以读取,这就是阻塞型i\o,阻塞型io可以通过使用进程休眠方法实现。在无数据可以读取的时候,采用等待队列让进程休眠,直到有数据到达的时候才唤醒进程完成数据的读操作。

在本驱动中的read,若循环队列缓冲区中没有数据,则进程进入休眠态,定时器函数每隔0.2s读取键值一次,将按键状态放入缓冲并且适时唤醒进程读取数据。

等待队列的使用流程如下:

1.声明一个等待队列

2.把当前进程加入到等待队列中

3.把进程的状态设置为TASK_INTERRUPTIBLE或TASK_UNINTERRUPTIBLE;

4.调用schele,以让出cpu

5.检测所需要的资源是否可用,若是,把当前进程从等待队列中删除,否则转3循环

接下来我们在对read中有关等待队列阻塞实现做具体的解释

static ssize_t Keypad_read(struct file *filp,char *buf,ssize_t count,loff_t *l)
{
DECLEARE_WAITQUEUE(wait,current);//声明等待队列,将当前进程加入到等待队列中
KEY_EVENT t;
ulong out_buf[2];
if(head==tail)//当前循环队列中没有数据可以读取
{
if(filp->f_flags & O_NONBLOCK)//假如用户采用的是非堵塞方式读取
return _EAGAIN;
add_wait_queue(&queue,&wait);//将当前进程加入等待队列
current->state=TASK_INTERRUPTIBLE;//设置当前进程的状态
while((head==tail)&&!signal_pending(current))//假若还没有数据到循环队列并且当前进程没有受到信号(该类信号具体来说是未决的休眠)
{
shele();//进程调度
current->state=TASK_INTERRUPTIBLE;
}
current->state=TASK_RUNNING;//该进程恢复执行
remove_wait_queue(&queue,&wait);//移出等待队列
if(head==tail)
return count;
t=get_data();//调用get_data()函数,得到缓冲区中的数据,下面将给予详细的 介绍
out_buf[0]=t.status;
out_buf[1]=t.click;
_to_user(buf,&out_buf,sizeof(out_buf));//将得到的键值拷贝到用户数据区
return count;
}
}

热点内容
sok编程 发布:2025-05-15 15:33:21 浏览:39
lms算法程序 发布:2025-05-15 15:31:53 浏览:568
数据库二级映射 发布:2025-05-15 15:14:09 浏览:476
3d文件加密 发布:2025-05-15 15:05:17 浏览:361
jquery拖拽上传图片 发布:2025-05-15 14:53:36 浏览:129
我的世界电脑服务器需要正版吗 发布:2025-05-15 14:38:53 浏览:694
大华录像机哪里有安卓设备 发布:2025-05-15 14:25:06 浏览:808
录制脚本方案 发布:2025-05-15 14:25:04 浏览:165
奇石脚本业 发布:2025-05-15 14:23:44 浏览:680
android中的socket 发布:2025-05-15 14:22:15 浏览:409