From 99d6864d21b3df9bf131b48f5289e10d55032ddd Mon Sep 17 00:00:00 2001 From: jruoho Date: Thu, 13 Jan 2011 03:40:50 +0000 Subject: [PATCH] Move the function that counts the CPUs from acpicpu(4) to the MD layer. --- sys/arch/ia64/acpi/acpi_machdep.c | 11 +++++++++-- sys/arch/ia64/include/acpi_machdep.h | 19 ++++++++++--------- sys/arch/x86/acpi/acpi_cpu_md.c | 16 +++++----------- sys/arch/x86/include/acpi_machdep.h | 3 ++- sys/arch/x86/x86/acpi_machdep.c | 13 +++++++++++-- sys/dev/acpi/acpi_cpu.h | 3 +-- sys/dev/acpi/acpi_cpu_cstate.c | 6 +++--- 7 files changed, 41 insertions(+), 30 deletions(-) diff --git a/sys/arch/ia64/acpi/acpi_machdep.c b/sys/arch/ia64/acpi/acpi_machdep.c index ee74d927abd3..8c3a2194a916 100644 --- a/sys/arch/ia64/acpi/acpi_machdep.c +++ b/sys/arch/ia64/acpi/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.2 2010/07/24 09:35:36 jruoho Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.3 2011/01/13 03:40:50 jruoho Exp $ */ /* * Copyright (c) 2009 KIYOHARA Takashi * All rights reserved. @@ -28,7 +28,7 @@ * Machine-dependent routines for ACPICA. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.2 2010/07/24 09:35:36 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.3 2011/01/13 03:40:50 jruoho Exp $"); #include @@ -185,6 +185,13 @@ acpi_md_OsDisableInterrupt(void) disable_intr(); } +uint32_t +acpi_md_ncpus(void) +{ + + return 0; /* XXX. */ +} + void acpi_md_callback(void) { diff --git a/sys/arch/ia64/include/acpi_machdep.h b/sys/arch/ia64/include/acpi_machdep.h index 989acf73d53c..7baee3cb365a 100644 --- a/sys/arch/ia64/include/acpi_machdep.h +++ b/sys/arch/ia64/include/acpi_machdep.h @@ -1,8 +1,8 @@ -/* $NetBSD: acpi_machdep.h,v 1.2 2009/07/20 04:41:37 kiyohara Exp $ */ +/* $NetBSD: acpi_machdep.h,v 1.3 2011/01/13 03:40:50 jruoho Exp $ */ ACPI_STATUS acpi_md_OsInitialize(void); ACPI_STATUS acpi_md_OsTerminate(void); -ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void); +ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void); #define acpi_md_OsIn8(x) inb((x)) #define acpi_md_OsIn16(x) inw((x)) @@ -13,7 +13,7 @@ ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void); #define acpi_md_OsOut32(x, v) outl((x), (v)) ACPI_STATUS acpi_md_OsInstallInterruptHandler(UINT32, ACPI_OSD_HANDLER, - void *, void **); + void *, void **); void acpi_md_OsRemoveInterruptHandler(void *); ACPI_STATUS acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS, UINT32, void **); @@ -21,10 +21,11 @@ void acpi_md_OsUnmapMemory(void *, UINT32); ACPI_STATUS acpi_md_OsGetPhysicalAddress(void *LogicalAddress, ACPI_PHYSICAL_ADDRESS *PhysicalAddress); -BOOLEAN acpi_md_OsReadable(void *, UINT32); -BOOLEAN acpi_md_OsWritable(void *, UINT32); -void acpi_md_OsEnableInterrupt(void); -void acpi_md_OsDisableInterrupt(void); +BOOLEAN acpi_md_OsReadable(void *, UINT32); +BOOLEAN acpi_md_OsWritable(void *, UINT32); +void acpi_md_OsEnableInterrupt(void); +void acpi_md_OsDisableInterrupt(void); -int acpi_md_sleep(int); -void acpi_md_callback(void); +int acpi_md_sleep(int); +uint32_t acpi_md_ncpus(void); +void acpi_md_callback(void); diff --git a/sys/arch/x86/acpi/acpi_cpu_md.c b/sys/arch/x86/acpi/acpi_cpu_md.c index 1387e6ac02a8..da178b554dcd 100644 --- a/sys/arch/x86/acpi/acpi_cpu_md.c +++ b/sys/arch/x86/acpi/acpi_cpu_md.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.37 2010/12/30 17:06:17 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.38 2011/01/13 03:40:50 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.37 2010/12/30 17:06:17 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.38 2011/01/13 03:40:50 jruoho Exp $"); #include #include @@ -48,6 +48,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.37 2010/12/30 17:06:17 jruoho Exp #include #include +#include + /* * AMD C1E. */ @@ -110,7 +112,6 @@ static int acpicpu_md_pstate_sysctl_get(SYSCTLFN_PROTO); static int acpicpu_md_pstate_sysctl_set(SYSCTLFN_PROTO); static int acpicpu_md_pstate_sysctl_all(SYSCTLFN_PROTO); -extern uint32_t cpus_running; extern struct acpicpu_softc **acpicpu_sc; static bool acpicpu_pstate_status = false; static struct sysctllog *acpicpu_log = NULL; @@ -157,7 +158,7 @@ acpicpu_md_quirks(void) uint32_t family, val = 0; uint32_t regs[4]; - if (acpicpu_md_cpus_running() == 1) + if (acpi_md_ncpus() == 1) val |= ACPICPU_FLAG_C_BM; if ((ci->ci_feat_val[1] & CPUID2_MONITOR) != 0) @@ -312,13 +313,6 @@ acpicpu_md_quirks_c1e(void) wrmsr(MSR_CMPHALT, val & ~c1e); } -uint32_t -acpicpu_md_cpus_running(void) -{ - - return popcount32(cpus_running); -} - int acpicpu_md_idle_start(struct acpicpu_softc *sc) { diff --git a/sys/arch/x86/include/acpi_machdep.h b/sys/arch/x86/include/acpi_machdep.h index 90301fd0cd27..278bd91e0235 100644 --- a/sys/arch/x86/include/acpi_machdep.h +++ b/sys/arch/x86/include/acpi_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.h,v 1.7 2010/07/24 21:53:54 jruoho Exp $ */ +/* $NetBSD: acpi_machdep.h,v 1.8 2011/01/13 03:40:50 jruoho Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -73,6 +73,7 @@ void acpi_md_OsEnableInterrupt(void); int acpi_md_sleep(int); void acpi_md_sleep_init(void); +uint32_t acpi_md_ncpus(void); void acpi_md_callback(void); #endif /* !_X86_ACPI_MACHDEP_H_ */ diff --git a/sys/arch/x86/x86/acpi_machdep.c b/sys/arch/x86/x86/acpi_machdep.c index 3a5a9cc10cde..d62d1b663078 100644 --- a/sys/arch/x86/x86/acpi_machdep.c +++ b/sys/arch/x86/x86/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.27 2010/04/28 19:17:04 dyoung Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.28 2011/01/13 03:40:50 jruoho Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.27 2010/04/28 19:17:04 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.28 2011/01/13 03:40:50 jruoho Exp $"); #include #include @@ -72,6 +72,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.27 2010/04/28 19:17:04 dyoung Exp #include "opt_mpbios.h" #include "opt_acpi.h" +extern uint32_t cpus_running; + ACPI_STATUS acpi_md_OsInitialize(void) { @@ -95,6 +97,7 @@ acpi_md_OsGetRootPointer(void) ACPI_STATUS Status; Status = AcpiFindRootPointer(&PhysicalAddress); + if (ACPI_FAILURE(Status)) PhysicalAddress = 0; @@ -282,6 +285,12 @@ acpi_md_OsEnableInterrupt(void) x86_enable_intr(); } +uint32_t +acpi_md_ncpus(void) +{ + return popcount32(cpus_running); +} + void acpi_md_callback(void) { diff --git a/sys/dev/acpi/acpi_cpu.h b/sys/dev/acpi/acpi_cpu.h index 72abaa84f749..6729b24faac8 100644 --- a/sys/dev/acpi/acpi_cpu.h +++ b/sys/dev/acpi/acpi_cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu.h,v 1.27 2010/12/30 12:05:02 jruoho Exp $ */ +/* $NetBSD: acpi_cpu.h,v 1.28 2011/01/13 03:40:51 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -236,7 +236,6 @@ int acpicpu_tstate_set(struct acpicpu_softc *, uint32_t); uint32_t acpicpu_md_cap(void); uint32_t acpicpu_md_quirks(void); void acpicpu_md_quirks_c1e(void); -uint32_t acpicpu_md_cpus_running(void); int acpicpu_md_idle_start(struct acpicpu_softc *); int acpicpu_md_idle_stop(void); void acpicpu_md_idle_enter(int, int); diff --git a/sys/dev/acpi/acpi_cpu_cstate.c b/sys/dev/acpi/acpi_cpu_cstate.c index ccd6557ba230..4f7869a18caf 100644 --- a/sys/dev/acpi/acpi_cpu_cstate.c +++ b/sys/dev/acpi/acpi_cpu_cstate.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_cstate.c,v 1.35 2011/01/04 05:48:48 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_cstate.c,v 1.36 2011/01/13 03:40:51 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.35 2011/01/04 05:48:48 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.36 2011/01/13 03:40:51 jruoho Exp $"); #include #include @@ -541,7 +541,7 @@ acpicpu_cstate_fadt(struct acpicpu_softc *sc) if (sc->sc_object.ao_pblkaddr == 0) return; - if (acpicpu_md_cpus_running() > 1) { + if (acpi_md_ncpus() > 1) { if ((AcpiGbl_FADT.Flags & ACPI_FADT_C2_MP_SUPPORTED) == 0) return;