summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halncr/i386/ncripi.asm
blob: ebbea00d8b5bc3960a0b3f47e39780a827dc38a5 (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

        title "Interprocessor Interrupt"
;++
;
;Copyright (c) 1992  NCR Corporation
;
;Module Name:
;
;    ncripi.asm
;
;Abstract:
;
;    Provides the HAL support for Interprocessor Interrupts.
;
;Author:
;
;    Richard Barton (o-richb) 24-Jan-1992
;
;Revision History:
;
;--
.386p
        .xlist
include i386\kimacro.inc
include callconv.inc                    ; calling convention macros
include hal386.inc
include i386\ncr.inc
include i386\ix8259.inc


        EXTRNP  Kei386EoiHelper,0,IMPORT
        EXTRNP  _KiCoprocessorError,0,IMPORT
        EXTRNP  _KeRaiseIrql,2
        EXTRNP  _HalBeginSystemInterrupt,3
        EXTRNP  _HalEndSystemInterrupt,2
        EXTRNP  _KiIpiServiceRoutine,2,IMPORT
        EXTRNP  _HalEnableSystemInterrupt,3
        EXTRNP  _NCRClearQicIpi,1
        extrn   _NCRLogicalNumberToPhysicalMask:DWORD

        page ,132
        subttl  "Post InterProcessor Interrupt"
_TEXT   SEGMENT DWORD USE32 PUBLIC 'CODE'
        ASSUME  CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING



;++
;
; VOID
; NCR3360EnableNmiButtoni(
;       VOID
;       );
;
;Routine Description:
;
;    Programs the recessed button on the 3360 to generate an NMI.
;
;    3360 SPECIFIC CODE ONLY !!!!!
;
;Arguments:
;
;    Mask - Supplies a mask of the processors to interrupt
;
;Return Value:
;
;    None.
;
;--

;
; in NMI handler, if you are interested in making sure button was source of
; NMI, check bit 6 (of 0 thru 7) of IO port 0xf820. If 0, button was pressed,
; 1 means NMI came from somewhere else.
;
; Also, in NMI interrupt handler, if NMI came fo...


cPublicProc _NCR3360EnableNmiButton, 0

        mov     ah, 41h         ; start with processor ASIC 0 (FRED ASIC)
        mov     cx, 2           ; loop through 2 processor cards

PollAsics:
        mov     al, ah          ; get ASIC select data
        out     97h, al         ; select ASIC through CAT Access port
        mov     dx, 0f800h      ; read CAT ID
        in      al, dx          ; 
        cmp     al, 0ffh        ; 0xff means no processor card is present
        je      @f

                                ; setup processor ASICs for g_nmi

        mov     dx, 0f80dh      ; turn on GNMI in FRED ASIC
        in      al, dx
        or      al, 1
        out     dx, al

@@:
        add     ah, 20h         ; go to next processor card

        loop    PollAsics       ; loop 'til done
        

        mov     al, 0c1h        ; select arbiter ASIC
        out     97h, al

        mov     dx, 0f80bh      ; enable EXP_FALCON_NMI (pushbutton NMI)
        in      al, dx
        or      al, 8
        out     dx, al

        mov     al, 0ffh        ; take CAT subsystem out of setup
        out     97h, al


        mov     dx, 0f823h      ; enable pushbutton NMI by disabling, then
        in      al, dx          ; reenable
        and     al, 11011111b   ; disable by setting MEM_DIS_L to 0
        out     dx, al
        or      al, 00100000b   ; enable by setting MEM_DIS_L to 0
        out     dx, al

        stdRET  _NCR3360EnableNmiButton
stdENDP _NCR3360EnableNmiButton



;++
;
; VOID
; HalVicRequestIpi(
;       IN ULONG Mask
;       );
;
;Routine Description:
;
;    Requests an interprocessor interrupt using the VIC
;
;Arguments:
;
;    Mask - Supplies a mask of the processors to interrupt
;
;Return Value:
;
;    None.
;
;--

cPublicProc _HalVicRequestIpi  ,1
        mov   eax, dword ptr 4[esp]
		TRANSLATE_LOGICAL_TO_VIC
        VIC_WRITE CpiLevel0Reg, al
        stdRET    _HalVicRequestIpi
stdENDP _HalVicRequestIpi


        page ,132
        subttl  "80387 Irq13 Interrupt Handler"

;++
;
; VOID
; HalpIrq13Handler (
;    );
;
; Routine Description:
;
;    When the 80387 detects an error, it raises its error line.  This
;    was supposed to be routed directly to the 386 to cause a trap 16
;    (which would actually occur when the 386 encountered the next FP
;    instruction).
;
;    However, the ISA design routes the error line to IRQ13 on the
;    slave 8259.  So an interrupt will be generated whenever the 387
;    discovers an error.
;
;    This routine handles that interrupt and passes control to the kernel
;    coprocessor error handler.
;
; Arguments:
;
;    None.
;    Interrupt is disabled.
;
; Return Value:
;
;    None.
;
;--

        ENTER_DR_ASSIST Hi13_a, Hi13_t

cPublicProc _HalpIrq13Handler       ,0

;
; Save machine state in trap frame
;

        ENTER_INTERRUPT Hi13_a, Hi13_t  ; (ebp) -> Trap frame

;
; HalBeginSystemInterrupt will save previous IRQL
;
        cli
        push    13 + PRIMARY_VECTOR_BASE
        sub     esp, 4                          ; placeholder for OldIrql

        stdCall   _HalBeginSystemInterrupt, <I386_80387_IRQL,13 + PRIMARY_VECTOR_BASE,esp>

        or      al,al                   ; check for spurious interrupt
        jz      SpuriousIrq13

        stdCall   _KiCoprocessorError     ; call CoprocessorError handler

;
;       Clear the busy latch so that the 386 doesn't mistakenly think
;       that the 387 is still busy.
;

        xor     al,al
        out     I386_80387_BUSY_PORT, al

        INTERRUPT_EXIT                  ; will return to caller

SpuriousIrq13:
        add     esp, 8                  ; spurious, no EndOfInterrupt
        SPURIOUS_INTERRUPT_EXIT         ; exit interrupt without eoi

stdENDP _HalpIrq13Handler


        page ,132
        subttl  "Interprocessor Interrupt Handler"

;++
;
; VOID
; NCRVicIPIHandler (
;    );
;
; Routine Description:
;
;    This routine handles an incoming cross-processor interrupt.
;
; Arguments:
;
;    None.
;    Interrupt is disabled.
;
; Return Value:
;
;    None.
;
;--

        ENTER_DR_ASSIST Ipi_a, Ipi_t

cPublicProc _NCRVicIPIHandler,0

;
; Save machine state in trap frame
;

        ENTER_INTERRUPT Ipi_a, Ipi_t  ; (ebp) -> Trap frame

;
; HalBeginSystemInterrupt will save previous IRQL
;

        push    NCR_CPI_VECTOR_BASE+NCR_IPI_LEVEL_CPI
        sub     esp, 4                          ; placeholder for OldIrql

        stdCall   _HalBeginSystemInterrupt, <IPI_LEVEL,NCR_CPI_VECTOR_BASE+NCR_IPI_LEVEL_CPI,esp>

        or      al,al                   ; check for spurious interrupt
        jz      short SpuriousIpi

; Pass TrapFrame to Ipi service rtn
; Pass Null ExceptionFrame

        stdCall   _KiIpiServiceRoutine, <ebp,0>

; BUGBUG shielint ignore returncode

NCRIpiisDone:
        INTERRUPT_EXIT                  ; will return to caller

        align   4
SpuriousIpi:
        add     esp, 8                  ; spurious, no EndOfInterrupt
        SPURIOUS_INTERRUPT_EXIT         ; exit interrupt without eoi

stdENDP _NCRVicIPIHandler


;++
;
; VOID
; NCRQicIPIHandler (
;    );
;
; Routine Description:
;
;    This routine handles an incoming cross-processor interrupt for the Quad Processor.
;
; Arguments:
;
;    None.
;    Interrupt is disabled.
;
; Return Value:
;
;    None.
;
;--

        ENTER_DR_ASSIST QicIpi_a, QicIpi_t

cPublicProc _NCRQicIPIHandler,0

;
; Save machine state in trap frame
;

        ENTER_INTERRUPT QicIpi_a, QicIpi_t  ; (ebp) -> Trap frame

;
; HalBeginSystemInterrupt will save previous IRQL
;

        push    NCR_QIC_CPI_VECTOR_BASE+NCR_IPI_LEVEL_CPI
        sub     esp, 4                          ; placeholder for OldIrql

        stdCall   _HalBeginSystemInterrupt, <IPI_LEVEL,NCR_QIC_CPI_VECTOR_BASE+NCR_IPI_LEVEL_CPI,esp>

        or      al,al                   ; check for spurious interrupt
        jz      short SpuriousQicIpi

; Pass TrapFrame to Ipi service rtn
; Pass Null ExceptionFrame

        stdCall   _KiIpiServiceRoutine, <ebp,0>

; BUGBUG shielint ignore returncode

NCRQicIpiisDone:
        INTERRUPT_EXIT                  ; will return to caller

        align   4
SpuriousQicIpi:
        add     esp, 8                  ; spurious, no EndOfInterrupt
        SPURIOUS_INTERRUPT_EXIT         ; exit interrupt without eoi

stdENDP _NCRQicIPIHandler




_TEXT   ENDS

        END