patch-1.3.71 linux/arch/sparc/kernel/irq.c

Next file: linux/arch/sparc/kernel/ksyms.c
Previous file: linux/arch/sparc/kernel/ioport.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.70/linux/arch/sparc/kernel/irq.c linux/arch/sparc/kernel/irq.c
@@ -1,4 +1,4 @@
-/*  $Id: irq.c,v 1.29 1995/11/25 00:58:08 davem Exp $
+/*  $Id: irq.c,v 1.34 1996/02/20 07:45:04 davem Exp $
  *  arch/sparc/kernel/irq.c:  Interrupt request handling routines. On the
  *                            Sparc the IRQ's are basically 'cast in stone'
  *                            and you are supposed to probe the prom's device
@@ -34,8 +34,7 @@
 unsigned char *interrupt_enable = 0;
 struct sun4m_intregs *sun4m_interrupts;
 
-void
-sun4c_disable_irq(unsigned int irq_nr)
+void sun4c_disable_irq(unsigned int irq_nr)
 {
 	unsigned long flags;
 	unsigned char current_mask, new_mask;
@@ -60,21 +59,20 @@
 	default:
 		restore_flags(flags);
 		return;
-	};
-  
+	}
 	*interrupt_enable = new_mask;
 	restore_flags(flags);
 }
 
-void
-sun4m_disable_irq(unsigned int irq_nr)
+void sun4m_disable_irq(unsigned int irq_nr)
 {
+#if 0
 	printk("IRQ routines not yet written for the sun4m\n");
 	panic("disable_irq: Unsupported arch.");
+#endif
 }
 
-void
-disable_irq(unsigned int irq_nr)
+void disable_irq(unsigned int irq_nr)
 {
 	switch(sparc_cpu_model) {
 	case sun4c:
@@ -82,13 +80,13 @@
 		break;
 	case sun4m:
 		sun4m_disable_irq(irq_nr);
+		break;
 	default:
 		panic("disable_irq: Unsupported arch.");
 	}
 }
 
-void
-sun4c_enable_irq(unsigned int irq_nr)
+void sun4c_enable_irq(unsigned int irq_nr)
 {
 	unsigned long flags;
 	unsigned char current_mask, new_mask;
@@ -113,21 +111,20 @@
 	default:
 		restore_flags(flags);
 		return;
-	};
-
+	}
 	*interrupt_enable = new_mask;
 	restore_flags(flags);
 }
 
-void
-sun4m_enable_irq(unsigned int irq_nr)
+void sun4m_enable_irq(unsigned int irq_nr)
 {
+#if 0
 	printk("IRQ routines not written for the sun4m yet.\n");
 	panic("IRQ unsupported arch.");
+#endif
 }
 
-void
-enable_irq(unsigned int irq_nr)
+void enable_irq(unsigned int irq_nr)
 {
 	switch(sparc_cpu_model) {
 	case sun4c:
@@ -144,17 +141,30 @@
 /*
  * Initial irq handlers.
  */
-static struct irqaction timer_irq = { NULL, 0, 0, NULL, NULL, NULL};
-static struct irqaction cascade_irq = { NULL, 0, 0, NULL, NULL, NULL};
-static struct irqaction math_irq = { NULL, 0, 0, NULL, NULL, NULL};
+extern void timer_interrupt(int, void *, struct pt_regs *);
+extern void rs_interrupt(int, void *, struct pt_regs *);
+
+static struct irqaction timer_irq = {
+	timer_interrupt,
+	SA_INTERRUPT,
+	0, "timer",
+	NULL, NULL
+};
+
+static struct irqaction serial_irq = {
+	rs_interrupt,
+	SA_INTERRUPT,
+	0, "zilog serial",
+	NULL, NULL
+};
 
 static struct irqaction *irq_action[16] = {
 	  NULL, NULL, NULL, NULL, NULL, NULL , NULL, NULL,
-	  NULL, NULL, NULL, NULL, NULL, NULL , NULL, NULL
+	  NULL, NULL, &timer_irq, NULL, &serial_irq, NULL , NULL, NULL
 };
 
-int
-get_irq_list(char *buf)
+
+int get_irq_list(char *buf)
 {
 	int i, len = 0;
 	struct irqaction * action;
@@ -177,8 +187,7 @@
 	return len;
 }
 
-void
-free_irq(unsigned int irq, void *dev_id)
+void free_irq(unsigned int irq, void *dev_id)
 {
 	struct irqaction * action = *(irq + irq_action);
 	struct irqaction * tmp = NULL;
@@ -193,35 +202,33 @@
 		return;
 	}
 	if (dev_id) {
-	    for (; action; action = action->next) {
-	        if (action->dev_id == dev_id) break;
-		tmp = action;
-	    }
-	    if (!action) {
-		printk("Trying to free free shared IRQ%d\n",irq);
-		return;
-	    }
+		for (; action; action = action->next) {
+			if (action->dev_id == dev_id) break;
+			tmp = action;
+		}
+		if (!action) {
+			printk("Trying to free free shared IRQ%d\n",irq);
+			return;
+		}
 	} else if (action->flags & SA_SHIRQ) {
-	    printk("Trying to free shared IRQ%d with NULL device ID\n", irq);
-	    return;
+		printk("Trying to free shared IRQ%d with NULL device ID\n", irq);
+		return;
 	}
         save_flags(flags); cli();
-	if (action && tmp) {
-	    tmp->next = action->next;
-	} else {
-	    *(irq + irq_action) = action->next;
-	}
+	if (action && tmp)
+		tmp->next = action->next;
+	else
+		*(irq + irq_action) = action->next;
+
 	kfree_s(action, sizeof(struct irqaction));
 
-	if (!(*(irq + irq_action))) {
-	    disable_irq(irq);
-	}
+	if (!(*(irq + irq_action)))
+		disable_irq(irq);
 
         restore_flags(flags);
 }
 
-void
-unexpected_irq(int irq, struct pt_regs * regs)
+void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs)
 {
         int i;
 	struct irqaction * action = *(irq + irq_action);
@@ -233,23 +240,22 @@
         for (i = 0; i < 16; i++)
                 if (action->handler)
                         prom_printf("[%s:%d:0x%x] ", action->name, (int) i,
-			       (unsigned int) action->handler);
+				    (unsigned int) action->handler);
         printk("AIEEE\n");
 	panic("bogus interrupt received");
 }
 
-void
-handler_irq(int irq, struct pt_regs * regs)
+void handler_irq(int irq, struct pt_regs * regs)
 {
 	struct irqaction * action = *(irq + irq_action);
 
 	kstat.interrupts[irq]++;
 	while (action) {
-	    if (!action->handler)
-	        unexpected_irq(irq, action->dev_id, regs);
-	    else
-		action->handler(irq, action->dev_id, regs);
-	    action = action->next;
+		if (!action->handler)
+			unexpected_irq(irq, action->dev_id, regs);
+		else
+			action->handler(irq, action->dev_id, regs);
+		action = action->next;
 	}
 }
 
@@ -260,17 +266,15 @@
  * IRQ's should use this format: notably the keyboard/timer
  * routines.
  */
-asmlinkage void
-do_IRQ(int irq, struct pt_regs * regs)
+asmlinkage void do_IRQ(int irq, struct pt_regs * regs)
 {
 	struct irqaction * action = *(irq + irq_action);
 
 	kstat.interrupts[irq]++;
 	while (action) {
-	    action->handler(irq, action->dev_id, regs);
-	    action = action->next;
+		action->handler(irq, action->dev_id, regs);
+		action = action->next;
 	}
-	return;
 }
 
 /*
@@ -278,37 +282,35 @@
  * stuff - the handler is also running with interrupts disabled unless
  * it explicitly enables them later.
  */
-asmlinkage void
-do_fast_IRQ(int irq)
+asmlinkage void do_fast_IRQ(int irq)
 {
 	kstat.interrupts[irq]++;
 	printk("Got FAST_IRQ number %04lx\n", (long unsigned int) irq);
 	return;
 }
 
-int
-request_fast_irq(unsigned int irq, void (*handler)(int, struct pt_regs *),
-		 unsigned long irqflags, const char *devname, void *dev_id)
-)
+/* Fast IRQ's on the Sparc can only have one routine attached to them,
+ * thus no sharing possible.
+ */
+int request_fast_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+		     unsigned long irqflags, const char *devname)
 {
-	struct irqaction * action, *tmp = NULL;
+	struct irqaction *action;
 	unsigned long flags;
 
 	if(irq > 14)
 		return -EINVAL;
-	if (!handler)
-	    return -EINVAL;
+	if(!handler)
+		return -EINVAL;
 	action = *(irq + irq_action);
-	if (action) {
-	    if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) {
-		for (tmp = action; tmp->next; tmp = tmp->next);
-	    } else {
+	if(action) {
+		if(action->flags & SA_SHIRQ)
+			panic("Trying to register fast irq when already shared.\n");
+		if(irqflags & SA_SHIRQ)
+			panic("Trying to register fast irq as shared.\n");
+
+		/* Anyway, someone already owns it so cannot be made fast. */
 		return -EBUSY;
-	    }
-	    if ((action->flags & SA_INTERRUPT) ^ (irqflags & SA_INTERRUPT)) {
-	      printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
-	      return -EBUSY;
-	    }   
 	}
 
 	save_flags(flags); cli();
@@ -316,8 +318,8 @@
 	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
 
 	if (!action) { 
-	    restore_flags(flags);
-	    return -ENOMEM;
+		restore_flags(flags);
+		return -ENOMEM;
 	}
 
 	/* Dork with trap table if we get this far. */
@@ -332,23 +334,16 @@
 	action->flags = irqflags;
 	action->mask = 0;
 	action->name = devname;
-	action->dev_id = dev_id;
+	action->dev_id = NULL;
 
-	if (tmp) {
-	    tmp->next = action;
-	} else {
-	    *(irq + irq_action) = action;
-	}
+	*(irq + irq_action) = action;
 
 	restore_flags(flags);
 	return 0;
 }
 
-extern void probe_clock(void);
-		
-int
-request_irq(unsigned int irq, void (*handler)(int, struct pt_regs *),
-	    unsigned long irqflags, const char * devname, void *dev_id)
+int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+		unsigned long irqflags, const char * devname, void *dev_id)
 {
 	struct irqaction * action, *tmp = NULL;
 	unsigned long flags;
@@ -360,22 +355,23 @@
 	    return -EINVAL;
 	action = *(irq + irq_action);
 	if (action) {
-	    if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) {
-		for (tmp = action; tmp->next; tmp = tmp->next);
-	    } else {
-		return -EBUSY;
-	    }
-	    if ((action->flags & SA_INTERRUPT) ^ (irqflags & SA_INTERRUPT)) {
-	      printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
-	      return -EBUSY;
-	    }   
+		if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) {
+			for (tmp = action; tmp->next; tmp = tmp->next);
+		} else {
+			return -EBUSY;
+		}
+		if ((action->flags & SA_INTERRUPT) ^ (irqflags & SA_INTERRUPT)) {
+			printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
+			return -EBUSY;
+		}   
 	}
+
 	save_flags(flags); cli();
 	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
 
 	if (!action) { 
-	    restore_flags(flags);
-	    return -ENOMEM;
+		restore_flags(flags);
+		return -ENOMEM;
 	}
 
 	action->handler = handler;
@@ -385,14 +381,12 @@
 	action->next = NULL;
 	action->dev_id = dev_id;
 
-	if (tmp) {
-	    tmp->next = action;
-	} else {
-	    *(irq + irq_action) = action;
-	}
+	if (tmp)
+		tmp->next = action;
+	else
+		*(irq + irq_action) = action;
+
 	enable_irq(irq);
-	if(irq == 10)
-		probe_clock();
 	restore_flags(flags);
 	return 0;
 }
@@ -410,8 +404,7 @@
   return 0;
 }
 
-void
-sun4c_init_IRQ(void)
+void sun4c_init_IRQ(void)
 {
 	struct linux_prom_registers int_regs[2];
 	int ie_node;
@@ -422,19 +415,15 @@
 		panic("Cannot find /interrupt-enable node");
 	/* Depending on the "address" property is bad news... */
 	prom_getproperty(ie_node, "reg", (char *) int_regs, sizeof(int_regs));
-	sparc_alloc_io(int_regs[0].phys_addr, (void *) INTREG_VADDR,
-		       int_regs[0].reg_size, "sun4c_interrupts",
-		       int_regs[0].which_io, 0x0);
-
-	interrupt_enable = (char *) INTREG_VADDR;
-
-	/* Default value, accept interrupts, but no one is actually active */
+	interrupt_enable = (char *) sparc_alloc_io(int_regs[0].phys_addr, 0,
+						   int_regs[0].reg_size,
+						   "sun4c_interrupts",
+						   int_regs[0].which_io, 0x0);
 	*interrupt_enable = (SUN4C_INT_ENABLE);
-	sti(); /* Turn irq's on full-blast. */
+	sti();
 }
 
-void
-sun4m_init_IRQ(void)
+void sun4m_init_IRQ(void)
 {
 	int ie_node;
 
@@ -442,7 +431,6 @@
 	int num_regs;
 
 	cli();
-
 	if((ie_node = prom_searchsiblings(prom_getchild(prom_root_node), "obio")) == 0 ||
 	   (ie_node = prom_getchild (ie_node)) == 0 ||
 	   (ie_node = prom_searchsiblings (ie_node, "interrupt")) == 0)
@@ -455,22 +443,18 @@
 	prom_apply_obio_ranges(int_regs, num_regs);
 
 	/* Map the interrupt registers for all possible cpus. */
-	sparc_alloc_io(int_regs[0].phys_addr, (void *) INTREG_VADDR,
-		       PAGE_SIZE*NCPUS, "interrupts_percpu",
-		       int_regs[0].which_io, 0x0);
+	sun4m_interrupts = sparc_alloc_io(int_regs[0].phys_addr, 0,
+					  PAGE_SIZE*NCPUS, "interrupts_percpu",
+					  int_regs[0].which_io, 0x0);
 
 	/* Map the system interrupt control registers. */
-	sparc_alloc_io(int_regs[num_regs-1].phys_addr,
-		       (void *) INTREG_VADDR+(NCPUS*PAGE_SIZE),
+	sparc_alloc_io(int_regs[num_regs-1].phys_addr, 0,
 		       int_regs[num_regs-1].reg_size, "interrupts_system",
 		       int_regs[num_regs-1].which_io, 0x0);
-
-	sun4m_interrupts = (struct sun4m_intregs *) INTREG_VADDR;
 	sti();
 }
 
-void
-init_IRQ(void)
+void init_IRQ(void)
 {
 	switch(sparc_cpu_model) {
 	case sun4c:
@@ -480,7 +464,7 @@
 		sun4m_init_IRQ();
 		break;
 	default:
-		panic("Cannot initialize IRQ's on this Sun machine...");
+		prom_printf("Cannot initialize IRQ's on this Sun machine...");
 		break;
-	};
+	}
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this