summaryrefslogblamecommitdiffstats
path: root/private/ntos/fw/alpha/fwhalt.c
blob: 853df392ed30722c5e19903b8249e2977987de37 (plain) (tree)
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
























































































































































































































































































































































































































































                                                                             
/*++

Copyright (c) 1993  Digital Equipment Corporation

Module Name:

    fwhalt.c

Abstract:


    This module implements routines to process halts from the operating
    system.

Author:

    Joe Notarangelo 24-Feb-1993

Environment:

    Firmware in Kernel mode only.

Revision History:

--*/


#include "fwp.h"
#include "fwpexcpt.h"
#include "axp21064.h"
#include "fwstring.h"

//
// Maximum size of Machine Check output string.
//

#define MAX_ERROR_STRING 100

//
// Function prototypes
//

VOID
FwDisplayMchk(
    IN PLOGOUT_FRAME_21064 LogoutFrame,
    IN ULONG HaltReason
    );

VOID
FwHaltToMonitor(
    IN PALPHA_RESTART_SAVE_AREA AlphaSaveArea,
    IN ULONG Reason
    );

VOID
FwHalt(
    VOID
    )
/*++

Routine Description:

    This function receives control on a halt from the operating
    system.

Arguments:

    None.

Return Value:

    None.

--*/

{

    PRESTART_BLOCK RestartBlock;
    PALPHA_RESTART_SAVE_AREA AlphaSaveArea;
    ALPHA_VIDEO_TYPE VideoType;
    UCHAR Character;
    ULONG Count;

    //
    // N.B. we will continue running on the stack re-established by
    //      the operating system for us.
    //

    //
    // Reset the video state.  If video init fails, continue as we may
    // be directing output to the serial port.
    //

    DisplayBootInitialize(&VideoType);
	

    //
    // Verify the restart block.
    //

    if (FwVerifyRestartBlock() == FALSE) {
        FwPrint (FW_INVALID_RESTART_BLOCK_MSG);  // temp message
	FwStallExecution(2 * 1000 * 1000);
        //FwRestart(); // this will be real one day
    }

    //
    // Dispatch on the halt reason code in the restart block.
    //

//    AlphaSaveArea = (PALPHA_RESTART_SAVE_AREA)
//                        &SYSTEM_BLOCK->RestartBlock->SaveArea;
    AlphaSaveArea = (PALPHA_RESTART_SAVE_AREA)
                        &SYSTEM_BLOCK->RestartBlock->u.SaveArea;

    switch (AlphaSaveArea->HaltReason) {


    case AXP_HALT_REASON_HALT:

        //
        // Dispatch to monitor so that Joe can find his bug.
        //

        FwHaltToMonitor(AlphaSaveArea, FW_EXC_HALT);

        //
        // If we return then it is time to restart to get a real stack.
        //

        FwRestart();


    case AXP_HALT_REASON_DBLMCHK:
    case AXP_HALT_REASON_PALMCHK:

        //
        // Machine Check.
        //

        FwDisplayMchk(AlphaSaveArea->LogoutFrame, AlphaSaveArea->HaltReason);
        
        //
        // Find out what the user wants to do next.  We will give her
        // 2 choices: 1. enter monitor  2. restart
        //

        FwPrint(FW_SYSRQ_MONITOR_MSG);
        FwRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);

        if (Character == ASCII_SYSRQ) {
            FwHaltToMonitor(AlphaSaveArea, FW_EXC_MCHK);
        }

        //
        // Restart the firmware when we return.
        //

        FwRestart();


    case AXP_HALT_REASON_REBOOT:

        FwReboot();


    case AXP_HALT_REASON_RESTART:
    default:

        FwRestart();

    }

}


VOID
FwDisplayMchk(
    IN PLOGOUT_FRAME_21064 LogoutFrame,
    IN ULONG HaltReason
    )
/*++

Routine Description:

    This function displays the logout frame for a 21064.

Arguments:

    LogoutFrame - Supplies a pointer to the logout frame.
    HaltReason - Supplies the reason for the halt.

Return Value:

    None.

--*/

{
    UCHAR OutBuffer[ MAX_ERROR_STRING ];


    //
    // PRINT_LOGOUT_VERBOSE controls the amount of text displayed
    // of the logout frame.  The macro can be undefined to save code and
    // initialized data space in the rom.  If the space exists it would be
    // preferable to give the entire print out.
    //

#define PRINT_LOGOUT_VERBOSE 1


    switch (HaltReason) {

    case AXP_HALT_REASON_DBLMCHK:

        FwPrint(FW_FATAL_DMC_MSG);
        break;

    case AXP_HALT_REASON_PALMCHK:

        FwPrint(FW_FATAL_MCINPALMODE_MSG);
        break;

    default:

        FwPrint(FW_FATAL_UNKNOWN_MSG);
    }


#ifdef PRINT_LOGOUT_VERBOSE

    FwPrint("BIU_STAT : %16Lx BIU_ADDR: %16Lx\r\n",
	    BIUSTAT_ALL_21064(LogoutFrame->BiuStat),
	    LogoutFrame->BiuAddr.QuadPart);

    FwPrint("FILL_ADDR: %16Lx FILL_SYN: %16Lx\r\n",
	    LogoutFrame->FillAddr.QuadPart,
	    FILLSYNDROME_ALL_21064(LogoutFrame->FillSyndrome) );

    FwPrint("DC_STAT  : %16Lx BC_TAG  : %16Lx\r\n",
	    DCSTAT_ALL_21064(LogoutFrame->DcStat),
	    BCTAG_ALL_21064(LogoutFrame->BcTag) );

    FwPrint("ICCSR    : %16Lx ABOX_CTL: %16Lx EXC_SUM: %16Lx\r\n",
	    ICCSR_ALL_21064(LogoutFrame->Iccsr),
	    ABOXCTL_ALL_21064(LogoutFrame->AboxCtl),
	    EXCSUM_ALL_21064(LogoutFrame->ExcSum) );

    FwPrint("EXC_ADDR : %16Lx VA      : %16Lx MM_CSR : %16Lx\r\n",
	    LogoutFrame->ExcAddr.QuadPart,
	    LogoutFrame->Va.QuadPart,
	    MMCSR_ALL_21064(LogoutFrame->MmCsr) );

    FwPrint("HIRR     : %16Lx HIER    : %16Lx PS     : %16Lx\r\n",
	    IRR_ALL_21064(LogoutFrame->Hirr),
	    IER_ALL_21064(LogoutFrame->Hier),
	    PS_ALL_21064(LogoutFrame->Ps) );

    FwPrint("PAL_BASE: %16Lx\r\n",
	    LogoutFrame->PalBase.QuadPart);

#endif //PRINT_LOGOUT_VERBOSE


    //
    // Print out interpretation of the error.
    //

    //
    // Check for tag control parity error.
    //

    if (BIUSTAT_TCPERR_21064(LogoutFrame->BiuStat) == 1) {

        FwPrint(FW_FATAL_TAGCNTRL_PE_MSG,
		BCTAG_TAGCTLP_21064(LogoutFrame->BcTag),
		BCTAG_TAGCTLD_21064(LogoutFrame->BcTag),
		BCTAG_TAGCTLS_21064(LogoutFrame->BcTag),
		BCTAG_TAGCTLV_21064(LogoutFrame->BcTag) );
    }

    //
    // Check for tag parity error.
    //

    if (BIUSTAT_TPERR_21064(LogoutFrame->BiuStat) == 1) {

        FwPrint(FW_FATAL_TAG_PE_MSG,
		BCTAG_TAG_21064(LogoutFrame->BcTag),
		BCTAG_TAG_21064(LogoutFrame->BcTag) );
    }

    //
    // Check for hard error.
    //

    if (BIUSTAT_HERR_21064(LogoutFrame->BiuStat) == 1) {
    
        FwPrint(FW_FATAL_HEACK_MSG,
		BIUSTAT_CMD_21064(LogoutFrame->BiuStat),
		LogoutFrame->BiuAddr.QuadPart);
    }

    //
    // Check for soft error.
    //

    if( BIUSTAT_SERR_21064(LogoutFrame->BiuStat) == 1 ){
    
        FwPrint(FW_FATAL_SEACK_MSG,
		BIUSTAT_CMD_21064(LogoutFrame->BiuStat),
		LogoutFrame->BiuAddr.QuadPart);
    }


    //
    // Check for fill ECC errors.
    //

    if( BIUSTAT_FILLECC_21064(LogoutFrame->BiuStat) == 1 ){

        FwPrint(FW_FATAL_ECC_ERROR_MSG,
		(BIUSTAT_FILLIRD_21064(LogoutFrame->BiuStat) ? 
                    "Icache Fill" : "Dcache Fill") ); 

        FwPrint(FW_FATAL_QWLWLW_MSG,
		LogoutFrame->FillAddr.QuadPart,
		BIUSTAT_FILLQW_21064(LogoutFrame->BiuStat),
		FILLSYNDROME_LO_21064(LogoutFrame->FillSyndrome),
		FILLSYNDROME_HI_21064(LogoutFrame->FillSyndrome) );
    }

    //
    // Check for fill Parity errors.
    //

    if( BIUSTAT_FILLDPERR_21064(LogoutFrame->BiuStat) == 1 ){

        FwPrint(FW_FATAL_PE_MSG,
		(BIUSTAT_FILLIRD_21064(LogoutFrame->BiuStat) ? 
                    "Icache Fill" : "Dcache Fill") ); 

        FwPrint(FW_FATAL_QWLWLW_MSG,
		LogoutFrame->FillAddr.QuadPart,
		BIUSTAT_FILLQW_21064(LogoutFrame->BiuStat),
		FILLSYNDROME_LO_21064(LogoutFrame->FillSyndrome),
		FILLSYNDROME_HI_21064(LogoutFrame->FillSyndrome) );
    }

    //
    // Check for multiple hard errors.
    //

    if (BIUSTAT_FATAL1_21064(LogoutFrame->BiuStat) == 1) {
        FwPrint(FW_FATAL_MULTIPLE_EXT_TAG_ERRORS_MSG);
    }

    //
    // Check for multiple fill errors.
    //

    if (BIUSTAT_FATAL2_21064(LogoutFrame->BiuStat) == 1) {
        FwPrint(FW_FATAL_MULTIPLE_FILL_ERRORS_MSG);
    }
    

    //
    // return to caller
    //

    return;
}

VOID
FwHaltToMonitor(
    IN PALPHA_RESTART_SAVE_AREA AlphaSaveArea,
    IN ULONG Reason
    )
/*++

Routine Description:

    This function transfers control to the firmware Monitor.

Arguments:

    AlphaSaveArea - Supplies a pointer to the Alpha save area portion
                    of the restart block.

    Reason	  - The reason for going to the monitor.

Return Value:

    None.

--*/
{
    PFW_EXCEPTION_FRAME ExceptionFrame;

    //
    // Allocate the exception frame.
    //

    ExceptionFrame = FwAllocatePool(sizeof(FW_EXCEPTION_FRAME));

    //
    // Copy the integer registers to the exception frame.
    //

    RtlMoveMemory(&ExceptionFrame->ExceptionV0, &AlphaSaveArea->IntV0,
		  32 * 8);

    //
    // Copy the floating point registers to the exception frame.
    //

    RtlMoveMemory(&ExceptionFrame->ExceptionF0, &AlphaSaveArea->FltF0,
		  32 * 8);

    //
    // Copy miscellaneous registers.
    //

    ExceptionFrame->ExceptionFaultingInstructionAddress =
                      (LONG)(AlphaSaveArea->ReiRestartAddress - 4);

    ExceptionFrame->ExceptionProcessorStatus = AlphaSaveArea->Psr;

    ExceptionFrame->ExceptionType = Reason;

    ExceptionFrame->ExceptionParameter1 = (LONG)AlphaSaveArea;

    //
    // Dispatch to the monitor.
    //

    Monitor( 0, ExceptionFrame );

    return;
}