summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halalpha/lca4err.c
blob: edf050f1e0509a8fc3239e19989246c1440a91b1 (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
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
/*++

Copyright (c) 1994  Digital Equipment Corporation

Module Name:

    lca4err.c

Abstract:

    This module implements error handling (machine checks and error
    interrupts) for machines based on the DECchip 21066
    microprocessor.

Author:

    Joe Notarangelo 8-Feb-1994

Environment:

    Kernel mode only.

Revision History:

--*/

#include "halp.h"
#include "axp21066.h"
#include "lca4.h"
#include "stdio.h"

//
// Declare the extern variable UncorrectableError declared in
// inithal.c.
//
extern PERROR_FRAME PUncorrectableError;

//
// MAX_RETRYABLE_ERRORS is the number of times to retry machine checks before
// just giving up.
//

#define MAX_RETRYABLE_ERRORS    32

//
//jnfix - temporary counts
//

ULONG CorrectableErrors = 0;
ULONG RetryableErrors = 0;


VOID
HalpDisplayLogout21066 ( 
    IN ESR_21066 Esr,
    IN IOC_STAT0_21066 IoStat0,
    IN PLOGOUT_FRAME_21066 LogoutFrame 
    );

VOID
HalpClearMachineCheck(
    VOID 
    );

ULONG
HalpBankError( 
    ULONG PhysicalAddress, 
    PLOGOUT_FRAME_21066 LogoutFrame 
    );

//jnfix - should be exported from platform-specific
ULONG
HalpSimmError( 
    ULONG PhysicalAddress, 
    PLOGOUT_FRAME_21066 LogoutFrame 
    );


VOID
HalpClearAllErrors(
    IN BOOLEAN SignalMemoryCorrectables
    )
/*++

Routine Description:

    This routine clears all of the error bits in the LCA4 memory
    controller and I/O controller.

Arguments:

    SignalMemoryCorrectables - Supplies a boolean value which specifies
                               if correctable error reporting should be
                               enabled in the memory controller.

Return Value:

    None.

--*/
{

    ESR_21066 ErrorStatus;
    IOC_STAT0_21066 IoStat0;

    //
    // The error status bits of the ESR are all write one to clear.
    // Clear the value and then set all of the error bits.  Then set
    // correctable enable according to specified input.
    //

    ErrorStatus.all.QuadPart = (ULONGLONG)0;

    ErrorStatus.Eav = 1;
    ErrorStatus.Cee = 1;
    ErrorStatus.Uee = 1;
    ErrorStatus.Cte = 1;
    ErrorStatus.Mse = 1;
    ErrorStatus.Mhe = 1;
    ErrorStatus.Nxm = 1;

    if( SignalMemoryCorrectables == TRUE ){
        ErrorStatus.Ice = 0;
    } else {
        ErrorStatus.Ice = 1;
    }

    WRITE_MEMC_REGISTER( &((PLCA4_MEMC_CSRS)(0))->ErrorStatus,
                        ErrorStatus.all.QuadPart );

    //
    // The ERR and LOST bits of the IO_STAT0 are write one to clear.
    //

    IoStat0.all.QuadPart = (ULONGLONG)0;

    IoStat0.Err = 1;
    IoStat0.Lost = 1;

    WRITE_IOC_REGISTER( &((PLCA4_IOC_CSRS)(LCA4_IOC_BASE_QVA))->IocStat0,
                        IoStat0.all.QuadPart );

    return;

}

VOID
HalpBuildLCAUncorrectableErrorFrame(
    VOID
    )
{
    PPROCESSOR_LCA_UNCORRECTABLE LcaUncorrerr = NULL;
    PEXTENDED_ERROR PExtErr;
    EAR_21066 Ear;

    if(PUncorrectableError){
        LcaUncorrerr = (PPROCESSOR_LCA_UNCORRECTABLE)
            PUncorrectableError->UncorrectableFrame.RawProcessorInformation;

        //
        // first fill in some generic processor Information.
        // For the Current (Reporting) Processor.
        //
        HalpGetProcessorInfo(
                &PUncorrectableError->UncorrectableFrame.ReportingProcessor);
        PUncorrectableError->
            UncorrectableFrame.Flags.ProcessorInformationValid = 1;


        PExtErr = &PUncorrectableError->UncorrectableFrame.ErrorInformation;
    }

    if(LcaUncorrerr) {
        PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;
        sprintf(PUncorrectableError->UncorrectableFrame.ErrorString,
                                      "Uncorrectable Error From "
                                      "LCA4 Detected");
        LcaUncorrerr->IocStat0 = (ULONGLONG)
         READ_IOC_REGISTER(&((PLCA4_IOC_CSRS)(LCA4_IOC_BASE_QVA))->IocStat0);

        LcaUncorrerr->IocStat1 = (ULONGLONG)
         READ_IOC_REGISTER(&((PLCA4_IOC_CSRS)(LCA4_IOC_BASE_QVA))->IocStat1);

        LcaUncorrerr->Esr = (ULONGLONG) 
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->ErrorStatus);

        Ear.all.QuadPart = LcaUncorrerr->Ear = (ULONGLONG)
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->ErrorAddress);

        PUncorrectableError->UncorrectableFrame.Flags.PhysicalAddressValid = 1;
        PUncorrectableError->UncorrectableFrame.PhysicalAddress = 
                            Ear.ErrorAddress;
    
        LcaUncorrerr->BankConfig0 =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankConfiguration0);

        LcaUncorrerr->BankConfig1 = 
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankConfiguration1);

        LcaUncorrerr->BankConfig2 = 
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankConfiguration2);

        LcaUncorrerr->BankConfig3 =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankConfiguration3);

        LcaUncorrerr->BankMask0 =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankMask0);

        LcaUncorrerr->BankMask1 =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankMask1);

        LcaUncorrerr->BankMask2 =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankMask2);

        LcaUncorrerr->BankMask3 =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->BankMask3);

        LcaUncorrerr->Car =
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->CacheControl);

        LcaUncorrerr->Gtr = 
         READ_MEMC_REGISTER(&((PLCA4_MEMC_CSRS)(0))->GlobalTiming);
    }
}


BOOLEAN
HalMachineCheck (
    IN PEXCEPTION_RECORD ExceptionRecord,
    IN PKEXCEPTION_FRAME ExceptionFrame,
    IN PKTRAP_FRAME      TrapFrame
    )
/*++

Routine Description:

    This function fields machine checks for 21066-based machines.

    The following errors may be the cause of the machine check:

    (a) Uncorrectable Dcache error
    (b) Uncorrectable Load from Memory Controller
    (c) Uncorrectable Load from I/O Controller
    (d) Non-existent device in PCI Configuration Space (I/O Controller) 
    (e) Retryable Icache parity error

Arguments:

    ExceptionRecord - Supplies a pointer to the exception record for the
                      machine check.  Included in the exception information
                      is the pointer to the logout frame.

    ExceptionFrame - Supplies a pointer to the kernel exception frame.

    TrapFrame - Supplies a pointer to the kernel trap frame.

Return Value:

    A value of TRUE is returned if the machine check has been
    handled by the HAL.  If it has been handled then execution may
    resume at the faulting address.  Otherwise, a value of FALSE
    is returned.

    N.B. - When a fatal error is recognized this routine does not
           return at all.

--*/

{

    PMCHK_STATUS MachineCheckStatus;
    ESR_21066 ErrorStatus;
    IOC_STAT0_21066 IoStat0;
    PPROCESSOR_LCA_UNCORRECTABLE LcaUncorrerr = NULL;

    MachineCheckStatus = 
                   (PMCHK_STATUS)&ExceptionRecord->ExceptionInformation[0];

    //
    // Print an error message if a correctable machine check is signalled.
    // Correctable machine checks are not possible on the 21066.
    //

    if( MachineCheckStatus->Correctable == 1 ){

#if DBG

	DbgPrint( "Illegal correctable error for LCA4\n" );

#endif //DBG

    }

    //
    // If the machine check is retryable then log the error and
    // and restart the operation.
    //

    if( MachineCheckStatus->Retryable == 1 ){

        //
        // jnfix Log the error, interface undefined.
        //

        //
        // Increment the number of retryable machine checks.
        //

        RetryableErrors += 1;


#if (DBG) || (HALDBG)

        DbgPrint( "HAL Retryable Errors = %d\n", RetryableErrors );
        // if( (RetryableErrors % 32) == 0 ){
        //     DbgPrint( "HAL Retryable Errors = %d\n", RetryableErrors );
        // }

#endif //DBG || HALDBG


        //
        // We'll retry MAX_RETRYABLE_ERRORS times and then give up.  We
        // do this to avoid infinite retry loops.
        //

        if( RetryableErrors > MAX_RETRYABLE_ERRORS ){

            //
            // Acknowledge receipt of the retryable machine check.
            //
            DbgPrint("Got too many Retryable Errors errors\n");
        }

        //
        // Clear the machine check in the MCES register.
        //

        HalpClearMachineCheck();

        //
        // Attempt to retry the operation.
        //

        return TRUE;

    }

    //
    // The machine check is uncorrectable according to the processor.
    // Read the error registers in the Memory and I/O Controller.
    // If the operation was a read to PCI configuration space and no
    // device is the error then we will fix up the operation and continue,
    // otherwise the machine has taken a fatal error.
    //

//jnfix - code here to check for dcache parity error?


    ErrorStatus.all.QuadPart = 
        READ_MEMC_REGISTER( 
            &((PLCA4_MEMC_CSRS)(0))->ErrorStatus );

    IoStat0.all.QuadPart = 
        READ_IOC_REGISTER( &((PLCA4_IOC_CSRS)(LCA4_IOC_BASE_QVA))->IocStat0 );

    //
    // If any of the following errors are indicated in the memory controller
    // then process a fatal error:
    //    Uncorrectable Error
    //    Cache Tag Error
    //    Multiple Hard Errors
    //    Non-existent Memory
    //

    if( (ErrorStatus.Uee == 1) ||
        (ErrorStatus.Cte == 1) ||
        (ErrorStatus.Mhe == 1) ||
        (ErrorStatus.Nxm == 1) ){

        goto FatalError;

    }

    //
    // Check for a PCI configuration read error.  An error is a 
    // candidate if the I/O controller has signalled an error, there
    // are no lost errors and the error was a no device error on the PCI.
    //

    if( (IoStat0.Err == 1) && (IoStat0.Code == IocErrorNoDevice) &&
        (IoStat0.Lost == 0) ){

        //
        // So far, the error looks like a PCI configuration space read
        // that accessed a device that does not exist.  In order to fix
        // this up we expect that the faulting instruction or the instruction 
        // previous to the faulting instruction must be a load with v0 as
        // the destination register.  If this condition is met then simply
        // update v0 in the register set and return.  However, be careful
        // not to re-execute the load.
        //
        // jnfix - add condition to check if Rb contains the superpage
        //         address for config space?

        ALPHA_INSTRUCTION FaultingInstruction;
        BOOLEAN PreviousInstruction = FALSE;

        FaultingInstruction.Long = *(PULONG)((ULONG)TrapFrame->Fir); 
        if( (FaultingInstruction.Memory.Ra != V0_REG) ||
            (FaultingInstruction.Memory.Opcode != LDL_OP) ){

            //
            // Faulting instruction did not match, try the previous
            // instruction.
            //

            PreviousInstruction = TRUE;

            FaultingInstruction.Long = *(PULONG)((ULONG)TrapFrame->Fir - 4); 
            if( (FaultingInstruction.Memory.Ra != V0_REG) ||
                (FaultingInstruction.Memory.Opcode != LDL_OP) ){

                //
                // No match, we can't fix this up.
                //

                goto FatalError;
            }
        }

        //
        // The error has matched all of our conditions.  Fix it up by
        // writing the value 0xffffffff into the destination of the load.
        // 

        TrapFrame->IntV0 = (ULONGLONG)0xffffffffffffffff;

        //
        // Clear the machine check condition in the processor.
        //

        HalpClearMachineCheck();

        //
        // Clear the error condition in the io controller.
        // The Err bit is write one to clear.
        //

        IoStat0.all.QuadPart = (ULONGLONG)0;
        IoStat0.Err = 1; 
        WRITE_IOC_REGISTER( &((PLCA4_IOC_CSRS)(LCA4_IOC_BASE_QVA))->IocStat0,
                            IoStat0.all.QuadPart );

        //
        // If the faulting instruction was the load the restart execution
        // at the instruction after the load.
        //

        if( PreviousInstruction == FALSE ){
            TrapFrame->Fir += 4;
        }

        return TRUE;

    } //end if (IoStat0.Err == 1) && (IoStat0.Code == IocErrorNoDevice) ){


//
// The system is not well and cannot continue reliable execution.
// Print some useful messages and shutdown the machine.
//

FatalError:

    HalpBuildLCAUncorrectableErrorFrame();

    if(PUncorrectableError){
        LcaUncorrerr = (PPROCESSOR_LCA_UNCORRECTABLE)
            PUncorrectableError->UncorrectableFrame.RawProcessorInformation;

        LcaUncorrerr->AboxCtl = (ULONGLONG)
           ((PLOGOUT_FRAME_21066) 
             (ExceptionRecord->ExceptionInformation[1] ))->AboxCtl.all.QuadPart;

        LcaUncorrerr->CStat = (ULONGLONG)
           ((PLOGOUT_FRAME_21066) 
             (ExceptionRecord->ExceptionInformation[1] ))->DcStat.all.QuadPart;

        LcaUncorrerr->MmCsr = (ULONGLONG)
           ((PLOGOUT_FRAME_21066) 
             (ExceptionRecord->ExceptionInformation[1] ))->MmCsr.all.QuadPart;
    }

    //
    // Display the logout frame.
    //

    HalpDisplayLogout21066(
        ErrorStatus,
        IoStat0,
        (PLOGOUT_FRAME_21066)(ExceptionRecord->ExceptionInformation[1]) );

    // 
    //
    // Bugcheck to dump the rest of the machine state, this will help
    // if the machine check is software-related.
    //

    KeBugCheckEx( DATA_BUS_ERROR, 
                  (ULONG)MachineCheckStatus->Correctable,
                  (ULONG)MachineCheckStatus->Retryable,
                  0,
                  (ULONG)PUncorrectableError );

}

VOID
HalpClearMachineCheck(
    VOID 
    )
/*++

Routine Description:

    Clear the machine check which is currently pending.  Clearing the
    pending machine check bit will allow us to take machine checks in
    the future without detecting a double machine check condition.
    The machine check pending bit must be cleared in the MCES register
    within the PALcode.

Arguments:

    None.

Return Value:

    None.

--*/
{
    MCES MachineCheckSummary;

    MachineCheckSummary.MachineCheck = 1;
    MachineCheckSummary.SystemCorrectable = 0;
    MachineCheckSummary.ProcessorCorrectable = 0;
    MachineCheckSummary.DisableProcessorCorrectable = 0;
    MachineCheckSummary.DisableSystemCorrectable = 0;
    MachineCheckSummary.DisableMachineChecks = 0;

    HalpWriteMces( MachineCheckSummary );

    return;

}

#define MAX_ERROR_STRING 100

VOID
HalpDisplayLogout21066 ( 
    IN ESR_21066 Esr,
    IN IOC_STAT0_21066 IoStat0,
    IN PLOGOUT_FRAME_21066 LogoutFrame 
    )
/*++

Routine Description:

    This function displays the logout frame for a 21066.

Arguments:

    Esr - Supplies the value of the memory controller error status register.

    IoStat0 - Supplies the value of the i/o controller status register 0.

    LogoutFrame - Supplies a pointer to the logout frame generated
                  by the 21066.
Return Value:

    None.

--*/

{
    UCHAR OutBuffer[ MAX_ERROR_STRING ];
    EAR_21066 Ear;
    CAR_21066 Car;
    IOC_STAT1_21066 IoStat1;
    ULONG Index;
    PKPRCB Prcb;
    extern HalpLogicalToPhysicalProcessor[HAL_MAXIMUM_PROCESSOR+1];
    PCHAR parityErrString = NULL;
    PEXTENDED_ERROR exterr;


    if(PUncorrectableError) {
        exterr = &PUncorrectableError->UncorrectableFrame.ErrorInformation;
        parityErrString = PUncorrectableError->UncorrectableFrame.ErrorString;
    }


    //
    // Capture other useful registers, EAR, CAR, and IO_STAT1.
    //

    Ear.all.QuadPart = 
        READ_MEMC_REGISTER( 
            &((PLCA4_MEMC_CSRS)(0))->ErrorAddress );

    Car.all.QuadPart = 
        READ_MEMC_REGISTER( 
            &((PLCA4_MEMC_CSRS)(0))->CacheControl );

    IoStat1.all.QuadPart = 
        READ_IOC_REGISTER( &((PLCA4_IOC_CSRS)(LCA4_IOC_BASE_QVA))->IocStat1);

    //
    // Acquire ownership of the display.  This is done here in case we take
    // a machine check before the display has been taken away from the HAL.
    // When the HAL begins displaying strings after it has lost the
    // display ownership then the HAL will be careful not to scroll information
    // off of the screen.
    //

    HalAcquireDisplayOwnership(NULL);

    //
    // Display the machine state via the logout frame.
    //

    HalDisplayString( "\nFatal system hardware error.\n\n" );


    sprintf( OutBuffer, "MEMC_ESR: %16Lx MEMC_EAR: %16Lx CAR: %16Lx\n",
                       Esr.all.QuadPart,
                       Ear.all.QuadPart,
                       Car.all.QuadPart );

    HalDisplayString( OutBuffer );

    sprintf( OutBuffer, "IO_STAT0: %16Lx IO_STAT1: %16Lx\n",
                       IoStat0.all.QuadPart,
                       IoStat1.all.QuadPart );

    HalDisplayString( OutBuffer );

    sprintf( OutBuffer, "ICCSR    : %016Lx ABOX_CTL: %016Lx DC_STAT: %016Lx\n",
                       ICCSR_ALL_21064(LogoutFrame->Iccsr),
                       ABOXCTL_ALL_21064(LogoutFrame->AboxCtl),
                       DCSTAT_ALL_21064(LogoutFrame->DcStat) );

    HalDisplayString( OutBuffer );

    sprintf( OutBuffer, "EXC_ADDR : %016Lx VA      : %016Lx MM_CSR : %016Lx\n",
                       LogoutFrame->ExcAddr.QuadPart,
                       LogoutFrame->Va.QuadPart,
                       MMCSR_ALL_21064(LogoutFrame->MmCsr) );

    HalDisplayString( OutBuffer );

    sprintf( OutBuffer, "HIRR     : %016Lx HIER    : %016Lx PS     : %016Lx\n",
                       IRR_ALL_21064(LogoutFrame->Hirr),
                       IER_ALL_21064(LogoutFrame->Hier),
                       PS_ALL_21064(LogoutFrame->Ps) );

    HalDisplayString( OutBuffer );

    sprintf( OutBuffer, "PAL_BASE : %016Lx  \n",
                       LogoutFrame->PalBase.QuadPart );

    HalDisplayString( OutBuffer );

    sprintf( OutBuffer, "Waiting 15 seconds...\n");
    HalDisplayString( OutBuffer );

    for( Index=0; Index<1500; Index++)
        KeStallExecutionProcessor( 10000 ); // ~15 second delay

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

    //
    // First print the processor on which we saw the error
    //

    Prcb = PCR->Prcb;
    sprintf( OutBuffer, "Error on processor number: %d\n",
                    HalpLogicalToPhysicalProcessor[Prcb->Number] );
    HalDisplayString( OutBuffer );

    //
    // If we got a Data Cache Parity Error print a message on screen.
    //

    if( DCSTAT_DCPARITY_ERROR_21064(LogoutFrame->DcStat) ){

        PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                    MEMORY_SPACE;
        PUncorrectableError->UncorrectableFrame.Flags.
                        MemoryErrorSource = PROCESSOR_CACHE;
        PUncorrectableError->UncorrectableFrame.Flags.
                                ExtendedErrorValid   = 1;
        PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid = 1;
        sprintf( parityErrString,
                    "Data Cache Parity Error.\n");        
        HalpGetProcessorInfo(&exterr->CacheError.ProcessorInfo);

        sprintf( OutBuffer, "Data Cache Parity Error.\n" );
        HalDisplayString( OutBuffer );
    }

    //
    // Check for uncorrectable error.
    //

    if( Esr.Uee == 1 ){

        if( Esr.Sor == 0 ){

            //
            // Uncorrectable error from cache.
            //
            PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                        MEMORY_SPACE;
            PUncorrectableError->UncorrectableFrame.Flags.
                            MemoryErrorSource = PROCESSOR_CACHE;
            PUncorrectableError->UncorrectableFrame.Flags.
                                    ExtendedErrorValid   = 1;
            HalpGetProcessorInfo(&exterr->CacheError.ProcessorInfo);
            PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;

            sprintf( parityErrString,
                "Uncorrectable error from cache on %s, Tag: 0x%x\n",
                Esr.Wre ? "write" : "read",
                Car.Tag );
            HalDisplayString( parityErrString );

        } else {

            //
            // Uncorrectable error from memory.
            //
            PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                    MEMORY_SPACE;
            PUncorrectableError->UncorrectableFrame.Flags.
                           MemoryErrorSource = SYSTEM_MEMORY;
            PUncorrectableError->UncorrectableFrame.Flags.
                                    ExtendedErrorValid   = 1;
            HalpGetProcessorInfo(&exterr->MemoryError.ProcessorInfo);
            PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;
    
            sprintf( parityErrString, 
                "Uncorrectable error from memory on %s\n",
                 Esr.Wre ? "write" : "read" );
            HalDisplayString( parityErrString );

            PUncorrectableError->UncorrectableFrame.Flags.
                        PhysicalAddressValid = 1;
            PUncorrectableError->UncorrectableFrame.PhysicalAddress = 
                            Ear.ErrorAddress;
    
            exterr->MemoryError.Flags.MemorySimmValid = 1;
            exterr->MemoryError.MemorySimm = 
                        HalpSimmError( Ear.ErrorAddress, LogoutFrame );

            sprintf( OutBuffer,
                "Physical Address: 0x%x, Bank: %d, SIMM: %d\n",
                Ear.ErrorAddress,
                HalpBankError( Ear.ErrorAddress, LogoutFrame ),
                HalpSimmError( Ear.ErrorAddress, LogoutFrame ) );
            HalDisplayString( OutBuffer );

        } //end if( Esr.Sor == 0 )

    } //end if( Esr.Uee == 1 )

    //
    // Check for cache tag errors.
    // 

    if( Esr.Cte == 1 ){
        PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                        MEMORY_SPACE;
        PUncorrectableError->UncorrectableFrame.Flags.
                        MemoryErrorSource = PROCESSOR_CACHE;
        PUncorrectableError->UncorrectableFrame.Flags.
                                    ExtendedErrorValid   = 1;
        HalpGetProcessorInfo(&exterr->CacheError.ProcessorInfo);
        PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;


        sprintf( parityErrString,
            "Cache Tag Error,  Tag: 0x%x, Hit: %d\n",
            Car.Tag, Car.Hit );
        HalDisplayString( parityErrString );

    }

    //
    // Check for non-existent memory error.
    //

    if( Esr.Nxm == 1 ){

        PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                    MEMORY_SPACE;
        PUncorrectableError->UncorrectableFrame.Flags.
                       MemoryErrorSource = SYSTEM_MEMORY;
        PUncorrectableError->UncorrectableFrame.Flags.
                                ExtendedErrorValid   = 1;
        HalpGetProcessorInfo(&exterr->MemoryError.ProcessorInfo);
        PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;

        sprintf( parityErrString,
                 "Non-existent memory accessed\n" );
        sprintf( OutBuffer,
            "Non-existent memory accessed, Physical Address: 0x%x.\n",
            Ear.ErrorAddress );
        HalDisplayString( OutBuffer );

    }

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

    if( Esr.Mhe == 1 ){
        PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                    MEMORY_SPACE;
        PUncorrectableError->UncorrectableFrame.Flags.
                       MemoryErrorSource = SYSTEM_MEMORY;
        PUncorrectableError->UncorrectableFrame.Flags.
                                ExtendedErrorValid   = 1;
        HalpGetProcessorInfo(&exterr->MemoryError.ProcessorInfo);
        PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;

        sprintf( parityErrString,
                 "Multiple hard errors detected\n" );

        sprintf( OutBuffer,
            "Multiple hard errors detected.\n" );
        HalDisplayString( OutBuffer );

    }

    //
    // If an I/O Error was pending print the interpretation.
    //

    if( IoStat0.Err == 1 ){
        PUncorrectableError->UncorrectableFrame.Flags.AddressSpace =
                    IO_SPACE;
        PUncorrectableError->UncorrectableFrame.Flags.
                                ExtendedErrorValid   = 1;
        exterr->IoError.Interface = PCIBus;
        exterr->IoError.BusNumber = 0;
        exterr->IoError.BusAddress.QuadPart = IoStat1.Address;
        PUncorrectableError->UncorrectableFrame.Flags.PhysicalAddressValid =
                    1;        
        PUncorrectableError->UncorrectableFrame.PhysicalAddress = 
                    IoStat1.Address;
        PUncorrectableError->UncorrectableFrame.Flags.ErrorStringValid =  1;


        switch( IoStat0.Code ){

        //
        // Retry Limit.
        //

        case IocErrorRetryLimit:
            sprintf(parityErrString,
                "Retry Limit Error, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );

            sprintf( OutBuffer,
                "Retry Limit Error, PCI Address 0x%x  PCI Cmd 0x%x\n",
                 IoStat1.Address,
                 IoStat0.Cmd );
            break;

        //
        // No device error.
        //

        case IocErrorNoDevice:
            sprintf(parityErrString,
                "No Device Error, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );


            sprintf( OutBuffer,
                "No Device Error, PCI Address 0x%x  PCI Cmd 0x%x\n",
                 IoStat1.Address,
                 IoStat0.Cmd );
            break;

        //
        // Bad data parity.
        //

        case IocErrorBadDataParity:
            sprintf(parityErrString,
                "Bad Data Parity Error, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );


            sprintf( OutBuffer,
                "Bad Data Parity Error, PCI Address 0x%x  PCI Cmd 0x%x\n",
                 IoStat1.Address,
                 IoStat0.Cmd );
            break;

        //
        // Target abort.
        //

        case IocErrorTargetAbort:
            sprintf(parityErrString,
                "Target Abort, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );


            sprintf( OutBuffer,
                "Target Abort, PCI Address 0x%x  PCI Cmd 0x%x\n",
                 IoStat1.Address,
                 IoStat0.Cmd );
            break;

        //
        // Bad address parity.
        //

        case IocErrorBadAddressParity:
            sprintf(parityErrString,
                "Bad Address Parity, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );


            sprintf( OutBuffer,
                "Bad Address Parity, PCI Address 0x%x  PCI Cmd 0x%x\n",
                 IoStat1.Address,
                 IoStat0.Cmd );
            break;

        //
        // Page Table Read Error.
        //

        case IocErrorPageTableReadError:
            sprintf(parityErrString,
                "Page Table Read Error, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );


            sprintf( OutBuffer,
                "Page Table Read Error, PCI Pfn 0x%x  PCI Cmd 0x%x\n",
                 IoStat0.PageNumber,
                 IoStat0.Cmd );
            break;

        //
        // Invalid page.
        //

        case IocErrorInvalidPage:
            sprintf(parityErrString,
                "Invalid Page Error, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );


            sprintf( OutBuffer,
                "Invalid Page Error, PCI Pfn 0x%x  PCI Cmd 0x%x\n",
                 IoStat0.PageNumber,
                 IoStat0.Cmd );
            break;

        //
        // Data error.
        //

        case IocErrorDataError:

            sprintf(parityErrString,
                "Data Error, PCI Cmd 0x%x\n",
                    IoStat0.Cmd );

            sprintf( OutBuffer,
                "Data Error, PCI Address 0x%x  PCI Cmd 0x%x\n",
                 IoStat1.Address,
                 IoStat0.Cmd );
            break;

        //
        // Unrecognized error code.
        //

        default:

            sprintf(parityErrString,
                "Unrecognized I/O Error.\n" );

            sprintf( OutBuffer, "Unrecognized I/O Error.\n" );
            break;

        } //end switch (IoStat0.Code)

        HalDisplayString( OutBuffer );

        if( IoStat0.Lost == 1 ){
            sprintf(parityErrString,
                "Additional I/O errors were lost.\n" );

            HalDisplayString( "Additional I/O errors were lost.\n" );
        }

    } //end if( IoStat0.Err == 1 )

    //
    // return to caller
    //

    return;

}


ULONG
HalpBankError( 
    ULONG PhysicalAddress, 
    PLOGOUT_FRAME_21066 LogoutFrame 
    )
/*++

Routine Description:

    Return the bank of memory that the physical address fails within.

Arguments:

    PhysicalAddress - Supplies the physical address to locate.

    LogoutFrame - Supplies a pointer to the logout frame that contains the
                  bank configuration information.

Return Value:

    Returns the number of the bank that contains the physical address.
    Returns 0xffffffff if the physical address is not contained within any of
        the banks.

--*/
{

    ULONG Bank;

    for( Bank=0; Bank < MEMORY_BANKS_21066; Bank++ ){

        //
        // If the bank is valid and the physical address is within the
        // bank then we have found the correct bank.
        //

        if( (LogoutFrame->BankConfig[Bank].Bav == 1) &&
            ((PhysicalAddress >> 20) & 
             (~LogoutFrame->BankMask[Bank].BankAddressMask)) ==
            LogoutFrame->BankConfig[Bank].BankBase ){

            return Bank;

        }

    }

    //
    // Did not find a bank which contains physical address.
    //

    return (0xffffffff);

}

//jnfix - this should be move to platform-specific
//jnfix - and made real depending upon how memory is configured
//jnfix - this current code is a simple guess which provides a model

ULONG
HalpSimmError( 
    ULONG PhysicalAddress, 
    PLOGOUT_FRAME_21066 LogoutFrame 
    )
/*++

Routine Description:

    Return the SIMM number that the physical address fails within.

Arguments:

    PhysicalAddress - Supplies the physical address to locate.

    LogoutFrame - Supplies a pointer to the logout frame that contains the
                  bank configuration information.

Return Value:

    Returns the number of the SIMM that contains the physical address.
    Returns 0xffffffffif the physical address is not contained within any of 
        the SIMMs.

--*/
{
    ULONG Bank;
    ULONG Simm;

    for( Bank=0; Bank < MEMORY_BANKS_21066; Bank++ ){

        //
        // If the bank is valid and the physical address is within the
        // bank then we have found the correct bank.
        //

        if( (LogoutFrame->BankConfig[Bank].Bav == 1) &&
            ((PhysicalAddress >> 20) & 
             (~LogoutFrame->BankMask[Bank].BankAddressMask)) ==
            LogoutFrame->BankConfig[Bank].BankBase ){

            //
            // Assume that each bank contains 2 SIMMs and that they are
            // numbered 0..N.  We need to determine which SIMM within the
            // bank.  We will guess that the SIMMs are 32-bits wide and
            // that the low 32-bits are in the low SIMM while the high
            // 32-bits are in the high SIMM.  So addresses 0..3 are low
            // and 4..7 are high.
            //

            Simm = Bank * 2;
            if( PhysicalAddress & 4 ) Simm += 1;
            return Simm;

        }

    }

    //
    // Did not find a bank which contains physical address.
    //

    return (0xffffffff);

}