svn commit: r277021 - in projects/arm_intrng/sys: arm/arm arm/include dev/fdt powerpc/powerpc

Andrew Turner andrew at FreeBSD.org
Sun Jan 11 20:16:17 UTC 2015


Author: andrew
Date: Sun Jan 11 20:16:14 2015
New Revision: 277021
URL: https://svnweb.freebsd.org/changeset/base/277021

Log:
  Rework describing interrupts to not use a static buffer and to build on
  PowerPC with at least the MPC85XX kernel.
  
  I don't like the name of fdt_describe_irq, it could be called from non-FDT
  code. As it's only called from simplebus I'll stick with it for now.

Modified:
  projects/arm_intrng/sys/arm/arm/intr.c
  projects/arm_intrng/sys/arm/arm/intrng.c
  projects/arm_intrng/sys/arm/include/fdt.h
  projects/arm_intrng/sys/arm/include/intr.h
  projects/arm_intrng/sys/dev/fdt/fdt_common.h
  projects/arm_intrng/sys/dev/fdt/simplebus.c
  projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c

Modified: projects/arm_intrng/sys/arm/arm/intr.c
==============================================================================
--- projects/arm_intrng/sys/arm/arm/intr.c	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/arm/arm/intr.c	Sun Jan 11 20:16:14 2015	(r277021)
@@ -126,16 +126,16 @@ arm_fdt_map_irq(phandle_t iparent, pcell
 
 	return (interrupt);
 }
-#endif
 
-const char *
-arm_describe_irq(int irq)
+int
+fdt_describe_irq(char *buf, u_int len, u_int irq)
 {
-	static char buffer[8];
+	int rv;
 
-	sprintf(buffer, "%d", irq);
-	return (buffer);
+	rv = snprintf(buf, len, "%u", irq);
+	return (rv);
 }
+#endif
 
 void
 arm_setup_irqhandler(const char *name, driver_filter_t *filt,

Modified: projects/arm_intrng/sys/arm/arm/intrng.c
==============================================================================
--- projects/arm_intrng/sys/arm/arm/intrng.c	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/arm/arm/intrng.c	Sun Jan 11 20:16:14 2015	(r277021)
@@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$");
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
+#include <dev/fdt/fdt_common.h>
+
 #include "pic_if.h"
 
 #define	INTRNAME_LEN	(MAXCOMLEN + 1)
@@ -265,7 +267,7 @@ resirq_encode(u_int picidx, u_int irqidx
 }
 
 static u_int
-resirq_decode(int resirq, struct arm_intr_controller **pic, 
+resirq_decode(u_int resirq, struct arm_intr_controller **pic, 
    struct arm_intr_handler **pih)
 {
 	struct arm_intr_controller *ic;
@@ -353,15 +355,12 @@ arm_fdt_map_irq(phandle_t icnode, pcell_
 	return (ih->ih_resirq);
 }
 
-const char *
-arm_describe_irq(int resirq)
+int
+fdt_describe_irq(char *buf, u_int len, u_int resirq)
 {
 	struct arm_intr_controller *ic;
 	struct arm_intr_handler *ih;
-	int irqidx;
-	static char buffer[INTRNAME_LEN];
-
-	/* XXX static buffer, can this be called after APs released? */
+	int irqidx, rv;
 
 	irqidx = resirq_decode(resirq, &ic, &ih);
 	KASSERT(ic != NULL, ("%s: bad resirq 0x%08x", resirq));
@@ -371,13 +370,13 @@ arm_describe_irq(int resirq)
 		 * IC device name nor interrupt number. All we can do is to
 		 * use its index (fdt names are unbounded length).
 		 */
-		snprintf(buffer, sizeof(buffer), "ic%d.%d", ic->ic_idx, irqidx);
+		rv = snprintf(buf, len, "ic%d.%d", ic->ic_idx, irqidx);
 	} else {
 		KASSERT(ih != NULL, ("%s: no handler for resirq 0x%08x\n", resirq));
-		snprintf(buffer, sizeof(buffer), "%s.%d", 
+		rv = snprintf(buf, len, "%s.%d",
 		    device_get_nameunit(ih->ih_ic->ic_dev), ih->ih_hwirq);
 	}
-	return (buffer);
+	return (rv);
 }
 
 void
@@ -416,7 +415,7 @@ arm_register_pic(device_t dev, int flags
 	}
 
 	/*
-	 * arm_describe_irq() has to print fake names earlier when the device
+	 * fdt_describe_irq() has to print fake names earlier when the device
 	 * issn't registered yet, emit a string that has the same fake name in
 	 * it, so that earlier output links to this device.
 	 */

Modified: projects/arm_intrng/sys/arm/include/fdt.h
==============================================================================
--- projects/arm_intrng/sys/arm/include/fdt.h	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/arm/include/fdt.h	Sun Jan 11 20:16:14 2015	(r277021)
@@ -47,7 +47,6 @@
 
 /* Map phandle/intpin pair to global IRQ number */ 
 #define	FDT_MAP_IRQ(node, pin)	(arm_fdt_map_irq(node, pin))
-#define	FDT_DESCRIBE_IRQ(irq)	(arm_describe_irq(irq))
 
 #else
 
@@ -56,7 +55,6 @@
 
 /* Map phandle/intpin pair to global IRQ number */
 #define	FDT_MAP_IRQ(node, pin)	(pin)
-#define	FDT_DESCRIBE_IRQ(irq)	(arm_describe_irq(irq))
 
 #endif	/* ARM_INTRNG */
 

Modified: projects/arm_intrng/sys/arm/include/intr.h
==============================================================================
--- projects/arm_intrng/sys/arm/include/intr.h	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/arm/include/intr.h	Sun Jan 11 20:16:14 2015	(r277021)
@@ -115,7 +115,6 @@ extern int (*arm_config_irq)(int irq, en
 
 #endif /* !ARM_INTRNG */
 
-const char *arm_describe_irq(int irq);
 void arm_intrnames_init(void);
 void arm_irq_memory_barrier(uintptr_t);
 

Modified: projects/arm_intrng/sys/dev/fdt/fdt_common.h
==============================================================================
--- projects/arm_intrng/sys/dev/fdt/fdt_common.h	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/dev/fdt/fdt_common.h	Sun Jan 11 20:16:14 2015	(r277021)
@@ -79,6 +79,7 @@ extern u_char fdt_static_dtb;
 int fdt_addrsize_cells(phandle_t, int *, int *);
 u_long fdt_data_get(void *, int);
 int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
+int fdt_describe_irq(char *, u_int, u_int);
 phandle_t fdt_find_compatible(phandle_t, const char *, int);
 phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
 int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);

Modified: projects/arm_intrng/sys/dev/fdt/simplebus.c
==============================================================================
--- projects/arm_intrng/sys/dev/fdt/simplebus.c	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/dev/fdt/simplebus.c	Sun Jan 11 20:16:14 2015	(r277021)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
-#include <machine/fdt.h>
+#include <dev/fdt/fdt_common.h>
 
 struct simplebus_range {
 	uint64_t bus;
@@ -408,7 +408,8 @@ static int
 simplebus_print_irqs(struct resource_list *rl)
 {
 	struct resource_list_entry *rle;
-	int printed, retval;
+	int err, printed, retval;
+	char buf[16];
 
 	printed = 0;
 	retval = 0;
@@ -417,8 +418,11 @@ simplebus_print_irqs(struct resource_lis
 		if (rle->type != SYS_RES_IRQ)
 			continue;
 
-		retval += printf("%s", printed ? "," : " irq ");
-		retval += printf("%s", FDT_DESCRIBE_IRQ(rle->start));
+		err = fdt_describe_irq(buf, sizeof(buf), rle->start);
+		if (err < 0)
+			snprintf(buf, sizeof(buf), "???");
+
+		retval += printf("%s%s", printed ? "," : " irq ", buf);
 		printed++;
 	}
 

Modified: projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c
==============================================================================
--- projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c	Sun Jan 11 20:07:07 2015	(r277020)
+++ projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c	Sun Jan 11 20:16:14 2015	(r277021)
@@ -61,6 +61,7 @@
  */
 
 #include "opt_isa.h"
+#include "opt_platform.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,6 +86,10 @@
 #include <machine/smp.h>
 #include <machine/trap.h>
 
+#ifdef FDT
+#include <dev/fdt/fdt_common.h>
+#endif
+
 #include "pic_if.h"
 
 #define	MAX_STRAY_LOG	5
@@ -604,3 +609,12 @@ stray:
 	if (i != NULL)
 		PIC_MASK(i->pic, i->intline);
 }
+
+#ifdef FDT
+int
+fdt_describe_irq(char *buf, u_int len, u_int irq)
+{
+
+	return (snprintf(buf, len, "%u", irq));
+}
+#endif


More information about the svn-src-projects mailing list