Use the new atomic ops.

This commit is contained in:
ad 2007-11-28 16:28:43 +00:00
parent 0cddf536c0
commit 6def667f04
9 changed files with 53 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.14 2007/11/22 20:24:25 bouyer Exp $ */
/* $NetBSD: db_interface.c,v 1.15 2007/11/28 16:28:43 ad Exp $ */
/*
* Mach Operating System
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.14 2007/11/22 20:24:25 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.15 2007/11/28 16:28:43 ad Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.14 2007/11/22 20:24:25 bouyer Exp
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/systm.h>
#include <sys/atomic.h>
#include <uvm/uvm_extern.h>
@ -53,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.14 2007/11/22 20:24:25 bouyer Exp
#include <machine/i82093var.h>
#include <machine/i82489reg.h>
#include <machine/i82489var.h>
#include <machine/atomic.h>
#include <ddb/db_sym.h>
#include <ddb/db_command.h>
@ -146,7 +146,7 @@ db_resume_others(void)
if (ci == NULL)
continue;
if (ci->ci_flags & CPUF_PAUSE)
x86_atomic_clearbits_l(&ci->ci_flags, CPUF_PAUSE);
atomic_and_32(&ci->ci_flags, ~CPUF_PAUSE);
}
}
@ -261,7 +261,7 @@ ddb_suspend(struct trapframe *frame)
ci->ci_ddb_regs = &regs;
x86_atomic_setbits_l(&ci->ci_flags, CPUF_PAUSE);
atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
while (ci->ci_flags & CPUF_PAUSE)
;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.h,v 1.15 2007/11/22 16:16:45 bouyer Exp $ */
/* $NetBSD: pmap.h,v 1.16 2007/11/28 16:28:43 ad Exp $ */
/*
*
@ -74,9 +74,10 @@
#include "opt_xen.h"
#endif
#include <sys/atomic.h>
#include <machine/pte.h>
#include <machine/segments.h>
#include <machine/atomic.h>
#ifdef _KERNEL
#include <machine/cpufunc.h>
#endif
@ -256,9 +257,12 @@
#define pmap_pa2pte(a) (a)
#define pmap_pte2pa(a) ((a) & PG_FRAME)
#define pmap_pte_set(p, n) do { *(p) = (n); } while (0)
#define pmap_pte_testset(p, n) x86_atomic_testset_u64(p, n)
#define pmap_pte_setbits(p, b) x86_atomic_setbits_u64(p, b)
#define pmap_pte_clearbits(p, b) x86_atomic_clearbits_u64(p, b)
#define pmap_pte_testset(p, n) \
atomic_swap_ulong((volatile unsigned long *)p, n)
#define pmap_pte_setbits(p, b) \
atomic_or_ulong((volatile unsigned long *)p, b)
#define pmap_pte_clearbits(p, b) \
atomic_and_ulong((volatile unsigned long *)p, ~(b))
#define pmap_pte_flush() /* nothing */
#define pmap_cpu_has_pg_n() (1)
#define pmap_cpu_has_invlpg (1)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.55 2007/11/15 19:46:44 ad Exp $ */
/* $NetBSD: db_interface.c,v 1.56 2007/11/28 16:28:44 ad Exp $ */
/*
* Mach Operating System
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.55 2007/11/15 19:46:44 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.56 2007/11/28 16:28:44 ad Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.55 2007/11/15 19:46:44 ad Exp $")
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/systm.h>
#include <sys/atomic.h>
#include <uvm/uvm_extern.h>
@ -53,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.55 2007/11/15 19:46:44 ad Exp $")
#include <machine/i82093var.h>
#include <machine/i82489reg.h>
#include <machine/i82489var.h>
#include <machine/atomic.h>
#include <ddb/db_sym.h>
#include <ddb/db_command.h>
@ -148,7 +148,7 @@ db_resume_others(void)
if (ci == NULL)
continue;
if (ci->ci_flags & CPUF_PAUSE)
x86_atomic_clearbits_l(&ci->ci_flags, CPUF_PAUSE);
atomic_and_32(&ci->ci_flags, ~CPUF_PAUSE);
}
}
@ -334,8 +334,7 @@ ddb_suspend(struct trapframe *frame)
ci->ci_ddb_regs = &regs;
x86_atomic_setbits_l(&ci->ci_flags, CPUF_PAUSE);
atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
while (ci->ci_flags & CPUF_PAUSE)
;
ci->ci_ddb_regs = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipifuncs.c,v 1.21 2007/11/14 17:54:59 ad Exp $ */
/* $NetBSD: ipifuncs.c,v 1.22 2007/11/28 16:28:44 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.21 2007/11/14 17:54:59 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.22 2007/11/28 16:28:44 ad Exp $");
#include "opt_ddb.h"
#include "opt_mtrr.h"
@ -53,12 +53,12 @@ __KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.21 2007/11/14 17:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/atomic.h>
#include <uvm/uvm_extern.h>
#include <x86/cpu_msr.h>
#include <machine/intr.h>
#include <machine/atomic.h>
#include <machine/cpuvar.h>
#include <machine/i82093var.h>
#include <machine/i82489reg.h>
@ -99,7 +99,7 @@ void
i386_ipi_halt(struct cpu_info *ci)
{
x86_disable_intr();
x86_atomic_clearbits_l(&ci->ci_flags, CPUF_RUNNING);
atomic_and_32(&ci->ci_flags, ~CPUF_RUNNING);
for(;;) {
x86_hlt();

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.h,v 1.95 2007/11/22 16:16:46 bouyer Exp $ */
/* $NetBSD: pmap.h,v 1.96 2007/11/28 16:28:44 ad Exp $ */
/*
*
@ -74,9 +74,10 @@
#include "opt_user_ldt.h"
#endif
#include <sys/atomic.h>
#include <machine/pte.h>
#include <machine/segments.h>
#include <machine/atomic.h>
#if defined(_KERNEL)
#include <machine/cpufunc.h>
#endif
@ -263,9 +264,12 @@
#define pmap_pa2pte(a) (a)
#define pmap_pte2pa(a) ((a) & PG_FRAME)
#define pmap_pte_set(p, n) do { *(p) = (n); } while (0)
#define pmap_pte_testset(p, n) x86_atomic_testset_ul(p, n)
#define pmap_pte_setbits(p, b) x86_atomic_setbits_l(p, b)
#define pmap_pte_clearbits(p, b) x86_atomic_clearbits_l(p, b)
#define pmap_pte_testset(p, n) \
atomic_swap_ulong((volatile unsigned long *)p, n)
#define pmap_pte_setbits(p, b) \
atomic_or_ulong((volatile unsigned long *)p, b)
#define pmap_pte_clearbits(p, b) \
atomic_and_ulong((volatile unsigned long *)p, ~(b))
#define pmap_pte_flush() /* nothing */
#define pmap_cpu_has_pg_n() (cpu_class != CPUCLASS_386)
#define pmap_cpu_has_invlpg() (cpu_class != CPUCLASS_386)

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.c,v 1.34 2007/10/17 19:58:16 garbled Exp $ */
/* $NetBSD: intr.c,v 1.35 2007/11/28 16:28:44 ad Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -140,7 +140,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.34 2007/10/17 19:58:16 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.35 2007/11/28 16:28:44 ad Exp $");
#include "opt_multiprocessor.h"
#include "opt_acpi.h"
@ -760,7 +760,7 @@ intr_disestablish(struct intrhand *ih)
mutex_enter(&x86_intr_lock);
pic->pic_hwmask(pic, ih->ih_pin);
x86_atomic_clearbits_l(&ci->ci_ipending, (1 << ih->ih_slot));
atomic_and_32(&ci->ci_ipending, ~(1 << ih->ih_slot));
/*
* Remove the handler from the chain.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipi.c,v 1.7 2005/12/11 12:19:47 christos Exp $ */
/* $NetBSD: ipi.c,v 1.8 2007/11/28 16:28:44 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -39,14 +39,14 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.7 2005/12/11 12:19:47 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.8 2007/11/28 16:28:44 ad Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/atomic.h>
#include <machine/intr.h>
#include <machine/atomic.h>
#include <machine/cpuvar.h>
#include <machine/i82093var.h>
#include <machine/i82489reg.h>
@ -57,7 +57,7 @@ x86_send_ipi(struct cpu_info *ci, int ipimask)
{
int ret;
x86_atomic_setbits_l(&ci->ci_ipis, ipimask);
atomic_or_32(&ci->ci_ipis, ipimask);
/* Don't send IPI to CPU which isn't (yet) running. */
if (!(ci->ci_flags & CPUF_RUNNING))
@ -86,7 +86,7 @@ x86_broadcast_ipi (int ipimask)
continue;
if ((ci->ci_flags & CPUF_RUNNING) == 0)
continue;
x86_atomic_setbits_l(&ci->ci_ipis, ipimask);
atomic_or_32(&ci->ci_ipis, ipimask);
count++;
}
if (!count)
@ -119,7 +119,7 @@ x86_ipi_handler(void)
u_int32_t pending;
int bit;
pending = x86_atomic_testset_ul(&ci->ci_ipis, 0);
pending = atomic_swap_32(&ci->ci_ipis, 0);
KDASSERT((pending >> X86_NIPI) == 0);
while ((bit = ffs(pending)) != 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: mtrr_i686.c,v 1.12 2007/10/19 21:34:56 pavel Exp $ */
/* $NetBSD: mtrr_i686.c,v 1.13 2007/11/28 16:28:44 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.12 2007/10/19 21:34:56 pavel Exp $");
__KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.13 2007/11/28 16:28:44 ad Exp $");
#include "opt_multiprocessor.h"
@ -47,11 +47,11 @@ __KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.12 2007/10/19 21:34:56 pavel Exp $")
#include <sys/lock.h>
#include <sys/user.h>
#include <sys/malloc.h>
#include <sys/atomic.h>
#include <uvm/uvm_extern.h>
#include <machine/specialreg.h>
#include <machine/atomic.h>
#include <machine/cpuvar.h>
#include <machine/cpufunc.h>
#include <machine/mtrr.h>
@ -180,7 +180,7 @@ i686_mtrr_reload(int synch)
* 3. Wait for all processors to reach this point.
*/
x86_atomic_setbits_l(&mtrr_waiting, mymask);
atomic_or_32(&mtrr_waiting, mymask);
while (mtrr_waiting != cpus_running)
DELAY(10);
@ -277,7 +277,7 @@ i686_mtrr_reload(int synch)
/*
* 14. Wait for all processors to reach this point.
*/
x86_atomic_clearbits_l(&mtrr_waiting, mymask);
atomic_and_32(&mtrr_waiting, ~mymask);
while (mtrr_waiting != 0)
DELAY(10);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.9 2007/11/23 16:33:25 bouyer Exp $ */
/* $NetBSD: pmap.c,v 1.10 2007/11/28 16:28:44 ad Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@ -154,7 +154,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.9 2007/11/23 16:33:25 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.10 2007/11/28 16:28:44 ad Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@ -2253,7 +2253,7 @@ pmap_reactivate(struct pmap *pmap)
ci->ci_tlbstate = TLBSTATE_VALID;
oldcpus = pmap->pm_cpus;
x86_atomic_setbits_l(&pmap->pm_cpus, cpumask);
atomic_or_32(&pmap->pm_cpus, cpumask);
KASSERT((pmap->pm_kernel_cpus & cpumask) != 0);
if (oldcpus & cpumask) {
/* got it */
@ -2330,8 +2330,8 @@ pmap_load(void)
* actually switch pmap.
*/
x86_atomic_clearbits_l(&oldpmap->pm_cpus, cpumask);
x86_atomic_clearbits_l(&oldpmap->pm_kernel_cpus, cpumask);
atomic_and_32(&oldpmap->pm_cpus, ~cpumask);
atomic_and_32(&oldpmap->pm_kernel_cpus, ~cpumask);
#ifdef XEN
KASSERT(oldpmap->pm_pdirpa == xen_current_user_pgd ||
@ -2350,8 +2350,8 @@ pmap_load(void)
*/
ci->ci_tlbstate = TLBSTATE_VALID;
x86_atomic_setbits_l(&pmap->pm_cpus, cpumask);
x86_atomic_setbits_l(&pmap->pm_kernel_cpus, cpumask);
atomic_or_32(&pmap->pm_cpus, cpumask);
atomic_or_32(&pmap->pm_kernel_cpus, cpumask);
ci->ci_pmap = pmap;
/*