Archive for the Driver Category

Touch Driver Architecture change on Windows Embedded Compact 7

Posted in Driver, WinCE with tags , on 2014 年 03 月 31 日 by Kun-Yi

這幾天又開始轉弄WINCE OS 的porting, 這次的任務是在 CedarTrail 上要 跑 WEC7, BSP 還是使用 Adeneo Embedded 所提供的, 根據前兩年做過的經驗, 很快就 Booting 成功了, Azalia Audio codec 這次換成 ALC269, 也稍微改一下就正常工作了,

但本來不預期會出意外的Touch Controller 卻不會動, 經過一早努力才發現, 原來 WEC7 把Touch Driver 的結構修改過了, 從以前單純的 PDD/MDD 結構, 又更一步把介面抽象化, 分成了 Touch Proxy 與 Touch Driver, Touch Driver 現在改成標準的 Steram Driver(但是還維持PDD/MDD結構) 更上層與系統GWES介面的改成單純由 Touch Proxy Driver 負責. 詳細的內容請參考MSDN 上的 Touch Driver Architecture 因應這個修改 Registry 需相應修改

廣告

WorkNote: a Debug message dump, Intel N450 with WEC7 Platform

Posted in Driver, OAL, WinCE on 2012 年 04 月 09 日 by Kun-Yi

Keypoint:
1. ACPI provide RAM size to CE kernel.
2. Due to Original code just discover ‘zero’ codec, so the InitHDA() always return failed. And the DiscoverCodec() still have a little bug,  so you need to patch it! May be still need added your codec ID into CheckcodecFG().

Debug Serial Init

SysInit: GDTBase=82acb000 IDTBase=82acf700 KData=82a85800
Windows CE Kernel for i486
INFO:OALLogSetZones: dpCurSettings.ulZoneMask: 0xb
PCIInitConfigMechanism():ucConfigMechanism 0x1
InitKitlNIC: Searching for PCI Ethernet NIC (dwIrq = 0, dwIoBase = 0, dwDfltType = 0) …
Intel(R) Ethernet Gigabit KITL driver [Build: Apr  9 2012  14:34:00]
InitKitlNIC: skipping unknown PCI Ethernet NIC: (subclass=0, Vendor=10EC, Device=8168)
Intel(R) Ethernet Gigabit KITL driver [Build: Apr  9 2012  14:34:00]
InitKitlNIC: skipping unknown PCI Ethernet NIC: (subclass=0, Vendor=10EC, Device=8168)
Intel(R) Ethernet Gigabit KITL driver [Build: Apr  9 2012  14:34:00]
InitKitlNIC: skipping unknown PCI Ethernet NIC: (subclass=0, Vendor=10EC, Device=8168)
Intel(R) Ethernet Gigabit KITL driver [Build: Apr  9 2012  14:34:00]
InitKitlNIC: skipping unknown PCI Ethernet NIC: (subclass=0, Vendor=10EC, Device=8168)
 x86InitMemory(): dwAcpiPHYS = 0x3F5CD627
x86InitMemory(): dwRamEndPHYS = 0x20000000
x86InitMemory(): dwRamTop(1)= 0xc0000000
Using ACPI location to determine RAM size
ACPI Tables found at 0x3f5cd627
RAM reported to kernel 1013MB
x86InitMemory():g_pOemGlobal->dwMainMemoryEndAddress = 0xa0000000
Found ACPI but it was located above 512MB at 1013MBIDE deviceId = 0x2828

disLegacyUsbSupport LPC deviceId=0x2815 PMBase=0x1000
+ disLegacyUsbSupport for ICH8M
– disLegacyUsbSupport for ICH8M

PID:00400002 TID:00410002  Found ACPI but it was located above 512MB at 1013MBReserve KITL IRQ: No IRQ reserved, KITL polling mode was specified
PID:00400002 TID:00510002 WARNING: COM1: has been reserved exclusively for Debug Messages.VBridge:: VB_INITIALIZED returns [0]
PID:00400002 TID:00A40006 HDA::InitHardware: InitHDA() failed

Note: WINCE 6, 3rd Party BSP install Folder and Catalog

Posted in Driver, WinCE on 2012 年 01 月 18 日 by Kun-Yi

寫這篇應該只有對我自己有用了 :P, 畢竟現在才開始做CE6 的人太少了, 以下是我自己嘗試實驗所得

WinCE 6 不在像 CE 5 時代有 Catalog Manager 的設計, 當Visual Studio 2005 with PB 6.0 plug-in 裝好後, 打開 VS2005, PB 會去自動在某些目錄下找 Catalog file , 目前我得知的有下面兩個位置 分別是 “3rdParty", “PUBLIC\ThridParty",

  • $(_WINCEROOT)\3rdParty\$(BSPNAME)\Catalog\*.pbcxml
  • $(_WINCEROOT)\PUBLIC\ThirdParty\Catalog\$(BSPNAME)\$(DRIVER)\Catalog\

P.S. M$ 網站上下載的 USBCAM 擺在第二個位置, 但是他的catalog file 有點小問題, 找到下面這行, 可以看到他固定為 C:\WINCE600

<Project>C:\WINCE600\Public\ThirdParty\Catalog\USBCAM\Driver\USBCAM.pbpxml</Project>

改成下面這樣比較好

<Project>$(_WINCEROOT)\Public\ThirdParty\Catalog\USBCAM\Driver\USBCAM.pbpxml</Project>

Update: 當擺在Public 下的folder 裡面有 Catalog Folder &  Catalog files, 好像就可以正常辨識了 不需要特地放在ThridParty下

Note: Spare Block for SLC NAND Device(x8)

Posted in Driver, NAND, WinCE on 2012 年 01 月 14 日 by Kun-Yi

SLC NAND 的 16 bytes Spare 區塊, 在區塊內的安排如下

Small Page (512+16) 是上圖, Bad Block Indicator 被安排在 第 6 個 Byte

Large Page(2048+16*4), 則Bad Block indicator 則被擺到第一個Byte

  • BAD: Bad page indicator, 當值不為0xFF, 表示該頁是壞的
  • LSN: Logical Block Number 提供上層 FTL 記錄邏輯扇區用
  • RESERVED: 也是主要用來提供 FTL 用來做一些演算法利用的儲存區
  • ECC0 ~ ECC2, Main Array 的 ECC Code 儲存區, 因 256 Byte 會用到 22bit 的ECC, 512 BYTE 則用到 24bits 剛好三個BYTE
  • S-ECC0 ~ S-ECC1, Spare 區域用的 ECC 碼, 主要針對 LSNx, 等校正

Ref. Spare Assignment Standard, Samsung App. Note

Note: SLC NAND Flash, Large Block, 2K page size

Posted in Driver, NAND, WinCE on 2012 年 01 月 11 日 by Kun-Yi

今年被公司安排, 從 PC BIOS Engineer 轉成了SW Engineer, 重操舊業搞起了WinCE, 因為案子需求, Study 了一下 NAND 的結構,這篇筆記以 2K Large Block 的SLC NAND 為例, 會想寫下筆記是因為網路上看了很多資料, 但是有些過於分散, 寫成code的也缺一些關鍵點, 不適合簡單入門的概念, 題外話, 下圖是用Google Documents 畫的, 現在 Web App 真的是很成熟!

NAND

上圖有三個部分

  • NAND PHYSICAL 是 NAND Flash datasheet 裡面寫的實體頁(page)配置, 2048Byte的Main Array + 64Byte的Spare Array
  • 中間則是 Driver 實作時, 透過邏輯上的概念切割把他分成 四塊, 讓它吻合如 Small Block,而 Sector 512Bytes 的大小
  • 而最下面則是FTL (Flash Translation Layer) 看到的樣子

至於Driver為啥可以做這種概念上的切割, 依據的應該是 Datasheet 中關於 Page programming 的下面這一段話

The device is programmed basically on a page basis, but it does allow multiple partial page programing of a word or consecutive bytes up to 2112, in a single page program cycle. The number of consecutive partial page programming operation within the same page without an intervening erase operation must not exceed 4 times for main array (1time/512byte) and 4 times for spare array(1time/16byte). The addressing should be done in sequential order in a block. A page program cycle consists of a serial data loading period in which up to 2112bytes of data may be loaded into the data register, followed by a non-volatile programming period where the loaded data is programmed into the appropriate cell.

此外 NAND 操作還有一些注意事項, (這裡用1Gb/128M 為例)

  1. Erase 以Block 為單位, 一個 Block 有 64 pages, 每頁 2K+64B
  2. Programming 以page 為單位, page 必須由Block 的page 0 依序寫到 page 63, 不能任意順序寫入

待續, 有空的話將補完 Spare 的業界標準, 1bit ECC 等.. (這兩部分補完的話, SLC NAND應該就打通底層)

Update:

如果不是採用 3rd party 的 FTL Driver, 會有下列限制

WinCE 4.2 只能支援 512B 的 small page 的 SLC NAND,  因為好像未採用 FlashInfo 去Get Sector Size(這個是看來的懶得去查了, 有求知心的可以查查, 確認後方便的話通知我)

WinCE 5.0 & WinCE 6.0 R2 以前, 只能支援 SLC, 因為 FAL (FTL) Driver 會有用到 partial page programming  feature, 換句話說要用 MLC NAND 要在 WinCE 6.0 R2或是之後版本的 MSFLASH 才能正常支援MLC 版本

因為 SLC 因為支援 Partial Page programming 關係 所以實際上也可把上圖的 User View 的結構, 用在Driver , 反正可以寫四次 所以spare 不見得一定要分區寫, 又 spare 要放在最前面也行, 反正只要自己的driver 能確認出data & spare 的定位就行了

Keyboard driver for Multi language layer support on WinCE

Posted in Driver, Keyboard, WinCE on 2008 年 04 月 09 日 by Kun-Yi

重點是 在HKUSERKeyboard LayoutPreload 與下面的子Key要match, Layout manager 才會載入正確的 Layout

子Key 範圍依照目前標準的LayoutManager 是 1 ~ 15, 覺得不夠,可以去改Layout Manager

[HKUSERKeyboard LayoutPreload]
@="xxxxxxxx" ; like to “00000409″/"e0010409″/"0000040C"
HKUSERKeyboard LayoutPreload1]
@="yyyyyyyy"
[HKUSERKeyboard LayoutPreloadN]
@="xxxxxxxx" ; match [HKUSERKeyboard LayoutPreload] key
[HKUSERKeyboard LayoutPreload15]
@="zzzzzzzz"

每個Layout 的設定 Registry 在[HKLMSYSTEMCurrentControlSetControlLayoutsxxxxxxxx] 下面設定

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLayouts0000409]
“Layout File"="kbdmouse.dll"        ;
“Layout Text"="US"
“PS2_AT"="kbdmouse.dll"              ; funciton Prefix , Layout Manager use it PS2_AT_00000409 function
“BuiltInKeypad"="kbdmouse.dll"    ; funciton Prefix , Layout Manager use it BuiltInKeypad_00000409 function

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLayouts000040C]
“Layout File"="kbdmouse.dll"        ;
“Layout Text"="US"
“PS2_AT"="kbdmouse.dll"              ; funciton Prefix , Layout Manager use it PS2_AT_0000040C function
“BuiltInKeypad"="kbdmouse.dll"    ; funciton Prefix , Layout Manager use it BuiltInKeypad_0000040C function

Keyboard layout 可以透過 kbdgen 去產生,正確的 PS_AT_XXXXXXXX 與 IL_XXXXXXXX 給MapVirtualKey(nCode, 3) 呼叫(某測試規範要求必測), 記得要改成正確的名稱,另外要注意的是使用kbdgen 時,它用到XP的Keyboard layout DLL 要從 \windows\system32 複製到執行目錄下。


Run kbdgen log

%WINCEROOT%PLATFORMMYDEVICEsrcdevlayout>kbdgen kbdfr.dll -o 040C
kbdgen for Windows CE (Release) (Built on Dec 30 2003 15:22:20)
Warning - Generating desktop VK to CE VK conversions for the Input Language:
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF
Warning - Generating VKeyToXTScanCodeTable:
Warning -   The following duplicate entries have been ignored
Warning -   Virtual key VK_CLEAR             (0x0C) - Scan code 0x59
Warning -   Virtual key VK_TAB               (0x09) - Scan code 0x7C
Warning -   Virtual key VK_RETURN            (0x0D) - Scan code 0xE01C
Warning - Generating desktop VK to CE VK conversions for the Device Layout:
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF
Warning -   Desktop VK_OEM_WSCTRL    no CE match
Warning -   Desktop VK_OEM_FINISH    assigned to CE VK_DBE_KATAKANA
Warning -   Desktop VK_OEM_JUMP      no CE match
Warning -   Desktop VK_OEM_BACKTAB   assigned to CE VK_DBE_ROMAN
Warning -   Desktop VK_OEM_AUTO      assigned to CE VK_DBE_SBCSCHAR
Warning -   Desktop VK_OEM_PA3       no CE match
Warning -   Desktop VK_OEM_RESET     no CE match
Warning -   Desktop VK_ABNT_C1       no CE match
Warning -   Desktop VK_OEM_PA1       no CE match
Warning -   Desktop VK_ABNT_C2       no CE match
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF

%WINCEROOT%PLATFORMMYDEVICEsrcdevlayout>kbdgen kbdgr.dll -o 0407
kbdgen for Windows CE (Release) (Built on Dec 30 2003 15:22:20)
Warning - Generating desktop VK to CE VK conversions for the Input Language:
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_MINUS     assigned to CE VK_HYPHEN
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning - Generating VKeyToXTScanCodeTable:
Warning -   The following duplicate entries have been ignored
Warning -   Virtual key VK_CLEAR             (0x0C) - Scan code 0x59
Warning -   Virtual key VK_TAB               (0x09) - Scan code 0x7C
Warning -   Virtual key VK_RETURN            (0x0D) - Scan code 0xE01C
Warning - Generating desktop VK to CE VK conversions for the Device Layout:
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning -   Desktop VK_OEM_MINUS     assigned to CE VK_HYPHEN
Warning -   Desktop VK_OEM_WSCTRL    no CE match
Warning -   Desktop VK_OEM_FINISH    assigned to CE VK_DBE_KATAKANA
Warning -   Desktop VK_OEM_JUMP      no CE match
Warning -   Desktop VK_OEM_BACKTAB   assigned to CE VK_DBE_ROMAN
Warning -   Desktop VK_OEM_AUTO      assigned to CE VK_DBE_SBCSCHAR
Warning -   Desktop VK_OEM_PA3       no CE match
Warning -   Desktop VK_OEM_RESET     no CE match
Warning -   Desktop VK_ABNT_C1       no CE match
Warning -   Desktop VK_OEM_PA1       no CE match
Warning -   Desktop VK_ABNT_C2       no CE match
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF

然後放在自己Driver 的source directory,還要改 .def 去 EXPORT 出正確的介面 

例如本來只有

IL_00000409
BuiltInKeypad_00000409
PS2_AT_00000409
改成
IL_00000409
IL_0000040C
IL_00000407

BuiltInKeypad_00000409
BuiltInKeypad_0000040C
BuiltInKeypad_00000407

PS2_AT_00000409
PS2_AT_0000040C
PS2_AT_00000407

Source 的 Link Lib. 也要加入, 這是目前改的有support 0409(En-US)/040C(FRA)/0407(GER)

SOURCELIBS=
$(_TARGETPLATROOT)lib$(_CPUINDPATH)mainstoneii_BuiltInKeypad_0409_Layout.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)mainstoneii_pddList.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)mainstoneii_keypad.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)InputLang_0409.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)InputLang_040C.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)InputLang_0407.lib

$(_COMMONOAKROOT)lib$(_CPUINDPATH)kbdus_lib.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)kbdfr_lib.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)kbdgr_lib.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)Nop_KbdCommon.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)LayoutManager.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)KeybdIst.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)NumPadRmp.lib


下面是個人目前工作平台上的一個 keyboard driver log, 可以看出LayoutManager 載入040C的相關 Layout 過程


Layout Manager : DLL_PROCESS_ATTACH
+KeybdDriverInitializeEx()
Lyg.p: Initialized PDD 0 – PS/2 NOP (Mask 4)
+KeyPad_Entry(), uiPddId: 0x1
KeyPad_Entry: Initialize Keypad_Entry ID 1

+KeyPad::Initialize()
+AllocKeyPadRegs()
-AllocKeyPadRegs(), Return: TRUE
+-KeyPad::KeyPadPowerOn()
Lyg.p: Received KBD1: notification
-KeyPad::Initialize()
+-KeyPad::IsrThreadStart()
+-KeyPad::KeyPadPowerOn()
-KeyPad_Entry(), KeyPad_Entry: Initialization complete
Lyg.p: Initialized PDD 1 – Keypad (Mask 16)
+GetDefaultInputMethodName(), pszName: “"
+GetPreloadUnNamedValue(), pszName :
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
-GetPreloadUnNamedValue(), pszName : 0000040C, fRet : TRUE
+GetPreloadInputMethodName(), PreloadIndex : 1, pszName :
+GetPreloadInputMethodKey(), uiPreloadIndex : 1
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
+-KeyPadIsrThread()
-GetPreloadInputMethodKey(), szKeyBuf:"1″, fRet : TRUE
+KeyPad::IsrThreadProc()
+KeypadPdd_GetEventEx2()
+KeyPad::KeyPadDataRead(), pui8Data: 0xA3EFDBC
-KeyPad::KeyPadDataRead(), Return: FALSE
KeyPress happens: 0xff
-KeypadPdd_GetEventEx2(), event count = 1-GetPreloadInputMethodName(), pszName : e0010409, fRet : TRUE
=== to called GetPreloadInputMethodName(), szTempInputMethodName : e0010409, szTempDefaultInputMethodName : 0000040C
+GetPreloadInputMethodName(), PreloadIndex : 2, pszName : e0010409
+GetPreloadInputMethodKey(), uiPreloadIndex : 2
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
-GetPreloadInputMethodKey(), szKeyBuf:"2″, fRet : TRUE
-GetPreloadInputMethodName(), pszName : 00000409, fRet : TRUE
=== to called GetPreloadInputMethodName(), szTempInputMethodName : 00000409, szTempDefaultInputMethodName : 0000040C
+GetPreloadInputMethodName(), PreloadIndex : 3, pszName : 00000409
+GetPreloadInputMethodKey(), uiPreloadIndex : 3
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
-GetPreloadInputMethodKey(), szKeyBuf:"3″, fRet : TRUE
-GetPreloadInputMethodName(), pszName : 0000040C, fRet : TRUE
=== to called GetPreloadInputMethodName(), szTempInputMethodName : 0000040C, szTempDefaultInputMethodName : 0000040C
-GetDefaultInputMethodName(), pszName: 0000040C, fRet : TRUE
Lyg.p: Found default input method 0000040C
+SetInputLanguage()
Lyg.p: Changing from input language 0x00000000 to 0x0000040c
+GetInputMethodInfo(), pszInputMethod : 0000040C
-GetInputMethodInfo(), pszFileValue : Layout File, pili->szDll : mainstoneii_keypad_Us.dll, fRet : TRUE

*** First(szProcName : ethod 000004
),2nd(szProcName : IL_, g_szProcPrefix : IL_)
*** Final : szProcName : IL_0000040C, iliNew.szName : 0000040C

+IL_0000040C(), French Keyboard
-IL_0000040C(), French Keyboard
-SetInputLanguage(), fRet : TRUE
+SetDeviceLayout(), uiPdd : 0x00000000
+SelectDeviceLayout() : pszHkl:(0000040C), pszDll:(),
pszProcName(), cchProcName(0x00000028)
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : TRUE
+BuiltInKeypad_0000040C(), pDeviceLayout: 0xA13F694
-BuiltInKeypad_0000040C(), SetBuiltInKeypad pDeviceLayout: 0xA13F694
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)
Lyg.p: Could not get the address of BuiltInKeypad from mainstoneii_keypad_Us.dll
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x00000000), pfnDLEntry(0x03B259C4)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B25D8C)), fRet : TRUE
+PS2_AT_0000040C(), French Keyboard
-PS2_AT_0000040C(), French Keyboard
Lyg.p: Found device layout match for PS/2 NOP and 0x0000040C: PS2_AT – mainstoneii_keypad_Us.dll
-SelectDeviceLayout(), fRet : TRUE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x00000000), pfnDLEntry(0x00000000)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B25D8C)), fRet : TRUE
+PS2_AT_0000040C(), French Keyboard
-PS2_AT_0000040C(), French Keyboard
+ATRemapVKey()
-SetDeviceLayout(), fRet : TRUE
+SetDeviceLayout(), uiPdd : 0x00000001
+SelectDeviceLayout() : pszHkl:(0000040C), pszDll:(), pszProcName(), cchProcName(0x00000028)
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : TRUE
+BuiltInKeypad_0000040C(), pDeviceLayout: 0xA13F694
-BuiltInKeypad_0000040C(), SetBuiltInKeypad pDeviceLayout: 0xA13F694
Lyg.p: Found device layout match for Keypad and 0x0000040C: BuiltInKeypad – mainstoneii_keypad_Us.dll
-SelectDeviceLayout(), fRet : TRUE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x00000000), pfnDLEntry(0x03B25D8C)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : TRUE
+BuiltInKeypad_0000040C(), pDeviceLayout: 0xA13FC58
-BuiltInKeypad_0000040C(), SetBuiltInKeypad pDeviceLayout: 0xA13FC58
+BuiltInKeypad_RemapVKey: cKbdEvents = 2
-SetDeviceLayout(), fRet : TRUE
Lyg.p: Layout Manager successfully initialized to  2
Lyg.p: keybd 1 scan code 0x000000ff Up
Lyg.p: PDD 1: Using device layout 0x0000040c with mask 0x0010
+ScanCodeToVKey(uiScanCode(0x000000FF), ScanCodeToVKeyData(0x01FBE110), cpscvk(2), puiVKey(0x0A38FE6C)
-ScanCodeToVKey(uiScanCode(0x000000FF), *puiVKey(0x00000000), fRet : FALSE
-KeybdDriverInitializeEx()
+Lyg.p
-Lyg.p

Technorati tags: , ,

New Driver should to implement IOCTL_POWER_SET to drop PowerUp() & PowerDown()

Posted in Driver, 電腦和網際網路, WinCE on 2007 年 11 月 17 日 by Kun-Yi

Suspend path on an implement power management device for WinCE 4.2 and Later

  1. Power Manager disable all Power-manageable none-block drivers.
  2. Power Manager calls the IOCTL_HAL_PRESUSPEND input/output control code. (to call OEMIoControl())
  3. Power Manager notifies file systems.
  4. Power Manager disable all Power-manageable block drivers.
  5. The operating system transitions to singnal threaded mode
  6. Power Manager calls all legcy XXX_PowerDown() callback function. In the state can not to calls any system call, because they will make the drivers non-pageable. The OS output the following event to the kernal debug port when to use any system call."!Unrecoverable Error: Exception or calling API inside Power Handler" or"ERROR : Power Handler function yield to low priority thread.
  7. Power Manager calls the OEMPowerOff(), which is the OEM code that suspends the CPU.
So when need write a new driver should to implement IOCTL_POWER_SET not to use PowerUP() and PowerDown() handle power state transition.The keypoint IOCTL_POWER_SET is pageable but PowerUp & PowerDown are non-pageable.
an example code:
FOO_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn,
        DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
	BOOL fRet = FALSE;
	switch(dwCode) {
	..... // Others IoControl Handle
	case IOCTL_POWER_CAPABILITIES:
		if (pBufOut && pdwActualOut && (dwLenOut >= sizeof (POWER_CAPABILITIES)))
		{
    			PPOWER_CAPABILITIES ppc = (PPOWER_CAPABILITIES) pBufOut;

			memset(ppc, 0, sizeof(*ppc));
			// Add support power states that need handling
			// D0=0x01, D1=0x02, D2=0x04, D3=0x08, D4=0x10
			ppc->DeviceDx = (0x01 | 0x10); // D0, D4
			//  Setup other power capabilietes here
			*pdwActualOut = sizeof(POWER_CAPABILITIES);
			fRet = TRUE;
		}
		else 
		{
			SetLastError(ERROR_INVALID_PARAMETER);
		}
		break;
	case IOCTL_POWER_GET:
		........
		break;
	case IOCTL_POWER_SET:
		if (pBufOut && pdwActualOut && (dwLenOut >= sizeof (CEDEVICE_POWER_STATE)))
		{
			CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE) pBufOut;

			//  Other IOCTL_POWER_SET code here
			switch(NewDx) {
			case D0:
				//  PowerUp() code moved here so we can page
        			break;
			case D1:
			case D2:
        			//  Other power states can be handled here
				break;
			case D3:
			case D4:
        			//  PowerDown() code moved here so we can page
        			break;
			}
		}
		else
		{
			SetLastError(ERROR_INVALID_PARAMETER);
		}
		break;
	}
}

Write a IClas interface of Power Mangeable value to registry of the driver let ActivateDeviceEx() automation notify Power Manager have a Power-manageable driver add when Driver Manager call.

Power manageable interface of IClass type

  • “{A32942B7-920C-486b-B0E6-92A702A99B35}" for Power-manageable non-block driver, generic driver
  • “{8DD679CE-8AB4-43c8-A14A-EA4963FAA715}" for Power-manageable block driver
  • “{98C5250D-C29A-4985-AE5F-AFE5367E5006}" for Power-manageable NDIS minport driver

Ref.

Line 880 into PlatformSetSystemPowerState() in PUBLICCOMMONOAKDRIVERSPMPDDPDAplatform.cpp

PowerHandlerGuardThrd() in PRIVATEWINCEOSCOREOSNKKERNELschedule.c

SC_PowerOffSystem() in PRIVATEWINCEOSCOREOSNKKERNELkwin32.c, system funciton PowerOffSystem() implement
Technorati tags: , ,