Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows CE Device Driver

Similar presentations


Presentation on theme: "Windows CE Device Driver"— Presentation transcript:

1 Windows CE Device Driver

2 강의 내용 Device Driver 구조 Device Driver 개발 실습 #1 모바일운영체제 - Windows CE

3 Device Driver 구조 Device Driver Overview
Built-in Device Driver vs Installable Device Driver Native Interface Device Driver vs Stream Interface Device Driver Stream Interface Device Driver Device Driver Loading 모바일운영체제 - Windows CE

4 Device Driver Overview
다른 운영체제들과 마찬가지로 Windows CE 운영체제도 하드웨어 장치를 관리하고 운영하기 위한 Device Driver라고 불리는 소프트웨어를 사용 Device Driver는 운영체제와 디바이스를 연결하여 운영체제가 디바이스를 인식하고 디바이스가 제공하는 기능을 어플리케이션이 사용할 수 있도록 함. Windows CE에서 대개의 경우 Device Driver는 DLL (Dynamic-link library) 형식을 가지며, 기능 접근을 위해서 Win32 API를 사용한다. 모바일운영체제 - Windows CE

5 Graphics, Windowing, and Events Subsystem (GWES)
Device Manager Stream Interface Stream- Interface Driver Card and Socket Services Stream Interface (DDI) MDD Layer Native Driver Device Driver Service-Provider Interface (DDSI) PDD Stream Interface NDIS Card and Socket Services Stream Interface USBD HCD NDIS Wrapper NDIS Miniport USB Interface USB Driver Graphics, Windowing, and Events Subsystem (GWES) Device Driver Interface(DDI) Monolithic Native Driver Device Driver Interface(DDI) MDD Layerd Native Driver Device Driver Service-Provider Interface(DDSI) PDD The DDI Interface of native Drivers is defined by Microsoft for Each device class 모바일운영체제 - Windows CE

6 Device Manager “Device.exe” – 장치관리자 프로세스
Kernel에 의해 실행 되는 user-level 프로세스 [HKEY_LOCAL_MACHINE\init] “Launch20”=“Device.exe” 디바이스 드라이버를 찾는 검색 루틴인 Regenum.dll을 호출 스트림 인터페이스 드라이브 등록 함수를 호출하여 디바이스 드라이브 등록 RegisterDevice() / ActivateDevice() / ActivateDeviceEX() 스트림 인터페이스 드라이브 등록 해제 함수를 호출하여 드라이브 제거 DeregisterDevice() / DeactivateDevice() 모바일운영체제 - Windows CE

7 Built-in Device Driver vs Installable Device Driver
하드웨어 플랫폼에 내장된 장치에 대해 OEM에 의해 기본적으로 제공되는 드라이버 디스플레이 / PC Card / USB 컨트롤러 Installable Device Driver Third Party가 공급 CE 장치의 최종 사용자가 하드웨어 소켓을 통해 언제든지 설치 가능한 장치를 지원 프린터나 PC Card 장치 모바일운영체제 - Windows CE

8 Native Interface Device Driver vs Stream Interface Device Driver
Built-In Device Driver OS에 필수적인 Device Driver GWES.exe에 의해 로딩 및 관리 GWES.exe 프로세스 문맥하에서 동작 GWES.exe는 드라이버를 시스템이 부트 될 때 로드 Display, Keyboard, Mouse, Touch driver, battery, Notification LED Stream Interface Device Driver Application에서 Driver를 file처럼 다룬다. DEVICE.exe (Device Manager)에 의해 로딩 및 관리 DEVICE.exe 프로세스 문맥하에서 동작 DEVICE.exe 는 드라이버를 부트 시에 로드 부팅된 후에는 모든 프로세스가 stream interface driver를 로드 가능 Serial, Block, Audio driver 모바일운영체제 - Windows CE

9 Bus Interface Device Driver
Windows CE가 지원하는 특정 버스에 대하 서비스 드라이버 응용 프로그램에게 서비스를 제공하는 것이 아니라 클라이언트 디바이스 드라이버에게 서비스를 제공 예 : Serial driver가 USB 버스 또는 1394 버스를 사용하는 경우 USB 버스 드라이버가 serial driver에게 서비스를 제공  USB-serial driver 1394 버스 드라이버가 serial driver에 서비스를 제공  1394-serial driver DEVICE.exe 프로세스에 의해 로딩 및 관리 스트림 인터페이스 드라이버와 같은 프로세스 문맥하에 동작 종류 : REGENUM.dll(Legacy BUS) PCI.dll(CPI BUS) USBD.dll(USB BUS) PCMCIA.dll(PCMCIA BUS) 모바일운영체제 - Windows CE

10 Monolithic Device Driver vs Layered Device Driver (1)
드라이버 기능을 계층화하여 구현 상위 계층 – MDD(Model Device Driver) 하위 계층 – PDD(Platform Dependent Driver) MDD(Model Device Driver) 디바이스 드라이버의 공통된 코드 부분 해당 응용 프로그램과의 인터페이스를 지원 DDI(Device Driver Interface) 지원 native interface 또는 stream interface를 제공 소스, 정적 라이브러리(lib) 또는 DLL 형식으로 제공 PDD(Platform Dependent Driver) 특정 하드웨어에 맞추어 작성된 코드 부분 해당 하드웨어에 대해 직접적으로 입출력 또는 제어 MDD와의 인터페이스 지원 – DDSI(Device Driver Service Provider Interface) 모바일운영체제 - Windows CE

11 Monolithic Device Driver vs Layered Device Driver (2)
Layered Device Driver (con’t) Windows CE Platform Builder에 포함된 많은 드라이버들이 Layered Driver 형식을 가짐 $(_PUBLICROOT)/COMMON/OAK/DRIVERS 폴더 MDD는 이미 작성된 것을 적용함으로써 하드웨어와 관련된 사항(PDD)만을 구현하면 되므로 드라이버 개발 부담이 줄어듬 Monolithic Device Driver 동작과 관련된 인터페이스를 직접 구현 불필요한 call을 하지 않아 효율이 좋다 Interrupt service thread code, platform에 한정된 code 모바일운영체제 - Windows CE

12 Monolithic Device Driver vs Layered Device Driver (3)
Miniport Device Driver Layered device driver 유형 MDD가 정형화된 드라이버 형태(DLL)로 제공 디바이스 드라이버로서의 DDI를 지원 PDD 하드웨어를 직접 제어하는 부분을 DLL로 구현 MDD dll이 직접 로딩하여 접근 이런 유형의 PDD를 미니포트 드라이브(Miniport Device Driver)라고 한다 모바일운영체제 - Windows CE

13 Monolithic Device Driver vs Layered Device Driver (4)
GWES(Graphics, Windowing, and Events Subsystem) DDI functions DDI functions Layered Device Drivers MDD Monolithic Device Drivers DDSI functions PDD Hardware 모바일운영체제 - Windows CE

14 Stream Interface Device Driver (1)
I/O 장치를 하나의 파일로 간주하여 접근할 수 있도록 지원하는 인터페이스 방식 연속적인 데이터 전송을 지원하는 I/O 장치에 적합 장치 종류(ex: usb, ethernet)에 상관없는 일관된 인터페이스를 제공 디바이스 드라이버 개발이 용이 인터페이스 함수가 File system Win32 API와 매칭 CreateFile(), CloseHandle(), ReadFile(), WriteFile(), SetFilePointer(), DeviceIOControl() 등 응용 프로그램에서 입출력 기능 구현이 용이 모바일운영체제 - Windows CE

15 Stream Interface Device Driver (2)
디바이스 드라이버 이름 지정 Prefix(예, ‘COM1') 세 자리 문자 + Index 한 자리 숫자 Prefix와 Index는 레지스트리(Registry)에 저장 Windows CE에서는 드라이버 이름 뒤에 ‘:’을 항상 붙인다 디바이스 드라이버로서의 시스템 레지스트리가 필요 디바이스 드리이버 이름 및 드라이버 파일명 인터페이스 GUID 등 DLL 형식으로 작성하며, DDI 함수를 반드시 구현 DDI와 관련된 모든 함수는 export하여야 함(DEF 파일 사용) DEVICE.exe 프로세스에 의해 로딩되어 이 프로세스 문맥하에 동작 모바일운영체제 - Windows CE

16 Stream Interface Device Driver (3)
10개의 스트림 인터페이스 함수를 기본적으로 제공 xxx는 디바이스의 Prefix(예, Block 드라이버인 경우 DSK) xxx_Init xxx_Deinit xxx_Open xxx_Close xxx_Read xxx_Write xxx_Seek xxx_IOControl xxx_PowerDown xxx_PowerUp 모바일운영체제 - Windows CE

17 Stream Interface Device Driver (4)
DWORD XXX_Init( DWORD dwContext ); BOOL XXX_Deinit( DWORD hDeviceContext ); DWORD XXX_Open( DWORD hOpenContext, DWORD AccessCode, DWORD ShareMode ); DWORD XXX_Close( DWORD hOpenContext ); DWORD XXX_Read( DWORD hOpenContext, LPVOID pBuffer, DWOR Count ); DWORD XXX_Write( DWORD hOpenContext, LPCVOID pBuffer, DWORD Count ); DWORD XXX_Seek( DWORD hOpenContext, long Amount, WORD Type ); BOOL XXX_IOControl( DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut ); void XXX_PowerDown( DWORD hDeviceContext ); void XXX_PowerUp( DWORD hDeviceContext ); 모바일운영체제 - Windows CE

18 Stream Interface Entry Points: Init and Deinit
Mobile & Embedded DevCon 2005 17년 3월 17일 19시 34분 35초 Stream Interface Entry Points: Init and Deinit XXX_Init() Device Manager가 driver를 load할 때, 호출 사용되어지는 resource를 초기화 한다. Memory mapping XXX_Deinit() Device Manager가 driver를 unload할 때, 호출 Resource를 해제, IST 정지 XXX_PreDeinit() 모바일운영체제 - Windows CE © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

19 Stream Interface Entry Points: Open and Close
Mobile & Embedded DevCon 2005 17년 3월 17일 19시 34분 35초 Stream Interface Entry Points: Open and Close XXX_Open() Device를 read / write하기 위해 open 특정한 device fie이름을 open하기 위해 CreateFile을 호출할 때, application이 직접 이 function을 불러 낸다. 이 function이 호출되면, device는 각각의 context open과 동작을 위한 준비를 필요로 하는 resource에 allocate될 것이다. XXX_Close() CloseHandle은 OS에서 이 function을 불러 낸다. XXX_PreClose() 모바일운영체제 - Windows CE © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

20 Stream Interface Entry Points: Read, Write and Seek
Mobile & Embedded DevCon 2005 17년 3월 17일 19시 34분 35초 Stream Interface Entry Points: Read, Write and Seek XXX_Read() Application이 ReadFile function을 호출할 때 불려짐 XXX_Write() Application이 WriteFile function을 호출할 때 불려짐 XXX_Seek() 현재 I/O pointer를 이동하는 것을 허용 모바일운영체제 - Windows CE © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

21 Stream Interface Entry Points: IOControl
XXX_IOControl() File에 따라 필수적이지 않은 custom operation의 허용 I/O control code는 동작을 정의 I/O control code 은 device 마다 다름 모바일운영체제 - Windows CE

22 Stream Interface Entry Points: PowerUp and PowerDown
Mobile & Embedded DevCon 2005 17년 3월 17일 19시 34분 35초 Stream Interface Entry Points: PowerUp and PowerDown XXX_PowerUp() Device에서 power를 돌려 받음 XXX_PowerDown() Device에 power를 정지 Software의 제어 하에 shut off 될 수 있는 device인 경우 유용 모바일운영체제 - Windows CE © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

23 Stream Interface 호출 (1) Application Stream Interface Driver File APLs
Filesystem IOCTLs File System Windows CE Kernel Device Manager Loaded at boot time OAL Interrupt Events Hardware Platforms Built-in Device 모바일운영체제 - Windows CE

24 Stream Interface 호출 (2) Device Driver KERNEL Application xxx_Init
DEVICE.EXE xxx_Deinit CreateFile xxx_Open xxx_Close CloseHandle xxx_Read ReadFile xxx_Write WriteFile xxx_Seek xxx_IOControl SetFilePointer xxx_PowerDown Interrupt Handler() DeviceIoCtlontrol xxx_PowerUp 모바일운영체제 - Windows CE

25 Device Driver Loading (1)
Device Manager(Device.exe)가 시스템에 로드 Device.exe는 Regenum.dll(장치 열거자)을 이용 레지스트리에서 [HKEY_LOCAL_MACHINE\Drivers\Builtin] 안에 있는 드라이버들을 조사 목록과 초기화 할 순서를 생성 위 내용은 레지스트리에 있는 gpio_led 드라이버의 설정 값 ‘DLL'  드라이버 파일 이름(gpio_led) 'Prefix' - 디바이스 이름을 구성하는 세 글자의 이름 ‘Index' - Prefix와 디바이스 이름을 구성하는 숫자 ‘Order' - Regenum.dll가 드라이버 로딩할 순서를 결정 [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\GPIO_LED]     "Dll"="gpio_led.dll"     "Prefix"="LED"     "Index"=dword:1     "Order"=dword:0 모바일운영체제 - Windows CE

26 Device Driver Loading (2)
Regenum.dll는 위의 레지스트리를 읽어 드라이버(DLL)를 로드 드라이버의 Active 키를 생성 ActivateDevice 혹은 ActivateDeviceEx 함수를 사용 새로운 키 생성 [HKEY_LOCAL_MACHINE\Drivers\Active]에 생성 RegisterDevice 함수를 실행, 드라이버 로드 완료 RegisterDevice는 xxx_Init 함수를 호출하여 드라이버를 초기화 CreateFile이 드라이버를 Open Open 한 후, WriteFile, ReadFile, DeviceIoControl 등으로 디바이스를 제어 모바일운영체제 - Windows CE

27 Stream Device Driver 제작 (1)
다음과 같은 파일 작성 Driver file(.c, .cpp, .h) : device driver source 파일 Sources file : make source 등을 정의 .def file : export된 함수 포함 Makefile Dirs : Build 실행 시에 참조할 subdirectory 정의 BIB file : Kernel image에 포함할 모듈을 정의 REG file : Kernel 부팅 시에 로드할 드라이브를 정의 모바일운영체제 - Windows CE

28 Stream Device Driver 제작 (2)
PLATFORM/pxa255pro3/INC/xsc1bd.h에 Device Driver address 등록 (주)휴인스의 PXA255PRO보드의 CS3에 FPGA Board가 연결 OFFSET을 각각의 Device IO의 Physical / Virtual(cached, uncached) addess 등록 Device Driver는 이 address에 접근하여 IO Device 제어 모바일운영체제 - Windows CE

29 FPGA Memory Map 모바일운영체제 - Windows CE

30 FPGA Board I/O Port Address
I/O device 비고 PXA255Pro1 0x0c000002 LED LED 출력 포트 0x0c000004 FND FND 출력 포트 0x0c00001e DOT #1 DOT #1 출력 포트 0x0c000018 Step Motor Step Motor 제어 포트 0x0c00001c Text LCD 명령어 포트 0x0c00001a 데이터 포트 0x0c ~0x0c000014 ADC ADC 입력값 FIFO(16Btes) 0x0d000016 DAC DAC 출력값FIFO(16Btes) 모바일운영체제 - Windows CE

31 FPGA Board I/O Port Address
I/O device 비고 PXA255Pro3 0x0c000016 LED LED 출력 포트 0x0c000002 FND FND 출력 포트 0x0c000004 DOT #1 DOT #1 출력 포트 0x0c00000c Step Motor Step Motor 제어 포트 0x0c000014 Text LCD 명령어 포트 0x0c000012 데이터 포트 0x0c800000 ADC ADC 입력값 FIFO(16Btes) 0x0d000000~0x0d000020 DAC DAC 출력값FIFO(16Btes) 0x0c800004 CDS CDS 출력값 모바일운영체제 - Windows CE

32 HAL(Hardware Adaptation Layer)
C:/WINCE420/PLATFORM/PXA255PRO3/INC/xsc1bd.h 모바일운영체제 - Windows CE

33 Device Driver 개발실습 #1 (1) LED Device Driver 제작 Kernel에 Address 등록
Stream device driver 작성 fpga_led.def 파일 작성 sources 파일 작성 makefile 파일 작성 Platform.bib / platform.reg 수정 Application 작성 LED control 모바일운영체제 - Windows CE

34 Device Driver 개발실습 #1 (2) Test Application 제작
디버깅 모드에서 디바이스를 테스트 할 수 있는 어플리케이션 제작 Platform Builder에서 작성 모바일운영체제 - Windows CE

35 LED 개요 Light Emitting Diode 순방향 전압시 다이오드 접합부 발광 D1 –D4 : Red
D5 – D8 : Green D1~D8 주소에 0 : On, 1 : Off Bit 7 6 5 4 3 2 1 LED D8 D7 D6 D5 D4 D3 D2 D1 모바일운영체제 - Windows CE

36 LED 디바이스 드라이버 작성 (1) 디바이스 드라이버 작성 헤드파일 작성 Def 파일 작성
/wince500/platform/Huinspro3/drivers/fpga_led/fpga_led.cpp 헤드파일 작성 /wince500/platform/Huinspro3/drivers/fpga_led/fpga_led.h Def 파일 작성 /wince500/platform/Huinspro3/drivers/fpga_led/fpga_led.def 모바일운영체제 - Windows CE

37 LED 디바이스 드라이버 작성 (2) Sources 파일 작성 OS 이미지에 드라이버 추가 레지스트리 등록
/wince420/platform/pxa255pro3/drivers/fpga_led/sources OS 이미지에 드라이버 추가 /wince420/platform/pxa255pro3/cesysgen/files/platform.bib 레지스트리 등록 /wince420/platform/pxa255pro3/cesysgen/files/platform.reg 모바일운영체제 - Windows CE

38 LED 디바이스 드라이버 작성 (3) 소스 빌드 OS이미지 생성
PB상에서 build – open build release directory fpga_led 디렉토리로 이동 커맨드라인에서 set WINCEREL = 1 입력 커맨드라인에서 build –cfs OS이미지 생성 커맨드라인에서 makeimg 모바일운영체제 - Windows CE

39 LED 테스트 프로그램 작성 (1) 신규 작성 Platform Builder의 File 메뉴에서 New Project or File..을 실행 적절한 어플이케이션 이름을 Project name에 작성한다. A simple Windows CE application을 선택한다. 소스코드를 작성 Build 또는 Build(selection only)를 실행하여 빌드한다. 모바일운영체제 - Windows CE

40 LED 테스트 프로그램 작성 (2) 기존의 프로젝트 추가
소스코드를 적절한 경로에 복사한다.(예, C:\WINCE420\PUBLIC\huinspro3_HH) Platform Builder의 File View 창에서 Insert Existing Project를 선택 *.pbp 파일을 선택한다.(제공된 소스를 카피한 디렉토리의 파일) 프로젝트가 추가되었다.(File View 창에서 확인) Build 또는 Build(selection only)를 실행하여 빌드한다. 모바일운영체제 - Windows CE

41 다운로드 및 테스트 다운로드 테스트 테스트 프로그램 종료 PB 상에서 Target – Run programs
Available program에서 led_test_app.exe 선택 테스트 프로그램 종료 PB상에서 Target – CE Target Control 타겟 컨트롤창에서 gi all 입력 타겟 컨트롤창에서 kp 프로세스번호 입력 모바일운영체제 - Windows CE


Download ppt "Windows CE Device Driver"

Similar presentations


Ads by Google