summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halsable/alpha/xiintsup.c
blob: 4c14ce1272872c2bf28d46dd6a47d6ba4e7f595f (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
/*++

Copyright (c) 1995  Digital Equipment Corporation

Module Name:

    xiintsup.c

Abstract:

    This module provides interrupt support for the Sable/Gamma/Lynx
    External I/O module.

Author:

    Dave Richarda   1-June-1995

Revision History:

--*/

#ifdef XIO_PASS1

#include "halp.h"
#include "eisa.h"
#include "sableref.h"
#include "xiintsup.h"

//
// External I/O 8259 Mask registers.
//

UCHAR XioMasterInterruptMask;
UCHAR XioSlaveInterruptMask;

//
// Define the context structure for use by interrupt service routines.
//

typedef BOOLEAN  (*PSECOND_LEVEL_DISPATCH)(
    PKINTERRUPT InterruptObject
    );

extern ULONG HalpProcessors;


ULONG
HalpGetXioInterruptVector(
    IN PBUS_HANDLER BusHandler,
    IN PBUS_HANDLER RootHandler,
    IN ULONG BusInterruptLevel,
    IN ULONG BusInterruptVector,
    OUT PKIRQL Irql,
    OUT PKAFFINITY Affinity
    )
{
    if( HalpXioPresent ){

        switch( BusInterruptLevel ){

        case XioPciSlot0AVector:
        case XioPciSlot0BVector:
        case XioPciSlot0CVector:
        case XioPciSlot0DVector:
        case XioPciSlot1AVector:
        case XioPciSlot1BVector:
        case XioPciSlot1CVector:
        case XioPciSlot1DVector:

            *Irql = PCI_DEVICE_LEVEL;

            if( HalpProcessors > 1 ){
                *Affinity = HAL_CPU1_MASK;
            } else {
                *Affinity = HAL_CPU0_MASK;
            }

            return( SABLE_VECTORS + BusInterruptLevel );

        }
    }

    //
    // The caller specified a bus level not support by this platform.
    //

    *Irql = 0;
    *Affinity = 0;
    return(0);
}


BOOLEAN
HalpInitializeXioInterrupts(
    VOID
    )

/*++

Routine Description:

    This routine does the following:
        (1) initializes the Xio 8259 interrupt registers
        (2) initializes structures necessary for EISA operations
        (3) connects the intermediate interrupt dispatcher. 
        (4) initializes the EISA interrupt controller.

Arguments:

    None.

Return Value:

    If the second level interrupt dispatcher is connected, then a value of
    TRUE is returned. Otherwise, a value of FALSE is returned.

--*/
{
    UCHAR DataByte;

    //
    // Initialize the Xio interrupt controllers.  The interrupt structure
    // is one master interrupt controller with 1 cascaded slave controller.
    // Proceed through each control word programming each of the controllers.
    //

    //
    // Write control word 1 for each of the controllers, indicate
    // that initialization is in progress and the control word 4 will
    // be used.
    //

    DataByte = 0;
    ((PINITIALIZATION_COMMAND_1) &DataByte)->Icw4Needed = 1;
//  ((PINITIALIZATION_COMMAND_1) &DataByte)->LevelTriggeredMode = 1;
    DataByte |= 0x04;
    ((PINITIALIZATION_COMMAND_1) &DataByte)->InitializationFlag = 1;

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterControl,
        DataByte
        );

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveControl,
        DataByte
        );

    //
    // Write control word 2 for each of the controllers, set the base
    // interrupt vector for each controller.
    //

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterMask,
        XioMasterBaseVector
        );

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveMask,
        XioSlaveBaseVector
        );

    //
    // The third initialization control word set the controls for slave mode.
    // The master ICW3 uses bit position and the slave ICW3 uses a numeric.
    //

    DataByte = (1 << (XioSlaveCascadeVector & ~XioMasterBaseVector) );

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterMask,
        DataByte
        );

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveMask,
        (XioSlaveCascadeVector & ~XioMasterBaseVector)
        );

    //
    // The fourth initialization control word is used to specify normal
    // end-of-interrupt mode and not special-fully-nested mode.
    //

    DataByte = 0;
    ((PINITIALIZATION_COMMAND_4) &DataByte)->I80x86Mode = 1;
#ifdef XIO_AEOI
    ((PINITIALIZATION_COMMAND_4) &DataByte)->AutoEndOfInterruptMode = 1;
#endif

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterMask,
        DataByte
        );

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveMask,
        DataByte
        );

    //
    // Disable all of the interrupts except the slave interrupts to the
    // master controller.
    //

    XioMasterInterruptMask =
        (UCHAR)( ~(1 << (XioSlaveCascadeVector & ~XioMasterBaseVector)) );

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterMask,
        XioMasterInterruptMask
        );

    XioSlaveInterruptMask = 0xFF;

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveMask,
        XioSlaveInterruptMask
        );

    return TRUE;

}

BOOLEAN
HalpXioDispatch(
    VOID
    )

/*++

Routine Description:

    This routine is entered as a result of an interrupt being generated
    via the vector that is directly connected XIO device interrupt.

    This routine is responsible for determining the
    source of the interrupt, performing the secondary dispatch and
    acknowledging the interrupt in the 8259 controllers.

    N.B. This interrupt is directly connected and therefore, no argument
         values are defined.

Arguments:

    None.

Return Value:

    Returns the value returned from the second level routine.

--*/

{
    UCHAR interruptVector;
    BOOLEAN returnValue;
    USHORT IdtIndex;
    UCHAR InService;
    PULONG DispatchCode;
    PKINTERRUPT InterruptObject;

    //
    // Acknowledge the Interrupt controller and receive the returned
    // interrupt vector.
    //

    interruptVector = READ_REGISTER_UCHAR(
                          &((PXIO_INTERRUPT_CSRS)
                          XIO_INTERRUPT_CSRS_QVA)->InterruptAcknowledge
                      );

    //
    // If we get a passive release, send a non-specific end of interrupt
    // command and return TRUE, indicating that we processed the interrupt.
    //

    switch( interruptVector ){

    case XioMasterPassiveReleaseVector:

#ifdef XIO_AEOI

        //
        // If the passive release vector has not been enabled, then we can
        // dismiss it now.
        //

        if( XioMasterInterruptMask & 0x80 ){
            return TRUE;
        }

#else // XIO_AEOI

       //
       // Read the "in-service" mask.
       //

        WRITE_PORT_UCHAR( &((PSABLE_INTERRUPT_CSRS)SABLE_INTERRUPT_CSRS_QVA)->MasterControl,
            0x0B
            );

        InService = READ_PORT_UCHAR(
            &((PSABLE_INTERRUPT_CSRS) SABLE_INTERRUPT_CSRS_QVA)->MasterControl
            );

        if( (InService & 0x80) == 0 ){

            //
            // Send end of interrupt to clear the passive release in the
            // master controller.
            //

            WRITE_PORT_UCHAR(
                &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterControl,
                NONSPECIFIC_END_OF_INTERRUPT
            );

            return TRUE;

        }

#endif // XIO_AEOI

        break;

    case XioSlavePassiveReleaseVector:

#ifdef XIO_AEOI

        //
        // If the passive release vector has not been enabled, then we can
        // dismiss it now.
        //

        if( XioSlaveInterruptMask & 0x80 ){
            return TRUE;
        }

#else // XIO_AEOI

       //
       // Read the "in-service" mask.
       //

        WRITE_PORT_UCHAR( &((PSABLE_INTERRUPT_CSRS)SABLE_INTERRUPT_CSRS_QVA)->SlaveControl,
            0x0B
            );

        InService = READ_PORT_UCHAR(
            &((PSABLE_INTERRUPT_CSRS) SABLE_INTERRUPT_CSRS_QVA)->SlaveControl
            );

        if( (InService & 0x80) == 0 ){

            //
            // Send end of interrupt to clear the passive release in the
            // slave controller.
            //

            WRITE_PORT_UCHAR(
                &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveControl,
                NONSPECIFIC_END_OF_INTERRUPT
            );

            return TRUE;

        }

#endif // XIO_AEOI

        break;

    }

    //
    // Dispatch to the secondary interrupt service routine.
    //

    IdtIndex = interruptVector + SABLE_VECTORS;
    DispatchCode = (PULONG)PCR->InterruptRoutine[IdtIndex];
    InterruptObject = CONTAINING_RECORD(DispatchCode,
                                        KINTERRUPT,
                                        DispatchCode);

    returnValue = ((PSECOND_LEVEL_DISPATCH)InterruptObject->DispatchAddress)(InterruptObject);

#ifndef XIO_AEOI

    //
    // Dismiss the interrupt in the 8259 interrupt controllers.
    // If this is a cascaded interrupt then the interrupt must be dismissed in
    // both controllers.
    //

    if( (interruptVector & XioSlaveBaseVector) == XioSlaveBaseVector ){

        WRITE_PORT_UCHAR(
            &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveControl,
            NONSPECIFIC_END_OF_INTERRUPT
            );

    }

    WRITE_PORT_UCHAR(
        &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->MasterControl,
        NONSPECIFIC_END_OF_INTERRUPT
        );

#endif // XIO_AEOI

    return(returnValue);

}



VOID
HalpDisableXioInterrupt(
    IN ULONG Vector
    )

/*++

Routine Description:

    This function Disables the External IO specified interrupt.

Arguments:

    Vector - Supplies the vector of the Xio interrupt that is Disabled.

Return Value:

     None.

--*/

{
    ULONG Interrupt;

    if( (Vector >= SABLE_VECTORS + XioMasterBaseVector) &&
        (Vector <= SABLE_VECTORS + XioSlavePassiveReleaseVector) ){

        //
        // Calculate the Xio relative interrupt vector.
        //

        Vector -= SABLE_VECTORS;

        //
        // Compute the interrupt within the interrupt controller.
        //

        Interrupt = Vector & 0x7;

        //
        // Enable the interrupt for the appropriate interrupt controller.
        //

        if( (Vector & XioSlaveBaseVector) == XioSlaveBaseVector ){

            XioSlaveInterruptMask |= (UCHAR) (1 << Interrupt);

            WRITE_PORT_UCHAR(
                &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveMask,
                XioSlaveInterruptMask
                );

        }
    }
}

BOOLEAN
HalpEnableXioInterrupt(
    IN ULONG Vector,
    IN KINTERRUPT_MODE InterruptMode
    )

/*++

Routine Description:

    This function enables the Xio specified interrupt in the
    appropriate 8259 interrupt controllers.  It also supports the
    edge/level control for EISA bus interrupts.  By default, all interrupts
    are edge detected (and latched).

Arguments:

    Vector - Supplies the vector of the Xio interrupt that is enabled.

    InterruptMode - Supplies the mode of the interrupt; LevelSensitive or
        Latched (Edge).

Return Value:

     None.

--*/

{
    ULONG Interrupt;

    if( (Vector >= SABLE_VECTORS + XioMasterBaseVector) &&
        (Vector <= SABLE_VECTORS + XioSlavePassiveReleaseVector) ){

        //
        // Calculate the Xio relative interrupt vector.
        //

        Vector -= SABLE_VECTORS;

        //
        // Compute the interrupt within the interrupt controller.
        //

        Interrupt = Vector & 0x7;

        //
        // Enable the interrupt for the appropriate interrupt controller.
        //

        if( (Vector & XioSlaveBaseVector) == XioSlaveBaseVector ){

            XioSlaveInterruptMask &= (UCHAR) ~(1 << Interrupt);

            WRITE_PORT_UCHAR(
                &((PXIO_INTERRUPT_CSRS) XIO_INTERRUPT_CSRS_QVA)->SlaveMask,
                XioSlaveInterruptMask
                );

            return TRUE;
        }
    }

    return FALSE;
}

#endif // XIO_PASS1

#ifdef XIO_PASS2

#include "halp.h"
#include "t2.h"
#include "icic.h"
#include "xiintsup.h"

//
// Define the context structure for use by interrupt service routines.
//

typedef BOOLEAN (*PSECOND_LEVEL_DISPATCH)(
    PKINTERRUPT InterruptObject
    );

extern ULONG HalpProcessors;

//
// Cached copies of the corresponding ICIC register(s).
//

ICIC_MASK_REGISTER XioIcIcMaskRegister;


ULONG
HalpGetXioInterruptVector(
    IN PBUS_HANDLER BusHandler,
    IN PBUS_HANDLER RootHandler,
    IN ULONG BusInterruptLevel,
    IN ULONG BusInterruptVector,
    OUT PKIRQL Irql,
    OUT PKAFFINITY Affinity
    )
{
    if( HalpXioPresent ){

        switch( BusInterruptLevel ){

        //
        // Handle Vectors for PCI devices.
        //

        case XioPciSlot0AVector:
        case XioPciSlot0BVector:
        case XioPciSlot0CVector:
        case XioPciSlot0DVector:
        case XioPciSlot1AVector:
        case XioPciSlot1BVector:
        case XioPciSlot1CVector:
        case XioPciSlot1DVector:
        case XioPciSlot2AVector:
        case XioPciSlot2BVector:
        case XioPciSlot2CVector:
        case XioPciSlot2DVector:
        case XioPciSlot3AVector:
        case XioPciSlot3BVector:
        case XioPciSlot3CVector:
        case XioPciSlot3DVector:
        case XioPciSlot4AVector:
        case XioPciSlot4BVector:
        case XioPciSlot4CVector:
        case XioPciSlot4DVector:
        case XioPciSlot5AVector:
        case XioPciSlot5BVector:
        case XioPciSlot5CVector:
        case XioPciSlot5DVector:
        case XioPciSlot6AVector:
        case XioPciSlot6BVector:
        case XioPciSlot6CVector:
        case XioPciSlot6DVector:
        case XioPciSlot7AVector:
        case XioPciSlot7BVector:
        case XioPciSlot7CVector:
        case XioPciSlot7DVector:

            *Irql = DEVICE_LEVEL;

            if( HalpProcessors > 1 ){
                *Affinity = HAL_CPU1_MASK;
            } else {
                *Affinity = HAL_CPU0_MASK;
            }

            return( BusInterruptLevel );

        }
    }

    *Irql = 0;
    *Affinity = 0;
    return 0;
}


BOOLEAN
HalpInitializeXioInterrupts(
    VOID
    )

/*++

Routine Description:

    This routine initializes the ICIC on the Standard I/O module.

Arguments:

    None.

Return Value:

    TRUE.

--*/

{
    T2_ICE Ice;
    ICIC_ELCR_REGISTER XioIcIcElcrRegister;

    //
    // Initialize the interface between the T3/T4 and the ICIC.
    //

    Ice.all = 0;
    Ice.EisaFlushAddress = 0x542;
    Ice.IcEnable = 1;
    Ice.HalfSpeedEnable = 0;

    WRITE_T2_REGISTER( &((PT2_CSRS)(T4_CSRS_QVA))->Ice,
                        Ice.all );

    //
    // Initialize the ICIC Mask Register.
    //

    XioIcIcMaskRegister = (ULONGLONG)-1;

    WRITE_ICIC_REGISTER( T4_CSRS_QVA, IcIcMaskRegister,
                         XioIcIcMaskRegister );

    //
    // Initialize the ICIC Edge/Level Control Register.
    //

    XioIcIcElcrRegister =
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot4AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot4BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot4CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot4DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot5AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot5BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot5CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot5DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot6AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot6BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot6CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot6DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot7AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot7BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot7CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot7DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot7DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot0AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot0BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot0CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot0DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot1AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot1BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot1CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot1DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot2AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot2BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot2CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot2DVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot3AVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot3BVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot3CVector - XioBaseVector)) |
        ((ICIC_ELCR_REGISTER)1 << (XioPciSlot3DVector - XioBaseVector));

    WRITE_ICIC_REGISTER( T4_CSRS_QVA, IcIcElcrRegister,
                         XioIcIcElcrRegister );

    //
    // Initialize the ICIC EISA Register.
    //

    WRITE_ICIC_REGISTER( T4_CSRS_QVA, IcIcEisaRegister, (ULONGLONG)0 );

    //
    // Initialize the ICIC Mode Register.
    //

    WRITE_ICIC_REGISTER( T4_CSRS_QVA, IcIcModeRegister, (ULONGLONG)0 );

    return TRUE;
}


BOOLEAN
HalpXioDispatch(
    VOID
    )

/*++

Routine Description:

    This routine dispatches interrupts received by the External I/O
    ICIC.

Arguments:

    None.

Return Value:

    A boolean value indicating whether the interrupt was handled by
    the FLIH/SLIH.

--*/

{
    T2_VAR Var;
    PULONG DispatchCode;
    PKINTERRUPT InterruptObject;
    BOOLEAN ReturnValue;

    //
    // Get the interrupt vector.
    //

    Var.all = READ_T2_REGISTER( &((PT2_CSRS)(T4_CSRS_QVA))->Var );

    //
    // If this is a passive release, ignore the interrupt.
    //

    if( Var.PassiveRelease == 1 ){

        return(TRUE);

    }

    //
    // Dispatch to the secondary interrupt service routine.
    //

    DispatchCode = (PULONG)PCR->InterruptRoutine[XioBaseVector + Var.Vector];
    InterruptObject = CONTAINING_RECORD(DispatchCode,
                                        KINTERRUPT,
                                        DispatchCode);

    ReturnValue = ((PSECOND_LEVEL_DISPATCH)InterruptObject->DispatchAddress)(InterruptObject);

    //
    // Send an SEOI.
    //

    WRITE_T2_REGISTER( &((PT2_CSRS)(T4_CSRS_QVA))->Var, Var.Vector );

    return(ReturnValue);
}

VOID
HalpDisableXioInterrupt(
    IN ULONG Vector
    )

/*++

Routine Description:

    This routine disables interrupts associated with the External I/O
    ICIC.

Arguments:

    Vector - The vector of the interrupt to disable.

Return Value:

    None.

--*/

{
    ULONGLONG IrqMask;

    if( (Vector >= XioBaseVector) &&
        (Vector <= XioPciSlot3DVector) ){

        //
        // Compute the IRQ mask.
        //

        IrqMask = (ICIC_MASK_REGISTER)1 << (Vector - XioBaseVector);

        //
        // Mask the interrupt.
        //

        XioIcIcMaskRegister |= IrqMask;

        //
        // Update the ICIC Mask Register.
        //

        WRITE_ICIC_REGISTER( T4_CSRS_QVA, IcIcMaskRegister,
                             XioIcIcMaskRegister );

    }
}

BOOLEAN
HalpEnableXioInterrupt(
    IN ULONG Vector,
    IN KINTERRUPT_MODE InterruptMode
    )

/*++

Routine Description:

    This routine enables interrupts associated with the External I/O
    ICIC.

Arguments:

    Vector - The vector of the interrupt to enable.

    InterruptMode - An indication of whether the interrupt should
                    be edge-triggered/level-sensitive.  (Ignored)

Return Value:

    None.

--*/

{
    ULONGLONG IrqMask;

    if( (Vector >= XioBaseVector) &&
        (Vector <= XioPciSlot3DVector) ){

        //
        // Compute the IRQ mask.
        //

        IrqMask = (ICIC_MASK_REGISTER)1 << (Vector - XioBaseVector);

        //
        // Un-mask the interrupt.
        //

        XioIcIcMaskRegister &= ~IrqMask;

        //
        // Update the ICIC Mask Register.
        //

        WRITE_ICIC_REGISTER( T4_CSRS_QVA, IcIcMaskRegister,
                             XioIcIcMaskRegister );

        return TRUE;
    }

    return FALSE;
}

#endif // XIO_PASS2