emb321 how to write a windows ce sdio client jay loney - program manager steve schrock – software...
TRANSCRIPT
EMB321EMB321
How To Write AHow To Write AWindows CE SDIO ClientWindows CE SDIO Client
Jay Loney - Program ManagerJay Loney - Program ManagerSteve Schrock – Software EngineerSteve Schrock – Software EngineerWindows CEWindows CEMicrosoft CorporationMicrosoft Corporation
MManagementanagementTToolsools
CCommunicationsommunications& & MMessagingessaging
Device Update Agent
Software Update Services
Live Communications Server
Exchange Server
Internet Security and Acceleration Server
Speech Server
Image Update
LLocation ocation SServiceservices
MMultimediaultimedia
MapPoint
DirectX
Windows Media
Visual Studio 2005DDevelopment evelopment TToolsools
MFC 8.0, ATL 8.0
Win32NNativeative
MManagedanaged
SServer erver SSideide
LLightweightightweight
RRelationalelationalSQL Server 2005 Express EditionEDB
DDa
taata
PPro
gra
mm
ing
ro
gra
mm
ing
MM
od
el
od
el
DDevice evice BBuilding uilding TToolsools
HHardware/ardware/DDriversrivers
Windows XP DDK
Windows Embedded Studio
Platform Builder
OEM/IHV SuppliedBSP
(ARM, SH4, MIPS)OEM Hardware and Standard Drivers
Standard PC Hardware and Drivers
SQL Server 2005SQL Server 2005 Mobile Edition
ASP.NET Mobile Controls ASP.NET
.NET Compact Framework .NET Framework
Microsoft Operations Manager
Systems Management Server
OverviewOverview
CE SDIO Stack FeaturesCE SDIO Stack Features
What does the CE stack look like?What does the CE stack look like?
How to write a client How to write a client
Bluetooth code walkthroughBluetooth code walkthrough
SDIO Support In CE 5.0SDIO Support In CE 5.0
Dynamic insert/removeDynamic insert/remove
DMA (optional in standard host spec, platform dependent)DMA (optional in standard host spec, platform dependent)
SDIO interruptsSDIO interrupts
Dynamic clock controlDynamic clock control
Error recoveryError recovery
Wake-upWake-up
Power will be handled using CE Power ManagerPower will be handled using CE Power ManagerClients may be power-managed and tell the controller to put its slot Clients may be power-managed and tell the controller to put its slot into a different power stateinto a different power state
Multi-function and Combo devicesMulti-function and Combo devices
Also support MMC v3.0 basic functionalityAlso support MMC v3.0 basic functionality
In the next Windows Mobile release we’re adding:In the next Windows Mobile release we’re adding:Support MMC v4.0 basic functionalitySupport MMC v4.0 basic functionality
Performance enhancements for single block cardsPerformance enhancements for single block cards
The Secure In SDThe Secure In SD
SDA SD Memory specification provides SDA SD Memory specification provides a mechanism to lock content to a a mechanism to lock content to a specific machinespecific machineWe are not providing a block driver We are not providing a block driver supporting it in 5.0 release explicitly. supporting it in 5.0 release explicitly. SDBus does allow you to build your SDBus does allow you to build your own thoughown thoughDigital Rights Management (DRM) for Digital Rights Management (DRM) for all of CE is being supplied by a all of CE is being supplied by a filesystem filter driver at a level above filesystem filter driver at a level above the SD Memory block driverthe SD Memory block driver
HostHost SoftwareSoftware
StackStack
HardwareHardware
ClientClientDriversDrivers
SD HostDriver
SDBus Driver
SDIO GPSClient Driver
SD Memory(block driver)
SDIO GPSCard
SD MemoryCard
LocationServices
FatFS
SD HostController
CE 5.0 SDIO ArchitectureCE 5.0 SDIO Architecture
SD Bus DriverSD Bus Driver
Enumerates cards to determine if MMC, Enumerates cards to determine if MMC, SD Memory or SDIOSD Memory or SDIO
Determines voltage to use for cardDetermines voltage to use for card
Loads clients based on registry valuesLoads clients based on registry values
Queues bus requestsQueues bus requests
Queues asynchronous notifications from Queues asynchronous notifications from host controllerhost controller
Bus request completion, SDIO interrupts, Bus request completion, SDIO interrupts, device insertion/removaldevice insertion/removal
Performs error handling with retryPerforms error handling with retry
Standard Host ControllerStandard Host Controller
SDA Host Working Group SDA Host Working Group (MSFT executive member)(MSFT executive member)
Defined Standard Host Register Specification Defined Standard Host Register Specification to standardize hardware interface from bus to to standardize hardware interface from bus to controllercontroller
Currently ratified to v1.0 by SDA executive Currently ratified to v1.0 by SDA executive committeecommittee
MSFT strongly advocating this standard to all MSFT strongly advocating this standard to all IHVs, ODMs, OEMs and SiliconsIHVs, ODMs, OEMs and Silicons
Also support for PXa270, OMAP730, Also support for PXa270, OMAP730, SMDK2410SMDK2410
Compatibility With SDIO Now!Compatibility With SDIO Now!
BSquare has an install baseBSquare has an install base
PPCs on the market todayPPCs on the market today
Target was to maintain client driver Target was to maintain client driver compatibility to ensure smooth compatibility to ensure smooth transition of marketplacetransition of marketplace
Have verified we’re compatible using Have verified we’re compatible using SDIO Now!SDIO Now!
Client Drivers compiled into x86 running Client Drivers compiled into x86 running on CEPC w/ Standard Host Controllerson CEPC w/ Standard Host Controllers
Windows CE Provided Windows CE Provided ClientsClients
SD Memory (MMC support verified)SD Memory (MMC support verified)
SDIO Bluetooth Type A classSDIO Bluetooth Type A class
SDIO GPS classSDIO GPS class
SDIO WiFi (vendor specific)SDIO WiFi (vendor specific)
How To Write A Client DriverHow To Write A Client Driver
Client Driver modelClient Driver model
Registry loads driverRegistry loads driver
Checklist of functionsChecklist of functions
Client Driver ModelClient Driver Model
Streams interface for APIStreams interface for API
Init, Deinit are the only ones strictly Init, Deinit are the only ones strictly requiredrequired
Suggested use of Open, Close, Read, Suggested use of Open, Close, Read, Write, IOControl, PowerUp/Down as Write, IOControl, PowerUp/Down as appropriateappropriate
Registry EntriesRegistry Entries
Custom Driver:Custom Driver:[HKEY_LOCAL_MACHINE\Drivers[HKEY_LOCAL_MACHINE\Drivers \SDCARD\ClientDrivers\Custom\SDCARD\ClientDrivers\Custom \MANF-02DB-CARDID-0002-FUNC-1]\MANF-02DB-CARDID-0002-FUNC-1]
"Dll"=“mydriver.dll""Dll"=“mydriver.dll""Prefix"=“XXX“"Prefix"=“XXX“
Class Driver:Class Driver:[HKEY_LOCAL_MACHINE\Drivers[HKEY_LOCAL_MACHINE\Drivers \SDCARD\ClientDrivers\Class\SDIO_Class\3]\SDCARD\ClientDrivers\Class\SDIO_Class\3] "Dll"=“bthsdio.dll""Dll"=“bthsdio.dll" "Prefix"=“BSD“"Prefix"=“BSD“SD Memory and MMC have special class keys SD Memory and MMC have special class keys
as wellas well
MANF, CARDID And FUNCMANF, CARDID And FUNC
For custom SDIO cardsFor custom SDIO cardsMANF is the four digit hexadecimal value MANF is the four digit hexadecimal value of the Manufacturer IDof the Manufacturer ID
CARDID is the four digit hexadecimal CARDID is the four digit hexadecimal value of the Card ID value of the Card ID
FUNC is the decimal value of the card FUNC is the decimal value of the card function number for which the driver is function number for which the driver is being loadedbeing loaded
ChecklistChecklist
Get SDA specs and card manufacturer Get SDA specs and card manufacturer specs. Use Bluetooth driver as an specs. Use Bluetooth driver as an exampleexample
XXX_Init()XXX_Init()
Get the unique identification handle Get the unique identification handle for the clientfor the client
SDGetDeviceHandleSDGetDeviceHandle
Takes in device initialization context Takes in device initialization context passed back from XXX_Init and passed back from XXX_Init and registry pathregistry path
Return Value: SD_DEVICE_HANDLEReturn Value: SD_DEVICE_HANDLE
This device handle is passed to every This device handle is passed to every other SD Bus APIother SD Bus API
ChecklistChecklist
Create a function to receive Create a function to receive asynchronous slot state change asynchronous slot state change notificationsnotifications
Register the client driver with the SD Register the client driver with the SD Bus driverBus driver
[SDIO] Enable the SDIO function[SDIO] Enable the SDIO function
[SDIO] Determine which function on [SDIO] Determine which function on the card the driver is associated withthe card the driver is associated with
Slot EventsSlot Events
Recommended Recommended
SlotEventCallBack()SlotEventCallBack()
Provides Asynchronous info about Provides Asynchronous info about changes in slot state changes in slot state
Example: SDCardEjectedExample: SDCardEjected
SDRegisterClientSDRegisterClient
Fill in structure with the local device Fill in structure with the local device context, slot event callback, and a context, slot event callback, and a friendly namefriendly name
Friendly name used for debug outputFriendly name used for debug output
After successful registration, all other After successful registration, all other SD Bus APIs may be calledSD Bus APIs may be called
SDSetCardFeatureSDSetCardFeature
Configures the cardConfigures the cardSD_IO_FUNCTION_ENABLESD_IO_FUNCTION_ENABLE
SD_IO_FUNCTION_DISABLESD_IO_FUNCTION_DISABLE
SD_IO_FUNCTION_SET_BLOCK_SIZESD_IO_FUNCTION_SET_BLOCK_SIZE
SD_SET_CARD_INTERFACESD_SET_CARD_INTERFACESets both the bus width and the bus clock Sets both the bus width and the bus clock frequencyfrequency
SDCardInfoQuerySDCardInfoQuery
Provides information about card and Provides information about card and host controllerhost controller
Function numberFunction numberHost controller maximum block sizeHost controller maximum block sizeCurrent bus clock and widthCurrent bus clock and widthAddress of function’s SDIO CIS regionAddress of function’s SDIO CIS regionParsed card register structuresParsed card register structures
CSDCSDCIDCIDDSRDSRRCARCASCRSCR
Code Sample – InitializationCode Sample – Initialization
public\common\oak\drivers\sdcardpublic\common\oak\drivers\sdcardsdclientdrivers\bluetooth\bthsdio.cppsdclientdrivers\bluetooth\bthsdio.cpp
CSdioDevice::Attach()CSdioDevice::Attach()
ChecklistChecklist
Retrieve the host controller’s max Retrieve the host controller’s max block sizeblock size
Use SDCardInfoQueryUse SDCardInfoQuery
[SDIO] Retrieve the function’s max [SDIO] Retrieve the function’s max block size from the card tuplesblock size from the card tuples
Use the smaller maximum block sizeUse the smaller maximum block size
[SDIO] Set the block size on the card[SDIO] Set the block size on the cardUse SDSetCardFeatureUse SDSetCardFeature
SDGetTupleSDGetTuple
Simplifies reading tuples from the CISSimplifies reading tuples from the CIS
Information residing in tuples:Information residing in tuples:Maximum block sizeMaximum block size
Power drawPower draw
Manufacturer codeManufacturer code
Code SampleCode SampleMaximum Block SizeMaximum Block Size
CSdioDevice::GetMaxBlockLen()CSdioDevice::GetMaxBlockLen()
ChecklistChecklist
[SDIO] Determine if the card supports [SDIO] Determine if the card supports multi-block transfersmulti-block transfers
Read from CCCRRead from CCCR
[SDIO] Create and register a function to [SDIO] Create and register a function to receive interrupt notificationsreceive interrupt notifications
Transfer data via Bus Requests…Transfer data via Bus Requests…
SDIO InterruptsSDIO Interrupts
Card notifies driver of Asynchronous Card notifies driver of Asynchronous events via SDIO interruptsevents via SDIO interrupts
SDIOConnectInterrupt() to register for SDIOConnectInterrupt() to register for a callbacka callback
Client must clear the interrupt before Client must clear the interrupt before exiting callbackexiting callback
Return SD_API_STATUS_SUCCESSReturn SD_API_STATUS_SUCCESS
Code Sample – InterruptsCode Sample – Interrupts
CSdioDevice::SDIOIsrCallBack()CSdioDevice::SDIOIsrCallBack()
CSdioDevice::SDIOIsrCallback_Int()CSdioDevice::SDIOIsrCallback_Int()
Touching Card RegistersTouching Card Registers
SDReadWriteRegistersDirect() – for multiple SDReadWriteRegistersDirect() – for multiple single-byte transferssingle-byte transfers
Single-byte transfers are slow so try Single-byte transfers are slow so try to avoid themto avoid them
Used for doing things like:Used for doing things like:Determining if the card is multi-block capable Determining if the card is multi-block capable (CCCR)(CCCR)
Clearing and enabling card specific interrupt Clearing and enabling card specific interrupt settingssettings
Setting card specific modesSetting card specific modes
Read if data is availableRead if data is available
Read/Write – Bus RequestsRead/Write – Bus Requests
Client driver interacts with the card via the Client driver interacts with the card via the Bus driver using Bus Requests. These Bus driver using Bus Requests. These requests pass the SD CMD to the cardrequests pass the SD CMD to the cardSync – must wait for response before issuing Sync – must wait for response before issuing subsequent commandssubsequent commands
SDSynchronousBusRequest()SDSynchronousBusRequest()Async – subsequent commands are queued Async – subsequent commands are queued by Bus driver. You must free the bus request by Bus driver. You must free the bus request after completionafter completion
SDBusRequest()SDBusRequest()Second parameter of both is the SD Second parameter of both is the SD CommandCommand
SDCancelBusRequest()SDCancelBusRequest()
Sync Versus AsyncSync Versus Async
Async helps the most when sending Async helps the most when sending many small blocks (Not multi-block)many small blocks (Not multi-block)
Async will always be at least as fast or Async will always be at least as fast or faster then Syncfaster then Sync
If you submit a bunch of async requests, If you submit a bunch of async requests, they’ll be queued by the bus driver, good they’ll be queued by the bus driver, good because bus driver optimizes bus activitybecause bus driver optimizes bus activity
Sync is easier to program, Sync is easier to program, less logic in clientless logic in client
Issuing An SDIO CommandIssuing An SDIO Command
CMDs are listed in the SDA CMDs are listed in the SDA specificationsspecificationsYou should build the arguments You should build the arguments via Macrosvia MacrosTwo macros that build the complex Two macros that build the complex command statements for you:command statements for you:
BUILD_IO_RW_DIRECT_ARG()BUILD_IO_RW_DIRECT_ARG()BUILD_IO_RW_EXTENDED_ARG()BUILD_IO_RW_EXTENDED_ARG()
Call Call SDSynchronousBusRequest()SDSynchronousBusRequest() or or SDBusRequest()SDBusRequest() with the with the command argumentcommand argument
Code Sample – TransfersCode Sample – Transfers
CSdioDevice::SDSend()CSdioDevice::SDSend()SynchronousSynchronous
CSdioDevice::SDRecv()CSdioDevice::SDRecv()AsynchronousAsynchronous
Call To ActionCall To Action
Write a CE driver for your SDIO Hardware and Write a CE driver for your SDIO Hardware and sell more chips sell more chips
Become a member of the Driver Developer Become a member of the Driver Developer programprogram
http://msdn.microsoft.com/embedded/usewinemb/http://msdn.microsoft.com/embedded/usewinemb/ce/drivers/driverdev/default.aspxce/drivers/driverdev/default.aspx
Advertise your driver on our web site of Advertise your driver on our web site of supported driverssupported drivers
http://msdn.microsoft.com/embedded/usewinemb/http://msdn.microsoft.com/embedded/usewinemb/ce/drivers/supdrivers/default.aspxce/drivers/supdrivers/default.aspx
Contact Contact JayLoneyJayLoney @ Microsoft.com @ Microsoft.com
While at MEDC 2005…While at MEDC 2005…Fill outFill out an evaluation for this session an evaluation for this session
Randomly selected instant Randomly selected instant WINWIN prizes! prizes!
Use Use real technology in a labreal technology in a lab Instructor led Instructor led Reef E/FReef E/F & & Breakers LBreakers L
Self-paced Self-paced Reef B/CReef B/C
VisitVisit the Microsoft Product Pavilion the Microsoft Product Pavilion
in the Exhibit Hall in the Exhibit Hall Shorelines BShorelines B
After The Conference…After The Conference…
DevelopDevelop
BuildBuild
InstallInstall
BuildBuild
JoinJoin
InstallInstall
EnterEnter
JoinJoin
Full-featured trial versions of Windows CE Full-featured trial versions of Windows CE and/or Windows XP Embeddedand/or Windows XP Embedded
Cool stuff & tell us about it: Cool stuff & tell us about it: msdn.microsoft.com/embedded/community
Windows Embedded Partner Program:Windows Embedded Partner Program:www.mswep.com
Windows Mobile 5.0 Eval Kit including Windows Mobile 5.0 Eval Kit including Visual Studio 2005 Beta 2Visual Studio 2005 Beta 2
Mobile2Market Contest and win up to $25000: Mobile2Market Contest and win up to $25000: mobile2marketcontest.com
Microsoft Solutions Partner Program:Microsoft Solutions Partner Program:partner.microsoft.com
Tools & ResourcesTools & 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
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.