Implement INT 15h, AH=4Fh "Keyboard intercept", which is used by INT 9h / IRQ 1 to possibly translate scan code before any further treatment. The default implementation is a trivial one, do it à la DosBox.

svn path=/trunk/; revision=64324
This commit is contained in:
Hermès Bélusca-Maïto 2014-09-27 02:17:54 +00:00
parent 7d8a75747a
commit 41e8832080
4 changed files with 37 additions and 4 deletions

View file

@ -146,6 +146,16 @@ static VOID WINAPI BiosMiscService(LPWORD Stack)
{
switch (getAH())
{
/* Keyboard intercept */
case 0x4F:
{
/* CF should be set but let's just set it again just in case */
/* Do not modify AL (the hardware scan code), but set CF to continue processing */
// setCF(1);
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
break;
}
/* Wait */
case 0x86:
{
@ -493,7 +503,7 @@ static VOID InitializeBiosInfo(VOID)
Bct->Model = BIOS_MODEL;
Bct->SubModel = BIOS_SUBMODEL;
Bct->Revision = BIOS_REVISION;
Bct->Feature[0] = 0x64; // At the moment we don't support "INT 15/AH=4Fh called upon INT 09h" nor "wait for external event (INT 15/AH=41h) supported"; see http://www.ctyme.com/intr/rb-1594.htm#Table510
Bct->Feature[0] = 0x70; // At the moment we don't support "wait for external event (INT 15/AH=41h)", we also don't have any "extended BIOS area allocated (usually at top of RAM)"; see http://www.ctyme.com/intr/rb-1594.htm#Table510
Bct->Feature[1] = 0x00; // We don't support anything from here; see http://www.ctyme.com/intr/rb-1594.htm#Table511
Bct->Feature[2] = 0x00;
Bct->Feature[3] = 0x00;

View file

@ -197,8 +197,26 @@ static VOID WINAPI BiosKeyboardIrq(LPWORD Stack)
BYTE ScanCode, VirtualKey;
WORD Character;
/* Get the scan code and virtual key code */
ScanCode = IOReadB(PS2_DATA_PORT);
/*
* Get the scan code from the PS/2 port, then call the
* INT 15h, AH=4Fh Keyboard Intercept function to try to
* translate the scan code. CF must be set before the call.
* In return, if CF is set we continue processing the scan code
* stored in AL, and if not, we skip it.
*/
setCF(1);
setAL(IOReadB(PS2_DATA_PORT));
setAH(0x4F);
Int32Call(&BiosContext, BIOS_MISC_INTERRUPT);
/* Check whether CL is clear. If so, skip the scan code. */
if (getCF() == 0) goto Quit;
/**/setCF(0);/**/ // FIXME: HACK: Reset CF otherwise we enter in an infinite loop.
/* Retrieve the modified scan code in AL */
ScanCode = getAL();
/* Get the corresponding virtual key code */
VirtualKey = MapVirtualKey(ScanCode & 0x7F, MAPVK_VSC_TO_VK);
/* Check if this is a key press or release */
@ -255,6 +273,10 @@ static VOID WINAPI BiosKeyboardIrq(LPWORD Stack)
if (BiosKeyboardMap[VK_CAPITAL] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_CAPSLOCK;
if (BiosKeyboardMap[VK_INSERT] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_INSERT;
DPRINT("BiosKeyboardIrq - Character = 0x%X, ScanCode = 0x%X, KeybdShiftFlags = 0x%X\n",
Character, ScanCode, Bda->KeybdShiftFlags);
Quit:
PicIRQComplete(Stack);
}

View file

@ -91,7 +91,6 @@ Quit:
default:
{
DPRINT1("Unknown DOS System BOP Function: 0x%02X\n", FuncNum);
// setCF(1); // Disable, otherwise we enter an infinite loop
break;

View file

@ -40,6 +40,8 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
PS2QueuePush(PS2Port, ScanCode);
}
DPRINT("Press 0x%X\n", ScanCode);
// PicInterruptRequest(1);
}