當前位置:首頁 » 操作系統 » linux匯流排驅動設備驅動

linux匯流排驅動設備驅動

發布時間: 2022-02-24 09:52:31

1. 如何 理解 linux 設備 驅動 匯流排

linux
主機的硬體配備
lspci
找到的是目前主機上面的硬體配備
[root@www
~]#
lspci
[-vvn]
選項與參數:
-v
:顯示更多的
pci
介面裝置的詳細信息
-vv
:比
-v
還要更詳細的信息
-n
:直接觀察
pci

id
而不是廠商名稱
查閱您系統內的
pci
裝置:
[root@www
~]#
lspci
#不必加上任何選項,就能夠顯示出目前的硬體配備為何
host
bridge:
<==主板晶元
vga
compatible
controller
<==顯卡
audio
device
<==音頻設備
pci
bridge
<==介面插槽
usb
controller
<==usb控制器
isa
bridge
ide
interface
smbus
ethernet
controller
<==網卡
04:00.0
ethernet
controller:
realtek
semiconctor
co.,
ltd.
查看一般詳細信息
[root@www
~]#
lspci
-v
查看網卡詳細信息:
[root@www
~]#
lspci
-s
04:00.0
-vv
-s
:後面接的是每個設備的匯流排、插槽與相關函數功能

2. linux 下platform設備和驅動注冊的先後順序

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()只負責將設備添加到匯流排的設備鏈表上。

3. linux匯流排驅動模型中,匯流排也是一種設備,匯流排與表示它的設備是怎麼聯系的

設備模型中,關心匯流排,設備,驅動這三個實體,匯流排將設備和驅動綁定,在系統每注冊一個設備的時候,會尋找與之匹配的驅動。相反,在系統每注冊一個驅動的時候,尋找與之匹配的設備,匹配是由匯流排來完成的。 你還可以看一看鏈表的信息。它們都是關聯的。 有個最牛的函數contain_o
f 非常牛。還有輪詢鏈表的函數。

4. vxworks驅動跟linux驅動有什麼區別匯流排驅動怎麼寫

vxworks和linux是不同的兩個操作系統,類似的還有wince。

首先,vxworks和linux系統內部很多實現都不一樣,導致驅動層實現也不一樣。

由於Linux操作系統和Linux引導裝載器在結構上的分離,使得它倆之間的設備驅動程序不能夠通用,當然在晶元的硬體初始化一些硬體相關的代碼上可以互相借鑒。而 VxWorks的BOOTROM和運行版本的設備驅動是相同的,因為,它的運行版本和BOOTROM的結構是一致的,使用同一操作系統內核。 Linux操作系統的設備驅動運行在內核空間,用戶進程運行在用戶空間。在Linux操作系統中,內核空間和用戶空間的內存管理和映射方式是不同的,應用和設備驅動在數據交換時會涉及到不同的內存空間,會影響到一定效率,但這個問題可以通過修改系統內存空間配置等方法來解決。 VxWorks操作系統沒有分開內核空間和用戶空間,設備驅動和應用都運行於同一空間,相互之間的內存都可以訪問,數據交換非常方便,但是,這種結構的穩定性就不如 Linux系統好了。 兩種操作系統都提供了很多設備驅動的資源和模板。但是由於Linux的開源特性,它提供的設備驅動的種類和數量遠遠超過了VxWorks.

參考:http://blog.csdn.net/cybertan/article/details/5707973

5. 怎麼查看linux usb設備驅動

下面的信息都是在VMware中運行Ubuntu12-04系統上執行的。同樣該命令也支持在嵌入式系統中進行USB調試。
一、cat設備節點獲取信息
在一些嵌入式開發中需要調試USB功能,經常會cat /sys 下的相關設備節點來查看某些信息,比如說我們可以看到 /sys/bus/usb/devices 目錄有多個子目錄。進入到某個子目錄可以看到usb設備更加詳細的信息(可以理解為設備描述符)。
1、usb設備在匯流排上的信息
// usb設備在匯流排上的信息
root@ubuntu:/sys/kernel/debug# cd /sys/bus/usb/devices
root@ubuntu:/sys/bus/usb/devices# ll
total 0
drwxr-xr-x 2 root root 0 Nov 26 21:21 ./
drwxr-xr-x 4 root root 0 Nov 26 21:21 ../
lrwxrwxrwx 1 root root 0 Nov 26 21:21 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-0:1.0/
lrwxrwxrwx 1 root root 0 Dec 15 23:10 1-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/
lrwxrwxrwx 1 root root 0 Dec 15 23:18 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-0:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/2-1:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/
其中 usbx/第x個匯流排,x-y:a.b/的目錄格式,x表示匯流排號,y表示埠,a表示配置,b表示介面。
具體解釋可以參照如下:
The names that begin with "usb" refer to USB controllers. More accurately, they refer to the "root hub" associated with each controller. The number is the USB bus number. In the example there is only one controller, so its bus is number 1. Hence the name "usb1".
"1-0:1.0" is a special case. It refers to the root hub's interface. This acts just like the interface in an actual hub an almost every respect; see below.
All the other entries refer to genuine USB devices and their interfaces. The devices are named by a scheme like this:
bus-port.port.port ...
In other words, the name starts with the bus number followed by a '-'. Then comes the sequence of port numbers for each of the intermediate hubs along the path to the device.
For example, "1-1" is a device plugged into bus 1, port 1. It happens to be a hub, and "1-1.3" is the device plugged into port 3 of that hub. That device is another hub, and "1-1.3.1" is the device plugged into its port 1.
The interfaces are indicated by suffixes having this form:
:config.interface
That is, a ':' followed by the configuration number followed by '.' followed by the interface number. In the above example, each of the devices is using configuration 1 and this configuration has only a single interface, number 0. So the interfaces show up as;
1-1:1.0 1-1.3:1.0 1-1.3.1:1.0
A hub will never have more than a single interface; that's part of the USB spec. But other devices can and do have multiple interfaces (and sometimes multiple configurations). Each interface gets its own entry in sysfs and can have its own driver.
2、特定設備的詳細信息
進入到某個目錄中去,可以看到該設備的詳細信息,可用cat命令獲取信息。
// usb設備的詳細信息
root@ubuntu:/sys/bus/usb/devices/usb1# ll
total 0
drwxr-xr-x 6 root root 0 Nov 26 21:21 ./
drwxr-xr-x 4 root root 0 Nov 26 21:21 ../
drwxr-xr-x 10 root root 0 Nov 26 21:21 1-0:1.0/
drwxr-xr-x 5 root root 0 Dec 15 23:10 1-1/
-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized
-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized_default
-rw-r--r-- 1 root root 4096 Dec 15 23:40 avoid_reset_quirk
-r--r--r-- 1 root root 4096 Nov 26 21:21 bcdDevice
-rw-r--r-- 1 root root 4096 Nov 26 21:21 bConfigurationValue
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceClass
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceProtocol
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceSubClass
-r--r--r-- 1 root root 4096 Dec 15 23:40 bmAttributes
-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPacketSize0
-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPower
-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumConfigurations
-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumInterfaces
-r--r--r-- 1 root root 4096 Nov 26 21:21 busnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 configuration
-r--r--r-- 1 root root 65553 Nov 26 21:21 descriptors
-r--r--r-- 1 root root 4096 Dec 15 23:40 dev
-r--r--r-- 1 root root 4096 Nov 26 21:21 devnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 devpath
lrwxrwxrwx 1 root root 0 Nov 27 20:06 driver -> ../../../../../bus/usb/drivers/usb/
drwxr-xr-x 3 root root 0 Dec 15 23:40 ep_00/
-r--r--r-- 1 root root 4096 Nov 26 21:21 idProct
-r--r--r-- 1 root root 4096 Nov 26 21:21 idVendor
-r--r--r-- 1 root root 4096 Dec 15 23:40 ltm_capable
-r--r--r-- 1 root root 4096 Nov 26 21:21 manufacturer
-r--r--r-- 1 root root 4096 Dec 15 23:40 maxchild
drwxr-xr-x 2 root root 0 Nov 26 21:21 power/
-r--r--r-- 1 root root 4096 Nov 26 21:21 proct
-r--r--r-- 1 root root 4096 Dec 15 23:40 quirks
-r--r--r-- 1 root root 4096 Nov 26 21:21 removable
--w------- 1 root root 4096 Dec 15 23:40 remove
-r--r--r-- 1 root root 4096 Nov 26 21:21 serial
-r--r--r-- 1 root root 4096 Nov 26 21:21 speed
lrwxrwxrwx 1 root root 0 Nov 26 21:21 subsystem -> ../../../../../bus/usb/
-rw-r--r-- 1 root root 4096 Nov 26 21:21 uevent
-r--r--r-- 1 root root 4096 Dec 15 23:40 urbnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 version
二、使用debugfs
1、掛載 debugfs 到 /sys/kernel/debug 路徑下
root@ubuntu:mount -t debugfs none /sys/kernel/debug
2、執行上述步驟之後,在 /sys/kernel/debug 就會生成如下的文件
root@ubuntu:/sys/bus/usb/devices# cd /sys/kernel/debug/
root@ubuntu:/sys/kernel/debug# ll
total 0
drwx------ 22 root root 0 Nov 26 21:21 ./
drwxr-xr-x 7 root root 0 Nov 26 21:21 ../
drwxr-xr-x 2 root root 0 Nov 26 21:21 acpi/
drwxr-xr-x 32 root root 0 Dec 4 16:30 bdi/
drwxr-xr-x 2 root root 0 Nov 26 21:21 bluetooth/
drwxr-xr-x 2 root root 0 Nov 26 21:21 cleancache/
drwxr-xr-x 2 root root 0 Nov 26 21:21 dma_buf/
drwxr-xr-x 4 root root 0 Nov 26 21:21 dri/
drwxr-xr-x 2 root root 0 Nov 26 21:21 dynamic_debug/
drwxr-xr-x 2 root root 0 Nov 26 21:21 extfrag/
drwxr-xr-x 2 root root 0 Nov 26 21:21 frontswap/
-r--r--r-- 1 root root 0 Nov 26 21:21 gpio
drwxr-xr-x 3 root root 0 Nov 26 21:21 hid/
drwxr-xr-x 2 root root 0 Nov 26 21:21 kprobes/
drwxr-xr-x 3 root root 0 Nov 26 21:21 kvm-guest/
drwxr-xr-x 2 root root 0 Nov 26 21:21 mce/
drwxr-xr-x 2 root root 0 Nov 26 21:21 pinctrl/
-r--r--r-- 1 root root 0 Nov 26 21:21 pwm
drwxr-xr-x 2 root root 0 Nov 26 21:21 regmap/
drwxr-xr-x 3 root root 0 Nov 26 21:21 regulator/
-rw-r--r-- 1 root root 0 Nov 26 21:21 sched_features
-r--r--r-- 1 root root 0 Nov 26 21:21 sleep_time
-r--r--r-- 1 root root 0 Nov 26 21:21 suspend_stats
drwxr-xr-x 7 root root 0 Nov 26 21:21 tracing/
drwxr-xr-x 3 root root 0 Nov 26 21:21 usb/
drwxr-xr-x 2 root root 0 Nov 26 21:21 virtio-ports/
-r--r--r-- 1 root root 0 Nov 26 21:21 vmmemctl
-r--r--r-- 1 root root 0 Nov 26 21:21 wakeup_sources
drwxr-xr-x 2 root root 0 Nov 26 21:21 x86/
3、cat 設備節點
執行下述命令之後會以特定格式列印目前USB匯流排上所有USB設備的信息如下:
root@ubuntu:/sys/kernel/debug# cat usb/devices
T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 17/900 us ( 2%), #Int= 1, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 3.13
S: Manufacturer=Linux 3.13.0-32-generic uhci_hcd
S: Proct=UHCI Host Controller
S: SerialNumber=0000:02:00.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0003 Rev= 1.03
S: Manufacturer=VMware
S: Proct=VMware Virtual USB Mouse
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=1ms
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 7
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0002 Rev= 1.00
S: Proct=VMware Virtual USB Hub
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6
B: Alloc= 0/800 us ( 0%), #Int= 1, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.13
S: Manufacturer=Linux 3.13.0-32-generic ehci_hcd
S: Proct=EHCI Host Controller
S: SerialNumber=0000:02:03.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1
P: Vendor=0bda ProdID=0129 Rev=39.60
S: Manufacturer=Generic
S: Proct=USB2.0-CRW
S: SerialNumber=20100201396000000
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=50 Driver=rts5139
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=83(I) Atr=03(Int.) MxPS= 3 Ivl=64ms
至於信息的詳細解析可以參照 Linux源代碼中 Documentation/usb/proc_usb_info.txt 文件。現摘錄其中對該格式的詳細解釋:

| | |__Proct ID code
| |__Vendor ID code
|__Device info tag #2

String descriptor info:
S: Manufacturer=ssss
| |__Manufacturer of this device as read from the device.
| For USB host controller drivers (virtual root hubs) this may
| be omitted, or (for newer drivers) will identify the kernel
| version and the driver which provi

6. 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()只負責將設備添加到匯流排的設備鏈表上。

7. 請問Linux驅動程序中,字元設備驅動,塊設備驅動以及網路驅動的區別和比較,學的時候需要注意些什麼

可以講字元設備和塊設備歸為一類,它們都是可以順序/隨機地進行讀取和存儲的單元,二者驅動主要在於塊設備需要具體的burst實現,對訪問也有一定的邊界要求。其他的沒有什麼不同。
網路設備是特殊設備的驅動,它負責接收和發送幀數據,可能是物理幀,也可能是ip數據包,這些特性都有網路驅動決定。它並不存在於/dev下面,所以與一般的設備不同。網路設備是一個net_device結構,並通過register_netdev注冊到系統里,最後通過ifconfig -a的命令就能看到。
不論是什麼設備,設備級的數據傳輸都是基本類似的,內核里的數據表示只是一部分,更重要的是匯流排的訪問,例如串列spi,i2c,並行dma等。

8. linux中設備和驅動到底有什麼區別,有什麼聯系啊學習2.6的內核,搞得好暈呢!

2.6.x版本的內核,核心部分變動不大。
每個小版本之間,都是在不停的添加新驅動、解一些小bug、對現有系統進行完善。
你如果讓我在這里說每個版本之間的區別的話,估計要寫好幾頁了。建議你到官網(www.kernel.org/目前已經可以訪問了)上去看下每個版本的ChangeLog。這個東西,沒有任何人比它說的更詳細了。如果你對某個修改比較感興趣,還可以下載對應的patch包,看看那些Hacker究竟做了哪些修改。
當然,最方便的方法,還是使用git把Kerne的代碼下載下來,然後用git log命令可以看到每次修改的歷史信息的。非常方便和詳細。
不明白的請追問。

9. 請問linux驅動怎麼調用底層的驅動啊 比如說已有SPI匯流排驅動,現要為一個SPI設備寫驅動,怎麼調用底層驅動

spi匯流排驅動在linux中是採用了分層設計和分隔設計的思想,spi控制器的驅動和核心層的通用api內核已經寫完了,你只要寫外設驅動就好,具體你可以去看一下你的spi_s3c24xx.c這個驅動是基於platfoem寫的,裡面含有如何調用核心api。

熱點內容
35歲資產如何配置 發布:2024-09-21 13:26:37 瀏覽:470
安卓哪個軟體燒流量 發布:2024-09-21 13:25:50 瀏覽:590
編譯局章程 發布:2024-09-21 13:12:45 瀏覽:710
清風演算法降權 發布:2024-09-21 12:28:33 瀏覽:566
雲租用伺服器費用 發布:2024-09-21 12:28:27 瀏覽:906
win2003ftp 發布:2024-09-21 12:20:43 瀏覽:562
展陳故事腳本設計 發布:2024-09-21 11:48:36 瀏覽:141
怎麼看電腦真實配置 發布:2024-09-21 11:12:54 瀏覽:331
騰訊雲輕量伺服器需要搭建環境 發布:2024-09-21 11:12:53 瀏覽:675
json格式php 發布:2024-09-21 11:08:02 瀏覽:247