📄 jiurl键盘驱动 3.htm
字号:
kbdclass 处理输入数据的函数)取走数据之后,i8042prt 的输入数据队列的 DataOut 相应后移,InputCount
相应减少。<BR><BR>kbdclass 处理输入数据的函数中,满足那个应用层发来的等着读数据的 IRP。<BR>当 IRP
要求读的数据的大小,大于等于,i8042prt的输入数据队列中的数据时,IRP 直接从
i8042prt的输入数据队列中,读出所有输入数据,不使用kbdclass的输入数据队列。大多数情况下都是这样。<BR>当 IRP
要求读的数据的大小,小于,i8042prt的输入数据队列中的数据时,IRP 直接从 i8042prt的输入数据队列中,读出它所要求的大小,然后这个
IRP 被完成。i8042prt的输入数据队列中剩余的数据,被放入kbdclass的输入数据队列中。当应用层发来下一个读数据的 IRP 时,那个
IRP 将直接从 kbdclass 的输入数据队列中,读取数据,不需要等待。<BR><BR>
键盘驱动各层的设备对象是在初始化过程中创建的。键盘驱动设备栈是在初始化过程中构造的。键盘中断是在初始化过程中连接的。kbdclass
处理输入数据的回调函数的入口地址,是在初始化过程中告诉 i8042prt的,i8042prt把这个入口地址保存起来。i8042prt 和
kbdclass 的输入数据队列是在初始化过程中分配的内存。他们的 InputData , DataIn , DataOut , DataEnd ,
InputCount 在初始化的时候设置的初值。<BR><BR>详细的键盘驱动对键盘按键的处理,在以后讨论。<BR><BR><BR><B>6
键盘驱动的初始化</B><BR><BR>6.1 键盘驱动初始化调试信息<BR><BR>以下是使用 WinDbg
获得的调试版键盘驱动在初始化过程中的调试打印的输出。<BR>符号 [注释] 后的内容,是我加的简单注释。<BR>以 jiurl
开头的语句,是我自己在 kbdclass 中加的调试打印语句。
<P align=center><IMG src="JIURL键盘驱动 3.files/init1.gif" border=0>
<P>[注释] i8042prt!DriverEntry<BR>8042: I8xServiceParameters: \Parameters
path is
\REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\i8042prt\Parameters<BR>8042:
breaking on SysRq<BR>8042: I8xServiceParameters results..<BR>8042: Debug
flags are 0x88888808, Isr Debug flags are 0x0<BR>8042: Interrupts are not
shared<BR>8042: StallMicroseconds = 50<BR>8042: ResendIterations =
3<BR>8042: PollingIterations = 12000<BR>8042: PollingTerationsMaximum =
12000<BR>8042: DriverEntry (0x0) <BR><BR>[注释]
kbdclass!DriverEntry<BR>jiurl DriverEntry<BR>KBDCLASS-KbdConfiguration:
parameters path is
\REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\kbdclass\Parameters<BR>KBDCLASS-KbdConfiguration:
Keyboard class base name = KeyboardClass<BR>KBDCLASS-KbdConfiguration:
KeyboardInputDataQueueLength = 0x4b0<BR>KBDCLASS-KbdConfiguration:
MaximumPortsServiced = 3<BR>KBDCLASS-KbdConfiguration: Connection Type =
1<BR>jiurl
KbdDeterminePortsServiced<BR>KBDCLASS-KbdDeterminePortsServiced:
RtlQueryRegistryValues failed with
0xc0000034<BR>KBDCLASS-KeyboardClassInitialize: Will service 0 port
devices<BR>KBDCLASS-KeyboardClassInitialize: exit<BR><BR>[注释]
i8042prt!I8xAddDevice<BR>8042: enter Add Device <BR>8042: Add Device
(0x0)<BR><BR>[注释] kbdclass!KeyboardAddDevice<BR>jiurl
KeyboardAddDevice<BR>jiurl
KbdCreateClassObject<BR>KBDCLASS-KbdCreateClassObject:
enter<BR>KBDCLASS-KbdCreateClassObject: Creating device object named
\Device\KeyboardClass0<BR>jiurl
KbdInitializeDataQueue<BR>KBDCLASS-KbdInitializeDataQueue:
enter<BR>KBDCLASS-KbdInitializeDataQueue:
exit<BR>KBDCLASS-KbdCreateClassObject: exit<BR>jiurl
KeyboardQueryDeviceKey<BR>jiurl KeyboardQueryDeviceKey<BR>jiurl
KeyboardQueryDeviceKey<BR>jiurl KeyboardAddDeviceEx<BR>jiurl
KbdSendConnectRequest<BR>KBDCLASS-KbdSendConnectRequest:
enter<BR><BR>8042: IOCTL: enter<BR>8042: IOCTL: keyboard
connect<BR><BR>jiurl KeyboardClassPassThrough<BR><BR>8042: IOCTL:
enter<BR>8042: hook keyboard received!<BR>8042: IOCTL: exit
(0x0)<BR><BR>8042: result of sending 0xb3fc3 was 0x0<BR>8042: IOCTL: exit
(0x0)<BR><BR>KBDCLASS-KbdSendConnectRequest:
exit<BR><BR>KBDCLASS-KeyboardClassInitialize: Stored
\Device\KeyboardClass0 in DeviceMap<BR><BR>[注释] IRP_MJ_PNP
IRP_MN_QUERY_LEGACY_BUS_INFORMATION<BR>jiurl KeyboardPnP<BR><BR>8042:
I8xPnP (kb), enter (min func=0x18)<BR>8042: I8xPnP (kb) exit
(status=0xc00000bb)<BR><BR>[注释] ps/2 鼠标的调试信息,我们不关心<BR>8042: enter Add
Device <BR>8042: Add Device (0x0)<BR>8042: IOCTL: enter<BR>8042:
IOCTL: mouse connect<BR>8042: IOCTL: enter<BR>8042: hook mouse
received!<BR>8042: Mou Hook Routine 0xf91ff2fa<BR>8042: IOCTL: exit
(0x0)<BR>8042: result of sending 0xf3fc3 was 0x0<BR>8042: IOCTL: exit
(0x0)<BR>8042: I8xPnP (mou), enter (min func=0x18)<BR>8042: I8xPnP (mou)
exit (status=0xc00000bb)<BR><BR><BR>[注释] IRP_MJ_PNP
IRP_MN_FILTER_RESOURCE_REQUIREMENTS<BR>jiurl KeyboardPnP<BR><BR>8042:
I8xPnP (kb), enter (min func=0xd)<BR>8042: Received
IRP_MN_FILTER_RESOURCE_REQUIREMENTS for kb<BR>8042: option = 0x1, flags =
0x11<BR>8042: Saw port [0x00000000 00000060] - [0x00000000
00000060]<BR>8042: option = 0x1, flags = 0x11<BR>8042: Saw port
[0x00000000 00000064] - [0x00000000 00000064]<BR>8042: I8xPnP (kb) exit
(status=0x0)<BR><BR>[注释] ps/2 鼠标的调试信息,我们不关心<BR>8042: I8xPnP (mou), enter
(min func=0xd)<BR>8042: Received IRP_MN_FILTER_RESOURCE_REQUIREMENTS for
mouse<BR>8042: I8xPnP (mou) exit (status=0x0)<BR><BR>[注释] IRP_MJ_PNP
IRP_MN_START_DEVICE<BR>jiurl KeyboardPnP<BR>jiurl
KeyboardSendIrpSynchronously<BR>8042: I8xPnP (kb), enter (min
func=0x0)<BR>8042: I8xKeyboardStartDevice, enter<BR>8042: port is
io.<BR>8042: port is io.<BR>8042: Keyboard interrupt config
--<BR>NonSharable, Latched, Irq = 0xb3<BR>8042: Using default keyboard
type<BR>8042: Keyboard device specific data --<BR>Type = 4, Subtype = 0,
Initial LEDs = 0x0<BR>8042: I8xKeyboardServiceParameters
results..<BR>8042: PollStatusIterations = 12000<BR>8042: PowerCapabilities
= 0x0<BR>8042: I8xServiceCrashDump: crashdump path is
\REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\i8042prt\Crashdump<BR>8042:
I8xServiceCrashDump: RtlQueryRegistryValues failed with
0xc0000034<BR>8042: I8xServiceCrashDump: Dump1Keys = 0<BR>8042:
I8xServiceCrashDump: Dump2Key = 0<BR>8042: I8xInitializeDataQueue:
enter<BR>8042: I8xInitializeDataQueue: keyboard<BR>8042:
I8xInitializeDataQueue: exit<BR>8042: skipping init until mouse<BR>8042:
I8xKeyboardStartDevice successful<BR>8042: I8xKeyboardStartDevice exit
(0x0)<BR>jiurl KbdSyncComplete<BR>8042: I8xPnP (kb) exit
(status=0x0)<BR>jiurl KeyboardSendIrpSynchronously<BR>8042: I8xPnP (kb),
enter (min func=0x9)<BR>jiurl KbdSyncComplete<BR>8042: I8xPnP (kb) exit
(status=0x0)<BR><BR>[注释] IRP_MJ_PNP IRP_MN_QUERY_CAPABILITIES<BR>jiurl
KeyboardPnP<BR>8042: I8xPnP (kb), enter (min func=0x9)<BR>8042: I8xPnP
(kb) exit (status=0x0)<BR><BR>[注释] IRP_MJ_PNP
IRP_MN_QUERY_PNP_DEVICE_STATE<BR>jiurl KeyboardPnP<BR>jiurl
KeyboardSendIrpSynchronously<BR>8042: I8xPnP (kb), enter (min
func=0x14)<BR>jiurl KbdSyncComplete<BR>8042: I8xPnP (kb) exit
(status=0x0)<BR><BR>[注释] IRP_MJ_PNP IRP_MN_QUERY_DEVICE_RELATIONS<BR>jiurl
KeyboardPnP<BR>8042: I8xPnP (kb), enter (min func=0x7)<BR>8042: I8xPnP
(kb) exit (status=0x0)<BR><BR>[注释] 鼠标的 IRP_MJ_PNP
IRP_MN_START_DEVICE<BR>8042: I8xPnP (mou), enter (min func=0x0)<BR>8042:
I8xMouseStartDevice, enter<BR>8042: Mouse interrupt config
--<BR>NonSharable, Latched, Irq = 0x52<BR>8042: results from services
key:<BR>mouse queue length = 100<BR>number of buttons = 0<BR>sample rate =
60<BR>resolution = 3<BR>synch tick count = 10000000<BR>wheel detection =
1<BR>detection timeout = 0<BR>intiailize polled = 0<BR>reset stall time =
1000<BR>8042: results from devnode key:<BR>mouse queue length =
100<BR>number of buttons = 0<BR>sample rate = 60<BR>resolution =
3<BR>synch tick count = 20000000<BR>wheel detection = 2<BR>initialize
polled = 0<BR>detection timeout = 1500<BR>8042: wheel id: MSH0002<BR>8042:
wheel id: MSH0005<BR>8042: wheel id: MSH0010<BR>8042:
I8xMouseServiceParameters results..<BR>8042: EnableWheelDetection =
0x2<BR>8042: MouseDataQueueSize = 0x960<BR>8042: NumberOfButtons =
2<BR>8042: SampleRate = 60<BR>8042: MouseResolution = 3<BR>8042:
MouseResetStallTime = 1000<BR>8042: WheelDetectionTimeout = 96<BR>8042:
MouseSynchIn100ns = 0x80<BR>8042: I8xInitializeDataQueue: enter<BR>8042:
I8xInitializeDataQueue: mouse<BR>8042: I8xInitializeDataQueue:
exit<BR><BR>[注释] i8042prt!I8xMouseStartDevice->
I8xMouseInitializeHardware-> [未完]<BR>[接上]
I8xInitializeHardwareAtBoot-> I8xSanityCheckResources<BR>8042:
NonSharable, Ports (#0) 0x60 - 0x60<BR>8042: NonSharable, Ports (#1) 0x64
- 0x64<BR><BR>[注释] i8042prt!I8xMouseStartDevice->
I8xMouseInitializeHardware-> [未完]<BR>[接上]
I8xInitializeHardwareAtBoot-> I8xToggleInterrupts(FALSE)<BR>8042:
I8xToggleInterrupts(FALSE), enter<BR><BR>8042:
I8xTransmitControllerCommand: enter<BR>8042: I8xGetControllerCommand:
enter<BR>8042: I8xPutBytePolled: enter<BR>8042: I8xDrainOutputBuffer:
enter<BR>8042: I8xDrainOutputBuffer: exit<BR>8042: I8xPutBytePolled:
sending 0x20 to command port<BR>8042: I8xPutBytePolled: exit<BR>8042:
I8xGetBytePolled: enter<BR>8042: I8xGetBytePolled: 8042
controller<BR>8042: I8xGetBytePolled: exit with Byte 0x47<BR>8042:
I8xGetControllerCommand: exit<BR>8042: I8xTransmitControllerCommand:
current CCB 0x47<BR>8042: I8xPutControllerCommand: enter<BR>8042:
I8xPutBytePolled: enter<BR>8042: I8xDrainOutputBuffer: enter<BR>8042:
I8xDrainOutputBuffer: exit<BR>8042: I8xPutBytePolled: sending 0x60 to
command port<BR>8042: I8xPutBytePolled: exit<BR>8042:
I8xPutControllerCommand: exit<BR>8042: I8xPutBytePolled: enter<BR>8042:
I8xDrainOutputBuffer: enter<BR>8042: I8xDrainOutputBuffer: exit<BR>8042:
I8xPutBytePolled: sending 0x44 to data port<BR>8042: I8xPutBytePolled:
exit<BR>8042: I8xTransmitControllerCommand: new CCB 0x44<BR>8042:
I8xGetControllerCommand: enter<BR>8042: I8xPutBytePolled: enter<BR>8042:
I8xDrainOutputBuffer: enter<BR>8042: I8xDrainOutputBuffer: exit<BR>8042:
I8xPutBytePolled: sending 0x20 to command port<BR>8042: I8xPutBytePolled:
exit<BR>8042: I8xGetBytePolled: enter<BR>8042: I8xGetBytePolled: 8042
controller<BR>8042: I8xGetBytePolled: exit with Byte 0x44<BR>8042:
I8xGetControllerCommand: exit<BR>8042: I8xTransmitControllerCommand:
exit<BR><BR>[注释] i8042prt!I8xMouseStartDevice->
I8xMouseInitializeHardware-> [未完]<BR>[接上]
I8xInitializeHardwareAtBoot-> I8xInitializeHardware<BR>8042:
I8xInitializeHardware: enter<BR><BR>8042: I8xDrainOutputBuffer:
enter<BR>8042: I8xDrainOutputBuffer: exit<BR>8042: I8xDrainOutputBuffer:
enter<BR>8042: I8xDrainOutputBuffer: exit<BR><BR>[注释]
i8042prt!I8xMouseStartDevice-> I8xMouseInitializeHardware->
[未完]<BR>[接上] I8xInitializeHardwareAtBoot-> I8xInitializeHardware->
I8xInitializeKeyboard<BR>8042: I8xInitializeKeyboard, enter<BR><BR>8042:
I8xPutBytePolled: enter<BR>8042: I8xDrainOutputBuffer: enter<BR>8042:
I8xDrainOutputBuffer: exit<BR>8042: I8xPutBytePolled: sending 0xff to data
port<BR>8042: I8xPutBytePolled: waiting for ACK<BR>8042: I8xGetBytePolled:
enter<BR>8042: I8xGetBytePolled: keyboard<BR>8042: I8xGetBytePolled: exit
with Byte 0xfa<BR>8042: I8xPutBytePolled: got ACK<BR>8042:
I8xPutBytePolled: exit<BR>8042: I8xGetBytePolled: enter<BR>8042:
I8xGetBytePolled: keyboard<BR>8042: I8xGetBytePolled: exit with Byte
0xaa<BR><BR>8042: I8xTransmitControllerCommand: enter<BR>8042:
I8xGetControllerCommand: enter<BR>8042: I8xPutBytePolled: enter<BR>8042:
I8xDrainOutputBuffer: enter<BR>8042: I8xDrainOutputBuffer: exit<BR>8042:
I8xPutBytePolled: sending 0x20 to command port<BR>8042: I8xPutBytePolled:
exit<BR>8042: I8xGetBytePolled: enter<BR>8042: I8xGetBytePolled: 8042
controller<BR>8042: I8xGetBytePolled: exit with Byte 0x44<BR>8042:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -