- 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
This commit is contained in:
parent
b39188331e
commit
51d85c463d
@ -52,11 +52,25 @@ extern struct mips_intrhand mips_intr_handlers[];
|
||||
|
||||
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_ */
|
||||
|
@ -96,6 +96,11 @@
|
||||
.set mips3
|
||||
#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
|
||||
@ -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:
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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, driver_filter_t *filt,
|
||||
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, driver_filter_t *filt,
|
||||
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, driver_filter_t *filt,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user