How to load the driver under WinCE (excerpt)

xiaoxiao2021-03-06  39

Device Manager is a core organization of Windows CE.NET device management, which is mainly responsible for tracking, maintaining system information and provisioning device resources. (You can see the code of the Windows CE Device Manager in% Winceroot% / Private / Wince ON / CETER / CIB)

Device Manager is mainly manifested as device.exe file in Windows CE. Device.exe is loaded in the system boot by the hkey_local_machine / init / "launch20" = "Device.exe" load (Windows CE startup, respectively) [HKEY_LOCAL_MACHINE / INIT] Under the procedure of all subrogaburs) Device Manager is a user-level program that is constantly running on Windows CE-based platforms. Equipment Manager is not part of the kernel, but it is a separate section that is interacting with the kernel, registry, and flow port driver. Device Manager completes the following tasks:

1) Initialize the loading of the driver when the system is started or received by the user to add a peripheral device.

2) Register a specific file name to the kernel, which maps the current I / O function used by the application to the implementation of those of the flow port driver.

3) Find the driver of the device by obtaining a plug-and-play sign from the peripheral device, or activating a check subroutine to find a driver that can be processed, find a suitable driver for the peripheral device.

4) Load the tracking driver by reading and writing registration values.

5) When the device is no longer needed, the driver is responsible for uninstalling the driver.

The loading of the initial stream driver at the time of system startup. There are three ways to load the flow driver.

The first load type is performed when the system is started. When the platform of Winows CE is started, start the device manager. Device Manager loads the entry point from the HKEY_LOCAL_MACHINE / DRIVERS / ROOTKEY of the registry, usually the value of rootkey is set to Drivers / Builtin. The device manager then begins to read HKEY_LOCAL_MACHINE / DRIVERS / Buillin health via the entry point provided by / rootkey and loads the listed stream driver.

The second load is to automatically detect the peripheral device device and the WINDOWS CE platform is automatically detected. The PC card is the most common type of automatic detection device, as the PC card slot control program is notified to Windows CE when the user is inserted into the PC card. When the user inserts the PC card into the slot, the device management program call driver (this is an internal device manager) to find a plug-and-play sign. Then, the device management program checks HKEY_LOCAL_MACHINE / Drivers / PCMCIA has got a subkey that matches the plug and play mark. If there is a subkey exists, the subkey loads the driver in the key value list. If there is no match, the device manager calls all the detection functions of the hkey_local_machine / drivers / pcmcia / detect key. If there is a function returns a value, the device management program is loaded and initializes that stream driver.

The third load type is that when the device manager program is not able to automatically detect or load a driver, most of this appear on the serial device because Windows CE cannot automatically detect serial devices. This time you can load the driver using the function ActiVatedEviceEx function provided by the system. Let's take a look at the ActivatedEviceEx function.

ActivatedEviceEx is used to load drivers. In fact, the implementation of Windows CE is connected to the system via the startONEDRIVER function, but this function is a pure internal function. Its implementation is achieved by ActivatedEviceex. % Winceroot% / Private / WinceOS /

The implementation of the ActiVatedEviceEx function can be found in the file device.c in the Coreos / Device / Lib / Directory. Its code section is as follows: Handle Fs_ActiVatedEviceEx (

LPCTSTR LPSZDEVKEY,

LpcRegini LPREG,

DWORD CREG,

LPVOID LPVPARAM

)

{

Debugmsg (1, (Text ("Device! ActivatedEviceEx (% s) entered / r / n"), lpszdevkey);

CELOG_ACTIVATEDEVICE (LPSZDEVKEY);

Return StartONEDRIVER

LPSZDEVKEY,

MAX_LOAD_ORDER,

LPREG, CREG, LPVPARAM;

}

The function of ActivatedEviceEx is simple. It is just responsible for calling the StartONedriver function. This function will initialize different device drivers based on the registry settings. Device.exe is called this function when the system is started to load to load the corresponding driver. This function will cause a specific driver loading process. Let's introduce the running process of StartONEDRIVER.

{

Debugmsg (1, (Text ("Device! ActivatedEviceEx (% s) entered / r / n"), lpszdevkey);

CELOG_ACTIVATEDEVICE (LPSZDEVKEY);

Return StartONEDRIVER

LPSZDEVKEY,

MAX_LOAD_ORDER,

LPREG, CREG, LPVPARAM;

}

The function of ActivatedEviceEx is simple. It is just responsible for calling the StartONedriver function. This function will initialize different device drivers based on the registry settings. Device.exe is called this function when the system is started to load to load the corresponding driver. This function will cause a specific driver loading process. Let's introduce the running process of StartONEDRIVER.

转载请注明原文地址:https://www.9cbs.com/read-52308.html

New Post(0)