@@ -63,18 +63,47 @@ static int gIER,gIFR,gBufA,gBufB;
6363#define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF)
6464#define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8)
6565
66- /* To disable a NuBus slot on Quadras we make that slot IRQ line an output set
67- * high. On RBV we just use the slot interrupt enable register. On Macs with
68- * genuine VIA chips we must use nubus_disabled to keep track of disabled slot
69- * interrupts. When any slot IRQ is disabled we mask the (edge triggered) CA1
70- * or "SLOTS" interrupt. When no slot is disabled, we unmask the CA1 interrupt.
71- * So, on genuine VIAs, having more than one NuBus IRQ can mean trouble,
72- * because closing one of those drivers can mask all of the NuBus interrupts.
73- * Also, since we can't mask the unregistered slot IRQs on genuine VIAs, it's
74- * possible to get interrupts from cards that MacOS or the ROM has configured
75- * but we have not. FWIW, "Designing Cards and Drivers for Macintosh II and
76- * Macintosh SE", page 9-8, says, a slot IRQ with no driver would crash MacOS.
66+
67+ /*
68+ * On Macs with a genuine VIA chip there is no way to mask an individual slot
69+ * interrupt. This limitation also seems to apply to VIA clone logic cores in
70+ * Quadra-like ASICs. (RBV and OSS machines don't have this limitation.)
71+ *
72+ * We used to fake it by configuring the relevent VIA pin as an output
73+ * (to mask the interrupt) or input (to unmask). That scheme did not work on
74+ * (at least) the Quadra 700. A NuBus card's /NMRQ signal is an open-collector
75+ * circuit (see Designing Cards and Drivers for Macintosh II and Macintosh SE,
76+ * p. 10-11 etc) but VIA outputs are not (see datasheet).
77+ *
78+ * Driving these outputs high must cause the VIA to source current and the
79+ * card to sink current when it asserts /NMRQ. Current will flow but the pin
80+ * voltage is uncertain and so the /NMRQ condition may still cause a transition
81+ * at the VIA2 CA1 input (which explains the lost interrupts). A side effect
82+ * is that a disabled slot IRQ can never be tested as pending or not.
83+ *
84+ * Driving these outputs low doesn't work either. All the slot /NMRQ lines are
85+ * (active low) OR'd together to generate the CA1 (aka "SLOTS") interrupt (see
86+ * The Guide To Macintosh Family Hardware, 2nd edition p. 167). If we drive a
87+ * disabled /NMRQ line low, the falling edge immediately triggers a CA1
88+ * interrupt and all slot interrupts after that will generate no transition
89+ * and therefore no interrupt, even after being re-enabled.
90+ *
91+ * So we make the VIA port A I/O lines inputs and use nubus_disabled to keep
92+ * track of their states. When any slot IRQ becomes disabled we mask the CA1
93+ * umbrella interrupt. Only when all slot IRQs become enabled do we unmask
94+ * the CA1 interrupt. It must remain enabled even when cards have no interrupt
95+ * handler registered. Drivers must therefore disable a slot interrupt at the
96+ * device before they call free_irq (like shared and autovector interrupts).
97+ *
98+ * There is also a related problem when MacOS is used to boot Linux. A network
99+ * card brought up by a MacOS driver may raise an interrupt while Linux boots.
100+ * This can be fatal since it can't be handled until the right driver loads
101+ * (if such a driver exists at all). Apparently related to this hardware
102+ * limitation, "Designing Cards and Drivers", p. 9-8, says that a slot
103+ * interrupt with no driver would crash MacOS (the book was written before
104+ * the appearance of Macs with RBV or OSS).
77105 */
106+
78107static u8 nubus_disabled ;
79108
80109void via_debug_dump (void );
@@ -354,34 +383,55 @@ void __init via_nubus_init(void)
354383 via2 [gBufB ] |= 0x02 ;
355384 }
356385
357- /* Disable all the slot interrupts (where possible). */
386+ /*
387+ * Disable the slot interrupts. On some hardware that's not possible.
388+ * On some hardware it's unclear what all of these I/O lines do.
389+ */
358390
359391 switch (macintosh_config -> via_type ) {
360392 case MAC_VIA_II :
361- /* Just make the port A lines inputs. */
362- switch (macintosh_config -> ident ) {
363- case MAC_MODEL_II :
364- case MAC_MODEL_IIX :
365- case MAC_MODEL_IICX :
366- case MAC_MODEL_SE30 :
367- /* The top two bits are RAM size outputs. */
368- via2 [vDirA ] &= 0xC0 ;
369- break ;
370- default :
371- via2 [vDirA ] &= 0x80 ;
372- }
393+ case MAC_VIA_QUADRA :
394+ pr_debug ("VIA2 vDirA is 0x%02X\n" , via2 [vDirA ]);
373395 break ;
374396 case MAC_VIA_IIci :
375397 /* RBV. Disable all the slot interrupts. SIER works like IER. */
376398 via2 [rSIER ] = 0x7F ;
377399 break ;
400+ }
401+ }
402+
403+ void via_nubus_irq_startup (int irq )
404+ {
405+ int irq_idx = IRQ_IDX (irq );
406+
407+ switch (macintosh_config -> via_type ) {
408+ case MAC_VIA_II :
378409 case MAC_VIA_QUADRA :
379- /* Disable the inactive slot interrupts by making those lines outputs. */
380- if ((macintosh_config -> adb_type != MAC_ADB_PB1 ) &&
381- (macintosh_config -> adb_type != MAC_ADB_PB2 )) {
382- via2 [vBufA ] |= 0x7F ;
383- via2 [vDirA ] |= 0x7F ;
410+ /* Make the port A line an input. Probably redundant. */
411+ if (macintosh_config -> via_type == MAC_VIA_II ) {
412+ /* The top two bits are RAM size outputs. */
413+ via2 [vDirA ] &= 0xC0 | ~(1 << irq_idx );
414+ } else {
415+ /* Allow NuBus slots 9 through F. */
416+ via2 [vDirA ] &= 0x80 | ~(1 << irq_idx );
384417 }
418+ /* fall through */
419+ case MAC_VIA_IIci :
420+ via_irq_enable (irq );
421+ break ;
422+ }
423+ }
424+
425+ void via_nubus_irq_shutdown (int irq )
426+ {
427+ switch (macintosh_config -> via_type ) {
428+ case MAC_VIA_II :
429+ case MAC_VIA_QUADRA :
430+ /* Ensure that the umbrella CA1 interrupt remains enabled. */
431+ via_irq_enable (irq );
432+ break ;
433+ case MAC_VIA_IIci :
434+ via_irq_disable (irq );
385435 break ;
386436 }
387437}
@@ -507,6 +557,7 @@ void via_irq_enable(int irq) {
507557 } else if (irq_src == 7 ) {
508558 switch (macintosh_config -> via_type ) {
509559 case MAC_VIA_II :
560+ case MAC_VIA_QUADRA :
510561 nubus_disabled &= ~(1 << irq_idx );
511562 /* Enable the CA1 interrupt when no slot is disabled. */
512563 if (!nubus_disabled )
@@ -518,14 +569,6 @@ void via_irq_enable(int irq) {
518569 */
519570 via2 [rSIER ] = IER_SET_BIT (irq_idx );
520571 break ;
521- case MAC_VIA_QUADRA :
522- /* Make the port A line an input to enable the slot irq.
523- * But not on PowerBooks, that's ADB.
524- */
525- if ((macintosh_config -> adb_type != MAC_ADB_PB1 ) &&
526- (macintosh_config -> adb_type != MAC_ADB_PB2 ))
527- via2 [vDirA ] &= ~(1 << irq_idx );
528- break ;
529572 }
530573 }
531574}
@@ -545,18 +588,14 @@ void via_irq_disable(int irq) {
545588 } else if (irq_src == 7 ) {
546589 switch (macintosh_config -> via_type ) {
547590 case MAC_VIA_II :
591+ case MAC_VIA_QUADRA :
548592 nubus_disabled |= 1 << irq_idx ;
549593 if (nubus_disabled )
550594 via2 [gIER ] = IER_CLR_BIT (1 );
551595 break ;
552596 case MAC_VIA_IIci :
553597 via2 [rSIER ] = IER_CLR_BIT (irq_idx );
554598 break ;
555- case MAC_VIA_QUADRA :
556- if ((macintosh_config -> adb_type != MAC_ADB_PB1 ) &&
557- (macintosh_config -> adb_type != MAC_ADB_PB2 ))
558- via2 [vDirA ] |= 1 << irq_idx ;
559- break ;
560599 }
561600 }
562601}
0 commit comments