About keyboard interrupt handler routine?

Here you can discuss ReactOS related topics.

Moderator: Moderator Team

Post Reply
bwahn
Posts: 4
Joined: Thu Dec 08, 2005 12:40 pm

About keyboard interrupt handler routine?

Post by bwahn »

I am working on Keyboard Driver for substitution PNPi8042 driver
At first, focusing on Windows 2000 or above. It's WinNT device driver.
it's not WDM

I have refereced _MpsIpiInterrupt Interrupt Handler in Reactos.


we have build a test driver, which is a keyboard interrupt driver.
we don't use IoConnectInterrupt() function.
In a alternative plan, we changed existing keyboard interrupt vector
address
into new interrupt vector address.


But, We have some problem in test driver.
Problem is
1. double interrupt
It meas that if happen keyboard interrupt, generate PNPi8042 interrupt
and MyKeyboard interrupt.


example)
- In example, If typing a "ABCDEF" as fastest, in our handler, "ABEF"
processing, In pnpi8042 , "CE" processing.


I would appreciate the help on this.


Eric. Ahn.


ps:In source code.
///////////////////////////////////////////////////////////////////////////­­­//////////////////////////////


#define MAKE_INT_HANDLER1_KEYBOARD(_CALLBACK) \
static ULONG GInt1_OldInt1KeyboardHandler = 0; \
static void _declspec(naked) MakeInt1_KeyboardHandler() \
{ \
__asm { PUSH ESP } \
__asm { PUSH EAX } \
__asm { PUSHAD } \
__asm { PUSHFD }\
__asm { push fs } \
__asm { mov bx, 0x30 } \
__asm { mov fs, bx } \
__asm { call _CALLBACK } \
__asm { pop fs } \
__asm { POPFD } \
__asm { POPAD } \
__asm { POP EAX } \
__asm { POP ESP } \
__asm { jmp dword ptr cs:[GInt1_OldInt1KeyboardHandler]



} \


}

BEGINE_MAKE_INT_HANDLER()
MAKE_INT_HANDLER1_KEYBOARD(KeyboardInterruptHandler)
END_MAKE_INT_HANDLER()


DriverEntry()
{
// starting driver
// IoCreateDevice()...
..
///////
// Get keyboard vector
gmappedSysVect = HalGetInterruptVector(
BusType,
(ULONG)BusNumber, // BusNumber,
Level, // Level
Vector, // Vector,
&Irql, // IRQL
&Affinity); // Affinity mask



}


DriverStarting()
{
PKTHREAD pThread;
X86_GATE *aIdtEntry;
char G_szBuffIdtr[6];
PIDTR G_pIDTR;
G_pIDTR=(PIDTR)G_szBuffIdtr;
__asm { sidt G_szBuffIdtr }
aIdtEntry=(PX86_GATE)G_pIDTR->Base;

// hooking keyboard interrupt handler
//
GInt1_OldInt1KeyboardHandler =
((unsigned int)aIdtEntry [gmappedSysVect ].OffsetHigh<<16U)
| (aIdtEntry[gmappedSysVect ].OffsetLow);
__asm { cli }
aIdtEntry[Globals.KeyboardExtension->mappedSysVect].OffsetLow
=(unsigned short)MakeInt1_KeyboardHandler;


aIdtEntry[Globals.KeyboardExtension->mappedSysVect].OffsetHigh
=(unsigned short)((unsigned
int)MakeInt1_KeyboardHandler>>16);
__asm { sti }



}


INT_API KeyboardInterruptHandler()
{
KEYBOARD_SCAN_STATE *scanState;
statusByte =
I8X_GET_STATUS_BYTE(Globals.ControllerData->DeviceRegisters[CommandPort]);

if ((statusByte & BUFFER_FULL) != OUTPUT_BUFFER_FULL) {
KdPrint((" status != OUTPUT_BUFFER_FULL\n"));
for (i = 0; i <
(ULONG)Globals.ControllerData->Configuration.PollStatusIterations; i++)


{
KeStallExecutionProcessor(1);
statusByte =
I8X_GET_STATUS_BYTE(Globals.ControllerData->DeviceRegisters[CommandPort]);


if ((statusByte & BUFFER_FULL) == (OUTPUT_BUFFER_FULL)) {
break;
}
}
statusByte =
I8X_GET_STATUS_BYTE(Globals.ControllerData->DeviceRegisters[CommandPort]);


if ((statusByte & BUFFER_FULL) != (OUTPUT_BUFFER_FULL))
{
KdPrint((" not our interrupt! %x\n", statusByte));
if (Globals.KeyboardExtension->EnableCount == 0) {
scanCode
=V8X_GET_DATA_BYTE(Globals.ControllerData->DeviceRegisters[DataPort]);
KdPrint((" EnableCount==0 %x\n", scanCode));
}
return;
}
}


I8xGetByteAsynchronous(
(CCHAR) KeyboardDeviceType,
&scanCode
);


KdPrint((" scanCode 0x%x\n", scanCode));


// processing more...
// ..
// ..
Post Reply

Who is online

Users browsing this forum: DotBot [Crawler] and 46 guests