{"id":403,"date":"2014-04-11T14:27:34","date_gmt":"2014-04-11T14:27:34","guid":{"rendered":"http:\/\/praveenkatiyar.wordpress.com\/?p=403"},"modified":"2014-04-11T14:27:34","modified_gmt":"2014-04-11T14:27:34","slug":"introduction-to-device-driver-development","status":"publish","type":"post","link":"https:\/\/praveenkatiyar.in\/blog\/index.php\/2014\/04\/11\/introduction-to-device-driver-development\/","title":{"rendered":"Introduction to Device Driver Development"},"content":{"rendered":"<div id=\"title\">\n<h1><a rel=\"bookmark\"><font face=\"Times New Roman\"><font style=\"font-size:18pt;\" color=\"#0066cc\"><font style=\"font-weight:bold;\">Introduction to Device Driver Development <\/font><\/font><\/font><\/a><\/h1>\n<\/p><\/div>\n<div id=\"maincontent\">\n<div id=\"maincontent_inner\">\n<div id=\"post-29\" class=\"post-29 post type-post status-publish format-standard hentry category-codeproject category-ddk category-device-driver category-driver-development tag-codeproject tag-ddk tag-device-driver\">\n<div class=\"post-info\">\n<div><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">What is a&#160; device driver<\/font><\/font><\/div>\n<\/p><\/div>\n<div class=\"content\">\n<p><font face=\"Times New Roman\"><font color=\"#000080\"><span><font style=\"font-size:12pt;\">Merely connecting the hardware device to the computer and providing it power is not sufficient for a device to function in a desired manner. <\/font><\/span><font style=\"font-size:12pt;\"><span>In a nutshell, the device driver is a software interface to hardware connected to a computer. It is a trusted part of the operating system. From the user application point of view, the device driver is the abstract connection to the device, and the user application should access the device without having to worry about how the hardware must be controlled,&#160; so<\/span><\/font><span><font style=\"font-size:12pt;\"> a device driver is a piece of software that enables a particular hardware device to function properly. Device driver is so named because it drives the operations of the device, in other words a device driver <strong>instructs the hardware device to perform different operations<\/strong>. Almost all externally or internally connected hardware device requires a device driver for its functioning.<\/font><\/span><\/font><\/font><\/p>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Device driver program although is a separate piece of program is considered to be a part\/extension of&#160; the Operating System. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">The Operating System becomes dynamically extensible by the use of device drivers. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Newer hardware can be added to the system, and installing their respective drivers, without recompiling the operating system, on the other way around, drivers can be updated to run on a newer version of OS. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Since <strong>device drivers becomes an extension to the OS<\/strong>, it is <strong>highly trusted<\/strong>, can perform operations, which are normally not allowed through application programs. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">In a multitasking environment like windows, hardware devices are a shared resources between all the running programs. allowing hardware access from application program can result in conflict if multiple applications try to access the same device at the same timey. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Device driver <strong>can not to be integral part of the Operating System<\/strong>. because <\/font><\/font><\/span>\n<ul>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Each hardware device internally operates in a different way than another. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">New hardware devices continue to evolve at a rapid rate, so it will not be practical to modify, recompile, and redistribute the OS again and again to accommodate the functionality of a new hardware. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">By keeping the code for controlling hardware devices in a separate module the operating system remains independent of any particular hardware devices.<\/font><\/font><\/span><\/li>\n<\/ul>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">Types of device driver<\/font><\/font><\/h3>\n<h4><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">From Functional point of view<\/font><\/font><\/h4>\n<p><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Every device driver<\/font><\/strong><font style=\"font-size:12pt;\"> program <strong>does not controls a hardware device<\/strong>. <\/font><span><font style=\"font-size:12pt;\">From the functional point of view device driver can be classified in to following categories.<\/font><\/span><\/font><\/font><\/span><\/p>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">A <strong>File System driver<\/strong> <strong>never interacts<\/strong> with with any physical hardware, The FSD (File System Driver is responsible for handling I\/O requests from application, converting these requests to a low level form(<strong>C<\/strong>ylinder, <strong>H<\/strong>ead, <strong>S<\/strong>ector request) and passing it to <strong>another driver<\/strong>. this another driver actually interacts with the physical storage device.&#160;&#160; <\/font><\/font><\/span><\/li>\n<li><font face=\"Times New Roman\"><font color=\"#000080\"><span><span><strong><font style=\"font-size:12pt;\">Another type <\/font><\/strong><font style=\"font-size:12pt;\">of driver programs is to write very <strong>low level system utilities<\/strong>, because they are trusted part of the system, so they can do things, which are normally not possible in application level code. these activities may include <\/font><\/span><\/span><span><font style=\"font-size:12pt;\">reading\/writing directly with I\/O Ports, device registers etc.<\/font><\/span><\/font><\/font><\/li>\n<li><span><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">System utilities<\/font><\/strong><font style=\"font-size:12pt;\"> in particular, sometimes have an additional module in the form of a driver that performs much of the low level activities on the behalf of the utility. <strong>System Monitoring utilities<\/strong> are the best example of this category, for example. <\/font><\/font><\/font><\/span><\/span>\n<ul>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">File Monitor, Disk Monitor, and other similar utilities, normally have two modules, one is a driver at its core, and the other is a GUI application which polls this driver and displays the desired activities.<\/font><\/font><\/span><\/li>\n<\/ul>\n<\/ul>\n<\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">An <strong>antivirus program may take help of a driver<\/strong> program to accomplish many of its activities like. <\/font><\/font><\/span>\n<ul>\n<ul>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Scanning memory areas of all the running processes including the <strong>O<\/strong>perating <strong>S<\/strong>ystem. <\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">providing auto protect feature, where by any program that is being scanned for a virus, if a virus is found, the antivirus program stops the execution of the said program.<\/font><\/font><\/span><\/li>\n<\/ul>\n<\/ul>\n<\/ul>\n<\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Driver code <strong>can also be used to emulate physical hardware devices<\/strong>. for example there are lot of commercial\/freeware\/shareware utilities available that can emulate a CDROM device.<\/font><\/font><\/span><\/li>\n<\/ul>\n<h4><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">From the lens of operating System<\/font><\/font><\/h4>\n<p><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">with the advent of Windows XP (NT based) OS as a main consumer windows, driver for 16 bit windows and MS-DOS does not make any sense. So when we talk about driver we simply means a Ring\u20130 driver unless and until explained otherwise. which can be different from functional point of view as explained above<\/font><\/font><\/span><\/p>\n<p><a><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;float:none;padding-top:0;padding-left:0;margin-left:auto;display:block;padding-right:0;margin-right:auto;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/developdriver.files.wordpress.com\/2013\/08\/image_thumb.png?w=619&amp;h=297\" width=\"619\" height=\"297\" \/><\/a><\/p>\n<p><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Kernel mode (Ring-0) drivers further can be divided into several categories as shown below.<\/font><\/font><\/span><\/p>\n<p><a><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/developdriver.files.wordpress.com\/2013\/08\/image_thumb1.png?w=623&amp;h=292\" width=\"623\" height=\"292\" \/><\/a><\/p>\n<p><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Kernel-mode drivers further can be divided into following subcategories. <\/font><\/font><\/span><\/p>\n<ul>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">A PnP driver<\/font><\/strong><font style=\"font-size:12pt;\"> is a kernel-mode driver that understands the Plug and Play protocols of Windows XP.&#160; <\/font><\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">WDM driver <\/font><\/strong><font style=\"font-size:12pt;\">is a PnP driver that understands power-management protocols and is <strong>source compatible with both Windows 98\/Me and Windows 2000\/XP<\/strong>. These type of drivers can be further subcategorized to. <\/font><\/font><\/font><\/span>\n<ul>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\"><font color=\"#000080\"><strong>Class drivers<\/strong> are those who manage a device belonging to some well-defined class of device.<\/font><\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Mini drivers <\/font><\/strong><font style=\"font-size:12pt;\">are those, who supply vendor-specific help to a class driver. <\/font><\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Monolithic Function drivers <\/font><\/strong><font style=\"font-size:12pt;\">are those<strong> <\/strong>which <strong>embody all the functionality<\/strong> needed to support a hardware device.<\/font><\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Filter drivers<\/font><\/strong><font style=\"font-size:12pt;\"> are those who \u201c<strong>filter\u201d the I\/O operations for a particular device<\/strong> in order <strong>to add or modify behavior<\/strong>.<\/font><\/font><\/font><\/span><\/li>\n<\/ul>\n<\/ul>\n<\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">File system drivers <\/font><\/strong><font style=\"font-size:12pt;\">implement the standard PC file system model (which includes the concepts of a hierarchical directory structure containing named files) on local hard disks or over network connections. These, too, are kernel-mode drivers.<\/font><\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Legacy device drivers <\/font><\/strong><font style=\"font-size:12pt;\">are kernel-mode drivers that directly control a hardware device without help from other drivers. This category essentially <\/font><strong><font style=\"font-size:12pt;\">includes drivers for earlier versions of Windows NT.<\/font><\/strong><\/font><\/font><\/span><\/li>\n<\/ul>\n<h3><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">What is required for writing a device driver<\/font><\/font><\/h3>\n<p><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Drivers for windows use a variety of architectures, and involve <strong>understanding of lot of complicated concepts<\/strong> including.<\/font><\/font><\/span><\/p>\n<ul>\n<ul>\n<ul>\n<li><span><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Learn hardware details<\/font><\/strong><font style=\"font-size:12pt;\">, one must has to to know the details of his hardware environment, memory mapping\/addressing, device registers and mapping, accessing them in an architecture independent manner. <\/font><\/font><\/font><\/span><\/span><\/li>\n<li><span><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Learning driver architecture<\/font><\/strong><font style=\"font-size:12pt;\">&#8211; drivers for windows follow a very specific architecture, that is a very well defined interface for an application to communicate with a driver, again when the <strong>O<\/strong>perating <strong>S<\/strong>ystem needs to communicate with the driver it follows a different packet driven model.<\/font><\/font><\/font><\/span><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font color=\"#000080\"><strong><font style=\"font-size:12pt;\">Learn Key Windows Concepts<\/font><\/strong><font style=\"font-size:12pt;\">, basically device driver is an extension to the <strong>O<\/strong>perating <strong>S<\/strong>ystem, writing device drivers needs a lot of details of windows internals.<\/font><\/font><\/font><\/span><\/li>\n<\/ul>\n<\/ul>\n<\/ul>\n<h3><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">DDK\/WDK<\/font><\/font><\/h3>\n<p><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">there are several <strong>DDK\/WDK<\/strong> are available form Microsoft\u2019s website depending version of windows.&#160; the latest version was <strong>Windows Driver Kit 7600 <\/strong>(WDK 7600). These kits are available free of cost.<\/font><\/font><\/span><\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"608\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"49\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">S.N.<\/font><\/font><\/td>\n<td valign=\"top\" width=\"113\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">DDK Version<\/font><\/font><\/td>\n<td valign=\"top\" width=\"444\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">Supported Operating Systems.<\/font><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"49\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">1<\/font><\/font><\/td>\n<td valign=\"top\" width=\"113\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">3790<\/font><\/font><\/td>\n<td valign=\"top\" width=\"444\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">Windows 2000, Windows XP<\/font><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"49\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">2<\/font><\/font><\/td>\n<td valign=\"top\" width=\"113\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">7600<\/font><\/font><\/td>\n<td valign=\"top\" width=\"444\"><font face=\"Times New Roman\"><font style=\"font-size:12pt;\">XP, Vista, Windows Server 2003, Windows 7, Windows Server 2008<\/font><\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><font face=\"Times New Roman\"><font style=\"font-weight:bold;\">Books &amp; online reference.<\/font><\/font><\/h3>\n<ul>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">First and foremost, <strong>Programming the Windows Driver Model<\/strong> by <strong>Walter Oney<\/strong>, can be said to be the <strong>Bible<\/strong> for driver development.<\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Programming the Windows Driver for Windows 2000, by Art Baker and Guy Lazano.<\/font><\/font><\/span><\/li>\n<li><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Windows NT Device Driver by Peter G. Viscarola.<\/font><\/font><\/span><\/li>\n<li><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">Windows Internals by Mark Russinovich<\/font><\/font><\/li>\n<\/ul>\n<p><span><font face=\"Times New Roman\"><font style=\"font-size:12pt;\" color=\"#000080\">there are several DDK\/WDK are available form Microsoft\u2019s website depending version of windows.&#160; the latest version was Windows Driver Kit 7600&#160; (WDK 7600). These kits are available free of cost.<\/font><\/font><\/span><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Device Driver Development What is a&#160; device driver Merely connecting the hardware device to the computer and providing it power is not sufficient for a device to function in a desired manner. In a nutshell, the device driver is a software interface to hardware connected to a computer. It is a trusted part&hellip; <a class=\"more-link\" href=\"https:\/\/praveenkatiyar.in\/blog\/index.php\/2014\/04\/11\/introduction-to-device-driver-development\/\">Continue reading <span class=\"screen-reader-text\">Introduction to Device Driver Development<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[20],"class_list":["post-403","post","type-post","status-publish","format-standard","hentry","category-ddk","category-driver-development","tag-device-driver","entry"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=403"}],"version-history":[{"count":0,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/403\/revisions"}],"wp:attachment":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}