From 3c100c7def39d40265a973ef41a190cc5981e804 Mon Sep 17 00:00:00 2001 From: Dale Rahn Date: Sat, 2 Mar 2002 17:17:38 +0000 Subject: These two drivers were incorrectly sharing variables, sometimes expecting them to be intialized by the other. also remove static variables and rename them so they are accessable via ddb. --- sys/arch/macppc/dev/macintr.c | 82 +++++++++++++++++++++---------------------- sys/arch/macppc/dev/openpic.c | 78 ++++++++++++++++++++-------------------- 2 files changed, 81 insertions(+), 79 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/macppc/dev/macintr.c b/sys/arch/macppc/dev/macintr.c index 5877af1480f..3766be45435 100644 --- a/sys/arch/macppc/dev/macintr.c +++ b/sys/arch/macppc/dev/macintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: macintr.c,v 1.9 2002/01/26 15:22:52 drahn Exp $ */ +/* $OpenBSD: macintr.c,v 1.10 2002/03/02 17:17:37 drahn Exp $ */ /*- * Copyright (c) 1995 Per Fogelstrom @@ -61,11 +61,11 @@ #define ICU_LEN 64 #define LEGAL_IRQ(x) ((x >= 0) && (x < ICU_LEN)) -static int intrtype[ICU_LEN], intrmask[ICU_LEN], intrlevel[ICU_LEN]; -static struct intrhand *intrhand[ICU_LEN]; -static int hwirq[ICU_LEN], virq[64]; -unsigned int imen = 0xffffffff; -int virq_max = 0; +int m_intrtype[ICU_LEN], m_intrmask[ICU_LEN], m_intrlevel[ICU_LEN]; +struct intrhand *m_intrhand[ICU_LEN]; +int m_hwirq[ICU_LEN], m_virq[64]; +unsigned int imen_m = 0xffffffff; +int m_virq_max = 0; struct evcnt evirq[ICU_LEN*2]; @@ -265,18 +265,18 @@ printf("vI %d ", irq); if (!LEGAL_IRQ(irq) || type == IST_NONE) panic("intr_establish: bogus irq or type"); - switch (intrtype[irq]) { + switch (m_intrtype[irq]) { case IST_NONE: - intrtype[irq] = type; + m_intrtype[irq] = type; break; case IST_EDGE: case IST_LEVEL: - if (type == intrtype[irq]) + if (type == m_intrtype[irq]) break; case IST_PULSE: if (type != IST_NONE) panic("intr_establish: can't share %s with %s", - intr_typename(intrtype[irq]), + intr_typename(m_intrtype[irq]), intr_typename(type)); break; } @@ -286,7 +286,7 @@ printf("vI %d ", irq); * This is O(N^2), but we want to preserve the order, and N is * generally small. */ - for (p = &intrhand[irq]; (q = *p) != NULL; p = &q->ih_next) + for (p = &m_intrhand[irq]; (q = *p) != NULL; p = &q->ih_next) ; /* @@ -332,7 +332,7 @@ macintr_disestablish(lcp, arg) * Remove the handler from the chain. * This is O(n^2), too. */ - for (p = &intrhand[irq]; (q = *p) != NULL && q != ih; p = &q->ih_next) + for (p = &m_intrhand[irq]; (q = *p) != NULL && q != ih; p = &q->ih_next) ; if (q) *p = q->ih_next; @@ -342,8 +342,8 @@ macintr_disestablish(lcp, arg) intr_calculatemasks(); - if (intrhand[irq] == NULL) - intrtype[irq] = IST_NONE; + if (m_intrhand[irq] == NULL) + m_intrtype[irq] = IST_NONE; } @@ -383,16 +383,16 @@ intr_calculatemasks() /* First, figure out which levels each IRQ uses. */ for (irq = 0; irq < ICU_LEN; irq++) { register int levels = 0; - for (q = intrhand[irq]; q; q = q->ih_next) + for (q = m_intrhand[irq]; q; q = q->ih_next) levels |= 1 << q->ih_level; - intrlevel[irq] = levels; + m_intrlevel[irq] = levels; } /* Then figure out which IRQs use each level. */ for (level = 0; level < 5; level++) { register int irqs = 0; for (irq = 0; irq < ICU_LEN; irq++) - if (intrlevel[irq] & (1 << level)) + if (m_intrlevel[irq] & (1 << level)) irqs |= 1 << irq; imask[level] = irqs | SINT_MASK; } @@ -418,20 +418,20 @@ intr_calculatemasks() /* And eventually calculate the complete masks. */ for (irq = 0; irq < ICU_LEN; irq++) { register int irqs = 1 << irq; - for (q = intrhand[irq]; q; q = q->ih_next) + for (q = m_intrhand[irq]; q; q = q->ih_next) irqs |= imask[q->ih_level]; - intrmask[irq] = irqs | SINT_MASK; + m_intrmask[irq] = irqs | SINT_MASK; } /* Lastly, determine which IRQs are actually in use. */ { register int irqs = 0; for (irq = 0; irq < ICU_LEN; irq++) { - if (intrhand[irq]) + if (m_intrhand[irq]) irqs |= 1 << irq; } - imen = ~irqs; - enable_irq(~imen); + imen_m = ~irqs; + enable_irq(~imen_m); } } static void @@ -446,7 +446,7 @@ enable_irq(x) state0 = state1 = 0; while (x) { v = 31 - cntlzw(x); - irq = hwirq[v]; + irq = m_hwirq[v]; if (irq < 32) { state0 |= 1 << irq; } else { @@ -471,13 +471,13 @@ mapirq(irq) if (irq < 0 || irq >= 64) panic("invalid irq"); - virq_max++; - v = virq_max; + m_virq_max++; + v = m_virq_max; if (v > HWIRQ_MAX) panic("virq overflow"); - hwirq[v] = irq; - virq[irq] = v; + m_hwirq[v] = irq; + m_virq[irq] = v; #if 0 printf("\nmapirq %x to %x\n", irq, v); #endif @@ -519,24 +519,24 @@ mac_ext_intr() start: irq = 31 - cntlzw(int_state); - intrcnt[hwirq[irq]]++; + intrcnt[m_hwirq[irq]]++; - o_imen = imen; + o_imen = imen_m; r_imen = 1 << irq; if ((cpl & r_imen) != 0) { ipending |= r_imen; /* Masked! Mark this as pending */ - imen |= r_imen; - enable_irq(~imen); + imen_m |= r_imen; + enable_irq(~imen_m); } else { - splraise(intrmask[irq]); + splraise(m_intrmask[irq]); /* * enable interrupts for the duration of the * interrupt handler */ ppc_intr_enable(1); - ih = intrhand[irq]; + ih = m_intrhand[irq]; while (ih) { (*ih->ih_fun)(ih->ih_arg); ih = ih->ih_next; @@ -544,7 +544,7 @@ start: ppc_intr_disable(); uvmexp.intrs++; - evirq[hwirq[irq]].ev_count++; + evirq[m_hwirq[irq]].ev_count++; } int_state &= ~r_imen; if (int_state) @@ -576,22 +576,22 @@ mac_intr_do_pending_int() asm volatile("mtmsr %0" :: "r"(dmsr)); hwpend = ipending & ~pcpl; /* Do now unmasked pendings */ - imen &= ~hwpend; - enable_irq(~imen); + imen_m &= ~hwpend; + enable_irq(~imen_m); hwpend &= HWIRQ_MASK; while (hwpend) { irq = 31 - cntlzw(hwpend); hwpend &= ~(1L << irq); - ih = intrhand[irq]; + ih = m_intrhand[irq]; while(ih) { (*ih->ih_fun)(ih->ih_arg); ih = ih->ih_next; } - evirq[hwirq[irq]].ev_count++; + evirq[m_hwirq[irq]].ev_count++; } - /*out32rb(INT_ENABLE_REG, ~imen);*/ + /*out32rb(INT_ENABLE_REG, ~imen_m);*/ do { if((ipending & SINT_CLOCK) & ~pcpl) { @@ -629,7 +629,7 @@ read_irq() state0save = state0; while (state0) { p = 31 - cntlzw(state0); - rv |= 1 << virq[p]; + rv |= 1 << m_virq[p]; state0 &= ~(1 << p); } @@ -643,7 +643,7 @@ read_irq() state1save = state1; while (state1) { p = 31 - cntlzw(state1); - rv |= 1 << virq[p + 32]; + rv |= 1 << m_virq[p + 32]; state1 &= ~(1 << p); } #if 0 diff --git a/sys/arch/macppc/dev/openpic.c b/sys/arch/macppc/dev/openpic.c index 8738953ef25..030a0320b52 100644 --- a/sys/arch/macppc/dev/openpic.c +++ b/sys/arch/macppc/dev/openpic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openpic.c,v 1.10 2002/01/26 15:22:52 drahn Exp $ */ +/* $OpenBSD: openpic.c,v 1.11 2002/03/02 17:17:37 drahn Exp $ */ /*- * Copyright (c) 1995 Per Fogelstrom @@ -61,11 +61,11 @@ #define ICU_LEN 128 #define LEGAL_IRQ(x) ((x >= 0) && (x < ICU_LEN)) -static int intrtype[ICU_LEN], intrmask[ICU_LEN], intrlevel[ICU_LEN]; -static struct intrhand *intrhand[ICU_LEN] = { 0 }; -static int hwirq[ICU_LEN], virq[ICU_LEN]; -unsigned int imen /* = 0xffffffff */; /* XXX */ -static int virq_max = 0; +int o_intrtype[ICU_LEN], o_intrmask[ICU_LEN], o_intrlevel[ICU_LEN]; +struct intrhand *o_intrhand[ICU_LEN] = { 0 }; +int o_hwirq[ICU_LEN], o_virq[ICU_LEN]; +unsigned int imen_o = 0xffffffff; +int o_virq_max; struct evcnt evirq[ICU_LEN]; @@ -204,6 +204,7 @@ fakeintr(arg) void nameinterrupt( int replace, char *newstr); + /* * Register an interrupt handler. */ @@ -241,18 +242,18 @@ printf("vI %d ", irq); if (!LEGAL_IRQ(irq) || type == IST_NONE) panic("intr_establish: bogus irq or type"); - switch (intrtype[irq]) { + switch (o_intrtype[irq]) { case IST_NONE: - intrtype[irq] = type; + o_intrtype[irq] = type; break; case IST_EDGE: case IST_LEVEL: - if (type == intrtype[irq]) + if (type == o_intrtype[irq]) break; case IST_PULSE: if (type != IST_NONE) panic("intr_establish: can't share %s with %s", - intr_typename(intrtype[irq]), + intr_typename(o_intrtype[irq]), intr_typename(type)); break; } @@ -262,7 +263,7 @@ printf("vI %d ", irq); * This is O(N^2), but we want to preserve the order, and N is * generally small. */ - for (p = &intrhand[irq]; (q = *p) != NULL; p = &q->ih_next) + for (p = &o_intrhand[irq]; (q = *p) != NULL; p = &q->ih_next) ; /* @@ -308,7 +309,7 @@ openpic_intr_disestablish(lcp, arg) * Remove the handler from the chain. * This is O(n^2), too. */ - for (p = &intrhand[irq]; (q = *p) != NULL && q != ih; p = &q->ih_next) + for (p = &o_intrhand[irq]; (q = *p) != NULL && q != ih; p = &q->ih_next) ; if (q) *p = q->ih_next; @@ -318,8 +319,8 @@ openpic_intr_disestablish(lcp, arg) intr_calculatemasks(); - if (intrhand[irq] == NULL) - intrtype[irq] = IST_NONE; + if (o_intrhand[irq] == NULL) + o_intrtype[irq] = IST_NONE; } @@ -360,16 +361,16 @@ intr_calculatemasks() /* First, figure out which levels each IRQ uses. */ for (irq = 0; irq < ICU_LEN; irq++) { register int levels = 0; - for (q = intrhand[irq]; q; q = q->ih_next) + for (q = o_intrhand[irq]; q; q = q->ih_next) levels |= 1 << q->ih_level; - intrlevel[irq] = levels; + o_intrlevel[irq] = levels; } /* Then figure out which IRQs use each level. */ for (level = 0; level < 5; level++) { register int irqs = 0; for (irq = 0; irq < ICU_LEN; irq++) - if (intrlevel[irq] & (1 << level)) + if (o_intrlevel[irq] & (1 << level)) irqs |= 1 << irq; imask[level] = irqs | SINT_MASK; } @@ -395,23 +396,24 @@ intr_calculatemasks() /* And eventually calculate the complete masks. */ for (irq = 0; irq < ICU_LEN; irq++) { register int irqs = 1 << irq; - for (q = intrhand[irq]; q; q = q->ih_next) + for (q = o_intrhand[irq]; q; q = q->ih_next) irqs |= imask[q->ih_level]; - intrmask[irq] = irqs | SINT_MASK; + o_intrmask[irq] = irqs | SINT_MASK; } /* Lastly, determine which IRQs are actually in use. */ { register int irqs = 0; for (irq = 0; irq < ICU_LEN; irq++) { - if (intrhand[irq]) { + if (o_intrhand[irq]) { irqs |= 1 << irq; - openpic_enable_irq(hwirq[irq], intrtype[irq]); + openpic_enable_irq(o_hwirq[irq], + o_intrtype[irq]); } else { - openpic_disable_irq(hwirq[irq]); + openpic_disable_irq(o_hwirq[irq]); } } - imen = ~irqs; + imen_o = ~irqs; } } /* @@ -425,13 +427,13 @@ mapirq(irq) if (irq < 0 || irq >= ICU_LEN) panic("invalid irq"); - virq_max++; - v = virq_max; + o_virq_max++; + v = o_virq_max; if (v > HWIRQ_MAX) panic("virq overflow"); - hwirq[v] = irq; - virq[irq] = v; + o_hwirq[v] = irq; + o_virq[irq] = v; #if 0 printf("\nmapirq %x to %x\n", irq, v); #endif @@ -474,22 +476,22 @@ openpic_do_pending_int() asm volatile("mtmsr %0" :: "r"(dmsr)); hwpend = ipending & ~pcpl; /* Do now unmasked pendings */ - imen &= ~hwpend; - openpic_enable_irq_mask(~imen); + imen_o &= ~hwpend; + openpic_enable_irq_mask(~imen_o); hwpend &= HWIRQ_MASK; while (hwpend) { irq = 31 - cntlzw(hwpend); hwpend &= ~(1L << irq); - ih = intrhand[irq]; + ih = o_intrhand[irq]; while(ih) { (*ih->ih_fun)(ih->ih_arg); ih = ih->ih_next; } - evirq[hwirq[irq]].ev_count++; + evirq[o_hwirq[irq]].ev_count++; } - /*out32rb(INT_ENABLE_REG, ~imen);*/ + /*out32rb(INT_ENABLE_REG, ~imen_o);*/ do { if((ipending & SINT_CLOCK) & ~pcpl) { @@ -538,11 +540,11 @@ openpic_enable_irq_mask(irq_mask) int irq_mask; { int irq; - for ( irq = 0; irq <= virq_max; irq++) { + for ( irq = 0; irq <= o_virq_max; irq++) { if (irq_mask & (1 << irq)) { - openpic_enable_irq(hwirq[irq], intrtype[irq]); + openpic_enable_irq(o_hwirq[irq], o_intrtype[irq]); } else { - openpic_disable_irq(hwirq[irq]); + openpic_disable_irq(o_hwirq[irq]); } } } @@ -614,7 +616,7 @@ ext_intr_openpic() realirq = openpic_read_irq(0); while (realirq != 255) { - irq = virq[realirq]; + irq = o_virq[realirq]; intrcnt[realirq]++; /* XXX check range */ @@ -625,14 +627,14 @@ ext_intr_openpic() ipending |= r_imen; /* Masked! Mark this as pending */ openpic_disable_irq(realirq); } else { - splraise(intrmask[irq]); + splraise(o_intrmask[irq]); /* * enable interrupts for the duration of the * interrupt handler */ ppc_intr_enable(1); - ih = intrhand[irq]; + ih = o_intrhand[irq]; while (ih) { (*ih->ih_fun)(ih->ih_arg); ih = ih->ih_next; -- cgit v1.2.3