BOOLEAN
WaitForKeyboardWrite(VOID)
{
INT i;
UCHAR c;
for (i = 0; i < 1000; ++i)
{
KeStallExecutionProcessor(50);
c = READ_PORT_UCHAR(defI8042_CTRL_PORT);
if ((c & defOBUFFER_FULL) == defOBUFFER_FULL)
break;
}
return i ? TRUE : FALSE;
}
VOID PressKeyByScanCode(
IN CONST BYTE ScanCode
)
{
WRITE_PORT_UCHAR(defI8042_CTRL_PORT, 0xd2);
typedef VOID (* PFN_KeyboardClassServiceCallback)(
IN PDEVICE_OBJECT DeviceObject,
IN PKEYBOARD_INPUT_DATA InputDataStart,
IN PKEYBOARD_INPUT_DATA InputDataEnd,
IN OUT PULONG InputDataConsumed
);
关于写端口部分,不知道楼住从哪里找的代码,写错了吧。
BOOLEAN
WaitForKeyboardWrite(VOID)
{
INT i;
UCHAR c;
for (i = 0; i < 1000; ++i)
{
KeStallExecutionProcessor(50);
c = READ_PORT_UCHAR(defI8042_CTRL_PORT);
if ((c & defOBUFFER_FULL) == defOBUFFER_FULL)
break;
}
return i ? TRUE : FALSE;
}
判断状态寄存器是否为空,判断条件应该是
if ((c & 0x02)==0)
下面这句判断出的结果是输出buffer为满的情况
if ((c & defOBUFFER_FULL) == defOBUFFER_FULL)