Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Stream Interface API

Stream Interface API

For Device Manager to load and manage a stream driver successfully, the stream driver must export a common interface, generally referred to as the stream interface. The stream interface consists of 12 functions to initialize and open the device, read and write data, power up or down the device, and close and de-initialize the device, as summarized in Table 6-1.

Table 6-1 Stream interface functions

Function Name Description
XXX_Init Device Manager calls this function to load a driver during the boot process or in answer to calls to ActivateDeviceEx in order to initialize the hardware and any memory structures used by the device.
XXX_PreDeinit Device Manager calls this function before calling XXX_Deinit to give the driver a chance to wake sleeping threads and invalidate open handles in order to accelerate the de-initialization process. Applications do not call this function.
XXX_Deinit Device Manager calls this function to de-initialize and deallocate memory structures and other resources in response to a DeActivateDevice call after deactivating and unloading a driver.
XXX_Open Device Manager calls this function when an application requests access to the device by calling CreateFile for reading, writing, or both.
XXX_PreClose Device Manager calls this function to give the driver a chance to invalidate handles and wake sleeping threads in order to accelerate the unloading process. Applications do not call this function.
XXX_Close Device Manager calls this function when an application closes an open instance of the driver, such as by calling the CloseHandle function. The stream driver must de-allocate all memory and resources allocated during the previous XXX_Open call.
XXX_PowerUp Device Manager calls this function when the operating system comes out of a low power mode. Applications do not call this function. This function executes in kernel mode, can therefore not call external APIs, and must not be paged out because the operating system is running in single-threaded, non-paged mode. Microsoft recommends that drivers implement power management based on Power Manager and power management IOCTLs for suspend and resume functionality in a driver.
XXX_PowerDown Device Manager calls this function when the operating system transitions into suspend mode. Similar to XXX_PowerUp, this function executes in kernel mode, can therefore not call external APIs, and must not be paged out. Applications do not call this function. Microsoft recommends that drivers implement power management based on Power Manager and power management IOCTLs.

NOTE

XXX prefix

In the function names, the prefix XXX is a placeholder that refers to the three-letter driver name. You need to replace this prefix with the actual name in the driver code, such as COM_Init for a driver called COM, or SPI_Init for a Serial Peripheral Interface (SPI) driver.

Оглавление книги


Генерация: 1.136. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз