EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions...

25
EMB432 EMB432 Developing Bus Developing Bus Agnostic Drivers for Agnostic Drivers for Windows CE Windows CE David G. Heil David G. Heil Chief Engineer Chief Engineer Solutions Division Solutions Division CalAmp Corporation CalAmp Corporation

Transcript of EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions...

Page 1: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

EMB432EMB432

Developing Bus Agnostic Developing Bus Agnostic Drivers for Windows CEDrivers for Windows CE

David G. HeilDavid G. HeilChief EngineerChief EngineerSolutions DivisionSolutions DivisionCalAmp CorporationCalAmp Corporation

Page 2: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.
Page 3: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

AgnosticAgnostic

Doubtful or noncommittalDoubtful or noncommittal

Uncertain of all claims to knowledgeUncertain of all claims to knowledge

Page 4: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

BusBus

A vehicle carrying many passengers; A vehicle carrying many passengers; used for public transportused for public transport

An electrical conductor that makes a An electrical conductor that makes a common connection between several common connection between several circuitscircuits

Page 5: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

DriverDriver

The operator of a motor vehicleThe operator of a motor vehicle

A program that determines how a A program that determines how a computer will communicate with a computer will communicate with a peripheral deviceperipheral device

Page 6: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Bus Agnostic DriverBus Agnostic Driver

An operator of a vehicle carrying many An operator of a vehicle carrying many passengers that has commitment passengers that has commitment issuesissues

A program that determines how a A program that determines how a computer will communicate with a computer will communicate with a peripheral device over a common peripheral device over a common electrical connection that makes no electrical connection that makes no claims to knowledgeclaims to knowledge

Page 7: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Bus Agnostic DriverBus Agnostic Driver

““A bus agnostic driver is a standard A bus agnostic driver is a standard driver that is relatively simple to driver that is relatively simple to implement and can be shared by implement and can be shared by various bus implementations for the various bus implementations for the same hardware chipset.” – same hardware chipset.” –

Windows CE 5.0 HelpWindows CE 5.0 Help

Page 8: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Obtain Registry HandleObtain Registry Handle

HKEY OpenDeviceKey( LPCTSTR HKEY OpenDeviceKey( LPCTSTR ActiveKeyActiveKey ); );

This function opens the device registry This function opens the device registry key specified by the key specified by the ActiveKeyActiveKey parameter. The caller of parameter. The caller of OpenDeviceKey is responsible for OpenDeviceKey is responsible for closing the registry handle it returns.closing the registry handle it returns.

Page 9: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Obtain Window InformationObtain Window Information

DWORD WINAPI DWORD WINAPI DDKReg_GetWindowInfo( HKEY DDKReg_GetWindowInfo( HKEY hkhk, , PDDKWINDOWINFO PDDKWINDOWINFO pwipwi ); );

This function fills the This function fills the DDKWINDOWINFO structure with DDKWINDOWINFO structure with information it reads from the registry. information it reads from the registry. This information includes everything a This information includes everything a driver must have to map its memory driver must have to map its memory (and I/O) windows.(and I/O) windows.

Page 10: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Structure ContentsStructure ContentsDDKWINDOWINFODDKWINDOWINFO

Bus number that your device was Bus number that your device was found onfound on

Bus type (PCI, PCMCIA, Cardbus, Bus type (PCI, PCMCIA, Cardbus, etc…)etc…)

Array of I/O windows (Each element Array of I/O windows (Each element contains the base address & length)contains the base address & length)

Array of memory windows (Each Array of memory windows (Each element contains the base address & element contains the base address & length)length)

Page 11: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Obtain Interrupt InformationObtain Interrupt Information

DWORD WINAPI DDKReg_GetIsrInfo( DWORD WINAPI DDKReg_GetIsrInfo( HKEY hk, PDDKISRINFO pii );HKEY hk, PDDKISRINFO pii );

This function populates a DDKISRINFO This function populates a DDKISRINFO structure with information from the structure with information from the registry. This information includes registry. This information includes everything a driver must have to everything a driver must have to activate an interrupt service thread.activate an interrupt service thread.

Page 12: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Structure ContentsStructure ContentsDDKISRINFODDKISRINFO

The hardware interrupt numberThe hardware interrupt number

The software interrupt identifier or The software interrupt identifier or SYSINTR numberSYSINTR number

A string containing the path to the A string containing the path to the Installable ISR (IISR) DLLInstallable ISR (IISR) DLL

A string containing the name of the A string containing the name of the interrupt handler function within the interrupt handler function within the IISR DLLIISR DLL

Page 13: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Obtain A Virtual AddressObtain A Virtual Address

BOOL BusTransBusAddrToVirtual ( BOOL BusTransBusAddrToVirtual ( HANDLE HANDLE hBusAccesshBusAccess, , INTERFACE_TYPE INTERFACE_TYPE InterfaceTypeInterfaceType, ,

ULONG ULONG BusNumberBusNumber, , PHYSICAL_ADDRESS PHYSICAL_ADDRESS BusAddressBusAddress, , ULONG ULONG LengthLength, , PULONG PULONG AddressSpaceAddressSpace, , PPVOID PPVOID

MappedAddressMappedAddress ););

This function translates a bus address This function translates a bus address to a virtual system address.to a virtual system address.

Page 14: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Obtain A Static AddressObtain A Static Address

BOOL BusTransBusAddrToStatic (BOOL BusTransBusAddrToStatic ( IN HANDLE hBusAccess, IN HANDLE hBusAccess, IN INTERFACE_TYPE InterfaceType, IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN ULONG Length, IN OUT PULONG AddressSpace, IN OUT PULONG AddressSpace, OUT PPVOID MappedAddress ); OUT PPVOID MappedAddress );

This function translates a bus address This function translates a bus address to a system address. Then, it creates a to a system address. Then, it creates a static, process independent, virtual static, process independent, virtual address mapping for that address.address mapping for that address.

Page 15: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Interrupt Handler ChainingInterrupt Handler Chaining

HANDLE LoadIntChainHandler(HANDLE LoadIntChainHandler( LPCWSTR lpFilename, LPCWSTR lpFilename, LPCWSTR lpszFunctionName, LPCWSTR lpszFunctionName, BYTE bIRQ); BYTE bIRQ);

This function is called by a driver This function is called by a driver to install an ISR to handle a to install an ISR to handle a particular interrupt.particular interrupt.

Page 16: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Plug Handler Into KernelPlug Handler Into Kernel

BOOL KernelLibIoControl(BOOL KernelLibIoControl( HANDLE hModule, HANDLE hModule, DWORD dwIoControlCode, DWORD dwIoControlCode, LPVOID lpInBuf, LPVOID lpInBuf, DWORD nInBufSize, DWORD nInBufSize, LPVOID lpOutBuf, LPVOID lpOutBuf, DWORD nOutBufSize, DWORD nOutBufSize, LPDWORD lpBytesReturned); LPDWORD lpBytesReturned);

This function is called with the This function is called with the IOCTL_GIISR_INFO parameter to IOCTL_GIISR_INFO parameter to tell the kernel to handle a tell the kernel to handle a particular interrupt with an IISR.particular interrupt with an IISR.

Page 17: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

Structure ContentsStructure ContentsGIISR_INFOGIISR_INFO

The system interrupt (SYSINTR) IDThe system interrupt (SYSINTR) IDWhether or not to check a status portWhether or not to check a status portWhether that port is an I/O portWhether that port is an I/O portWhether or not to check a mask Whether or not to check a mask registerregisterThe address of the interrupt status portThe address of the interrupt status portThe size of the status port (in bytes)The size of the status port (in bytes)The interrupt bit maskThe interrupt bit maskThe address of the mask registerThe address of the mask register

Page 18: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

PCI/PC Card EntriesPCI/PC Card Entries

PCI & PC Card (bus-agnostic) driver PCI & PC Card (bus-agnostic) driver entries are entered in a “match entries are entered in a “match template” areatemplate” area

[HKLM\Drivers\BuiltIn\PCI\Template\<…>][HKLM\Drivers\BuiltIn\PCI\Template\<…>]

““VendorID” (string or multi-string)VendorID” (string or multi-string)Contains the PCI vendor identifier(s) of Contains the PCI vendor identifier(s) of the cards that this driver services.the cards that this driver services.

““DeviceID” (string or multi-string)DeviceID” (string or multi-string)Contains the PCI device identifier(s) of the Contains the PCI device identifier(s) of the cards that this driver services.cards that this driver services.

Page 19: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

PCMCIA EntriesPCMCIA Entries

PCMCIA Card (bus-agnostic) driver PCMCIA Card (bus-agnostic) driver entries are entered in a “plug and play” entries are entered in a “plug and play” areaarea

[HKLM\Drivers\PCCARD\PCMCIA\PNP\<PNP-ID>][HKLM\Drivers\PCCARD\PCMCIA\PNP\<PNP-ID>]

The PNP-ID is generated based on the The PNP-ID is generated based on the CIS structure of the target cardCIS structure of the target card

The PNP-ID is a concatenation of the The PNP-ID is a concatenation of the product information, manufacturer product information, manufacturer identifier, and product identifier tuplesidentifier, and product identifier tuples

Page 20: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

GIISR EntriesGIISR Entries

The GIISR mechanism is configured by The GIISR mechanism is configured by registry entries included under the registry entries included under the template or PNP keys.template or PNP keys.

““IsrDLL” (string)IsrDLL” (string)This value contains the path to the GIISR This value contains the path to the GIISR DLL for your driverDLL for your driver

If the DLL is in the standard search path If the DLL is in the standard search path you can just use the filename hereyou can just use the filename here

““IsrHandler” (string)IsrHandler” (string)This value contains the name of the ISR This value contains the name of the ISR handler functionhandler function

Page 21: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

GIISR Entries (cont.)GIISR Entries (cont.)

““CheckPort” (dword)CheckPort” (dword)Set to “1” if GIISR should check bits of interrupt Set to “1” if GIISR should check bits of interrupt status register before passing this interrupt on to status register before passing this interrupt on to the interrupt threadthe interrupt thread

““PortIsIo” (dword)PortIsIo” (dword)Set to “1” if GIISR should use an I/O access to Set to “1” if GIISR should use an I/O access to check the interrupt status registercheck the interrupt status register

““PortAddr” (dword)PortAddr” (dword)Contains the system address of the interrupt Contains the system address of the interrupt status registerstatus register

““PortSize” (dword)PortSize” (dword)Contains the size (byte (1), word (2), dword (4)) Contains the size (byte (1), word (2), dword (4)) of the interrupt status registerof the interrupt status register

Page 22: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

GIISR Entries (cont.)GIISR Entries (cont.)

““Mask” (dword)Mask” (dword)This value will be logically ANDed with the This value will be logically ANDed with the value of the status register value of the status register

““UseMaskReg” (dword)UseMaskReg” (dword)Set to “1” if GIISR should read the mask Set to “1” if GIISR should read the mask from a register instead of using the from a register instead of using the “Mask” value from the registry “Mask” value from the registry

““MaskAddr” (dword)MaskAddr” (dword)Contains the system address of the Contains the system address of the interrupt mask registerinterrupt mask register

Page 23: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

CEliteCElite

Page 24: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

What is CELite?What is CELite?

CELite is a patch to the Windows CE CELite is a patch to the Windows CE kernel that allows it to run on kernel that allows it to run on microprocessors without memory microprocessors without memory management units.management units.

Key contributorsKey contributorsJames Y. WilsonJames Y. Wilson

David G. HeilDavid G. Heil

http://http://celite.sourceforge.netcelite.sourceforge.net

Page 25: EMB432 Developing Bus Agnostic Drivers for Windows CE David G. Heil Chief Engineer Solutions Division CalAmp Corporation.

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.