當前位置:首頁 » 操作系統 » 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;
}
}

熱點內容
編譯失敗什麼意思 發布:2025-05-15 11:58:18 瀏覽:86
lcs腳本官網 發布:2025-05-15 11:56:15 瀏覽:86
三國志戰略版打9級礦什麼配置 發布:2025-05-15 11:41:29 瀏覽:952
安卓加速器怎麼關 發布:2025-05-15 11:38:16 瀏覽:464
密碼鎖壞了如何打開 發布:2025-05-15 11:30:19 瀏覽:837
怎樣增加共享文件夾連接數量 發布:2025-05-15 11:24:50 瀏覽:961
安卓如何關閉單應用音量 發布:2025-05-15 11:22:31 瀏覽:351
抖音電腦後台伺服器中斷 發布:2025-05-15 11:11:59 瀏覽:307
sql2008伺服器 發布:2025-05-15 11:03:27 瀏覽:306
我的世界pe伺服器創造 發布:2025-05-15 10:51:17 瀏覽:608