Move the function that counts the CPUs from acpicpu(4) to the MD layer.

This commit is contained in:
jruoho 2011-01-13 03:40:50 +00:00
parent a894fd595d
commit 99d6864d21
7 changed files with 41 additions and 30 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
@ -185,6 +185,13 @@ acpi_md_OsDisableInterrupt(void)
disable_intr();
}
uint32_t
acpi_md_ncpus(void)
{
return 0; /* XXX. */
}
void
acpi_md_callback(void)
{

View File

@ -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);

View File

@ -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 <jruohonen@iki.fi>
@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/bus.h>
@ -48,6 +48,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.37 2010/12/30 17:06:17 jruoho Exp
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#include <machine/acpi_machdep.h>
/*
* 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)
{

View File

@ -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_ */

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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)
{

View File

@ -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 <jruohonen@iki.fi>
@ -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);

View File

@ -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 <jruohonen@iki.fi>
@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/cpu.h>
@ -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;