blob: 1cc618c4ece32487a4adac22542554d705a0bfb5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*++
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
}
|