Nicolas Besson - Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Здесь есть возможность читать онлайн «Nicolas Besson - Microsoft Windows Embedded CE 6.0 Exam Preparation Kit» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Redmond, Год выпуска: 2008, Издательство: Microsoft, Жанр: Руководства, ОС и Сети, Программы, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Microsoft Windows Embedded CE 6.0 Exam Preparation Kit: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Microsoft Windows Embedded CE 6.0 Exam Preparation Kit — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

1. Device context<\/strong>The driver initializes this context in the XXX_Init function. This context is therefore also called the Init Context. Its primary purpose is to help the driver manage resources related to hardware access. Device Manager passes this context information to the XXX_Init, XXX_Open, XXX_PowerUp, XXX_PowerDown, XXX_PreDeinit and XXX_Deinit functions.<\/p>

2. Open context<\/strong>The driver initializes this second context in the XXX_Open function. Each time an application calls CreateFile for a stream driver, the stream driver creates a new open context. The open context then enables the stream driver to associate data pointers and other resources with each opened driver instance. Device Manager passes the device context to the stream driver in the XXX_Open function so that the driver can store a reference to the device context in the open context. In this way, the driver can retain access to the device context information in subsequent calls, such as XXX_Read, XXX_Write, XXX_Seek, XXX_IOControl, XXX_PreClose and XXX_Close. Device Manager only passes the open context to these functions in the form of a DWORD parameter.<\/p>

The following code listing illustrates how to initialize a device context for a sample driver with the driver name SMP (such as SMP1:):<\/p>

DWORD SMP_Init(LPCTSTR pContext, LPCVOID lpvBusContext) {<\/code> <\/p>

T_DRIVERINIT_STRUCTURE *pDeviceContext = (T_DRIVERINIT_STRUCTURE *)<\/code> <\/p>

LocalAlloc(LMEM_ZEROINIT|LMEM_FIXED, sizeof(T_DRIVERINIT_STRUCTURE));<\/code> <\/p>

if (pDeviceContext == NULL) {<\/code> <\/p>

DEBUGMSG(ZONE_ERROR,(L" SMP: ERROR: Cannot allocate memory "<\/code> <\/p>

+ "for sample driver's device context.\r\n"));<\/code> <\/p>

// Return 0 if the driver failed to initialize.<\/code> <\/p>

return 0;<\/code> <\/p>

}<\/code> <\/p>

// Perform system intialization...<\/code> <\/p>

pDeviceContext->dwOpenCount = 0;<\/code> <\/p>

DEBUGMSG(ZONE_INIT,(L"SMP: Sample driver initialized.\r\n"));<\/code> <\/p>

return (DWORD)pDeviceContext;<\/code> <\/p>

}<\/code> <\/p>

Building a Device Driver<\/p> <\/div>

To create a device driver, you can add a subproject for a Windows Embedded CE DLL to your OS design, but the most common way to do it is to add the device driver's source files inside the Drivers folder of the Board Support Package (BSP). For detailed information about configuring Windows Embedded CE subprojects, see Chapter 1, "Customizing the Operating System Design."<\/p>

A good starting point for a device driver is A Simple Windows Embedded CE DLL Subproject, which you can select on the Auto-Generated Subproject Files page in the Windows Embedded CE Subproject Wizard. It automatically creates a source code file with a definition for the DllMain entry point for the DLL, various parameter files, such as empty module-definition (.def) and registry (.reg) files, and preconfigures the Sources file to build the target DLL. For more detailed information about parameter files and the Sources file, see Chapter 2, "Building and Deploying a Run-Time Image."<\/p>

Implementing Stream Functions<\/p> <\/div>

Having created the DLL subproject, you can open the source code file in Visual Studio and add the required functions to implement the stream interface and required driver functionality. The following code listing shows the definition of the stream interface functions.<\/p>

// SampleDriver.cpp : Defines the entry point for the DLL application.<\/code> <\/p>

//<\/code> <\/p>

#include "stdafx.h"<\/code> <\/p>

BOOL APIENTRY DllMain(HANDLE hModule,<\/code> <\/p>

DWORD ul_reason_for_call, LPVOID lpReserved) {<\/code> <\/p>

return TRUE;<\/code> <\/p>

}<\/code> <\/p>

DWORD SMP_Init(LPCTSTR pContext, LPCVOID lpvBusContext) {<\/code> <\/p>

// Implement device context initialization code here.<\/code> <\/p>

return 0x1;<\/code> <\/p>

}<\/code> <\/p>

BOOL SMP_Deinit(DWORD hDeviceContext) {<\/code> <\/p>

// Implement code to close the device context here.<\/code> <\/p>

return TRUE;<\/code> <\/p>

}<\/code> <\/p>

DWORD SMP_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode) {<\/code> <\/p>

// Implement open context initialization code here.<\/code> <\/p>

return 0x2;<\/code> <\/p>

}<\/code> <\/p>

BOOL SMP_Close(DWORD hOpenContext) {<\/code> <\/p>

// Implement code to close the open context here.<\/code> <\/p>

return TRUE;<\/code> <\/p>

}<\/code> <\/p>

DWORD SMP_Write(DWORD hOpenContext, LPCVOID pBuffer, DWORD Count) {<\/code> <\/p>

// Implement the code to write to the stream device here.<\/code> <\/p>

return Count;<\/code> <\/p>

}<\/code> <\/p>

DWORD SMP_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count) {<\/code> <\/p>

// Implement the code to read from the stream device here.<\/code> <\/p>

return Count;<\/code> <\/p>

}<\/code> <\/p>

BOOL SMP_IOControl(DWORD hOpenContext, DWORD dwCode,<\/code> <\/p>

PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut,<\/code> <\/p>

DWORD dwLenOut, PDWORD pdwActualOut) {<\/code> <\/p>

// Implement code to handle advanced driver actions here.<\/code> <\/p>

return TRUE;<\/code> <\/p>

}<\/code> <\/p>

void SMP_PowerUp(DWORD hDeviceContext) {<\/code> <\/p>

// Implement power management code here or use IO Control.<\/code> <\/p>

return;<\/code> <\/p>

}<\/code> <\/p>

void SMP_PowerDown(DWORD hDeviceContext) {<\/code> <\/p>

// Implement power management code here or use IO Control.<\/code> <\/p>

return;<\/code> <\/p>

}<\/code> <\/p>

Exporting Stream Functions<\/p> <\/div>

Making the stream functions in the driver DLL accessible to external applications requires the linker to export the functions during the build process. C++ provides several options to accomplish this, yet for driver DLLs compatible with Device<\/p>

Manager, you must export the functions by defining them in the .def file of the DLL subproject. The linker uses the .def file to determine which functions to export and how to do so. For a standard stream driver, you must export the stream interface functions using the prefix that you specify in the driver's source code and registry settings. Figure 6-3 shows a sample .def file for the stream interface skeleton listed in the previous section.<\/p>

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit»

Представляем Вашему вниманию похожие книги на «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit»

Обсуждение, отзывы о книге «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x