Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

120 lines
2.0 KiB

/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
modesw.c
Abstract:
This module provides support for performing mode switching on the 32 bit
side.
Author:
Dave Hastings (daveh) 24-Nov-1992
Revision History:
Neil Sandlin (neilsa) 31-Jul-1995 - Updates for the 486 emulator
--*/
#include "precomp.h"
#pragma hdrstop
#include "softpc.h"
VOID
DpmiSwitchToRealMode(
VOID
)
/*++
Routine Description:
This routine performs a mode switch to real (v86) mode. CS
register is loaded with the dosx real mode code segment
Arguments:
None.
Return Value:
None.
--*/
{
#if defined(i386)
// bugbug hack hack
*((PUSHORT)(DosxRmCodeSegment << 4) + 2) = DosxStackSegment;
#else
PWORD16 Data;
Data = (PWORD16)Sim32GetVDMPointer(
((ULONG)DosxRmCodeSegment << 16) | 4,
1,
FALSE
);
*(Data) = DosxStackSegment;
#endif
setCS(DosxRmCodeSegment);
setMSW(getMSW() & ~MSW_PE);
#ifndef i386
//BUGBUG This is a workaround to reload a 64k limit into SS for the
// emulator, now that we are in real mode.
// Not doing this would cause the emulator to do a hardware reset
setSS_BASE_LIMIT_AR(getSS_BASE(), 0xffff, getSS_AR());
#endif
}
VOID
DpmiSwitchToProtectedMode(
VOID
)
/*++
Routine Description:
This routine switches to protected mode. It assumes that the caller
will take care of setting up the segment registers.
Arguments:
None.
Return Value:
None.
--*/
{
#if defined(i386)
// bugbug hack hack
*((PUSHORT)(DosxRmCodeSegment << 4) + 2) = 0xb7;
#else
PWORD16 Data;
Data = (PWORD16)Sim32GetVDMPointer(
((ULONG)DosxRmCodeSegment << 16) | 4,
1,
FALSE
);
*(Data) = 0xb7;
#endif
setMSW(getMSW() | MSW_PE);
#ifndef i386
//BUGBUG This is a workaround to make sure the emulator goes back
// to privilege level 3 now that we are in protect mode.
// Not doing this would cause an access violation in dpmi32.
setCPL(3);
#endif
}