slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
How To Write A Windows CE SDIO Client Driver PowerPoint Presentation
Download Presentation
How To Write A Windows CE SDIO Client Driver

Loading in 2 Seconds...

play fullscreen
1 / 40

How To Write A Windows CE SDIO Client Driver - PowerPoint PPT Presentation


  • 241 Views
  • Uploaded on

How To Write A Windows CE SDIO Client Driver. 饶大春 技术专家 微软中国技术中心 微软(中国)有限公司. Overview . CE SDIO Stack Features How to write a client driver Bluetooth code walkthrough. SDA and MMCA. SD and MultiMediaCard Associations SPI mode vs. SD/MMC mode 9 pins vs. 7 pins 4 bits vs. 1 bits

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'How To Write A Windows CE SDIO Client Driver' - phyllis-martinez


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2

How To Write AWindows CE SDIO Client Driver

饶大春

技术专家

微软中国技术中心

微软(中国)有限公司

overview
Overview
  • CE SDIO Stack Features
  • How to write a client driver
  • Bluetooth code walkthrough
sda and mmca
SDA and MMCA
  • SD and MultiMediaCard Associations
  • SPI mode vs. SD/MMC mode
  • 9 pins vs. 7 pins
  • 4 bits vs. 1 bits
  • Command different
  • MMC,SD Memory card and IO card
  • RS-MMC,miniSD and TransFlash
sd io support in ce 5 0
SD(IO) Support In CE 5.0
  • Dynamic insert/remove
  • DMA (optional in standard host spec, platform dependent)
  • SDIO interrupts
  • Dynamic clock control
  • Error recovery
  • Soft-block support
  • Wake-up
  • Power will be handled using CE Power Manager
    • Clients may be power-managed and tell the controller to put its slot into a different power state
  • Multi-function and Combo devices
  • Also support MMC v3.0 basic functionality
  • In the next Windows Mobile release we’re adding:
    • Support MMC v4.0 basic functionality
    • Performance enhancements for single block cards
the secure in sd
The Secure In SD
  • SDA SD Memory specification provides a mechanism to lock content to a specific machine
  • We are not providing a block driver supporting it in 5.0 release explicitly. SDBus does allow you to build your own though
  • Digital Rights Management (DRM) for all of CE is being supplied by a filesystem filter driver at a level above the SD Memory block driver
slide7

Location Services

FatFS

SDIO GPS

Client Driver

SD Memory

(block driver)

Client

Drivers

SDBus Driver

Host

Software

Stack

SD Host

Driver

SD Host Controller

Hardware

SDMemory

Card

SD GPS

Card

sd bus driver
SD Bus Driver
  • Enumerates cards to determine if MMC, SD Memory or SDIO
  • Determines voltage to use for card
  • Loads clients based on registry values
  • Queues bus requests
  • Queues asynchronous notifications from host controller
    • Bus request completion, SDIO interrupts, device insertion/removal
  • Performs error handling with retry
standard host controller
Standard Host Controller
  • SDA Host Working Group Defined Standard Host Register Specification to standardize hardware interface from bus to controller
  • Currently ratified to v1.0 by SDA executive committee
  • MSFT strongly advocating this standard to all IHVs, ODMs, OEMs and Silicons
  • Also support for PXa270, OMAP730, SMDK2410
compatibility with sdio now
Compatibility With SDIO Now!
  • BSquare has an install base
  • PPCs on the market today
  • Target was to maintain client driver compatibility to ensure smooth transition of marketplace
  • Have verified we’re compatible using SDIO Now!
windows ce provided clients
Windows CE Provided Clients
  • SD Memory (MMC support verified)
  • SDIO Bluetooth Type A class
  • SDIO GPS class
  • SDIO WiFi
how to write a client driver
How To Write A Client Driver
  • Client Driver model
  • Registry loads driver
  • Checklist of functions
client driver model
Client Driver Model
  • Streams interface for API
  • Init, Deinit are the only ones strictly required
  • Suggested use of Open, Close, Read, Write, IOControl, PowerUp/Down as appropriate
registry entries
Registry Entries

Custom Driver:

[HKEY_LOCAL_MACHINE\Drivers

\SDCARD\ClientDrivers\Custom

\MANF-02DB-CARDID-0002-FUNC-1]

"Dll"=“mydriver.dll"

"Prefix"=“XXX“

Class Driver:

[HKEY_LOCAL_MACHINE\Drivers

\SDCARD\ClientDrivers\Class\SDIO_Class\3]

"Dll"=“bthsdio.dll"

"Prefix"=“BSD“

SD Memory and MMC have special class keys as well

checklist
Checklist
  • Get SDA specs and card manufacturer specs. Use Bluetooth driver as an example
  • XXX_Init()
  • Get the unique identification handle for the client
    • SDGetDeviceHandle
checklist1
Checklist
  • Create a function to receive asynchronous slot state change notifications
  • Register the client driver with the SD Bus driver
  • [SDIO] Enable the SDIO function
  • [SDIO] Determine which function on the card the driver is associated with
slot events
Slot Events
  • Recommended
  • SlotEventCallBack()
  • Provides Asynchronous info about changes in slot state
    • Example: SDCardEjected
sdregisterclient
SDRegisterClient
  • Fill in structure with the local device context, slot event callback, and a friendly name
  • Friendly name used for debug output
  • After successful registration, all other SD Bus APIs may be called
sdsetcardfeature
SDSetCardFeature
  • Configures the card
    • SD_IO_FUNCTION_ENABLE
    • SD_IO_FUNCTION_DISABLE
    • SD_IO_FUNCTION_SET_BLOCK_SIZE
    • SD_SET_CARD_INTERFACE
      • Sets both the bus width and the bus clock frequency
sdcardinfoquery
SDCardInfoQuery
  • Provides information about card and host controller
    • Function number
    • Host controller maximum block size
    • Current bus clock and width
    • Address of function’s SDIO CIS region
    • Parsed card register structures
      • CSD
      • CID
      • DSR
      • RCA
      • SCR
code sample initialization
Code Sample – Initialization
  • public\common\oak\drivers\sdcard\sdclientdrivers\bluetooth\bthsdio.cpp
  • CSdioDevice::Attach()
slide22
BOOL CSdioDevice::Attach(DWORD dwContext)
  • {

……

m_hDevice = SDGetDeviceHandle(dwContext, &m_pRegPath);

  • if (NULL == m_hDevice) {
  • goto exit;
  • }
  • wcscpy(clientInfo.ClientName, TEXT("Bluetooth Card"));
  • if (! SD_API_SUCCESS(SDRegisterClient(m_hDevice, this, &clientInfo))) {
  • goto exit;
  • }
  • if (! SD_API_SUCCESS(SDIOConnectInterrupt(m_hDevice, SDIOIsrCallBack))) {
  • goto exit;
  • }
slide23
functionEnable.Interval = DEFAULT_SDIO_FUNCTION_RETRY_TIMEOUT;
  • functionEnable.ReadyRetryCount = DEFAULT_SDIO_FUNCTION_RETRIES;
  • if (! SD_API_SUCCESS(SDSetCardFeature(m_hDevice, SD_IO_FUNCTION_ENABLE, &functionEnable, sizeof(functionEnable)))) {
  • ASSERT(0);
  • fRetVal = FALSE;
  • goto exit;
  • }
  • if (! SD_API_SUCCESS(SDCardInfoQuery(m_hDevice, SD_INFO_SDIO, &sdioInfo, sizeof(sdioInfo)))) {
  • ASSERT(0);
  • fRetVal = FALSE;
  • goto exit;
  • }
  • Exit:
  • ……
  • }
checklist2
Checklist
  • Retrieve the host controller’s max block size
    • Use SDCardInfoQuery
  • [SDIO] Retrieve the function’s max block size from the card tuples
    • Use the smaller maximum block size
  • [SDIO] Set the block size on the card
    • Use SDSetCardFeature
sdgettuple
SDGetTuple
  • Simplifies reading tuples from the CIS
  • Information residing in tuples:
    • Maximum block size
    • Power draw
    • Manufacturer code
code sample maximum block size
Code SampleMaximum Block Size
  • CSdioDevice::GetMaxBlockLen()
slide27
BOOL CSdioDevice::GetMaxBlockLen(void)
  • {
  • ……
  • if (! SD_API_SUCCESS(SDGetTuple(m_hDevice, SD_CISTPL_FUNCE, NULL, &ulLength, FALSE)) ||
  • (ulLength > sizeof(rgucTuple)) ) {
  • ASSERT(0);
  • fRetVal = FALSE;
  • goto exit;
  • }
  • if (! SD_API_SUCCESS(SDGetTuple(m_hDevice, SD_CISTPL_FUNCE, rgucTuple, &ulLength, FALSE)) ||
  • (pFunce->bType != SD_CISTPL_FUNCE_FUNCTION_TYPE) ) {
  • ASSERT(0);
  • fRetVal = FALSE;
  • goto exit;
  • }
slide28
usCardBlockLen = pFunce->wMaxBlkSize;
  • ……
  • if (! SD_API_SUCCESS(SDCardInfoQuery(m_hDevice, SD_INFO_HOST_BLOCK_CAPABILITY, &blockCapability, sizeof(blockCapability)))) {
  • goto exit;
  • }
  • m_usBlockLen = (usHostBlockLen < usCardBlockLen) ? usHostBlockLen : usCardBlockLen;
  • ……
  • }
checklist3
Checklist
  • [SDIO] Determine if the card supports multi-block transfers
    • Read from CCCR
  • [SDIO] Create and register a function to receive interrupt notifications
  • Transfer data via Bus Requests…
sdio interrupts
SDIO Interrupts
  • Card notifies driver of Asynchronous events via SDIO interrupts
  • SDIOConnectInterrupt() to register for a callback
  • Client must clear the interrupt before exiting callback
  • Return SD_API_STATUS_SUCCESS
code sample interrupts
Code Sample – Interrupts
  • CSdioDevice::SDIOIsrCallBack()
  • CSdioDevice::SDIOIsrCallback_Int()
slide32
SD_API_STATUS CSdioDevice::SDIOIsrCallback_Int(void)
  • {
  • ……
  • status = SDGetRegister(REG_INTRD, m_ucFunction, &ucRegValue, 1);
  • if (!SD_API_SUCCESS(status)) {

……

  • }
  • if (ucRegValue) {
  • SetEvent(m_hReadPacketEvent);
  • // Clear INTRD register
  • ucRegValue = 0x01;
  • status = SDSetRegister(REG_INTRD, m_ucFunction, &ucRegValue, 1);
  • ……
  • }
  • }
  • ……
  • }
touching card registers
Touching Card Registers
  • SDReadWriteRegistersDirect() – for multiple single-byte transfers
  • Single-byte transfers are slow so try to avoid them
  • Used for doing things like:
    • Determining if the card is multi-block capable (CCCR)
    • Clearing and enabling card specific interrupt settings
    • Setting card specific modes
    • Read if data is available
read write bus requests
Read/Write – Bus Requests
  • Client driver interacts with the card via the Bus driver using Bus Requests. These requests pass the SD CMD to the card
  • Sync – must wait for response before issuing subsequent commands

SDSynchronousBusRequest()

  • Async – subsequent commands are queued by Bus driver. You must free the bus request after completion

SDBusRequest()

  • Second parameter of both is the SD Command

SDCancelBusRequest()

sync versus async
Sync Versus Async
  • Async helps the most when sending many small blocks (Not multi-block)
  • Async will always be at least as fast or faster then Sync
    • If you submit a bunch of async requests, they’ll be queued by the bus driver, good because bus driver optimizes bus activity
  • Sync is easier to program, less logic in client
issuing an sdio command
Issuing An SDIO Command
  • CMDs are listed in the SDA specifications
  • You should build the arguments via Macros
  • Two macros that build the complex command statements for you:
    • BUILD_IO_RW_DIRECT_ARG()
    • BUILD_IO_RW_EXTENDED_ARG()
  • Call SDSynchronousBusRequest()or SDBusRequest() with the command argument
code sample transfers
Code Sample – Transfers
  • CSdioDevice::SDSend()
    • Synchronous
  • CSdioDevice::SDRecv()
    • Asynchronous
tools resources
Tools & Resources

Build

Develop

Websites

msdn.microsoft.com/embedded

msdn.microsoft.com/mobility

Newsgroups

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

microsoft.public.windowsxp.embedded

windowsce.platbuilder

windowsce.embedded.vc

Blogs

blogs.msdn.com/mikehall

blogs.msdn.com/windowsmobilevsdteamnetcfteam

Tools

Windows CE 5.0 Eval KitWindows XP Embedded Eval Kit

Windows Mobile 5.0 Eval Kit

slide39

大会注意事项

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

请填写资料袋内的黄色大会来宾反馈表,到大会接待台领取大会纪念包。

您还可以:

参加Windows Mobile动手实验室;

参观微软及合作伙伴展区;

体验基于 Windows Mobile平台开发的最新硬件产品及解决方案。