WDM Driver Design System Environment Settings

Source: Internet
Author: User

System environment settings when writing USB device drivers, developers need to use the following software: 1. Microsoft Visual C ++. 2. the SDK (software development kit) is optional. 3. DDK (driver development kit, driver development kit ). Visual c ++ is an integrated development environment that contains a standard compilation tool (compiler and Connection Program). It can be used to establish a device driver in kernel mode by correct settings. Although other compilation tools can do this, most WDM driver developers prefer to use visual c ++, it provides users with a good programming environment, a convenient debugger, and some useful tools (such as rebase and guidgen), all of which contribute to driver development. SDK is a software development kit provided by Microsoft, which contains more tools than visual C ++. It is an optional software component for device driver development. DDK is a driver development kit provided by Microsoft. It is a required software component for developing Device Drivers and can be downloaded from Microsoft's website at an annual fee. Windows 98 uses Win98 DDK, which is installed in the 98ddk folder by default; Windows 2000 uses Win2000 DDK, which is installed in the ntddk folder by default. After the ddkinstallation is complete, the bindirectories in the folder contain executable files, such as build.exe (used to create drivers) and setenv. BAT (used to set the driver's Build Environment). They are indispensable tools for creating drivers. If you select full installation, the src directory also contains the source code of some device drivers, such as for Win98 DDK, the/98ddk/src/USB directory contains the source code of the USB driver. For Win2000 DDK, the content is stored in the/ntddk/src/WDM/USB directory. For USB device drivers, Win98 DDK and win2000 DDK are roughly the same, but there are some slight differences between them, such as setupapi. the H header file is different, and the folders that are constructed and checked are different. The two drivers cannot be mixed, that is, they cannot use Win2000 DDK-compiled drivers in Windows 98, nor use Win98 DDK-compiled drivers in Windows 2000. It is worth noting that visual C ++ must be installed before DDK is installed. Otherwise, when setenv. bat is used to DDK, it will not be able to correctly set the construction environment. For Windows 98 operating systems, Win98 DDK, compilation tools, and assembly tools all use additional environment space to search for paths in the storage area. Therefore, it may need to increase its environment space, the method is config in the C root directory. add or modify the following command in the SYS file: shell = C:/command.com/P/E: 4096 this command sets the Windows 98 environment space to 4096 bytes. If you receive the "out of Environment Space" message when creating a driver, developers should increase the environment space for Windows 98. This problem does not exist in Windows 2000. During Win98 DDK installation, a "Development Kits/Windows 98 DDK" directory is created under the "program" folder of the operating system. The directory contains two executable files: "Free Build Environment (Free Build Environment)" and "checked build environment (check the Build Environment )". For Win2000 DDK, the corresponding directory is "Development Kits/Windows 2000 DDK", and the executable file name is the same as Win98 DDK. Before creating a device driver, developers must run one of the two executable files. They call the setenv. BAT file of DDK to create the driver construction environment and set an environment variable. The final version of the device driver is created in the free construction environment. It optimizes the source code of the driver and disables the debugging statement, all debugging information is deleted, so that the driver has the advantages of short refining, fast running, and low memory usage. Check the construction environment for debugging or testing the driver, it creates an unoptimized debug version that executes the debug statements in the driver and contains all the debugging information. They help the driver Developers find errors in the driver. Generally, all drivers should be debugged and tested in the check environment first, and hidden internal errors have been found. After the driver can run normally in the check environment, developers need to re-compile the driver in a free environment to obtain its optimal version. Check the version of the driver, because almost all driver developers cannot ensure that the driver they develop can be successful once without debugging. That is, the device driver must be debugged during development. Visual c ++ debugging programs cannot be used for kernel-mode code, that is, the device driver cannot be debugged. However, Microsoft provides other auxiliary debugging tools. For Windows 98, developers can use wdeb386.extand wdeb98.exe. For Windows 2000, developers can use windbg.exe system tools. However, this tool has a fatal drawback: it must be used between two computers to complete debugging. To overcome this disadvantage, driver developers can use debugging tools provided by other third-party manufacturers, such as conpuware numega SoftICE debugging software, it can run on the same computer as the tested driver. When setting the driver's Build Environment, developers can also manually call setenv at the MS-DOS prompt, instead of directly running the Free Build Environment or checked build environment executable file. the command format is as follows: setenv [Free | checked] The first parameter of the command specifies the installation path of the DDK (such as C:/98ddk ); the second parameter is optional, indicating the created constructor environment. The default value is "free", that is, to create a free constructor environment. "checked" indicates to create a check constructor environment. For example, if you type setenv C:/98ddk at a MS-DOS prompt, it creates a Free Build Environment for the driver. After the setenv command is executed, a command prompt window similar to ms_dos appears on the computer screen. In this window, developers can use the build tool to create the driver they have written, A typical method is to first enter the directory where the driver is located, and then run the "Build-c" command. This command will search for all the driver source files and execute "completely create" (before creating the driver, it will delete all existing. OBJ files ). After the driver is executed, the executable files of the driver are created in the corresponding directory (specified by the source file of the build tool ). Now we can use the driver provided by DDK. Taking USB block transfer as an example, the steps are as follows: 1. Create the driver construction environment. For Windows 98, Run "Start/Program/Development Kits/Windows 98 DDK/Free Build Environment (or checked build environment)" on its taskbar )", 1. Establish a free construction environment for the driver or check the construction environment. For Windows 2000, you need to run related files under the "Windows 2000 DDK" directory. Of course, you can also use the manual call method described earlier. 2. Enter the directory where the driver source file is located. For Windows 98 DDK, the device driver source files that support USB Block Transmission are stored in the src/USB/bulkusb/sys folder. If WIN 98 DDK is installed in the C:/98ddk directory, you can enter the command "cd c:/98ddk/src/USB/bulkusb/sys ". For Windows 2000 DDK, these source files are stored in the "src/WDM/USB/bulkusb/sys" folder. 3. Use the build tool to compile the driver source file to obtain the executable file. Enter the command "Build-c" at the command prompt ". After the command is executed, a new bulkusb can be found in "lib/i386/free (or checked)" in the "Win 98 DDK" directory. SYS file, which is the executable file of the driver. For Win2000 DDK, the executable file is stored in "objfre/i386" or "objchk/i386" in its source file directory. The file name you love is bulkusb. sys.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.