svn commit: r199496 - in projects/mips/sys/mips: include mips
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Wed Nov 18 22:52:06 UTC 2009
Author: gonzo
Date: Wed Nov 18 22:52:05 2009
New Revision: 199496
URL: http://svn.freebsd.org/changeset/base/199496
Log:
- Add cpu_init_interrupts function that is supposed to
prepeare stuff required for spinning out interrupts later
- Add API for managing intrcnt/intrnames arrays
- Some minor style(9) fixes
Modified:
projects/mips/sys/mips/include/intr_machdep.h
projects/mips/sys/mips/mips/exception.S
projects/mips/sys/mips/mips/genassym.c
projects/mips/sys/mips/mips/intr_machdep.c
projects/mips/sys/mips/mips/machdep.c
Modified: projects/mips/sys/mips/include/intr_machdep.h
==============================================================================
--- projects/mips/sys/mips/include/intr_machdep.h Wed Nov 18 22:31:10 2009 (r199495)
+++ projects/mips/sys/mips/include/intr_machdep.h Wed Nov 18 22:52:05 2009 (r199496)
@@ -52,11 +52,25 @@ extern struct mips_intrhand mips_intr_ha
struct trapframe;
+void cpu_init_interrupts(void);
void cpu_establish_hardintr(const char *, driver_filter_t *, driver_intr_t *,
void *, int, int, void **);
void cpu_establish_softintr(const char *, driver_filter_t *, void (*)(void*),
void *, int, int, void **);
void cpu_intr(struct trapframe *);
+/*
+ * Opaque datatype that represents intr counter
+ */
+typedef unsigned long* mips_intrcnt_t;
+mips_intrcnt_t mips_intrcnt_create(const char *);
+void mips_intrcnt_setname(mips_intrcnt_t, const char *);
+
+static __inline void
+mips_intrcnt_inc(mips_intrcnt_t counter)
+{
+ if (counter)
+ atomic_add_long(counter, 1);
+}
#endif /* !_MACHINE_INTR_MACHDEP_H_ */
Modified: projects/mips/sys/mips/mips/exception.S
==============================================================================
--- projects/mips/sys/mips/mips/exception.S Wed Nov 18 22:31:10 2009 (r199495)
+++ projects/mips/sys/mips/mips/exception.S Wed Nov 18 22:52:05 2009 (r199496)
@@ -97,6 +97,11 @@
#endif
/*
+ * Reasonable limit
+ */
+#define INTRCNT_COUNT 128
+
+/*
* Assume that w alaways need nops to escape CP0 hazard
* TODO: Make hazard delays configurable. Stuck with 5 cycles on the moment
* For more info on CP0 hazards see Chapter 7 (p.99) of "MIPS32 Architecture
@@ -1273,15 +1278,11 @@ END(MipsFPTrap)
.globl intrnames
.globl eintrnames
intrnames:
- .asciiz "clock"
- .asciiz "rtc"
- .asciiz "sio"
- .asciiz "pe"
- .asciiz "pic-nic"
+ .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
eintrnames:
- .align 2
+ .align 4
intrcnt:
- .word 0,0,0,0,0
+ .space INTRCNT_COUNT * 4 * 2
eintrcnt:
Modified: projects/mips/sys/mips/mips/genassym.c
==============================================================================
--- projects/mips/sys/mips/mips/genassym.c Wed Nov 18 22:31:10 2009 (r199495)
+++ projects/mips/sys/mips/mips/genassym.c Wed Nov 18 22:52:05 2009 (r199496)
@@ -99,3 +99,4 @@ ASSYM(NPTEPG, NPTEPG);
ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
ASSYM(TDF_ASTPENDING, TDF_ASTPENDING);
ASSYM(PCPU_SIZE, sizeof(struct pcpu));
+ASSYM(MAXCOMLEN, MAXCOMLEN);
Modified: projects/mips/sys/mips/mips/intr_machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/intr_machdep.c Wed Nov 18 22:31:10 2009 (r199495)
+++ projects/mips/sys/mips/mips/intr_machdep.c Wed Nov 18 22:52:05 2009 (r199496)
@@ -46,12 +46,29 @@ __FBSDID("$FreeBSD$");
static struct intr_event *hardintr_events[NHARD_IRQS];
static struct intr_event *softintr_events[NSOFT_IRQS];
+static mips_intrcnt_t mips_intr_counters[NSOFT_IRQS + NHARD_IRQS];
-#ifdef notyet
-static int intrcnt_tab[NHARD_IRQS + NSOFT_IRQS];
-static int intrcnt_index = 0;
-static int last_printed = 0;
-#endif
+static int intrcnt_index;
+
+mips_intrcnt_t
+mips_intrcnt_create(const char* name)
+{
+ mips_intrcnt_t counter = &intrcnt[intrcnt_index++];
+
+ mips_intrcnt_setname(counter, name);
+ return counter;
+}
+
+void
+mips_intrcnt_setname(mips_intrcnt_t counter, const char *name)
+{
+ int idx = counter - intrcnt;
+
+ KASSERT(counter != NULL, ("mips_intrcnt_setname: NULL counter"));
+
+ snprintf(intrnames + (MAXCOMLEN + 1) * idx,
+ MAXCOMLEN + 1, "%-*s", MAXCOMLEN, name);
+}
static void
mips_mask_hard_irq(void *source)
@@ -85,6 +102,30 @@ mips_unmask_soft_irq(void *source)
mips_wr_status(mips_rd_status() | ((1 << irq) << 8));
}
+/*
+ * Perform initialization of interrupts prior to setting
+ * handlings
+ */
+void
+cpu_init_interrupts()
+{
+ int i;
+ char name[MAXCOMLEN + 1];
+
+ /*
+ * Initialize all available vectors so spare IRQ
+ * would show up in systat output
+ */
+ for (i = 0; i < NSOFT_IRQS; i++) {
+ snprintf(name, MAXCOMLEN + 1, "sint%d:", i);
+ mips_intr_counters[i] = mips_intrcnt_create(name);
+ }
+
+ for (i = 0; i < NHARD_IRQS; i++) {
+ snprintf(name, MAXCOMLEN + 1, "int%d:", i);
+ mips_intr_counters[NSOFT_IRQS + i] = mips_intrcnt_create(name);
+ }
+}
void
cpu_establish_hardintr(const char *name, driver_filter_t *filt,
@@ -107,23 +148,17 @@ cpu_establish_hardintr(const char *name,
if (event == NULL) {
error = intr_event_create(&event, (void *)(uintptr_t)irq, 0,
irq, mips_mask_hard_irq, mips_unmask_hard_irq,
- NULL, NULL, "hard intr%d:", irq);
+ NULL, NULL, "int%d", irq);
if (error)
return;
hardintr_events[irq] = event;
-#ifdef notyet
- last_printed += snprintf(intrnames + last_printed,
- MAXCOMLEN + 1, "hard irq%d: %s", irq, name);
- last_printed++;
- intrcnt_tab[irq] = intrcnt_index;
- intrcnt_index++;
-#endif
-
}
intr_event_add_handler(event, name, filt, handler, arg,
intr_priority(flags), flags, cookiep);
+ mips_intrcnt_setname(mips_intr_counters[NSOFT_IRQS + irq], event->ie_fullname);
+
mips_unmask_hard_irq((void*)(uintptr_t)irq);
}
@@ -146,7 +181,7 @@ cpu_establish_softintr(const char *name,
if (event == NULL) {
error = intr_event_create(&event, (void *)(uintptr_t)irq, 0,
irq, mips_mask_soft_irq, mips_unmask_soft_irq,
- NULL, NULL, "intr%d:", irq);
+ NULL, NULL, "sint%d:", irq);
if (error)
return;
softintr_events[irq] = event;
@@ -155,6 +190,8 @@ cpu_establish_softintr(const char *name,
intr_event_add_handler(event, name, filt, handler, arg,
intr_priority(flags), flags, cookiep);
+ mips_intrcnt_setname(mips_intr_counters[irq], event->ie_fullname);
+
mips_unmask_soft_irq((void*)(uintptr_t)irq);
}
@@ -184,6 +221,7 @@ cpu_intr(struct trapframe *tf)
i--; /* Get a 0-offset interrupt. */
hard = 0;
event = softintr_events[i];
+ mips_intrcnt_inc(mips_intr_counters[i]);
break;
default:
/* Hardware interrupt. */
@@ -191,6 +229,7 @@ cpu_intr(struct trapframe *tf)
i--; /* Get a 0-offset interrupt. */
hard = 1;
event = hardintr_events[i];
+ mips_intrcnt_inc(mips_intr_counters[NSOFT_IRQS + i]);
break;
}
Modified: projects/mips/sys/mips/mips/machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/machdep.c Wed Nov 18 22:31:10 2009 (r199495)
+++ projects/mips/sys/mips/mips/machdep.c Wed Nov 18 22:52:05 2009 (r199496)
@@ -75,16 +75,17 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/user.h>
+#include <sys/interrupt.h>
#include <sys/cons.h>
#include <sys/syslog.h>
-#include <machine/cache.h>
-#include <machine/cpu.h>
-#include <net/netisr.h>
-#include <machine/md_var.h>
-#include <machine/clock.h>
#include <machine/asm.h>
#include <machine/bootinfo.h>
+#include <machine/cache.h>
+#include <machine/clock.h>
+#include <machine/cpu.h>
#include <machine/hwfunc.h>
+#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
#ifdef DDB
#include <sys/kdb.h>
#include <ddb/ddb.h>
@@ -186,6 +187,7 @@ cpu_startup(void *dummy)
printf("avail memory = %lu (%luMB)\n", ptoa(cnt.v_free_count),
ptoa(cnt.v_free_count) / 1048576);
+ cpu_init_interrupts();
/*
* Set up buffers, so they can be used to read disk labels.
More information about the svn-src-projects
mailing list