目錄:http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html
[不提供插圖,讀者最好從網上下載源書]
5.3. Basic Goals of NIC Initialization NIC初始化的基本目的
Each network device is represented in the Linux kernel by an instance of the net_device data structure. In Chapter 8, you will see how net_device data structures are allocated and how their fields are initialized, partly by the device driver and partly by core kernel routines. In this chapter, we focus on how device drivers allocate the resources needed to establish device/kernel communication, such as:
每一個網路裝置在Linux核心中都要以net_device資料結構的形式表現出來。在第8章中,你會看到net_device資料結構是如何被分配的,以及它們的欄位中如何初始化的,一部份是由裝置驅動程式初始化的,一部份是核心常式初始化的。在這一章裡,我們集中於裝置驅動是 如何分配資源的,這些資源是在建立裝置/核心互動中必須的:例如:
IRQ line IRQ線
As you will see in the section "Interaction Between Devices and Kernel," NICs need to be assigned an IRQ and to use it to call for the kernel's attention when needed. Virtual devices, however, do not need to be assigned an IRQ: the loopback device is an example because its activity is totally internal (see the later section "Virtual Devices").
正如你在"Interaction Between Devices and Kernel,"中所看到的,NIC須要指定一個IRQ,以便核心在必要時可以調用它。然而,虛擬設備不須要指定一個IRQ,環回裝置就是一個例子,因為實際上完全是內部的(參見後面的一節“Virtual Devices”)。
The two functions used to request and release IRQ lines are introduced in the later section "Hardware Interrupts." As you will see in the later section "Tuning via /proc Filesystem," the /proc/interrupts file can be used to view the status of the current assignments.
在後面的一節“Hardware Interrupts.”中會介紹兩個函數用於申請和釋放IRQ線。你會在“Tuning via /proc Filesystem,”中看到,通過/proc/interrupts檔案你可以看到當前系統已經指定的(中斷的)狀態。
I/O ports and memory registration I/O連接埠和記憶體註冊
It is common for a driver to map an area of its device's memory (its configuration registers, for example) into the system memory so that read/write operations by the driver will be made on system memory addresses directly; this can simplify the code. I/O ports and memory are registered and released with request_region and release_region, respectively.
通常,裝置在系統記憶體中映射一塊它自己的裝置記憶體(例如,它的配置註冊),這樣裝置的讀和寫操作就可以通過直接存取記憶體來完成;這樣可以簡化代碼。I/O連接埠和記憶體通過request_region 和release_region分別註冊和釋放。