[Full]
完整版
[Rss]
訂閱
[Xml]
無圖版
[Xhtml]
無圖版
Rss
& SiteMap
曙海教育集團論壇
http://www.bjzhda.cn
曙海教育集團論壇
◎
曙海教育集團論壇
→
Windows驅動開發
→
Windows2000設備驅動程序的研制開發
共1 條記錄, 每頁顯示 10 條, 頁簽:
[1]
[瀏覽完整版]
標題:Windows2000設備驅動程序的研制開發
1樓
wangxinxin
發表于:2010-12-17 14:51:49
以下內容含腳本,或可能導致頁面不正常的代碼
由于工作關系,我經常涉及<font face="Times New="New" Roman">PC</font>機與外圍設備接口的工作,從<font face="Times New="New" Roman">PC</font>機這方面要做的工作看來,主要是通過接口處理外圍設備的中斷,通過<font face="Times New="New" Roman">I/O</font>端口或內存地址與外設互相傳遞數據。從<font face="Times New="New" Roman"></font>計算<font face="Times New="New" Roman"></font>機原理的角度看,所要達到的目的很簡單,那么如何編寫程序完成上述功能呢? 目前<font face="Times New="New" Roman"></font>國內流行的<font face="Times New="New" Roman">PC</font>操作系統有三種:<font face="Times New="New" Roman">DOS</font>,<font face="Times New="New" Roman">Win95/98</font>系列,<font face="Times New="New" Roman">WindowsNT</font>。<font face="Times New="New" Roman">DOS</font>是單用戶、單任務操作系統,由于<font face="Times New="New" Roman">PC</font>機硬件處理速度不斷提高,基于單用戶、單任務的操作系統越來越不能充分發揮硬件的功能,現在只<font face="Times New="New" Roman"></font>應用<font face="Times New="New" Roman"></font>于一些老式<font face="Times New="New" Roman">PC</font>及其它個別場合,有逐漸被淘汰的趨勢;<font face="Times New="New" Roman">Win95/98</font>系列和<font face="Times New="New" Roman">WindowsNT</font>屬于多任務操作系統,不論從其原理還是界面上看,這兩種操作系統都比<font face="Times New="New" Roman">DOS</font>有著無可比擬的優越性,這兩種操作系統雖然在界面和操作上及其相似,但其內部實現的諸多方面有許多區別,有些區別是本質上的。<font face="Times New="New" Roman">Win95/98</font>設計目標是針對一般家庭用戶,安全性及可靠性存在許多薄弱環節,就可靠性而言,<font face="Times New="New" Roman">Win95/98</font>系列不能很好的防止多任務環境中某個進程的非法操作導致系統中其它程序甚至整個系統的崩潰,而<font face="Times New="New" Roman">WindowsNT</font>在這方面及其它諸多方面設計的相當嚴謹。這兩種操作系統是<font face="Times New="New" Roman">Microsoft</font>公司同一時期的產品,但針對不同的使用群,所以在一些重要場合及生產實踐中應該選擇<font face="Times New="New" Roman">WindowsNT</font>作為<a title="計算機類相關論文" href="http://www.lwlm.com/search.aspx?Where=title&cid=0&Keyword=%BC%C6%CB%E3%BB%FA&x=36&y=10"><font color="#000000">計算機</font></a>的操作系統,此外,從<font face="Times New="New" Roman"></font>發展<font face="Times New="New" Roman"></font>趨勢來看,<font face="Times New="New" Roman">WindowsNT</font>已經成為定型產品,具有相對穩定性。 在不同操作系統下編寫驅動程序是有很大區別的,在<font face="Times New="New" Roman">DOS</font>平臺上,應用程序和設備驅動程序之間沒有標準的接口,它們在外部表現為一個擴展名為<font face="Times New="New" Roman">EXE</font>的文件,驅動程序的作用被柔和在應用程序中,這樣,應用程序為了使用不同廠商的同一類設備,必須了解這些設備在接口上具體的硬件實現,同時,對于一個特定型號的硬件產品,所有支持它的應用軟件中對于控制整個設備動作的這部分代碼,可能被多次重寫。這種情況不適應硬件及應用軟件的飛速發展。<font face="Times New="New" Roman">Windows</font>系統在這方面,進行了根本性改進,把控制設備動作的這部分代碼獨立出來,提出了設備驅動程序的概念<font face="Times New="New" Roman">,</font>驅動程序是應用程序和硬件設備之間的一個橋梁,應用程序與驅動程序之間有明確的接口,應用程序通過與驅動程序交換信息,達到控制外設的目的。接口定義的操作是面向設備的,這就是說,在應用程序的設計中,并不用關心對外設操作的具體硬件實現,只是對驅動程序發出一系列指令既可;驅動程序接受來自上層應用程序的指示,具體操縱實際硬件,完成用戶功能。具體實現上,<font face="Times New="New" Roman">Win95/98</font>系列與<font face="Times New="New" Roman">WindowsNT</font>又有所區別,<font face="Times New="New" Roman">WindowsNT</font>是嚴格按照上述思路設計的;而<font face="Times New="New" Roman">Win95/98</font>系列不那么嚴格,其支持上述思路,但同時應用程序也可以繞過驅動程序直接訪問實際物理<font face="Times New="New" Roman">I/O</font>,這樣做,增加程序設計的靈活性,但同時,對系統可靠性造成一定隱患。這也正是<font face="Times New="New" Roman">Win95/98</font>系列可靠性低于<font face="Times New="New" Roman">WinNT</font>的原因之一。 表<font face="Times New="New" Roman">1-1</font>三種操作系統下訪問接口比較 <table cellspacing="0" cellpadding="0" width="100%" border="1"> <tbody> <tr> <td width="33%"> 操作系統 </td> <td width="33%"> 應用程序訪問接口方式 </td> <td width="34%"> 訪問權限 </td></tr> <tr> <td width="33%"> <font face="Times New="New" Roman">DOS</font> </td> <td width="33%"> 直接訪問 </td> <td width="34%"> 所有<font face="Times New="New" Roman">[</font>注<font face="Times New="New" Roman">]</font> </td></tr> <tr> <td width="33%" rowspan="2"> <font face="Times New="New" Roman">Windows95/98</font> </td> <td width="33%"> 通過設備驅動程序<font face="Times New="New" Roman">*.VXD</font> </td> <td width="34%"> 所有<font face="Times New="New" Roman">[</font>注<font face="Times New="New" Roman">]</font> </td></tr> <tr> <td width="33%"> 直接訪問 </td> <td width="34%"> 僅<font face="Times New="New" Roman">I/O</font>端口 </td></tr> <tr> <td width="33%"> <font face="Times New="New" Roman">WindowsNT</font> </td> <td width="33%"> 通過設備驅動程序<font face="Times New="New" Roman">*.SYS</font> </td> <td width="34%"> 所有<font face="Times New="New" Roman">[</font>注<font face="Times New="New" Roman">]</font> </td></tr></tbody></table> <font face="Times New="New" Roman">[</font>注<font face="Times New="New" Roman">]‘</font>所有<font face="Times New="New" Roman">’</font>指<font face="Times New="New" Roman">I/O</font>端口,<font face="Times New="New" Roman">RAM</font>總線,中斷,<font face="Times New="New" Roman">DMA</font>。 <font face="Times New="New" Roman">WindowsNT</font>設備驅動程序的組成原理 <font face="Times New="New" Roman">WindowsNT</font>操作系統結構分為用戶模式和內核模式,用戶模式下的<a href="javascript:;" target="_self"><u><strong>編程</strong></u></a>為應用程序的設計,而開發設備驅動程序,則屬于內核模式下的編程,內核模式組件包括<font face="Times New="New" Roman">NT Executive(ExXxx),</font>內核<font face="Times New="New" Roman">(KeXxx),</font>硬件抽象層<font face="Times New="New" Roman">(HalXxx)</font>。其層次如圖<font face="Times New="New" Roman">2-1</font>所示,其中<font face="Times New="New" Roman">NT Executive</font>包括幾個獨立的軟件組件,它們是系統服務接口<font face="Times New="New" Roman">(ZwXxx)</font>,對象<a title="管理類相關論文" href="http://www.lwlm.com/search.aspx?Where=title&cid=0&Keyword=%B9%DC%C0%ED%A1%A1&x=35&y=9"><font color="#000000">管理</font></a>器<font face="Times New="New" Roman">(ObXxx)</font>,配置管理器,進程管理器<font face="Times New="New" Roman">(PsXxx)</font>,安全監視器<font face="Times New="New" Roman">(SeXxx)</font>,虛擬空間管理器<font face="Times New="New" Roman">(MemXxx)</font>,本地進程調用,<font face="Times New="New" Roman">I/O</font>管理器<font face="Times New="New" Roman">(IoXxx)</font>。內核模式的系統服務并不是全部公開的,而是提供了一系列開發設備驅動程序需要的函數<font face="Times New="New" Roman">(</font>上文括號內為函數形式,函數手冊參見<font face="Times New="New" Roman">[2]Kernel-Mode Drivers-Reference</font>章節<font face="Times New="New" Roman">)</font>,換言之,這些函數功能是所有內核模式的系統服務功能的子集。 驅動程序由一系列相對獨立的函數組成,由<font face="Times New="New" Roman">I/O</font><a title="管理類相關論文" href="http://www.lwlm.com/search.aspx?Where=title&cid=0&Keyword=%B9%DC%C0%ED%A1%A1&x=35&y=9"><font color="#000000">管理</font></a>器根據需要調用這些函數,對于一個需要處理中斷的最簡單的驅動程序也需要由以下幾個函數構成: <font face="Times New="New" Roman">1.DriverEntry()</font>運行于<font face="Times New="New" Roman">PASSIVE_LEVEL </font>驅動程序入口點,當驅動程序被手動或自動裝入系統后,驅動程序從這點開始執行,主要用于定位硬件資源,建立指向其它驅動程序函數的指針等其它初始化工作。 <font face="Times New="New" Roman">2.XxUnload()</font>運行于<font face="Times New="New" Roman">PASSIVE_LEVEL </font>用于驅動程序從系統卸出之前,釋放由驅動程序占用的所有系統資源。 <font face="Times New="New" Roman">3.XxIsr()</font>運行于<font face="Times New="New" Roman">DIRQL </font>中斷服務程序。 <font face="Times New="New" Roman">4.XxDpcForIsr()</font>運行于<font face="Times New="New" Roman">DISPATCH_LEVEL </font>中斷服務程序后處理程序,以排隊方執行不太關鍵代碼的執行,由于排隊機制及優先級,不會造成代碼擁塞從而提高中斷服務程序的響應并且提高系統總體<font face="Times New="New" Roman">I/O</font>吞吐率。 <font face="Times New="New" Roman">5.XxOpen()</font>運行于<font face="Times New="New" Roman">PASSIVE_LEVEL </font>處理應用程序<font face="Times New="New" Roman">Win32</font>函數<font face="Times New="New" Roman">CreateFile()</font>請求。 <font face="Times New="New" Roman">6.XxClose()</font>運行于<font face="Times New="New" Roman">PASSIVE_LEVEL </font>處理應用程序<font face="Times New="New" Roman">Win32</font>函數<font face="Times New="New" Roman">CloseHandle()</font>請求。 <font face="Times New="New" Roman">7.XxDispatch()</font>運行于<font face="Times New="New" Roman">PASSIVE_LEVEL </font>處理應用程序<font face="Times New="New" Roman">Win32</font>函數<font face="Times New="New" Roman">DeviceIoControl()</font>請求,通過一系列自定義命令,驅動程序與應用程序交換特定的信息。 <font face="Times New="New" Roman">WindowsNT</font>使用一個抽象化的<font face="Times New="New" Roman">CPU</font>優先級方案,<font face="Times New="New" Roman">IRQL</font>代表中斷請求級,任一時刻<font face="Times New="New" Roman">CPU</font>總處在某一級上,這個數越大,表示當前的任務重要性越大,如表<font face="Times New="New" Roman">2-1</font>所示,從上至下<font face="Times New="New" Roman">IRQL</font>越來越小。所有上述驅動程序的函數及內核模式函數都必須運行于各自的<font face="Times New="New" Roman">IRQL</font>級上,如果違反這一調用規定,會造成系統崩潰。例如,中斷服務程序<font face="Times New="New" Roman">(XxIsr)</font>運行于<font face="Times New="New" Roman">DIRQL</font>及上,那幺在編寫中斷服務程序時,只能調用允許在這一級運行的內核模式函數<font face="Times New="New" Roman">(</font>并不是所有內核模式函數都能運行于<font face="Times New="New" Roman">DIRQL</font>級<font face="Times New="New" Roman">)</font>。至于每個內核模式函數運行級別的說明,詳見<font face="Times New="New" Roman">[2]Kernel-Mode Drivers-Reference</font>章節。 <font face="Times New="New" Roman">WindowsNT</font>是一多任務系統,許多設備的驅動程序同時存在系統中,這樣各個設備所占用的資源<font face="Times New="New" Roman">(</font>中斷,<font face="Times New="New" Roman">I/O</font>及<font face="Times New="New" Roman">RAM</font>地址空間<font face="Times New="New" Roman">)</font>很有可能沖突,如果設備驅動程序在運行之前不進行<font face="Times New="New" Roman">‘</font>探測<font face="Times New="New" Roman">’</font>而使用自己硬件設備的資源,有可能和系統內其它設備占用的資源沖突,后果不堪設想。<font face="Times New="New" Roman">WindowsNT</font>通過注冊表<a title="管理類相關論文" href="http://www.lwlm.com/search.aspx?Where=title&cid=0&Keyword=%B9%DC%C0%ED%A1%A1&x=35&y=9"><font color="#000000">管理</font></a>硬件資源的占用信息,作為內核模式信任的組件,驅動程序使用硬件資源之前必須遵循<font face="Times New="New" Roman">‘</font>查詢<font face="Times New="New" Roman">-</font>申請<font face="Times New="New" Roman">-</font>使用<font face="Times New="New" Roman">-</font>釋放<font face="Times New="New" Roman">’</font>的原則<font face="Times New="New" Roman">(</font>如圖<font face="Times New="New" Roman">2-2</font>所示<font face="Times New="New" Roman">)</font>。 表<font face="Times New="New" Roman">2-1</font> <table cellspacing="0" cellpadding="0" width="100%" border="1"> <tbody> <tr> <td width="50%"> 來源 </td> <td width="50%"> <font face="Times New="New" Roman">IRQL</font> </td></tr> <tr> <td width="50%" rowspan="7"> 硬件 </td> <td width="50%"> <font face="Times New="New" Roman">HIGHEST_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">POWER_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">IPI_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">CLOCK2_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">CLOCK1_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">PROFILE_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">DIRQLs(I/O</font>設備中斷平臺相關的級數<font face="Times New="New" Roman">)</font> </td></tr> <tr> <td width="50%" rowspan="3"> 軟件 </td> <td width="50%"> <font face="Times New="New" Roman">DISPATCH_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">APC_LEVEL</font> </td></tr> <tr> <td width="50%"> <font face="Times New="New" Roman">PASSIVE_LEVEL</font> </td></tr></tbody></table> <font face="Times New="New" Roman">WindowsNT</font>設備驅動程序的編寫步驟與實例<font face="Times New="New" Roman"> </font>現以一實際例子簡要說明設備驅動程序的開發步驟,本例以<font face="Times New="New" Roman">CINRAD</font>天氣雷達測試卡實際應用為原型,加以簡化、抽象。
說明:
上面顯示的是代碼內容。您可以先檢查過代碼沒問題,或修改之后再運行.
共1 條記錄, 每頁顯示 10 條, 頁簽:
[1]
Copyright © 2000 - 2009
曙海
教育集團
Powered By
曙海教育集團
Version 2.2
Processed in .01563 s, 2 queries.
[Full]
完整版
[Rss]
訂閱
[Xml]
無圖版
[Xhtml]
無圖版
主站蜘蛛池模板:
四虎影视1515hh四虎免费
|
好吊妞视频一区二区
|
亚洲视频手机在线
|
老子午夜精品我不卡影院
|
国产精品视频九九九
|
中文字幕人成无码免费视频
|
日韩精品一区在线
|
亚洲黄色免费网址
|
精品久久久久中文字幕日本
|
国产成人av乱码在线观看
|
99精品国产在热久久
|
怡红院怡春院首页
|
久久精品一区二区影院
|
欧美77777
|
亲胸揉胸膜下刺激网站
|
精品人妻VA出轨中文字幕
|
国产在线爱做人成小视频
|
91短视频网站
|
夜鲁鲁鲁夜夜综合视频欧美
|
女性特黄一级毛片
|
久久久精品人妻一区二区三区蜜桃
|
有人有看片的资源吗www在线观看
|
伊人久久精品亚洲午夜
|
精品人妻VA出轨中文字幕
|
国产商场真空露出在线观看
|
69视频免费看
|
国外成人免费高清激情视频
|
中国一级特黄高清免费的大片中国一级黄色片
|
人人妻人人澡人人爽人人精品浪潮
|
精品小视频在线观看
|
国产大陆xxxx做受视频
|
2019中文字幕无线乱码
|
国产色a在线观看
|
xxxxhd93
|
好男人影视在线WWW官网
|
久久久久久国产精品视频
|
日本欧美在线观看
|
亚洲va欧美va
|
欧洲无码一区二区三区在线观看
|
亚洲精品成人片在线观看精品字幕
|
狠狠色狠狠色综合日日不卡
|