2011年9月2日 星期五

Windows CE 的 debug console

一般來講, Windows CE (或 mobile 或 phone, ...) 都會用到一個 UART port 當 debug console, 因為最少 e-boot 裡會用到 debug console, 進 OS 後也會在 debug console 裡秀一些錯誤訊息.

OK, 有人提議說把這個 debug console 拿掉, 還原回一般 UART 的功能. 怎麼做咧? 一開始想到的就是改掉整個 BSP 裡對 OALMSG, DEBUGMSG, RETAILMSG 的定義, 我的 BSP 裡是被轉向到 printf_exp 這個東西, 但我找不到 printf_exp 的進入點在哪裡...

於是我轉而去改另一樣東西, 也就是 e-boot 跟 kernel 在啟始時都會啟始的 debug console, 這個 function 一般是 "OEMDebugInit" (BOOL OEMDebugInit(void)), 在 blcommon.c 中 BootloadertMain 裡會呼叫它, 如果都追不到這些 function name 也沒關係, 因為這些都還不算重點, 我覺的重點在 "OALLogSetZones" 這個 function 上, 用 ultraedit 搜尋 BSP 裡有沒有地方用上, 有用上就是了.

一般 BSP 會用 OALLogSetZones(initialOALLogZones); 的方式向系統告知有 debug console 可用, 如果可以的話, 在這之前做點要不要 debug console 的判斷, 來打開或關掉 (移作它用) 它吧.

後記:
OALLogSetZones 設定的是要輸出哪些 debug message, 設 0 就是不輸出任何訊息, 而 console debug message 的實作是 call 兩個東西:
int OEMReadDebugByte();
VOID OEMWriteDebugByte(UINT8 ch);
(ps.它本來就沒有佔用任何 COM 的 file header)
要在這裡直接攔掉 debug console 的操作.

至於要不要把 output console message 轉向到 IPU, input 指去 keyboard array, 那又是另一段工程了....

2011/11/15 update:
這樣做還有另一個副作用, 就是進 suspend 會死當, 不過這種情況要滿足兩種條件:
1.UART1 為 debug port, 而且 OALLogSetZones() 設定時不為 0 (message enable)
2.UART1 設定可以被 OS 使用.

這樣在進 suspend 時, UART1 也當然會 power-off, 但當 power-off 時, debug message 也就跟著送不出去, 然後系統就 hang 住.

可以靠修改 code 解這個問題.
------------------
\\WINCE600\PLATFORM\COMMON\src\soc\COMMON_FSL_V2_PDK1_7\SERIAL\serial.c
extern DWORD initialOALLogZones;
static BOOL SerPowerOff(PVOID pContext)
{
PUART_INFO pHWHead = (PUART_INFO)pContext;
if(pHWHead->HwAddr == 0x43f90000L && initialOALLogZones != 0) return TRUE;
...
}
------------------
在這兩個 sources 檔案的 link 裡加上 "$(_PLATCOMMONLIB)\$(_CPUDEPPATH)\oal_log.lib":
\\WINCE600\PLATFORM\COMMON\src\soc\COMMON_FSL_V2_PDK1_7\SERIAL\sources
\\WINCE600\PLATFORM\iMX35-3DS-PDK1_7\src\DRIVERS\SERIAL\sources

沒有留言: