mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[NTVDM]
Programs don't expect the XMS function AH = 07h to access the keyboard controller, since the specification says it's done in a hardware-independent way. So, reimplement this function by calling EmulatorGetA20() instead. Also, for the sake of simplicity, use EmulatorSetA20 instead of PCAT_A20Control to change the A20 state. svn path=/trunk/; revision=68029
This commit is contained in:
parent
50f36e7cb3
commit
b0c5426a7c
1 changed files with 4 additions and 63 deletions
|
@ -76,47 +76,13 @@ static LONG A20EnableCount = 0;
|
||||||
|
|
||||||
/* HELPERS FOR A20 LINE *******************************************************/
|
/* HELPERS FOR A20 LINE *******************************************************/
|
||||||
|
|
||||||
static BOOLEAN PCAT_A20Control(BYTE Control, PBOOLEAN A20Status)
|
|
||||||
{
|
|
||||||
BYTE ControllerOutput;
|
|
||||||
|
|
||||||
/* Retrieve PS/2 controller output byte */
|
|
||||||
IOWriteB(PS2_CONTROL_PORT, 0xD0);
|
|
||||||
ControllerOutput = IOReadB(PS2_DATA_PORT);
|
|
||||||
|
|
||||||
switch (Control)
|
|
||||||
{
|
|
||||||
case 0: /* Disable A20 line */
|
|
||||||
ControllerOutput &= ~0x02;
|
|
||||||
IOWriteB(PS2_CONTROL_PORT, 0xD1);
|
|
||||||
IOWriteB(PS2_DATA_PORT, ControllerOutput);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: /* Enable A20 line */
|
|
||||||
ControllerOutput |= 0x02;
|
|
||||||
IOWriteB(PS2_CONTROL_PORT, 0xD1);
|
|
||||||
IOWriteB(PS2_DATA_PORT, ControllerOutput);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* Get A20 status */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (A20Status)
|
|
||||||
*A20Status = (ControllerOutput & 0x02) != 0;
|
|
||||||
|
|
||||||
/* Return success */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VOID XmsLocalEnableA20(VOID)
|
static VOID XmsLocalEnableA20(VOID)
|
||||||
{
|
{
|
||||||
/* Enable A20 only if we can do so, otherwise make the caller believe we enabled it */
|
/* Enable A20 only if we can do so, otherwise make the caller believe we enabled it */
|
||||||
if (!CanChangeA20) goto Quit;
|
if (!CanChangeA20) goto Quit;
|
||||||
|
|
||||||
/* The count is zero so enable A20 */
|
/* The count is zero so enable A20 */
|
||||||
if (A20EnableCount == 0 && !PCAT_A20Control(1, NULL))
|
if (A20EnableCount == 0) EmulatorSetA20(TRUE);
|
||||||
goto Fail;
|
|
||||||
|
|
||||||
++A20EnableCount;
|
++A20EnableCount;
|
||||||
|
|
||||||
|
@ -124,11 +90,6 @@ Quit:
|
||||||
setAX(0x0001); /* Line successfully enabled */
|
setAX(0x0001); /* Line successfully enabled */
|
||||||
setBL(XMS_STATUS_SUCCESS);
|
setBL(XMS_STATUS_SUCCESS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Fail:
|
|
||||||
setAX(0x0000); /* Line failed to be enabled */
|
|
||||||
setBL(XMS_STATUS_A20_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID XmsLocalDisableA20(VOID)
|
static VOID XmsLocalDisableA20(VOID)
|
||||||
|
@ -142,8 +103,7 @@ static VOID XmsLocalDisableA20(VOID)
|
||||||
--A20EnableCount;
|
--A20EnableCount;
|
||||||
|
|
||||||
/* The count is zero so disable A20 */
|
/* The count is zero so disable A20 */
|
||||||
if (A20EnableCount == 0 && !PCAT_A20Control(0, NULL))
|
if (A20EnableCount == 0) EmulatorSetA20(FALSE);
|
||||||
goto Fail;
|
|
||||||
|
|
||||||
Quit:
|
Quit:
|
||||||
setAX(0x0001); /* Line successfully disabled */
|
setAX(0x0001); /* Line successfully disabled */
|
||||||
|
@ -156,25 +116,6 @@ Fail:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID XmsGetA20State(VOID)
|
|
||||||
{
|
|
||||||
BOOLEAN A20Status = FALSE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: The XMS specification explicitely says that this check is done
|
|
||||||
* in a hardware-independent manner, by checking whether high memory wraps.
|
|
||||||
* For our purposes we just call the emulator API.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Get A20 status */
|
|
||||||
if (PCAT_A20Control(2, &A20Status))
|
|
||||||
setBL(XMS_STATUS_SUCCESS);
|
|
||||||
else
|
|
||||||
setBL(XMS_STATUS_A20_ERROR);
|
|
||||||
|
|
||||||
setAX(A20Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
static inline PXMS_HANDLE GetHandleRecord(WORD Handle)
|
static inline PXMS_HANDLE GetHandleRecord(WORD Handle)
|
||||||
|
@ -395,8 +336,8 @@ static VOID WINAPI XmsBopProcedure(LPWORD Stack)
|
||||||
/* Query A20 State */
|
/* Query A20 State */
|
||||||
case 0x07:
|
case 0x07:
|
||||||
{
|
{
|
||||||
/* This call sets AX and BL to their correct values */
|
setAX(EmulatorGetA20());
|
||||||
XmsGetA20State();
|
setBL(XMS_STATUS_SUCCESS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue