Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/acorn32 Turn curcpu() into a macro.



details:   https://anonhg.NetBSD.org/src/rev/d689a62528de
branches:  trunk
changeset: 537853:d689a62528de
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Sun Oct 06 18:28:48 2002 +0000

description:
Turn curcpu() into a macro.
Rename cpu_info_array to cpu_info and make it public.
Add CPU_FOREACH() and friends.

diffstat:

 sys/arch/acorn32/acorn32/hydra.c |  18 +++++++++++-------
 sys/arch/acorn32/include/cpu.h   |  16 ++++++++++++++--
 2 files changed, 25 insertions(+), 9 deletions(-)

diffs (87 lines):

diff -r 02e9d4696f14 -r d689a62528de sys/arch/acorn32/acorn32/hydra.c
--- a/sys/arch/acorn32/acorn32/hydra.c  Sun Oct 06 17:28:46 2002 +0000
+++ b/sys/arch/acorn32/acorn32/hydra.c  Sun Oct 06 18:28:48 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hydra.c,v 1.10 2002/10/06 12:37:59 bjh21 Exp $ */
+/*     $NetBSD: hydra.c,v 1.11 2002/10/06 18:28:48 bjh21 Exp $ */
 
 /*-
  * Copyright (c) 2002 Ben Harris
@@ -29,7 +29,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: hydra.c,v 1.10 2002/10/06 12:37:59 bjh21 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hydra.c,v 1.11 2002/10/06 18:28:48 bjh21 Exp $");
 
 #include <sys/device.h>
 #include <sys/systm.h>
@@ -86,7 +86,7 @@
 extern struct cpu_info cpu_info_store;
 
 static struct hydra_softc *the_hydra;
-static struct cpu_info *cpu_info_array[8] = {&cpu_info_store};
+struct cpu_info *cpu_info[CPU_MAXNUM] = {&cpu_info_store};
 
 static int
 hydra_match(struct device *parent, struct cfdata *cf, void *aux)
@@ -323,8 +323,9 @@
                panic("cpu_hydra_attach: uvm_fault_wire failed: %d", error);
 
        /* Set up a struct cpu_info for this CPU */
-       cpu_info_array[slave | HYDRA_ID_ISSLAVE] = &cpu->sc_cpuinfo;
+       cpu_info[slave | HYDRA_ID_ISSLAVE] = &cpu->sc_cpuinfo;
        cpu->sc_cpuinfo.ci_dev = &cpu->sc_dev;
+       cpu->sc_cpuinfo.ci_cpunum = slave | HYDRA_ID_ISSLAVE;
 
        /* Copy hatch code to boot page, and set up arguments */
        memcpy((caddr_t)sc->sc_bootpage_va, hydra_hatchcode,
@@ -403,10 +404,13 @@
        return 0;
 }
 
-struct cpu_info *
-curcpu(void)
+cpuid_t
+cpu_next(cpuid_t cpunum)
 {
 
-       return cpu_info_array[cpu_number()];
+       do
+               cpunum++;
+       while (cpunum < CPU_MAXNUM && cpu_info[cpunum] == NULL);
+       return cpunum;
 }
 #endif
diff -r 02e9d4696f14 -r d689a62528de sys/arch/acorn32/include/cpu.h
--- a/sys/arch/acorn32/include/cpu.h    Sun Oct 06 17:28:46 2002 +0000
+++ b/sys/arch/acorn32/include/cpu.h    Sun Oct 06 18:28:48 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.2 2002/10/05 13:46:58 bjh21 Exp $    */
+/*     $NetBSD: cpu.h,v 1.3 2002/10/06 18:28:48 bjh21 Exp $    */
 
 /*-
  * Copyright (c) 2002 Ben Harris
@@ -37,9 +37,21 @@
        int ci_cpunum;                                                  \
        struct proc *ci_curproc;
 
+#define CPU_MAXNUM 8
+
+extern struct cpu_info *cpu_info[];
+
 #define CPU_IS_PRIMARY(ci)     ((ci)->ci_cpunum == 0)
 extern cpuid_t cpu_number(void);
-extern struct cpu_info *curcpu();
+#define curcpu()               (cpu_info[cpu_number()])
+
+extern cpuid_t cpu_next(cpuid_t);
+
+#define CPU_INFO_ITERATOR cpuid_t
+#define CPU_INFO_FOREACH(cii, ci)                                      \
+       cii = 0, ci = cpu_info[0];                                      \
+       cii < CPU_MAXNUM;                                               \
+       cii = cpu_next(cii), ci = cpu_info[cii]
 
 #endif /* MULTIPROCESSOR */
 #endif /* _KERNEL && _KERNEL_OPT && !_LOCORE */



Home | Main Index | Thread Index | Old Index