summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halalpha/ev5int.c
blob: 3fa1eec25484c37512ab3e96ca678c4c288ee195 (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
/*++

Copyright (c) 1994  Digital Equipment Corporation

Module Name:

    ev5int.c

Abstract:

    This module implements the support routines to control DECchip 21164
    interrupts.

Author:

    Joe Notarangelo  20-Jul-1994

Environment:

    Kernel mode

Revision History:

--*/

#include "halp.h"
#include "axp21164.h"

//
// Function prototype.
//

VOID
HalpCachePcrValues(
    ULONG InterruptMask
    );


VOID
HalpInitialize21164Interrupts(
    VOID
    )
/*++

Routine Description:

    This routine initializes the data structures for the 21164
    interrupt routines.

Arguments:

    None.

Return Value:

    None.

--*/
{
    PIMSK_21164 InterruptMask;
    PBOOLEAN InterruptsStarted;

    //
    // Set up the standard correspondence of NT IRQLs to EV5 IPLs.
    // It is possible that some machines may need a different correspondence
    // then the one below - HALs that change this table do so at their
    // own risk.
    //
    // NT IRQL          EV5 IPL
    // -------          -------
    // PASSIVE_LEVEL        0
    // APC_LEVEL            1
    // DISPATCH_LEVEL       2
    // DEVICE_LEVEL         20
    // DEVICE_HIGH_LEVEL    21
    // CLOCK_LEVEL          22
    // IPI_LEVEL            23
    // HIGH_LEVEL           31
    //

    PCR->IrqlTable[PASSIVE_LEVEL] = EV5_IPL0;
    PCR->IrqlTable[APC_LEVEL] = EV5_IPL1;
    PCR->IrqlTable[DISPATCH_LEVEL] = EV5_IPL2;
    PCR->IrqlTable[DEVICE_LEVEL] = EV5_IPL20;
    PCR->IrqlTable[DEVICE_HIGH_LEVEL] = EV5_IPL21;
    PCR->IrqlTable[CLOCK_LEVEL] = EV5_IPL22;
    PCR->IrqlTable[IPI_LEVEL] = EV5_IPL23;
    PCR->IrqlTable[HIGH_LEVEL] = EV5_IPL31;
 
    //
    // Define the default set of disables (masks) for the EV5 interrupt
    // pins INT0 - INT3.  All interrupts are enabled by default and may
    // be disabled by the interface: HalpDisable21164HardwareInterrupt().
    //

    InterruptMask = (PIMSK_21164)(&PCR->IrqlMask[0]);

    InterruptMask->all = 0;

    //
    // Indicate that interrupts have not been started yet.
    //

    InterruptsStarted = (PBOOLEAN)(&PCR->IrqlMask[1]);
    *InterruptsStarted = FALSE;

    return;

}


VOID
HalpStart21164Interrupts(
    VOID
    )
/*++

Routine Description:

    This function starts interrupt dispatching on the current 21164.  

Arguments:

    None.

Return Value:

    None.

--*/
{
    PIMSK_21164 InterruptMask;
    PBOOLEAN InterruptsStarted;

    //
    // Issue the initpcr call pal to alert the PALcode that it can
    // begin taking interrupts, pass the disable mask for the hardware
    // interrupts.
    //

    InterruptMask = (PIMSK_21164)(&PCR->IrqlMask);
    HalpCachePcrValues( InterruptMask->all );

    //
    // Indicate that interrupts have been started yet.
    //

    InterruptsStarted = (PBOOLEAN)(&PCR->IrqlMask[1]);
    *InterruptsStarted = TRUE;

    return;
}


#if 0 // used ??

VOID
HalpEnable21164HardwareInterrupt(
    IN ULONG Irq
    )
/*++

Routine Description:

    Clear the mask value for the desired Irq pin so that interrupts
    are enabled from that pin.

Arguments:

    Irq - Supplies the interrupt pin number to be enabled.

Return Value:

    None.

--*/
{
    PIMSK_21164 InterruptMask;
    PBOOLEAN InterruptsStarted;
    KIRQL OldIrql;

    //
    // Raise Irql to HIGH_LEVEL to prevent any interrupts.
    //

    KeRaiseIrql( HIGH_LEVEL, &OldIrql );

    //
    // Clear the mask value for the desired Irq pin.
    //

    InterruptMask = (PIMSK_21164)(&PCR->IrqlMask);

    switch( Irq ){

        case Irq0:

            InterruptMask->Irq0Mask = 0;
            break;

        case Irq1:

            InterruptMask->Irq1Mask = 0;
            break;

        case Irq2:

            InterruptMask->Irq2Mask = 0;
            break;

        case Irq3:

            InterruptMask->Irq3Mask = 0;
            break;

    } //end switch (Irq)

    //
    // Set the new masks in the PALcode.
    //

    InterruptsStarted = (PBOOLEAN)(&PCR->IrqlMask[1]);
    if( *InterruptsStarted == TRUE ){
        HalpCachePcrValues( InterruptMask->all );
    }

    //
    // Lower Irql to the previous level and return.
    //

    KeLowerIrql( OldIrql );
    return;

}


VOID
HalpDisable21164HardwareInterrupt(
    IN ULONG Irq
    )
/*++

Routine Description:

    Set the mask value for the desired Irq pin so that interrupts
    are disabled from that pin.

Arguments:

    Irq - Supplies the interrupt pin number to be disabled.

Return Value:

    None.

--*/
{
    PIMSK_21164 InterruptMask;
    PBOOLEAN InterruptsStarted;
    KIRQL OldIrql;

    //
    // Raise Irql to HIGH_LEVEL to prevent any interrupts.
    //

    KeRaiseIrql( HIGH_LEVEL, &OldIrql );

    //
    // Set the mask value for the desired Irq pin.
    //

    InterruptMask = (PIMSK_21164)(&PCR->IrqlMask);

    switch( Irq ){

        case Irq0:

            InterruptMask->Irq0Mask = 1;
            break;

        case Irq1:

            InterruptMask->Irq1Mask = 1;
            break;

        case Irq2:

            InterruptMask->Irq2Mask = 1;
            break;

        case Irq3:

            InterruptMask->Irq3Mask = 1;
            break;

    } //end switch (Irq)

    //
    // Set the new masks in the PALcode, if interrupts have been started.
    //

    InterruptsStarted = (PBOOLEAN)(&PCR->IrqlMask[1]);
    if( *InterruptsStarted == TRUE ){
        HalpCachePcrValues( InterruptMask->all );
    }

    //
    // Lower Irql to the previous level and return.
    //

    KeLowerIrql( OldIrql );
    return;

}

#endif // Used ??


ULONG
HalpGet21164PerformanceVector(
    IN ULONG BusInterruptLevel,
    OUT PKIRQL Irql
    )

/*++

Routine Description:

    This function returns the system interrupt vector and IRQL level
    corresponding to the specified performance counter interrupt.

Arguments:

    BusInterruptLevel - Supplies the performance counter number.

    Irql - Returns the system request priority.

Return Value:

    Returns the system interrupt vector corresponding to the specified device.

--*/

{

    //
    // Handle the special internal bus defined for the processor itself
    // and used to control the performance counters in the 21164.
    //

    *Irql = PROFILE_LEVEL;

    switch( BusInterruptLevel ){

    //
    // Performance Counter 0
    //

    case 0:

        return PC0_SECONDARY_VECTOR;

    //
    // Performance Counter 1
    //

    case 1:

        return PC1_SECONDARY_VECTOR;

    //
    // Performance Counter 2
    //

    case 2:

        return PC2_SECONDARY_VECTOR;

    } //end switch( BusInterruptLevel )

    //
    // Unrecognized.
    //

    *Irql = 0;
    return 0;            

}

ULONG
HalpGet21164CorrectableVector(
    IN ULONG BusInterruptLevel,
    OUT PKIRQL Irql
    )

/*++

Routine Description:

    This function returns the system interrupt vector and IRQL level
    corresponding to the specified correctable interrupt.

Arguments:

    BusInterruptLevel - Supplies the performance counter number.

    Irql - Returns the system request priority.

Return Value:

    Returns the system interrupt vector corresponding to the specified device.

--*/

{
  //
  // Get the correctable interrupt vector.
  //

  if (BusInterruptLevel == 5) {

    //
    // Correctable error interrupt was sucessfully recognized.
    //

    *Irql = DEVICE_HIGH_LEVEL;
    return CORRECTABLE_VECTOR;


  } else {

    //
    // Unrecognized.
    //

    *Irql = 0;
    return 0;
  }
}