Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Planning for NetBSD 5.0



macallan%NetBSD.org@localhost wrote:

> I just found a stupid typo in the ohare PIC code, I have no idea why  
> I never ran into the problem you described. Please apply the attached  
> patch and things should work properly.

Yes, this one also works fine. Thanks.

But we should kill more magic numbers?
---
Index: pic_ohare.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/macppc/pic_ohare.c,v
retrieving revision 1.5
diff -u -r1.5 pic_ohare.c
--- pic_ohare.c 7 May 2008 00:39:12 -0000       1.5
+++ pic_ohare.c 7 May 2008 11:01:32 -0000
@@ -51,13 +51,15 @@
 static void ohare_ack_irq(struct pic_ops *, int);
 static void ohare_establish_irq(struct pic_ops *, int, int, int);
 
+#define NIRQ   32
+
 struct ohare_ops {
        struct pic_ops pic;
        uint32_t pending_events;
        uint32_t enable_mask;
        uint32_t level_mask;
        uint32_t irqs[NIPL];            /* per priority level */
-       uint32_t priority_masks[32];    /* per IRQ */
+       uint32_t priority_masks[NIRQ];  /* per IRQ */
 };
 
 static struct ohare_ops *setup_ohare(uint32_t, int);
@@ -122,7 +124,7 @@
        KASSERT(ohare != NULL);
        pic = &ohare->pic;
 
-       pic->pic_numintrs = 32;
+       pic->pic_numintrs = NIRQ;
        pic->pic_cookie = (void *)addr;
        pic->pic_enable_irq = ohare_enable_irq;
        pic->pic_reenable_irq = ohare_reenable_irq;
@@ -141,9 +143,9 @@
                strcpy(pic->pic_name, "ohare");
                ohare->level_mask = 0;
        }
-       for (i = 0; i < 32; i++)
+       for (i = 0; i < NIRQ; i++)
                ohare->priority_masks[i] = 0;
-       for (i = 0; i < 16; i++)
+       for (i = 0; i < NIPL; i++)
                ohare->irqs[i] = 0;
        pic_add(pic);
        ohare->pending_events = 0;
@@ -289,7 +291,7 @@
        int realpri = min(NIPL, max(0, pri)), i;
        uint32_t level = 1 << realpri;
 
-       KASSERT((irq >= 0) && (irq < 32));
+       KASSERT((irq >= 0) && (irq < NIRQ));
 
        if (type == IST_LEVEL) {
 
@@ -303,7 +305,7 @@
        for (i = 0; i < NIPL; i++)
                ohare->irqs[i] = 0;
                
-       for (i = 0; i < 32; i++) {
+       for (i = 0; i < NIRQ; i++) {
                if (ohare->priority_masks[i] == 0)
                        continue;
                level = 31 - cntlzw(ohare->priority_masks[i]);

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index