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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
/*++
Copyright (c) 1992 NCR Corporation
Module Name:
ncrstop.c
Abstract:
Provides the interface to the firmware for x86.
Author:
Richard R. Barton (o-richb) 04-Feb-1992
Revision History:
--*/
#include "halp.h"
#include "ncr.h"
/*
* Some plagarism from ixreboot.c
*/
//
// Defines to let us diddle the CMOS clock and the keyboard
//
#define CMOS_CTRL (PUCHAR )0x70
#define CMOS_DATA (PUCHAR )0x71
// below 2 defines are for 3450/3550 machines
#define SHUT_DOWN 0x8F
#define SHUT5 0x05
#define RESET 0xfe
#define KEYBPORT (PUCHAR )0x64
extern ULONG NCRPlatform;
extern BOOLEAN NCRPowerOffSystem;
//
// Private function prototypes
//
VOID
HalpReboot (
VOID
);
VOID
HalReturnToFirmware(
IN FIRMWARE_ENTRY Routine
)
/*++
Routine Description:
Returns control to the firmware routine specified.
BUGBUG This can probably do useful things (like rebooting) for some
values of Routine.
Arguments:
Routine - Supplies a value indicating which firmware routine to invoke.
Return Value:
Does not return.
--*/
{
switch (Routine) {
case HalPowerDownRoutine:
if (NCRPlatform != NCR3360) {
HalpCatPowerOffSystem();
}
case HalHaltRoutine:
case HalRestartRoutine:
case HalRebootRoutine:
//
// Never returns
//
if ((NCRPlatform != NCR3360) && (NCRPowerOffSystem == TRUE)) {
HalpCatPowerOffSystem();
} else {
HalpVideoReboot();
HalpReboot();
}
break;
default:
DBGMSG(("HalReturnToFirmware called\n"));
DbgBreakPoint();
break;
}
}
VOID
HalpReboot (
VOID
)
/*++
Routine Description:
This procedure resets the CMOS clock to the standard timer settings
so the bios will work, and then issues a reset command to the keyboard
to cause a warm boot.
It is very machine dependent, this implementation is intended for
PC-AT like machines.
This code copied from the "old debugger" sources.
N.B.
Will NOT return.
--*/
{
UCHAR Scratch;
PUSHORT Magic;
//
// By sticking 0x1234 at physical location 0x472, we can bypass the
// memory check after a reboot.
//
Magic = HalpMapPhysicalMemory(0, 1);
Magic[0x472 / sizeof(USHORT)] = 0x1234;
//
// Turn off interrupts
//
HalpAcquireCmosSpinLock();
_asm {
cli
}
//
// Reset the cmos clock to a standard value
// (We are setting the periodic interrupt control on the MC147818)
//
//
// Disable periodic interrupt
//
WRITE_PORT_UCHAR(CMOS_CTRL, 0x0b); // Set up for control reg B.
KeStallExecutionProcessor(1);
Scratch = READ_PORT_UCHAR(CMOS_DATA);
KeStallExecutionProcessor(1);
Scratch &= 0xbf; // Clear periodic interrupt enable
WRITE_PORT_UCHAR(CMOS_DATA, Scratch);
KeStallExecutionProcessor(1);
//
// Set "standard" divider rate
//
WRITE_PORT_UCHAR(CMOS_CTRL, 0x0a); // Set up for control reg A.
KeStallExecutionProcessor(1);
Scratch = READ_PORT_UCHAR(CMOS_DATA);
KeStallExecutionProcessor(1);
Scratch &= 0xf0; // Clear rate setting
Scratch |= 6; // Set default rate and divider
WRITE_PORT_UCHAR(CMOS_DATA, Scratch);
KeStallExecutionProcessor(1);
//
// Set a "neutral" cmos address to prevent weirdness
// (Why is this needed? Source this was copied from doesn't say)
//
WRITE_PORT_UCHAR(CMOS_CTRL, 0x15);
KeStallExecutionProcessor(1);
//
// for 3450/3550 machines - Set shutdown flag to reset
//
if ((NCRPlatform == NCR3450) || (NCRPlatform == NCR3550)) {
WRITE_PORT_UCHAR(CMOS_CTRL, SHUT_DOWN);
WRITE_PORT_UCHAR(CMOS_DATA, SHUT5);
}
//
// Send the reset command to the keyboard controller
//
WRITE_PORT_UCHAR(KEYBPORT, RESET);
_asm {
hlt
}
}
|