12.26.2006

Address Space , Device Driver and DeviceIoControl

提供DeviceIoControl( ) function 的有兩個 EXE : Service.EXE, Device.EXE。
在 devcore.c 和 service. cpp 中 都有這樣的function table :

DevFileApiMethods[] 其中第11個entry 就是 DeviceIoControl。

這個Set API function array 要經由CreateApiSet( )向kernel 註冊,才能成為一個經由"File Handler"呼叫的function。

Kernel 的SC_DeviceIoControl ( ) 會經由 pci->ppfnMethods[11] 呼叫 entry11 - DeviceIoControl。

SC_DeviceIoControl( )是 g_KmodeEntries 中的一個entry。

在CoreDllInit( ) 的DLL_PROCESS_ATTACH時, copy 一份到Coredll的位址空間。
-- 但是找不到 invoke g_KmodeEntries( )的code :(

因為 API entry (wrapper) 的code完全沒有 (例如 DeviceIoControl( ) ),只能找到下一層,所以不知道user program call DeviceIoControl( )後,有沒有切換到其他process (device.exe ? kernel ?) 的位址空間。
所以不知道 各Driver 的Iocontrol Function 是 run 在那一個process 的address space (猜大概是device.exe吧)。

http://blogs.msdn.com/ce_base/archive/2006/02/02/Inside-Windows-CE-API-Calls.aspx
有說明這一段,wrapper implement在coredll中,所有user application link coredll.dll。
coredll 經由 coredll.def 修改 export 出來的function 名稱:
   DeviceIoControl=xxx_DeviceIoControl @179 
所以呼叫DeviceIoControl( )是會呼叫到 xxx_DeviceIoControl ( )。


在oak\inc\pkfunc.h 中可以看到memory model 的constant 宣告:
http://140.114.71.71/WinCE/templates/chapters/chapter10.v1.doc
FIRST_MAPPER_ADDRESS
LAST_MAPPER_ADDRESS 0x7C000000
在這段code的附近可以看到有關"slot", 每個slot 32M (25bit) ,slot 0 reserve 給 running process 和MAX_PROCESS = 32的宣告。

沒有留言: