Module Name: src Committed By: thorpej Date: Mon Jan 15 18:47:03 UTC 2024
Modified Files: src/sys/arch/m68k/include: intr.h src/sys/arch/m68k/m68k: m68k_intr.c src/sys/arch/sun3/sun3: clock.c src/sys/arch/sun3/sun3x: clock.c Log Message: Provide a m68k_count_intr() macro that hides the details of how interrupts are counted, and also ensures that ci_data.cpu_nintr is incremented. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/m68k/include/intr.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/m68k/m68k_intr.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/sun3/sun3/clock.c cvs rdiff -u -r1.43 -r1.44 src/sys/arch/sun3/sun3x/clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/m68k/include/intr.h diff -u src/sys/arch/m68k/include/intr.h:1.3 src/sys/arch/m68k/include/intr.h:1.4 --- src/sys/arch/m68k/include/intr.h:1.3 Mon Jan 15 17:12:00 2024 +++ src/sys/arch/m68k/include/intr.h Mon Jan 15 18:47:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.3 2024/01/15 17:12:00 thorpej Exp $ */ +/* $NetBSD: intr.h,v 1.4 2024/01/15 18:47:03 thorpej Exp $ */ /*- * Copyright (c) 2023, 2024 The NetBSD Foundation, Inc. @@ -134,13 +134,27 @@ struct m68k_ih_allocfuncs; #include <sys/evcnt.h> -#ifndef __HAVE_LEGACY_INTRCNT +#ifdef __HAVE_LEGACY_INTRCNT +#define m68k_count_intr(x) \ +do { \ + extern u_int intrcnt[]; \ + intrcnt[(x)]++; \ + curcpu()->ci_data.cpu_nintr++; \ +} while (/*CONSTCOND*/0) +#else /* * This is exposed here so that platform-specific interrupt handlers * can access it. */ extern struct evcnt m68k_intr_evcnt[]; -#endif + +#define m68k_count_intr(x) \ +do { \ + /* 32-bit counter should be sufficient for m68k. */ \ + m68k_intr_evcnt[(x)].ev_count32++; \ + curcpu()->ci_data.cpu_nintr++; \ +} while (/*CONSTCOND*/0) +#endif /* __HAVE_LEGACY_INTRCNT */ /* * Common m68k interrupt dispatch: Index: src/sys/arch/m68k/m68k/m68k_intr.c diff -u src/sys/arch/m68k/m68k/m68k_intr.c:1.5 src/sys/arch/m68k/m68k/m68k_intr.c:1.6 --- src/sys/arch/m68k/m68k/m68k_intr.c:1.5 Mon Jan 15 17:12:00 2024 +++ src/sys/arch/m68k/m68k/m68k_intr.c Mon Jan 15 18:47:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: m68k_intr.c,v 1.5 2024/01/15 17:12:00 thorpej Exp $ */ +/* $NetBSD: m68k_intr.c,v 1.6 2024/01/15 18:47:03 thorpej Exp $ */ /*- * Copyright (c) 1996, 2023, 2024 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: m68k_intr.c,v 1.5 2024/01/15 17:12:00 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: m68k_intr.c,v 1.6 2024/01/15 18:47:03 thorpej Exp $"); #define _M68K_INTR_PRIVATE @@ -77,10 +77,7 @@ static struct m68k_intrhand_list m68k_in static struct m68k_intrhand *m68k_intrhands_vectored[NVECHANDS]; #endif -#ifdef __HAVE_LEGACY_INTRCNT -extern u_int intrcnt[]; -#define INTRCNT(x) intrcnt[(x)]++ -#else +#ifndef __HAVE_LEGACY_INTRCNT #ifndef MACHINE_INTREVCNT_NAMES #define MACHINE_INTREVCNT_NAMES \ { "spur", "lev1", "lev2", "lev3", "lev4", "lev5", "lev6", "nmi" } @@ -100,8 +97,6 @@ struct evcnt m68k_intr_evcnt[] = { __CTASSERT(__arraycount(m68k_intr_evcnt) == NAUTOVECTORS); #undef INTRCNT_INIT - -#define INTRCNT(x) m68k_intr_evcnt[(x)].ev_count++ #endif /* __HAVE_LEGACY_INTRCNT */ const uint16_t ipl2psl_table[NIPL] = { @@ -364,8 +359,7 @@ m68k_intr_autovec(struct clockframe fram idepth++; - INTRCNT(ipl); - curcpu()->ci_data.cpu_nintr++; + m68k_count_intr(ipl); LIST_FOREACH(ih, &m68k_intrhands_autovec[ipl], ih_link) { void *arg = ih->ih_arg ? ih->ih_arg : &frame; @@ -400,8 +394,7 @@ m68k_intr_vectored(struct clockframe fra idepth++; - INTRCNT(ipl); - curcpu()->ci_data.cpu_nintr++; + m68k_count_intr(ipl); #ifdef DIAGNOSTIC if (vec < MACHINE_USERVEC_START || vec >= NVECTORS) { Index: src/sys/arch/sun3/sun3/clock.c diff -u src/sys/arch/sun3/sun3/clock.c:1.67 src/sys/arch/sun3/sun3/clock.c:1.68 --- src/sys/arch/sun3/sun3/clock.c:1.67 Mon Jan 15 17:40:35 2024 +++ src/sys/arch/sun3/sun3/clock.c Mon Jan 15 18:47:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.67 2024/01/15 17:40:35 thorpej Exp $ */ +/* $NetBSD: clock.c,v 1.68 2024/01/15 18:47:03 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.67 2024/01/15 17:40:35 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.68 2024/01/15 18:47:03 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -316,8 +316,7 @@ clock_intr(struct clockframe cf) /* Read the clock intr. reg. AGAIN! */ intersil_clear(); - m68k_intr_evcnt[CLOCK_PRI].ev_count++; - curcpu()->ci_data.cpu_nintr++; + m68k_count_intr(CLOCK_PRI); { /* Entertainment! */ #ifdef LED_IDLE_CHECK Index: src/sys/arch/sun3/sun3x/clock.c diff -u src/sys/arch/sun3/sun3x/clock.c:1.43 src/sys/arch/sun3/sun3x/clock.c:1.44 --- src/sys/arch/sun3/sun3x/clock.c:1.43 Mon Jan 15 17:40:35 2024 +++ src/sys/arch/sun3/sun3x/clock.c Mon Jan 15 18:47:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.43 2024/01/15 17:40:35 thorpej Exp $ */ +/* $NetBSD: clock.c,v 1.44 2024/01/15 18:47:03 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -95,7 +95,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.43 2024/01/15 17:40:35 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.44 2024/01/15 18:47:03 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -441,8 +441,7 @@ clock_intr(struct clockframe cf) } #endif /* SUN3_470 */ - m68k_intr_evcnt[CLOCK_PRI].ev_count++; - curcpu()->ci_data.cpu_nintr++; + m68k_count_intr(CLOCK_PRI); /* Entertainment! */ if (cf.cf_pc == (long)_Idle)