Windows Device Driver

Download Report

Transcript Windows Device Driver

Windows95 VxD Design
and Win32 Application inter face
발 표 : 노 원국
(컴퓨터 시스템 설계)
목
차
History of Device Driver for Windows
VxD Programming 환경
Two Scenario for VxD Programming
VxD Basic Conceptio
결 론
History of Device Drivers for Windows
Real-Mode Windows(DOS)
 MS-DOS and System BIOS가 Driver 제공
 Software Interrup를 이용하여 Driver Service export
 Application이 하드웨어 자원을 직접 제어
 BIOS가 Hardware Interrupt Managing
 Config.sys를 이용하여 Driver 등록
 .COM and .SYS type(tiny memory model)
Standard-Mode Windows(Win1.0)
 Windows는 단지 Large Graphics App에 불과
 Intel 80286의 출현으로 Protected Mode가 가능
 Protected Mode는 16M이상의 Physical Memory Access를 가능
History of Device Drivers for Windows
Standard-Mode Windows(cont’d)
 Processor가 Protected-Mode와 Real-Mode사이를 Switching하






여 Windows가 MS-DOS와 BIOS를 사용할 수 있도록 하는 Mode.
Window가 Real-Mode로의 Switching을 요구하지 않는 경우 발
생(Keystrokes or Mouse Motion)
Protected-Mode에서 I/O Interrupt를 Handle하는 ProtectedMode Device Driver가 요구
Mouse.Drv, Comm.Drv etc
.Drv는 16bit Ring-Three DLL
Protected-Mode하에서, Hardware와 Standard Windows Kernel,
User, GDI Module사이의 Interface를 담당
MS-DOS와 Windows는 Processor를 Reset(Reboot)하여 Switch
History of Device Drivers for Windows
Enhanced-Mode Windows(Win3.1)
 Intel 80386은 Real, Protected, V86 Mode를 지원
 V86(Virtualize 80386)은 Physical Machine을 Virtualization
 Application은 마치 자신이 Real Machine을 독점하여 사용하는





것처럼 동작(Multitask 개념 등장)
Enhanced Mode의 Main advantage는 Graphical desktop의
Window하에서 MS-DOS를 실행시킬 수 있다는 것
Driver의 형태는 기존의 xxx.Drv와 xxx.Dll, xxx.Vxd를 Support
그러나 Disk and File I/O는 MS-DOS and BIOS를 사용한다.
16bit Driver 사용
진정한 32bit OS라 할 수 없다.
History of Device Drivers for Windows
Windows95
 기존의 16bit Driver와 Application 지원
 Real, Protected, V86 Mode를 지원
 Ring-three Component 대신에 32bit, Ring-zero virtual Device




Driver사용(Vxd type-32bit Device Driver)
VxD는 Hardware와 Application사이의 모든 Interrupt를 Handling
하고 Data Transfer를 실행
Application은 VxD와 Communication을 하기 위하여 Function
Call을 사용
16bit Application과 16bit Device Driver의 Interface를 위하여
Software Interrupt INT 2Fh를 사용
32bit Application과 32bit Device Driver에서 Software Interrupt
사용이 불가능
History of Device Drivers for Windows
Windows95(cont’d)
 32bit App와 32bit Device Driver의 Interface는 단지 Win32




DeviceIoControl API function사용
Windows95는 Real Machine의 모든 Component(Hardware)를
가상화하여 System VxD를 제공한다.
VMM.VxD, VPICD.VxD, VCOMM.VxD
Hardware Design Vendor는 자신들의 Device를 위하여 Virtual
Device Driver를 제공해야 한다.
Microsoft는 순수한 32bit Device Driver Design을 권고하고 있으
며 Hardware에 관련된 모든 작업을 Device Driver에서 전담하고
App는 단지 Data를 조작하는 수준으로 만들도록 권고.
VxD Programming 환경
VxD Programming 환경
 Windows95 DDK (Microsoft MSDN)
 32bit Assembler (MSAM 6.11c)
 32bit C Complier & Linker (Visual C++ 2.0 이상)
VToolsD
 Vireo사의 DDK Tool
 C & C++로 VxD 작성가능
 완벽한 C Wrapper Function 제공
 풍부한 C++ Class Library 제공
 Quick VxD Wizzard를 이용한 VxD 기본 골격을 자동 생성
Two Scenario for VxD Programming
First Scenario




Hardware Resource를 VxD & Application에서 제어
I/O Trapping & Interrupt Virtualization 요구
Application 간 Thread Switching으로 인한 High Latency 문제
Ring-zero와 Ring-Three간 Switching으로 인한 High Latency
문제
Second Scenario
 Hardware Resource를 VxD에서 전담하여 처리
 Application은 처리할 Data만을 VxD로 넘겨주고 처리된 Data를
받아서 Windows Processing 수행
 I/O Trapping 불필요
 Interrupt의 경우 Hw_Int_Proc만을 고려하여 작성
 Microsoft에서 권장하고 있는 방법(32bit VxD)
VxD Basic Conception
Device Declaration Block(DDB)
 Device Driver의 구조에 대한 선언
 VMM과 Device Driver의 Communication에서 사용됨
 DDB에 선언되는 내용
- Device Driver Name
- Major Version
- Minor Version
- Control Procedure
- Device ID
- Initial Order
- V86 API Procedure(16bit Application에서 사용)
- PM API Procedure(16bit Application에서 사용)
VxD Basic Conception
Control Procedure
 VMM은 모든 Loaded VxDs로 System Control 메세지를 보낸다.
 VxD는 이들 Messages를 받기 위하여 Device Control Procedure
를 Export한다.(Begin_Control_Dispatch macro에서 정의)
 Procedure는 Message Code를 분석하고 SubProcedure를 실행
- Startup and Shutdown Message
- Virtual Machine Message
- Other Control Message(Dynamic VxD Message외 다수)
- Sys_Dynamic_Device_Init
- Sys_Dynamic_Device_Exit
- W32_DeviceIoControl
VxD Basic Conception
Dynamic Device Driver(Dynamic VxD)
 Sys_Dynamic_Device_Init
- Device가 Load되는 시점에 Device Driver 초기화하는 Routine
- I/O Port Virtualization
- Interrupt Virtualization
 Sys_Dynamic_Device_Exit
- Device가 Unload되는 시점에 Device Driver가 획득한
모든 Handle 및 Memory를 System에 반환하는 Routine
- I/O Port Trapping을 Remove
- Interrupt Virtualization Handle을 System에 반환
VxD Basic Conception
VxD & 16bit Application Interface
 Software Interrupt 사용
 DDB에서 선언된 V86 & PM API Procedure 이용
 INT 2Fh.. Function 1684h를 이용하여 API의 Address를 얻는
다.
 VM Control Block, Client_Register, Thread Control Block
Data Stucture를 이용
VxD Basic Conception
VxD & 32bit Application Interface
 CreateFile Function을 이용하여 VxD를 Load시키고 VxD에 대한






Handle을 얻는다.
Win32 Application과 Communication할 수 있는 유일한
Interface는 W32_DeviceIoControl Message를 이용
Device Driver Load시 VMM으로부터 첫번째
W32_DeviceIoControl Message 가 보내지고
Device Driver에서 이 Message를 받아 Interface가 생성
Application은 DeviceIoControl Function을 이용하여
W32_DeviceIoControl Message를 생성
Device Driver는 W32_DeviceIoControl Procedure를 정의하고
Application이 요구하는 일을 수행
SHELL_PostMessage Function 사용
VxD Basic Conception
Create File
Sys_Dynamic_Device_Init
Device Driver Handle
NO_ERROR
Win32
App
API
DeviceIoControl
Return Valve
VMM
VxD
W32_DEVICE_IO_CONTROL
Return
결
론
Windos Device Driver 개발의 필요성
 PC용 Hardware 개발자에게 있어서
 Windows95 OS는 많은 베일에 가려져 있다.
 더욱이 Win32 Application Software개발시
 현재 가장 많이 사용되는 Visual C++ & MFC에서는
 개발한 Hardware를 제어할 수 있는 Function이 거의 없다.
Device Driver 개발시 어려움
 Document가 거의 없다.
 Hardware & Software Bug의 출처를 파악하기 힘들다.
 Bug 발생시 System Down의 원인
 Source가 풍부하지 않다(Win32 Application & VxD)
참고자료
Systems Programming for Windows95
(Walter Oney Microsoft Press)
Writing Windows VxDs and Device Drivers
(Karen Hazzah R&D Books Lawrence, KS 66046)
http:\\www.numega.com
http:\\bd-lab.co.kr