Chris Cant - Writing Windows WDM Device Drivers
Здесь есть возможность читать онлайн «Chris Cant - Writing Windows WDM Device Drivers» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Lawrence, Kansas 66046, ISBN: , Издательство: R & D Books, Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:Writing Windows WDM Device Drivers
- Автор:
- Издательство:R & D Books
- Жанр:
- Год:неизвестен
- Город:Lawrence, Kansas 66046
- ISBN:0-87930-565-7
- Рейтинг книги:5 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 100
- 1
- 2
- 3
- 4
- 5
Writing Windows WDM Device Drivers: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Writing Windows WDM Device Drivers»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
Writing Windows WDM Device Drivers — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Writing Windows WDM Device Drivers», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
The second aim of the Plug and Play system is to make standard drivers available for other drivers to use.
At the lowest level, a bus or class driver talks directly to the hardware. One or more client drivers are layered on top of such system drivers. These client drivers work at the functional level. For example, a USB printer client driver uses the USB bus driver to send its messages. However, the messages are only understood by the printer firmware. The client driver therefore controls the printer functions, letting the USB system driver handle all the messy low-level communications details.
Each bus driver has one device object that represents the whole bus. The bus driver creates a new device object, called the Physical Device Object (PDO), for each device that it finds on its bus. It provides various device identifiers to the PnP Manager. The PnP Manager finds and loads the most appropriate driver, and calls its AddDevice routine.
The newly loaded driver is called a functiondriver, as it should know how to control its device's function. The function driver must create its own new device object, called a Functional Device Object (FDO) which stores its information about the device [17] Both FDOs and PDOs use exactly the same DEVICE_OBJECT structure.
. The FDO is created in a function driver's AddDevice routine. The AddDevice routine then goes on to layer itself above the bus driver PDO.
In this simple case, two device objects refer to the same physical device. The PDO is the bus driver's representation of the device, while the FDO stores the function driver information about the device.
Figure 8.1 shows the situation when two devices are attached to a single bus. The bus driver has two 'child' PDOs, one for each device. A suitable function driver has been found for each device. Each function driver has created an FDO to store information about its device.
The bus driver controls three different device objects. Each child PDO receives requests from the function driver layered about it. In addition, the bus driver has an FDO of its own which it uses to store information about the whole bus. A bus driver might handle child PDO requests by sending them to its FDO for processing.
Just to reiterate, each functiondriver knows how to control the functions in a device. However, a function driver usually uses the facilities of its underlying busdriver to talk to its device.
Even a virtual device driver like Wdm1has a device stack. Wdm1is a function driver and so its device object is an FDO. There is a bus driver underneath Wdm1, the system unknown driver. the unknown bus driver makes a PDO to represent each Wdm1 device. The Unknown driver does some important jobs, even though it does not correspond to a hardware bus. The following chapter describes the jobs that even a minimal bus driver like Unknown must do.
Figure 8.1 A bus driver, two devices, and their function drivers
Device Stacks
When one driver layers its device over another, it forms a device stack. Each device in the stack usually plays some part in processing user requests.
Figure 8.2 shows a generic device stack. A bus driver is always at the bottom of the stack. One or more function drivers do the main device control functions.
Filter drivers are used to modify the behavior of standard device drivers. Rather than rewrite a whole bus or class driver, a filter driver modifies its actions in the area of interest. As the figure shows, there are various types of filter driver. A bus filter driver acts on all devices that attach to a particular bus driver. Class filter drivers are installed in the stack for each device of the specified class. Finally, a device filter driver is installed for one particular device. Lower-level filter drivers are below the function driver, while upper-level drivers are above the function driver in the stack.
Filter drivers are only installed when a device is first installed, so they cannot be inserted once a device stack has been built.
Figure 8.2 Bus, function, and filter drivers
Monolithic and Layered Drivers
When a standard keyboard is found, Windows loads the appropriate driver. This talks directly to the keyboard through its controller electronics. The keyboard driver is described as monolithic because it takes over all the processing required to handle the keyboard (i.e., it does not use other drivers to do its job).
In contrast, USB drivers use a layered approach. To use a USB keyboard, the keyboard driver uses the services of the USB class drivers.
As shown in Chapter 21, the USB class drivers expose an upper edge that drivers higher than it must use. Such drivers can issue USB Request Blocks (URBs), which transmit or receive information from a USB device. The keyboard driver does not care how the USB class drivers do their job.
The situation for the USB class drivers themselves is probably slightly different [18] I don't know for sure because I don't know how they work. And I don't care!
. They are told where the USB bus controller electronics live, and they make use of the services of the PCI bus driver. However, I suspect that the USB class drivers talk directly to their own hardware. Asking the PCI bus driver to write or read memory would be too slow.
A different approach would have been to let each USB driver talk directly to the USB hardware in a monolithic driver. This would lead to two problems. The first is that each USB driver would need a large amount of code. Duplicating this code would waste memory and writing large drivers is decidedly error prone. The second problem is almost of more significance: how would all these different drivers coordinate their activities? The answer is, of course, with difficulty. Using different layers of drivers solves both these problems.
Plug and Play Messages
This section looks at the messages that a PnP driver receives. Its AddDevice routine is called when a device is added. After that, messages are sent using the PnP IRP. The PnP messages have the same major function code IRP_MJ_PNP, but each message uses a different minor function code. Each message has different parameters in the IRP.
A PnP driver must implement an AddDevice routine and handle various PnP IRPs. Table 8.2 is a list of all the minor function codes. The first eight of these minor codes are the most important. The other minor function codes are usually just handled by bus drivers.
Table 8.2 Plug and Play minor function codes
Common PnP IRPs | |
---|---|
IRP_MN_START_DEVICE |
Assign resources and start a device |
IRP_MN_QUERY_REMOVE_DEVICE |
Ask if a device can be removed |
IRP_MN_CANCEL_REMOVE_DEVICE |
Cancel a query remove request |
IRP_MN_REMOVE_DEVICE | Device has been unplugged or uninstalled Deallocate resources and remove a device |
IRP_MN_SURPRISE_REMOVAL (W2000 only) |
A user has unexpectedly unplugged a device |
IRP_MN_QUERY_STOP_DEVICE |
Ask if a device can be stopped |
IRP_MN_CANCEL_STOP_DEVICE |
Cancel a query stop request |
IRP_MN_STOP_DEVICE |
Stop a device for resource reallocation |
Unusual PnP IRPs | |
IRP_MN_QUERY_DEVICE_RELATIONS |
Ask for PDOs that have certain characteristics |
IRP_MN_QUERY_INTERFACE |
Let a driver export a direct-call interface |
IRP_MN_QUERY_CAPABILITIES |
Ask about device capabilities (e.g., whether it can be locked or ejected) |
IRP_MN_QUERY_RESOURCES |
Get a device's boot configuration resources |
IRP_MN_QUERY_RESOURCE_REQUIREMENTS |
Ask what resources a device requires |
IRP_MN_QUERY_DEVICE_TEXT |
Get a device's description or location string |
IRP_MN_FILTER_RESOURCE_REQUIREMENTS |
Let filter and function drivers filter a device's resource requirements |
IRP_MN_READ_CONFIG |
Read configuration space information |
IRP_MN_WRITE_CONFIG |
Set configuration space information |
IRP_MN_EJECT |
Eject the device from its slot |
IRP_MN_SET_LOCK |
Set device locking state |
IRP_MN_QUERY_ID |
Get hardware, compatible, and instance IDs for a device |
IRP_MN_QUERY_PNP_DEVICE_STATE |
Set bits in a device state bitmap |
IRP_MN_QUERY_BUS_INFORMATION |
Get type and instance number of parent bus |
IRP_MN_DEVICE_USAGE_NOTIFICATION |
Notify whether a device is in the path of a paging, hibernation, or crash dump file. |
IRP_MN_QUERY_LEGACY_BUS_INFORMATION |
Returns legacy bus information (W2000 only) |
Figure 8.3 shows the PnP states for a device and the messages that are sent to change state. The minor function code names are shortened in the figure (e.g., IRP_MN_START_DEVICE is shown as START_DEVICE). In this book, a PnP IRP with an IRP_MN_START_DEVICE minor function code is called a Start Device message. The other PnP function codes are given similar names.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Writing Windows WDM Device Drivers»
Представляем Вашему вниманию похожие книги на «Writing Windows WDM Device Drivers» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Writing Windows WDM Device Drivers» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.