Add CPU_INFO_INTERATOR/FOREACH support.

This commit is contained in:
matt 2004-03-19 20:17:51 +00:00
parent 3ff01ef842
commit d06905d5ce
3 changed files with 20 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.68 2004/01/22 01:24:10 matt Exp $ */
/* $NetBSD: cpu.h,v 1.69 2004/03/19 20:17:51 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden
@ -55,6 +55,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
#include <sys/queue.h>
#include <sys/device.h>
#include <sys/lock.h>
#include <sys/sched.h>
@ -147,6 +148,7 @@ struct cpu_info {
int ci_flags; /* See below */
long ci_ipimsgs; /* Sent IPI bits */
struct trapframe *ci_ddb_regs; /* Used by DDB */
SIMPLEQ_ENTRY(cpu_info) ci_next; /* next cpu_info */
#endif
};
#define CI_MASTERCPU 1 /* Set if master CPU */
@ -180,6 +182,12 @@ struct cpu_mp_softc {
#if defined(MULTIPROCESSOR)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CI_MASTERCPU)
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = SIMPLEQ_FIRST(&cpus); \
ci != NULL; \
ci = SIMPLEQ_NEXT(ci, ci_next)
extern SIMPLEQ_HEAD(cpu_info_qh, cpu_info) cpus;
extern char tramp;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: multicpu.c,v 1.15 2003/07/15 02:15:05 lukem Exp $ */
/* $NetBSD: multicpu.c,v 1.16 2004/03/19 20:17:51 matt Exp $ */
/*
* Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: multicpu.c,v 1.15 2003/07/15 02:15:05 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: multicpu.c,v 1.16 2004/03/19 20:17:51 matt Exp $");
#include "opt_multiprocessor.h"
@ -66,6 +66,7 @@ struct cpuq {
SIMPLEQ_HEAD(, cpuq) cpuq = SIMPLEQ_HEAD_INITIALIZER(cpuq);
extern long avail_start, avail_end, proc0paddr;
struct cpu_info_qh cpus = SIMPLEQ_HEAD_INITIALIZER(cpus);
void
cpu_boot_secondary_processors()
@ -124,11 +125,12 @@ cpu_slavesetup(struct device *dev)
ci = &sc->sc_ci;
ci->ci_dev = dev;
ci->ci_exit = scratch;
(u_long)ci->ci_pcb = (u_long)pcb & ~KERNBASE;
ci->ci_pcb = (void *)((intptr_t)pcb & ~KERNBASE);
ci->ci_istack = istackbase + PAGE_SIZE;
pcb->KSP = (u_long)pcb + USPACE; /* Idle kernel stack */
pcb->SSP = (u_long)ci;
pcb->PC = (u_long)slaverun + 2;
SIMPLEQ_INSERT_TAIL(&cpus, ci, ci_next);
pcb->KSP = (uintptr_t)pcb + USPACE; /* Idle kernel stack */
pcb->SSP = (uintptr_t)ci;
pcb->PC = (uintptr_t)slaverun + 2;
pcb->PSL = 0;
cq = malloc(sizeof(*cq), M_TEMP, M_NOWAIT);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.133 2004/02/13 11:36:20 wiz Exp $ */
/* $NetBSD: pmap.c,v 1.134 2004/03/19 20:17:51 matt Exp $ */
/*
* Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.133 2004/02/13 11:36:20 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.134 2004/03/19 20:17:51 matt Exp $");
#include "opt_ddb.h"
#include "opt_cputype.h"
@ -396,6 +396,7 @@ pmap_bootstrap()
curcpu()->ci_dev = (void *)(pcb->SSP + sizeof(struct cpu_info));
#if defined(MULTIPROCESSOR)
curcpu()->ci_flags = CI_MASTERCPU|CI_RUNNING;
SIMPLEQ_FIRST(&cpus) = curcpu();
#endif
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
simple_lock_init(&pvtable_lock);