44

Developing Windows CE 5.0 OAL

  • Upload
    gordon

  • View
    56

  • Download
    0

Embed Size (px)

DESCRIPTION

Developing Windows CE 5.0 OAL. Li-Ming Fan Escalation Engineer Microsoft GCR-GTSC. Agenda. Windows CE 5.0 BSPs and Kernels Development Process OAL Architecture and Design Boot Sequence and Required OAL Functions Kernel and KITL Optional OAL Functions Building Power Management. - PowerPoint PPT Presentation

Citation preview

Page 1: Developing Windows CE 5.0 OAL
Page 2: Developing Windows CE 5.0 OAL

DevelopingDevelopingWindows CE 5.0 OAL Windows CE 5.0 OAL

Li-Ming Fan

Escalation Engineer

Microsoft GCR-GTSC

Page 3: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 4: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 5: Developing Windows CE 5.0 OAL

Windows CE 5.0 BSPsWindows CE 5.0 BSPs/CSPs

Family BSP/CSP Kernel

ARM

Intel Mainstone II ARMV4I

Samsung SMDK-2410 ARMV4I

CSP Only - Intel Xscale Lubbock ARMV4I

MIPS

AMD DBAu1000 MIPSII

AMD DBAu1100 MIPSII

AMD DBAu1500 MIPSII

NEC Solution Gear2 Vr4131 MIPSII

NEC Solution Gear2 Vr5500 MIPSII & II_PF, MIPSIV & IV_FP

Broadcom VoIP Reference MIPSII

SH SH4 Aspen SH4

x86

x86 (CEPC) x86

x86 Emulator x86

Geode x86

• Intel Assabet and Lubbock (use Mainstone II)• ARM Integrator (use Samsung SMDK2410)• SH3 Keywest (deprecated)

BSPs NO LONGER SUPPORTED

Page 6: Developing Windows CE 5.0 OAL

Windows CE 5.0 Kernels• Kernels & OS builds in 4.2 = 9

– ARMV4, ARMV4I, ARMV4T– MIPSIIB/16, MIPSII, MIPSII_FP, MIPSIV, MIPSIV_FP– SH3, SH4– x86

• Kernels & OS builds in 5.0 = 7– ARMV4I, ARMV4– MIPSII, MIPSII_FP, MIPSIV, MIPSIV_FP– SH4, SH3– x86

Page 7: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 8: Developing Windows CE 5.0 OAL

BSP Development Process

Test Hardware,Test Hardware,Rom MonitorRom Monitor

Develop Develop Boot LoaderBoot Loader

Clone Reference Clone Reference BSPBSP

Power Power ManagementManagement

Develop OAL Develop OAL (Minimal Kernel)(Minimal Kernel)

Add Add Device DriversDevice Drivers

Package Package (CEC/MSI)(CEC/MSI)

Page 9: Developing Windows CE 5.0 OAL

Boot Loader Architecture

A typical development boot loader

blcommonblcommon

OEM codeOEM code

ebooteboot

……

NE

200N

E200

00 RT

L813

RT

L813

99 DP

83815D

P83815

bootpartbootpart

flash FMDflash FMD

EDBG driversEDBG drivers

Page 10: Developing Windows CE 5.0 OAL

Bootloader Architecture• Blcommon – generic boot loader framework• OEM code – general board init and extensions• Eboot – Ethernet functions (UDP, DHCP, TFTP)• EDBG drivers – Ethernet drivers

– 3Com 3C90x, AMD AM79C97x, CS8900A, NS DP83815, NE2000, RealTek RTL8139, SMSC9000 & SMSC100

• Bootpart – storage partition management• FMD – flash management driver

– Samsung/Sandisk (NAND), Intel StrataFlash (NOR)

Page 11: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 12: Developing Windows CE 5.0 OAL

Windows CE 5.0 BSPs• Reduce OS “bring-up” time on OEM hardware• Avoid changing the "public" OAL interface• Provide production features (power management, performance

optimizations, IOCTLs, etc.)• Maximize code re-use (and testing)• Provide a consistent OAL architecture that can be easily

extended/customized• Increase BSP coverage in-the-box

– One BSP for each supported CPU

– Integrate BSPs into the IDE Catalog

– Integrate BSPs into the Platform Wizard

• Enable third parties to create BSPs easily– Ship CSP drivers for many CPUs and SOCs

– PB Tools - BSP Wizard and IDE tools

– Enables faster, easier porting to OEM devices

Page 13: Developing Windows CE 5.0 OAL

PQOAL Design

• Collection of OAL software libraries organized by CPU architecture (or model) and by OAL “function”

• Common Code Directory Structure

• BSP configuration files are located in a single location (platform\<BSP>\src\inc)

RTCRTC

Cach

e L

ibrary

Inte

rrup

t L

ibrary

IOC

TL

L

ibrary

Startu

p

Lib

rary

RT

CL

ibrary

KIT

LL

ibrary

OS

Tim

erL

ibrary

TimersTimers CachesCaches SerialSerialportport

EthernetEthernetportport

USBUSBportport

OALOAL

KernelKernel

HardwareHardware

Page 14: Developing Windows CE 5.0 OAL

Directory Structure Example

platform\common\src

inc

ARM

common

cache

memory

ARM720T

ARM920T

Intel

Samsung S3C2410

inc

interrupt

power

RTC

startup

timer

MIPS, SHx, x86

common

platform\<BSP_name>

cesysgen

files

intltrns

0409

src

bootloader

kernel

OAL

kern

kernkitl

kernkitlprof

inc

common

debug

drivers PCMCIA

Common code directory BSP code directory

Page 15: Developing Windows CE 5.0 OAL

BSP Configuration Files• BSP configuration files are located in a single

location (platform\<BSP>\src\inc)– Simplifies porting/customization work– Consistent file naming scheme

• args.h – bootloader-OAL shared memory structure• bsp.h – master bsp include file• bsp_base_regs.h – board-level address definitions• bsp_cfg.h – general BSP configs (device name, clock

settings,…)• image_cfg.h – memory layout address definitions• ioctl_cfg.h – definitions used by BSP IOCTL routines• ioctl_tab.h – IOCTL function table• kitl_cfg.h – KITL transport name/device/driver table• oemaddrtab_cfg.inc – (ARM/x86) VA-PA mapping table

Page 16: Developing Windows CE 5.0 OAL

Shared Design

• Chip/set Support Package (CSP) drivers will share include files that define hardware registers and layout

public\common\oak\csp\arm\samsung\s3c2410x\inc:public\common\oak\csp\arm\samsung\s3c2410x\inc:

s3c2410x.h

s3c2410x.inc

s3c2410x_adc.h

s3c2410x_base_regs.h

s3c2410x_base_regs.inc

s3c2410x_clkpwr.h

s3c2410x_dma.h

s3c2410x_iicbus.h

s3c2410x_iisbus.h

s3c2410x_intr.h

s3c2410x_ioport.h

s3c2410x_lcd.h

s3c2410x_memctrl.h

s3c2410x_nand.h

s3c2410x_pwm.h

s3c2410x_rtc.h

s3c2410x_sdi.h

s3c2410x_spi.h

s3c2410x_uart.h

s3c2410x_usbd.h

s3c2410x_wdog.h

Page 17: Developing Windows CE 5.0 OAL

Creating A BSP• BSP wizard

– IDE Tool to clone BSP or create a BSP definition – Can add/remove drivers to a BSP definition

• Export wizard– IDE Tool to export feature components from the IDE Catalog to other

PB users– Creates a MS Windows Installer (MSI) file

• CEC editor– IDE Tool to create and/or edit .CEC files– A .CEC file defines the properties of an object/component in the IDE

catalog – No more .bsp files

• Two methods to create a BSP– Use the command line method– Use the BSP Wizard – Both methods rely on cloning a sample BSP

Page 18: Developing Windows CE 5.0 OAL

Creating An OAL• Create directory for OAL code in the BSP

– platform\<BSPname>\kernel\oal– Add <dirname> to “dirs” file to build OAL with BSP

• Required OAL functions– Startup– Debug serial– OEMInit– System timer– Interrupt processing– Kernel input/output, KITL

• Optional OAL functions (Platform Dependent)– Real-time clock and timer– Parallel port I/O code– Ethernet port debug

• More information in PB docs– “How-to Create an OEM adaptation layer”

Page 19: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 20: Developing Windows CE 5.0 OAL

Required OAL Functions

• Startup

• Debug Serial

• OEMInit

• System Timer

• Interrupt Processing

• Kernel Input/Output

• Example: Custom Kernel IOCTL

• KITL

Page 21: Developing Windows CE 5.0 OAL

StartUp

• First function called when target device boots

• Purpose is to initialize CPU to known state and to call the kernel initialization function (KernelInitialize for x86 and KernelStart on all other platforms)

ARM ARM exampleexample

LEAF_ENTRY StartUp . . .; Initialize CPU to a known state; Set up OEMAddressTable for KernelStart . . .bl KernelStart . . .; KernelStart should never return

LEAF_ENTRY StartUp . . .; Initialize CPU to a known state; Set up OEMAddressTable for KernelStart . . .bl KernelStart . . .; KernelStart should never return

Page 22: Developing Windows CE 5.0 OAL

CE 5.0 Boot SequenceBoot loader startup sequence

Startup()

EbootMain()

BootloaderMain()

OEMDebugInit()

OEMPlatformInit()

OEMPreDownload()

Download Occurs

OEMLaunch()

Kernel startup sequence

Startup()

KernelStart()

ARMInit()

OEMInitDebugSerial()

OEMInit()

KernelInit()

HeapInit()

InitMemoryPool()

ProcInit()

SchedInit()

FirstSchedule()

SystemStartupFunc()

IOCTL_HAL_POSTINIT

Page 23: Developing Windows CE 5.0 OAL

Debug Serial

• OEMInitDebugSerial()– Configures Speed, Parity, Stop bit length

• OEMReadDebugByte()– Retrieves a byte from the debug monitor port

• OEMWriteDebugByte()– Outputs a byte to the debug monitor port

• OEMWriteDebugString()– Writes a string to the debug monitor port

Page 24: Developing Windows CE 5.0 OAL

OEMInit

• Required task is to set up hardware and register interrupt for the system tick

• ISRs and HookInterrupt

• Setting Up the Interrupt Map– Define a mapping of Interrupt IDs

• Mapping can be dynamic at driver load time

– Interrupt IDs’ are returned by the ISRs to the kernel and are used to link an incoming IRQ with a software IST

Page 25: Developing Windows CE 5.0 OAL

OEMInit: An Example

Void OEMInit() { SetUpInterruptMap(); PCIInitBusInfo(); InitDebugEther(); OEMParallelPortInit() InitPICs(); InitClock(); if (MainMemoryEndAddress == CEPC_EXTRA_RAM_START) { MainMemoryEndAddress += IsDRAM(MainMemoryEndAddress, CEPC_EXTRA_RAM_SIZE); } pKDIoControl = OEMKDIoControl;}

Void OEMInit() { SetUpInterruptMap(); PCIInitBusInfo(); InitDebugEther(); OEMParallelPortInit() InitPICs(); InitClock(); if (MainMemoryEndAddress == CEPC_EXTRA_RAM_START) { MainMemoryEndAddress += IsDRAM(MainMemoryEndAddress, CEPC_EXTRA_RAM_SIZE); } pKDIoControl = OEMKDIoControl;}

Page 26: Developing Windows CE 5.0 OAL

Interrupt Processing• OEMInterruptEnable()

– Performs hardware operations necessary to allow a device to generate the specified interrupt

– Includes• Setting a hardware priority for the device• Setting a hardware interrupt enable port• Clearing any pending interrupt conditions from the device

• OEMInterruptDisable()– Disables the specified hardware interrupt

• OEMInterruptDone()– Unmasked and reenables of interrupt processing

Page 27: Developing Windows CE 5.0 OAL

Interrupt Processing• OEMGetInterrupt()

– Used by the any device wanting and IRQ. Example PCI bus

• OEMRequestSysIntr()– Used in the OEMIoControl routine to implement

IOCTL_HAL_TRANSLATE_IRQ and IOCTL_HAL_REQUEST_SYSINTR

• OEMTranslateIrq()– Used by the main ISR to translate a non-shareable IRQ

into a SYSINTR

• OEMTranslateSysIntr()– Translates a SYSINTR to its corresponding IRQ

Page 28: Developing Windows CE 5.0 OAL

System Timer

• Make sure the system timer interrupt is registered with the ISR

• Program the system timer to generate an interrupt every 1ms – Can also support variable tick

• In the system timer ISR, update the global system tick counter CurMSec and CurTicks. If reschedule time is expired then return SYSINTR_Resched else SYSINTR_NOP

Page 29: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 30: Developing Windows CE 5.0 OAL

Kernel LibrariesLibrary Description

kern.exe kernkitl.exe kernkitlprof.exe

   basickernel

kernel w/ dbg suppt

kernel w/ profiling suppt

Nk.lib Microprocessor-specific Kernel code that MS supplies X X  

Hal.lib OAL that you implement for target HW X X X

NkProf.lib Profile version of the MS Kernel code     X

KITL.lib Kernel Independent Transport Layer (KITL) debugging services   X X

SMC9000 Sample Ethernet debugging driver. Must have for KITL suppt X X X

FullLibc Microsoft C Run-Time Library X X X

Page 31: Developing Windows CE 5.0 OAL

Kernel Input/Output

• OEMIoControl is called by the kernel when a device driver or application program calls the KernelIoControl function

• Extend the Ethernet Debugging Interface

BOOL OEMIoControl(. . .) { switch (dwIoControlCode) { case IOCTL_HAL_SET_DEVICE_INFO : case IOCTL_HAL_REBOOT: . . . default: return FALSE; } return TRUE;}

BOOL OEMIoControl(. . .) { switch (dwIoControlCode) { case IOCTL_HAL_SET_DEVICE_INFO : case IOCTL_HAL_REBOOT: . . . default: return FALSE; } return TRUE;}

Page 32: Developing Windows CE 5.0 OAL

Example: Custom Kernel IOCTL

#define IOCTL_MY_CONTROL1 \ CTL_CODE(FILE_DEVICE_HAL, 2048, METHOD_NEITHER, FILE_ANY_ACCESS)BOOL OEMIoControl(. . .) { switch (dwIoControlCode) { case IOCTL_MY_CONTROL1: . . . }RetCode = KernelIoControl( IOCTL_MY_CONTROL1 , . . . );

#define IOCTL_MY_CONTROL1 \ CTL_CODE(FILE_DEVICE_HAL, 2048, METHOD_NEITHER, FILE_ANY_ACCESS)BOOL OEMIoControl(. . .) { switch (dwIoControlCode) { case IOCTL_MY_CONTROL1: . . . }RetCode = KernelIoControl( IOCTL_MY_CONTROL1 , . . . );

Page 33: Developing Windows CE 5.0 OAL

KITLKernel Independent Transport Layer

• Designed to provide an easy way for you to support any debug service

• OEM Function to implement is OEMKitlINit

• Including the KITL support in the operating system image

• Vmini not always necessary. EDBG driver can talk directly to desktop

• Passive KITL also available

Page 34: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 35: Developing Windows CE 5.0 OAL

Optional OAL Functions

• Real-time Clock and Timer

• OEMGetExtensionDRAM()

Page 36: Developing Windows CE 5.0 OAL

Real-time Clock And Timer• OEMGetRealTime()

– Called by the kernel to get the time from the real-time clock

• OEMSetRealTime() – Sets the real time clock

• OEMSetAlarmTime()– Sets the alarm time

• OEMQueryPerformanceCounter()– Retrieves the current value of the high-resolution

performance counter, if one exists • OEMQueryPerformanceFrequency()

– Retrieves the frequency of the high-resolution performance counter, if one exists

Page 37: Developing Windows CE 5.0 OAL

OEMGetExtensionDRAM()

• pNKEnumExtensionDRAM AND OEMEnumExtensionDRAM

Example 2Example 2 Extended Extended 4MB DRAM 4MB DRAM available at available at 0x818000000x81800000

Example 1Example 1 No extension No extension DRAM DRAM availableavailable

BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen)

{ return FALSE; // no extension DRAM}

BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen)

{ *lpMemStart = 0x81800000; *lpMemLen = 0x00400000; // 4MB return TRUE;}

BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen)

{ return FALSE; // no extension DRAM}

BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen)

{ *lpMemStart = 0x81800000; *lpMemLen = 0x00400000; // 4MB return TRUE;}

Page 38: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 39: Developing Windows CE 5.0 OAL

Building OAL and Kernel• No longer necessary to SYSGEN OAL libraries• Shared OAL code is built just before the BSP directory (platform\common)• BSP kernel (kernkitl.exe) sources file:

TARGETLIBS= \ $(_COMMONOAKROOT)\lib\$(_CPUDEPPATH)\nk.lib \ $(_TARGETPLATROOT)\lib\$(_CPUDEPPATH)\oal.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_startup_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_abort_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_cache_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_memory_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUDEPPATH)\oal_io_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_intr_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_timer_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_rtc_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_ioctl_s3c2410x.lib \ $(_PLATCOMMONLIB)\$(_CPUDEPPATH)\oal_other.lib \ $(_PLATCOMMONLIB)\$(_CPUDEPPATH)\oal_log.lib \ $(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\ddk_io.lib \ $(_COMMONOAKROOT)\lib\$(_CPUDEPPATH)\kitl.lib \ $(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\fulllibc.lib \ $(_PLATCOMMONLIB)\$(_CPUINDPATH)\oal_ethdrv_cs8900a.lib

Page 40: Developing Windows CE 5.0 OAL

Agenda

• Windows CE 5.0 BSPs and Kernels

• Development Process

• OAL– Architecture and Design– Boot Sequence and Required OAL Functions– Kernel and KITL– Optional OAL Functions– Building – Power Management

Page 41: Developing Windows CE 5.0 OAL

OAL Power Management Functions

• OAL Power Management Functions– OEMIdle – Puts the CPU in reduced power

mode– OEMPowerOff – Puts the CPU in suspend

mode

Page 42: Developing Windows CE 5.0 OAL

Tools & Resources

msdn.microsoft.com/msdn.microsoft.com/ embeddedembedded

microsoft.public.microsoft.public. windowsxp.embeddedwindowsxp.embedded windowsce.platbuilderwindowsce.platbuilder windowsce.embedded.vcwindowsce.embedded.vc

blogs.msdn.com/blogs.msdn.com/ mikehallmikehall

Windows CE 5.0 Eval KitWindows CE 5.0 Eval KitWindows XP Embedded Eval KitWindows XP Embedded Eval Kit

msdn.microsoft.com/msdn.microsoft.com/ mobilitymobility

microsoft.public.microsoft.public. pocketpc.developer pocketpc.developer smartphone.developer smartphone.developer dotnet.framework.compactframeworkdotnet.framework.compactframework

blogs.msdn.com/blogs.msdn.com/ windowsmobilewindowsmobile vsdteamvsdteam netcfteamnetcfteam

Windows Mobile 5.0 Eval KitWindows Mobile 5.0 Eval Kit

WebsitesWebsites

NewsgroupsNewsgroups

BlogsBlogs

ToolsTools

BuildBuild DevelopDevelop

Page 43: Developing Windows CE 5.0 OAL

请在课程结束后填写课程培训反馈表,参加抽奖。

请填写资料袋内的蓝色大会满意度反馈表,到大会接待台领取《 Windows Mobile手机应用开发》工具书。

您还可以:参加 Windows Mobile 动手实验室;参观微软及合作伙伴展区;体验基于 Windows Mobile 平台开发的最新硬件产品及解决方案。

大会注意事项

Page 44: Developing Windows CE 5.0 OAL