Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows CE.NET Device Driver

Similar presentations


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

1 Windows CE.NET Device Driver

2 강의 내용 Windows CE 구조 Device Driver 구조 Device Driver 개발 실습 #1
Windows CE.Net

3 Windows CE 구조 (1) Windows CE.Net

4 Windows CE 구조 (2) Kernel의 주요 역할 메모리 관리 스케줄링 Win32 API 지원 Process 관리
32개 process, process당 32MB 크기 Windows 2000 process의 2GB 주소 영역 Thread 관리 Windows CE 3.0 이전은 8개의 thread priority Windows CE.NET은 256개의 thread priority Windows CE.Net

5 Windows CE 구조 (3) Windows CE Kernel은 “NK.EXE” “New Kernel” 이라는 의미
NK.LIB Kernel의 기능을 갖춘 library Microsoft OAL.LIB OEM hardware에 맞춘 layer 개발자 NK.LIB + OAL.LIB = NK.EXE Windows CE.Net

6 Windows CE 구조 (4) Memory Model Windows CE.Net

7 Windows CE 구조 (5) OEM Adaptation Layer(OAL) Windows CE.Net

8 Windows CE 구조 (6) Interrupt Sequence Windows CE.Net

9 Windows CE 구조 (7) OAL Interrupt Service Routine :
Xscale(PXA255)에서의 수정 사항 PLATFORM\HUINSPRO\KERNEL\HAL\cfwxsc1.c PLATFORM\HUINSPRO\KERNEL\HAL\ARM\intxsc1.c PLATFORM\HUINSPRO\INC\oalintr.inc PLATFORM\HUINSPRO\INC\oalintr.h Windows CE.Net

10 Device Driver 구조 Device Driver Overview
Built-in Device Driver VS Installable Device Driver Native Device Driver VS Stream Interface Device Driver Stream Device Driver Device Driver Loading Windows CE.Net

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

12 Device Manager Kernel에 의해 실행 되는 user-level 프로세스
[HKEY_LOCAL_MACHINE\init] “Launch20=“Device.exe” 디바이스 드라이버를 찾는 검색 루틴인 Regenum.dll을 호출 ActiveDeviceEX function을 호출하여, 적절한 디바이스 드라이버 검색 DeactiveDeivce function을 호출 드라이버 제거 Windows CE.Net

13 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.Net

14 Built-in Device Driver vs Installable Device Driver
Windows CE Device에 내장되어 OEM에 의해 설치되는 드라이버 디스플레이나 PC Card/USB 컨트롤러 Installable Device Driver Third Party가 공급 CE 장치의 최종 사용자가 하드웨어 소켓을 통해 언제든지 설치 프린터나 PC Card 장치 Windows CE.Net

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

16 Monolithic Device Driver vs Layered Device Driver (1)
상위 계층(MDD, Model Device Driver), 하위 계층(PDD, Platform Dependent Driver)으로 나눔 MDD는 디바이스 드라이버의 공통된 코드, 하드웨어와 연결 PDD는 특정 하드웨어에 맞춰진 코드 , native 또는 stream interface를 제공 Windows CE Platform Builder에 포함된 많은 드라이버들이 Layered Driver 하드웨어와 관련된 사항만을 구현하면 됨 드라이버 작성할 때의 노력을 감소 Monolithic Device Driver 동작과 관련된 인터페이스를 직접 구현 불필요한 call을 하지 않아 효율이 좋다. Interrupt service thread code, platform에 한정된 code Windows CE.Net

17 Monolithic Device Driver vs Layered Device Driver (2)
GWES(Graphics, Windowing, and Events Subsystem) DDI functions DDI functions Layered Device Drivers MDD Monolithic Device Drivers DDSI functions PDD Hardware Windows CE.Net

18 Stream Device Driver (1)
Device(ex: usb, ethernet)에 상관없는 일관된 인터페이스를 제공 논리적으로 데이터를 주고받는 디바이스에 적합 Stream 드라이버의 함수들이 File system API와 매칭 CreateFile, ReadFile, IOControl.. File 다루듯이 Stream Device를 다룸 응용 프로그램 개발자는 쉽게 디바이스에 접근 Stream 디바이스 드라이버 이름 규칙 Prefix(예, ‘COM1') 세 자리 문자 + Index 한 자리 숫자 Prefix와 Index는 레지스트리에 저장. Windows CE에서는 드라이버 이름 뒤에 ‘:’을 항상 붙인다. Windows CE.Net

19 Stream Device Driver (2)
xxx는 디바이스의 Prefix (예, Block 드라이버인 경우 DSK_Init) xxx_Init xxx_Deinit xxx_Open xxx_Close xxx_Read xxx_Write xxx_Seek xxx_IOControl xxx_PowerDown xxx_PowerUp Windows CE.Net

20 Stream Device Driver 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.Net

21 Streams Entry Points: Open and Close
Mobile & Embedded DevCon 2005 17년 3월 17일 19시 35분 28초 Streams 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을 불러 낸다. Windows CE.Net © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

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

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

24 Streams Entry Points: IOControl
XXX_IOControl File에 따라 필수적이지 않은 custom operation의 허용 I/O control code는 동작을 정의 I/O control code 은 device 마다 다름 Windows CE.Net

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

26 Stream Device Driver Interface (2)
DWORD XXX_Init( DWORD dwContext ); BOOL XXX_Deinit( DWORD hDeviceContext ); 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.Net

27 Stream Device Driver Interface (3)
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 DeviceIoCtlontrol xxx_PowerUp Windows CE.Net

28 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.Net

29 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.Net

30 Stream Device Driver 제작 (1)
다음과 같은 파일 작성 Driver file(.cpp, .h) Sources file .def file : export된 함수 포함 Dirs Makefile REG file BIB file Windows CE.Net

31 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.Net

32 FPGA Memory Map Windows CE.Net

33 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.Net

34 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.Net

35 HAL(Hardware Adaptation Layer)
~WINCE420/PLATFORM/PXA255PRO3/INC/xsc1bd.h Windows CE.Net

36 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.Net

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

38 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.Net

39 LED 디바이스 드라이버 작성 (1) 디바이스 드라이버 작성 헤드파일 작성 Def 파일 작성
/wince420/platform/pxa255pro3/drivers/fpga_led/fpga_led.cpp 헤드파일 작성 /wince420/platform/pxa255pro3/drivers/fpga_led/fpga_led.h Def 파일 작성 /wince420/platform/pxa255pro3/drivers/fpga_led/fpga_led.def Windows CE.Net

40 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.Net

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

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

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

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


Download ppt "Windows CE.NET Device Driver"

Similar presentations


Ads by Google